pub trait ComputeBackend:
Send
+ Sync
+ 'static {
type Device: ComputeDevice;
type Buffer: Buffer;
type CommandEncoder: CommandEncoder<Buffer = Self::Buffer>;
type Fence: Fence;
// Required methods
fn name() -> &'static str;
fn enumerate_devices() -> ComputeResult<Vec<Self::Device>>;
fn new(device: &Self::Device) -> ComputeResult<Self>
where Self: Sized;
fn device(&self) -> &Self::Device;
fn allocate_buffer(
&self,
size: usize,
usage: BufferUsage,
) -> ComputeResult<Self::Buffer>;
fn create_encoder(&self) -> ComputeResult<Self::CommandEncoder>;
fn submit(
&self,
encoder: Self::CommandEncoder,
) -> ComputeResult<Self::Fence>;
fn wait(&self, fence: &Self::Fence) -> ComputeResult<()>;
fn synchronize(&self) -> ComputeResult<()>;
fn seed(&self, seed: u64);
// Provided method
fn supports_operation(&self, op: &str) -> bool { ... }
}Expand description
Core backend trait for compute operations.
Each backend implementation provides device enumeration, buffer management, command encoding, and synchronization primitives.
Required Associated Types§
Sourcetype Device: ComputeDevice
type Device: ComputeDevice
Associated device type for this backend.
Sourcetype CommandEncoder: CommandEncoder<Buffer = Self::Buffer>
type CommandEncoder: CommandEncoder<Buffer = Self::Buffer>
Command encoder / stream type.
Required Methods§
Sourcefn enumerate_devices() -> ComputeResult<Vec<Self::Device>>
fn enumerate_devices() -> ComputeResult<Vec<Self::Device>>
Enumerate all available devices for this backend.
Sourcefn new(device: &Self::Device) -> ComputeResult<Self>where
Self: Sized,
fn new(device: &Self::Device) -> ComputeResult<Self>where
Self: Sized,
Create a backend instance bound to a specific device.
Sourcefn allocate_buffer(
&self,
size: usize,
usage: BufferUsage,
) -> ComputeResult<Self::Buffer>
fn allocate_buffer( &self, size: usize, usage: BufferUsage, ) -> ComputeResult<Self::Buffer>
Allocate a buffer on the device.
Sourcefn create_encoder(&self) -> ComputeResult<Self::CommandEncoder>
fn create_encoder(&self) -> ComputeResult<Self::CommandEncoder>
Create a command encoder for batching operations.
Sourcefn submit(&self, encoder: Self::CommandEncoder) -> ComputeResult<Self::Fence>
fn submit(&self, encoder: Self::CommandEncoder) -> ComputeResult<Self::Fence>
Submit encoded commands and return a fence for synchronization.
Sourcefn wait(&self, fence: &Self::Fence) -> ComputeResult<()>
fn wait(&self, fence: &Self::Fence) -> ComputeResult<()>
Wait for a specific fence to complete.
Sourcefn synchronize(&self) -> ComputeResult<()>
fn synchronize(&self) -> ComputeResult<()>
Synchronize all pending operations on this backend.
Provided Methods§
Sourcefn supports_operation(&self, op: &str) -> bool
fn supports_operation(&self, op: &str) -> bool
Check if this backend supports a specific operation.
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.