Skip to main content
QAROS Rust API Dev (main) · versions: Dev (main) · Developer Guide

RenderSender

Struct RenderSender 

Source
pub struct RenderSender { /* private fields */ }
Expand description

A CPU render stream sender. Keeps its session alive; destroyed with qar_render_stream_handle_destroy after the last open frame.

Implementations§

Source§

impl RenderSender

Source

pub fn d3d11_frame_state(&self) -> Result<D3D11Frame<'_>>

The sender’s D3D11 frame record outside a frame cycle (qar_render_sender_frame_d3d11), readable from creation: create views on the shared textures here, before the first frame, but render into them only inside a cycle. Fails while a frame is open on this sender; inside a cycle use Frame::d3d11_frame or OwnedFrame::d3d11_frame. Fails for a sender not created for D3D11.

Source

pub fn vulkan_frame_state(&mut self) -> Result<VulkanFrameState<'_>>

The sender-owned Vulkan frame outside a frame cycle (qar_render_sender_frame_vulkan), readable from creation: create image views and framebuffers against the real images here, before the first frame. Fails while a frame is open on this sender; inside a cycle use Frame::vulkan_frame or OwnedFrame::vulkan_frame, which also allow the write-back.

Source

pub fn as_raw(&self) -> *mut QarRenderSender

The QarRenderSender handle, for the functions only the raw table of crate::Library::raw_api reaches, such as qar_render_sender_last_hands, qar_render_sender_stream_id and qar_render_sender_change_layout.

Taking the pointer is safe; using it is unsafe, under the rules of crate::Session::as_raw for a sender: valid while this RenderSender lives, never destroyed by the caller, used on the thread that drives this sender. The frame cycle stays with the safe API: never begin or show a frame through the raw table.

Source

pub fn layout(&self) -> Result<VideoFrameLayout>

The layout negotiated with the receiver (qar_render_sender_layout).

Source

pub fn next_render_pose(&self, view_count: usize) -> Result<Vec<ViewPose>>

For a sender created with RenderLoop::FreeRunning: the poses and fields of view to render the next frame with, taken before begin-frame (qar_render_sender_next_render_pose). Predicted now from the newest head pose for when the frame is shown, in the same app content space as a frame’s views. The next begin-frame opens its frame with exactly these poses: render into your own target, then begin the frame, copy into it and show it. A second call before that begin-frame replaces the poses.

view_count is at most the number of views the sender was created with; the result is in the frame’s view order, as OwnedFrame::view indexes it. Fails with crate::StatusCode::RENDERING_MISSING_POSE_DATA before the viewer’s first head pose, crate::StatusCode::RENDERING_APP_VOLUME_UNRESOLVED while the app volume does not resolve, and crate::StatusCode::LOGIC_ERROR for a request-driven sender or too many views.

Source

pub fn is_ready_for_next_frame(&self) -> Result<bool>

For a sender created with RenderLoop::FreeRunning: whether a frame rendered now can be sent without waiting (qar_render_sender_is_ready_for_next_frame). Never blocks.

True once the receiver has handed back the previous frame’s destination: it is then reserved for this sender’s next frame, and the next begin-frame takes it without waiting. False while it is still out, and while the stream is paused, reconnecting or has no receiver yet. A loop serving several senders checks each one first and takes Self::next_render_pose, renders and begins only for those that are ready, so a slower receiver or a reconnecting stream holds back no other. Fails with crate::StatusCode::RENDERING_STREAM_IS_CLOSED once the stream closed, and with crate::StatusCode::LOGIC_ERROR for a request-driven sender or while a begin-frame is waiting.

Source

pub fn begin_frame( &mut self, options: &BlockingOptions<'_>, ) -> Result<Frame<'_>>

Begins a frame (qar_render_sender_begin_frame). Render with the returned views’ poses and fields of view, then Frame::show.

Source

pub fn begin_owned_frame( &mut self, options: &BlockingOptions<'_>, ) -> Result<OwnedFrame>

Like RenderSender::begin_frame, for a frame that stays open while the caller does other work, for example across several UI frames until a GPU readback arrives. The frame keeps the sender alive. One frame is open per sender at a time; a second call before the first frame is shown or dropped fails without calling the library.

Source

pub fn start_owned_frame( &mut self, timeout: Option<Duration>, wake: impl Fn() + Send + Sync + 'static, ) -> Result<PendingFrame>

Starts a frame without blocking (qar_render_sender_begin_frame_async) and returns at once; PendingCall::poll or PendingCall::wait picks up the OwnedFrame, which behaves like one from RenderSender::begin_owned_frame (CPU, Vulkan and D3D11 access alike). Same poses, failures and wait through a paused stream as the blocking begin.

The frame counts as open from the start: another begin on this sender fails without a library call until the pending frame is taken and shown or dropped. timeout cancels the call through its token, after which the library calls back with crate::StatusCode::TIMEOUT. wake runs on a library thread right after the result arrived.

Dropping the pending frame cancels it and returns at once. The next begin on this sender first waits for its callback and destroys a frame info it delivered; destroying the sender cancels it and waits for its callback. The frame info the callback hands over is owned by the caller, as the runtime’s tests use it; the header does not say so.

Source

pub fn try_begin_owned_frame(&mut self) -> Result<Option<OwnedFrame>>

Polls for a frame without blocking (qar_render_sender_try_begin_frame, the call QuaternAR’s Vulkan cube uses). The first call starts the library’s begin-frame wait; Ok(None) means not ready yet, poll again later on the same sender. A frame it returns behaves like one from RenderSender::begin_owned_frame. Fails without calling the library while a frame is open on this sender.

Trait Implementations§

Source§

impl Debug for RenderSender

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.