Trait CommandEncoder

Source
pub trait CommandEncoder {
    // Required methods
    fn begin_render_pass<'encoder>(
        &'encoder mut self,
        descriptor: &RenderPassDescriptor<'encoder>,
    ) -> Box<dyn RenderPass<'encoder> + 'encoder>;
    fn begin_compute_pass<'encoder>(
        &'encoder mut self,
        descriptor: &ComputePassDescriptor<'encoder>,
    ) -> Box<dyn ComputePass<'encoder> + 'encoder>;
    fn begin_profiler_compute_pass<'encoder>(
        &'encoder mut self,
        label: Option<&str>,
        profiler: &'encoder dyn GpuProfiler,
        pass_index: u32,
    ) -> Box<dyn ComputePass<'encoder> + 'encoder>;
    fn copy_buffer_to_buffer(
        &mut self,
        source: &BufferId,
        source_offset: u64,
        destination: &BufferId,
        destination_offset: u64,
        size: u64,
    );
    fn finish(self: Box<Self>) -> CommandBufferId;
    fn as_any_mut(&mut self) -> &mut dyn Any;
}
Expand description

A trait for an object that records a sequence of GPU commands.

A CommandEncoder is the main tool for building a CommandBufferId. It creates render and compute passes, and can also record commands that happen outside of a pass, such as buffer copies.

The encoder is a stateful object; its lifetime ('encoder) is tied to the passes it creates.

Required Methods§

Source

fn begin_render_pass<'encoder>( &'encoder mut self, descriptor: &RenderPassDescriptor<'encoder>, ) -> Box<dyn RenderPass<'encoder> + 'encoder>

Begins a new render pass, returning a mutable RenderPass object.

The returned RenderPass object borrows the encoder mutably, so only one pass can be active at a time. When the RenderPass object is dropped, the pass is ended.

Source

fn begin_compute_pass<'encoder>( &'encoder mut self, descriptor: &ComputePassDescriptor<'encoder>, ) -> Box<dyn ComputePass<'encoder> + 'encoder>

Begins a new compute pass, returning a mutable ComputePass object.

Source

fn begin_profiler_compute_pass<'encoder>( &'encoder mut self, label: Option<&str>, profiler: &'encoder dyn GpuProfiler, pass_index: u32, ) -> Box<dyn ComputePass<'encoder> + 'encoder>

Begins a special-purpose compute pass exclusively for profiler timestamps. The implementation of this method will handle the backend-specific query details.

Source

fn copy_buffer_to_buffer( &mut self, source: &BufferId, source_offset: u64, destination: &BufferId, destination_offset: u64, size: u64, )

Records a command to copy data from one buffer to another on the GPU.

Source

fn finish(self: Box<Self>) -> CommandBufferId

Finalizes the command recording and returns a handle to the resulting command buffer.

This method consumes the encoder. The returned CommandBufferId can then be submitted to the [GraphicsDevice]’s command queue.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to the underlying trait object as Any.

Implementors§