pub struct BatchedComputePass { /* private fields */ }Expand description
Accumulates compute dispatch commands and issues them in batches.
Batching reduces command-encoder overhead by coalescing small dispatches and sorting them by pipeline so that pipeline switches are minimised.
When the number of pending commands reaches max_batch_size, an automatic
flush is triggered and the commands are sorted by pipeline_id before
being returned.
Implementations§
Source§impl BatchedComputePass
impl BatchedComputePass
Sourcepub fn new(max_batch_size: usize) -> Self
pub fn new(max_batch_size: usize) -> Self
Create a BatchedComputePass with the given max_batch_size.
A max_batch_size of 0 is treated as 1 (each submit is auto-flushed).
Sourcepub fn submit(&mut self, cmd: DispatchCommand) -> bool
pub fn submit(&mut self, cmd: DispatchCommand) -> bool
Submit a dispatch command.
Returns true if an automatic flush was triggered (i.e., the pending
queue reached max_batch_size). The caller should retrieve the flushed
batch via flush when this returns true.
Sourcepub fn flush(&mut self) -> Vec<DispatchCommand>
pub fn flush(&mut self) -> Vec<DispatchCommand>
Drain all pending commands, sorted by pipeline_id (ascending) to
minimise pipeline state switches on the GPU.
Returns the sorted batch. If the queue is empty, returns an empty Vec.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of commands currently pending.
Sourcepub fn total_flushed(&self) -> u64
pub fn total_flushed(&self) -> u64
Total commands flushed across all batches.
Sourcepub fn max_batch_size(&self) -> usize
pub fn max_batch_size(&self) -> usize
Maximum batch size before an auto-flush is triggered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BatchedComputePass
impl RefUnwindSafe for BatchedComputePass
impl Send for BatchedComputePass
impl Sync for BatchedComputePass
impl Unpin for BatchedComputePass
impl UnsafeUnpin for BatchedComputePass
impl UnwindSafe for BatchedComputePass
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