Skip to main content

Batch

Struct Batch 

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

A batch of dispatches recorded into a single command buffer.

Created via Device::batch. Use barrier between dispatches that have data dependencies (where one dispatch reads from another’s output).

Implementations§

Source§

impl Batch

Source

pub fn run( &mut self, kernel: &Kernel, buffers: &[&dyn GpuBuf], invocations: u32, ) -> Result<&mut Self>

Record a kernel dispatch with auto-calculated workgroups.

Source

pub fn run_with_push_constants( &mut self, kernel: &Kernel, buffers: &[&dyn GpuBuf], invocations: u32, push_constants: &[u8], ) -> Result<&mut Self>

Record a kernel dispatch with push constants.

Source

pub fn run_configured( &mut self, kernel: &Kernel, buffers: &[&dyn GpuBuf], workgroups: [u32; 3], push_constants: Option<&[u8]>, ) -> Result<&mut Self>

Record a kernel dispatch with explicit workgroups and optional push constants.

Source

pub fn barrier(&mut self) -> &mut Self

Insert a compute-to-compute barrier.

Use this between dispatches where a later dispatch reads from an earlier dispatch’s output buffer. Without a barrier, the GPU may execute dispatches out of order or overlap writes with reads.

Source

pub fn submit(self) -> Result<()>

Submit all recorded dispatches and wait for completion.

All dispatches execute in a single command buffer with one fence wait, eliminating per-dispatch synchronization overhead.

Equivalent to self.submit_async()?.wait().

Source

pub fn submit_async(self) -> Result<Ticket>

Submit all recorded dispatches and return a Ticket for non-blocking completion tracking.

The GPU work is queued immediately. Use Ticket::wait to block until completion, or Ticket::is_ready to poll.

§Example
let mut batch = gpu.batch()?;
batch.run(&kernel, &[&input, &output], n)?;
let ticket = batch.submit_async()?;

// ... CPU work while GPU runs ...

ticket.wait()?;
let result: Vec<f32> = output.download()?;

Auto Trait Implementations§

§

impl Freeze for Batch

§

impl RefUnwindSafe for Batch

§

impl Send for Batch

§

impl Sync for Batch

§

impl Unpin for Batch

§

impl UnsafeUnpin for Batch

§

impl UnwindSafe for Batch

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.