pub trait HardwareQueue: Send + Debug {
type Signal: TimelineSignal;
// Required methods
fn wait(&mut self, signal: &Self::Signal, value: u64) -> &mut Self;
fn signal(&mut self, signal: &Self::Signal, value: u64) -> &mut Self;
fn exec(
&mut self,
program: &dyn Program,
buffers: &[&Buffer],
params: &ExecParams,
) -> &mut Self;
fn copy(&mut self, dst: &Buffer, src: &Buffer) -> &mut Self;
fn memory_barrier(&mut self) -> &mut Self;
fn submit(&mut self) -> Result<()>;
fn device(&self) -> &DeviceSpec;
}Expand description
Hardware command queue for submitting operations to a device.
Queues batch operations and submit them to hardware atomically.
All operations are non-blocking until submit() is called.
§Thread Safety
Queues are Send but not necessarily Sync. Each queue should be
owned by a single thread/task at a time.
Required Associated Types§
Sourcetype Signal: TimelineSignal
type Signal: TimelineSignal
The timeline signal type used by this queue.
Required Methods§
Sourcefn wait(&mut self, signal: &Self::Signal, value: u64) -> &mut Self
fn wait(&mut self, signal: &Self::Signal, value: u64) -> &mut Self
Wait for a signal to reach a value before executing subsequent operations.
This creates a dependency: operations after this call won’t start
until the signal reaches value.
Sourcefn signal(&mut self, signal: &Self::Signal, value: u64) -> &mut Self
fn signal(&mut self, signal: &Self::Signal, value: u64) -> &mut Self
Signal a value after all previous operations complete.
Operations submitted after this call may start before the signal is set.
Sourcefn exec(
&mut self,
program: &dyn Program,
buffers: &[&Buffer],
params: &ExecParams,
) -> &mut Self
fn exec( &mut self, program: &dyn Program, buffers: &[&Buffer], params: &ExecParams, ) -> &mut Self
Execute a compiled program with the given buffers and parameters.
§Arguments
program- The compiled program to executebuffers- Buffer arguments (raw pointers extracted internally)params- Execution parameters (grid size, etc.)
§Safety
Caller must ensure:
- All buffers are allocated
- No conflicting buffer accesses (handled by executor)
Sourcefn copy(&mut self, dst: &Buffer, src: &Buffer) -> &mut Self
fn copy(&mut self, dst: &Buffer, src: &Buffer) -> &mut Self
Copy data between buffers.
Both buffers must be accessible from this queue’s device. For cross-device copies, use the executor’s transfer mechanism.
Sourcefn memory_barrier(&mut self) -> &mut Self
fn memory_barrier(&mut self) -> &mut Self
Insert a memory barrier.
Ensures all previous memory operations are visible to subsequent operations. Mostly needed for CPU and some GPU memory models.
Sourcefn submit(&mut self) -> Result<()>
fn submit(&mut self) -> Result<()>
Submit all batched operations to the hardware.
This is the only blocking point - it submits work but doesn’t wait for completion. Use signals to synchronize.
Sourcefn device(&self) -> &DeviceSpec
fn device(&self) -> &DeviceSpec
Get the device this queue belongs to.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.