ComputeBackend

Trait ComputeBackend 

Source
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§

Source

type Device: ComputeDevice

Associated device type for this backend.

Source

type Buffer: Buffer

Buffer handle type.

Source

type CommandEncoder: CommandEncoder<Buffer = Self::Buffer>

Command encoder / stream type.

Source

type Fence: Fence

Synchronization primitive.

Required Methods§

Source

fn name() -> &'static str

Get the backend name identifier.

Source

fn enumerate_devices() -> ComputeResult<Vec<Self::Device>>

Enumerate all available devices for this backend.

Source

fn new(device: &Self::Device) -> ComputeResult<Self>
where Self: Sized,

Create a backend instance bound to a specific device.

Source

fn device(&self) -> &Self::Device

Get the device this backend is bound to.

Source

fn allocate_buffer( &self, size: usize, usage: BufferUsage, ) -> ComputeResult<Self::Buffer>

Allocate a buffer on the device.

Source

fn create_encoder(&self) -> ComputeResult<Self::CommandEncoder>

Create a command encoder for batching operations.

Source

fn submit(&self, encoder: Self::CommandEncoder) -> ComputeResult<Self::Fence>

Submit encoded commands and return a fence for synchronization.

Source

fn wait(&self, fence: &Self::Fence) -> ComputeResult<()>

Wait for a specific fence to complete.

Source

fn synchronize(&self) -> ComputeResult<()>

Synchronize all pending operations on this backend.

Source

fn seed(&self, seed: u64)

Seed the random number generator for this backend.

Provided Methods§

Source

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.

Implementors§