pub struct DoubleBufferSubmitter { /* private fields */ }Expand description
Double-buffered command submission manager.
Manages two CommandSlots in a ping-pong fashion to enable overlapping
CPU encoding and GPU execution.
Implementations§
Source§impl DoubleBufferSubmitter
impl DoubleBufferSubmitter
Sourcepub fn begin_encode(&mut self) -> Result<usize, DoubleBufferError>
pub fn begin_encode(&mut self) -> Result<usize, DoubleBufferError>
Begin encoding a new frame in the next available slot.
Returns the slot index (0 or 1) that was acquired.
§Errors
Returns DoubleBufferError::NoFreeSlot if both slots are busy.
Sourcepub fn set_payload_size(&mut self, slot_idx: usize, size: usize)
pub fn set_payload_size(&mut self, slot_idx: usize, size: usize)
Set the payload size for the current encoding slot.
This is informational and can be used for statistics.
Sourcepub fn submit<F>(
&mut self,
slot_idx: usize,
gpu_work: F,
) -> Result<(), DoubleBufferError>
pub fn submit<F>( &mut self, slot_idx: usize, gpu_work: F, ) -> Result<(), DoubleBufferError>
Finish encoding and submit the slot for GPU execution.
The gpu_work closure receives the slot index and should perform
the actual GPU command submission.
§Errors
Returns an error if the slot is not in the Encoding state or if
gpu_work fails.
Sourcepub fn mark_complete(&mut self, slot_idx: usize)
pub fn mark_complete(&mut self, slot_idx: usize)
Mark a slot as complete (GPU execution finished).
Should be called when the GPU fence/completion signal fires.
Sourcepub fn submit_sync<F>(
&mut self,
payload_size: usize,
gpu_work: F,
) -> Result<u64, DoubleBufferError>
pub fn submit_sync<F>( &mut self, payload_size: usize, gpu_work: F, ) -> Result<u64, DoubleBufferError>
Convenience: encode, submit, and immediately mark complete.
Useful for synchronous (non-pipelined) operation.
§Errors
Returns an error if no slot is free or if GPU work fails.
Sourcepub fn stats(&self) -> &DoubleBufferStats
pub fn stats(&self) -> &DoubleBufferStats
Get a snapshot of the current statistics.
Sourcepub fn slot(&self, idx: usize) -> Option<&CommandSlot>
pub fn slot(&self, idx: usize) -> Option<&CommandSlot>
Get the state of a specific slot.
Sourcepub fn active_slot(&self) -> usize
pub fn active_slot(&self) -> usize
Get the current active (encoding) slot index.
Sourcepub fn frame_counter(&self) -> u64
pub fn frame_counter(&self) -> u64
The total number of frames that have been assigned frame indices.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DoubleBufferSubmitter
impl RefUnwindSafe for DoubleBufferSubmitter
impl Send for DoubleBufferSubmitter
impl Sync for DoubleBufferSubmitter
impl Unpin for DoubleBufferSubmitter
impl UnsafeUnpin for DoubleBufferSubmitter
impl UnwindSafe for DoubleBufferSubmitter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more