craballoc::runtime

Trait IsRuntime

Source
pub trait IsRuntime: Clone {
    type Buffer;
    type BufferUsages: Clone;

    // Required methods
    fn buffer_create(
        &self,
        capacity: usize,
        label: Option<&str>,
        usages: Self::BufferUsages,
    ) -> Self::Buffer;
    fn buffer_copy(
        &self,
        source_buffer: &Self::Buffer,
        destination_buffer: &Self::Buffer,
        label: Option<&str>,
    );
    fn buffer_write<U: Iterator<Item = SlabUpdate>>(
        &self,
        updates: U,
        buffer: &Self::Buffer,
    );
    fn buffer_read(
        &self,
        buffer: &Self::Buffer,
        buffer_len: usize,
        range: impl RangeBounds<usize>,
    ) -> impl Future<Output = Result<Vec<u32>, SlabAllocatorError>>;
}
Expand description

Represents the runtime that provides the interface to the GPU buffer.

For example, this could be a struct that contains wgpu::Device and wgpu::Queue, or it could be a struct that contains Vulkan types, etc.

Required Associated Types§

Source

type Buffer

The type of buffer this runtime engages with.

Source

type BufferUsages: Clone

The type used to denote the configuration of the buffer.

Required Methods§

Source

fn buffer_create( &self, capacity: usize, label: Option<&str>, usages: Self::BufferUsages, ) -> Self::Buffer

Create a new buffer with the given capacity, where capacity is the number of u32s that can be stored in the buffer.

Source

fn buffer_copy( &self, source_buffer: &Self::Buffer, destination_buffer: &Self::Buffer, label: Option<&str>, )

Copy the contents of one buffer into another at index 0.

Source

fn buffer_write<U: Iterator<Item = SlabUpdate>>( &self, updates: U, buffer: &Self::Buffer, )

Write the updates into the given buffer.

Source

fn buffer_read( &self, buffer: &Self::Buffer, buffer_len: usize, range: impl RangeBounds<usize>, ) -> impl Future<Output = Result<Vec<u32>, SlabAllocatorError>>

Read the range from the given buffer.

§Note

This function is async.

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§