Skip to main content

Queue

Trait Queue 

Source
pub trait Queue<D: Device> {
    // Required methods
    fn write_buffer(&self, buffer: &D::Buffer, offset: u64, data: &[u8]);
    fn write_texture(&self, texture: &D::Texture, write: &TextureWrite<'_>);
    fn submit(&self, encoder: D::CommandEncoder);
    fn submit_tracked(&self, encoder: D::CommandEncoder) -> FenceValue;
    fn completed_fence(&self, device: &D) -> Result<FenceValue, GpuError>;
    fn read_buffer_async<'a>(
        &'a self,
        device: &'a D,
        buffer: &'a D::Buffer,
        offset: u64,
        size: u64,
    ) -> impl Future<Output = Result<Vec<u8>, GpuError>> + 'a;
    fn read_buffer_blocking(
        &self,
        device: &D,
        buffer: &D::Buffer,
        offset: u64,
        size: u64,
    ) -> Result<Vec<u8>, GpuError>;
    fn timestamp_period(&self) -> f32;
}
Expand description

Uploads and submission. One submission per frame is the discipline the engine holds; the trait does not enforce it, the render loop does.

Required Methods§

Source

fn write_buffer(&self, buffer: &D::Buffer, offset: u64, data: &[u8])

Writes bytes into a buffer at an offset. The source is borrowed for the duration of the call — an upload from a caller’s slice is copy-free on the host side.

Source

fn write_texture(&self, texture: &D::Texture, write: &TextureWrite<'_>)

Uploads a borrowed, tightly described region into a texture.

Source

fn submit(&self, encoder: D::CommandEncoder)

Submits one encoder’s recorded work.

Source

fn submit_tracked(&self, encoder: D::CommandEncoder) -> FenceValue

Submits work whose completion must gate resource residency.

Source

fn completed_fence(&self, device: &D) -> Result<FenceValue, GpuError>

Polls the backend and returns the greatest submission known complete.

§Errors

Returns device loss when completion status can no longer be queried.

Source

fn read_buffer_async<'a>( &'a self, device: &'a D, buffer: &'a D::Buffer, offset: u64, size: u64, ) -> impl Future<Output = Result<Vec<u8>, GpuError>> + 'a

Resolves a mapped buffer range without blocking the browser event loop. Off the frame path only: golden-image capture, picking and export.

§Errors

The device was lost, or the buffer was not readable.

Source

fn read_buffer_blocking( &self, device: &D, buffer: &D::Buffer, offset: u64, size: u64, ) -> Result<Vec<u8>, GpuError>

Native convenience that waits for a mapped range. Browser callers use Self::read_buffer_async.

§Errors

The device was lost, or the buffer was not readable.

Source

fn timestamp_period(&self) -> f32

Nanoseconds represented by one timestamp-query tick.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§