pub struct Encoder<R: Resources, C> { /* private fields */ }
Expand description
Graphics Command Encoder
Overview
The Encoder
is a wrapper structure around a CommandBuffer
. It is responsible for sending
commands to the CommandBuffer
.
Construction & Handling
The Encoder
implements From<CommandBuffer>
, which is how it is constructed. There is no
cross-API way to create a CommandBuffer
, however, an API back-end should expose a function to
create one in its Factory
type. See the specific back-end for details on how to construct a
CommandBuffer
.
The encoder exposes multiple functions that add commands to its internal CommandBuffer
. To
submit these commands to the GPU so they can be rendered, call flush
.
Implementations§
source§impl<R: Resources, C: Buffer<R>> Encoder<R, C>
impl<R: Resources, C: Buffer<R>> Encoder<R, C>
sourcepub fn flush<D>(&mut self, device: &mut D)where
D: Device<Resources = R, CommandBuffer = C>,
pub fn flush<D>(&mut self, device: &mut D)where D: Device<Resources = R, CommandBuffer = C>,
Submits the commands in this Encoder
’s internal CommandBuffer
to the GPU, so they can
be executed.
Calling flush
before swapping buffers is critical as without it the commands of the
internal ´CommandBuffer´ will not be sent to the GPU, and as a result they will not be
processed. Calling flush too often however will result in a performance hit. It is
generally recommended to call flush once per frame, when all draw calls have been made.
sourcepub fn flush_no_reset<D>(&mut self, device: &mut D) -> SubmissionResult<()>where
D: Device<Resources = R, CommandBuffer = C>,
pub fn flush_no_reset<D>(&mut self, device: &mut D) -> SubmissionResult<()>where D: Device<Resources = R, CommandBuffer = C>,
Like flush
but keeps the encoded commands.
sourcepub fn fenced_flush_no_reset<D>(
&mut self,
device: &mut D,
after: Option<Fence<R>>
) -> SubmissionResult<Fence<R>>where
D: Device<Resources = R, CommandBuffer = C>,
pub fn fenced_flush_no_reset<D>( &mut self, device: &mut D, after: Option<Fence<R>> ) -> SubmissionResult<Fence<R>>where D: Device<Resources = R, CommandBuffer = C>,
Like flush_no_reset
but places a fence.
sourcepub fn copy_buffer<T: Pod>(
&mut self,
src: &Buffer<R, T>,
dst: &Buffer<R, T>,
src_offset: usize,
dst_offset: usize,
size: usize
) -> CopyBufferResult
pub fn copy_buffer<T: Pod>( &mut self, src: &Buffer<R, T>, dst: &Buffer<R, T>, src_offset: usize, dst_offset: usize, size: usize ) -> CopyBufferResult
Copy part of a buffer to another
sourcepub fn copy_buffer_to_texture_raw(
&mut self,
src: &RawBuffer<R>,
src_offset_bytes: usize,
dst: &RawTexture<R>,
cube_face: Option<CubeFace>,
info: RawImageInfo
) -> CopyBufferTextureResult
pub fn copy_buffer_to_texture_raw( &mut self, src: &RawBuffer<R>, src_offset_bytes: usize, dst: &RawTexture<R>, cube_face: Option<CubeFace>, info: RawImageInfo ) -> CopyBufferTextureResult
Copy part of a buffer to a texture
sourcepub fn copy_texture_to_buffer_raw(
&mut self,
src: &RawTexture<R>,
cube_face: Option<CubeFace>,
info: RawImageInfo,
dst: &RawBuffer<R>,
dst_offset_bytes: usize
) -> CopyTextureBufferResult
pub fn copy_texture_to_buffer_raw( &mut self, src: &RawTexture<R>, cube_face: Option<CubeFace>, info: RawImageInfo, dst: &RawBuffer<R>, dst_offset_bytes: usize ) -> CopyTextureBufferResult
Copy part of a texture to a buffer
sourcepub fn copy_texture_to_texture_raw(
&mut self,
src: &RawTexture<R>,
src_face: Option<CubeFace>,
src_info: RawImageInfo,
dst: &RawTexture<R>,
dst_face: Option<CubeFace>,
dst_info: RawImageInfo
) -> Result<(), CopyError<[Size; 3], [Size; 3]>>
pub fn copy_texture_to_texture_raw( &mut self, src: &RawTexture<R>, src_face: Option<CubeFace>, src_info: RawImageInfo, dst: &RawTexture<R>, dst_face: Option<CubeFace>, dst_info: RawImageInfo ) -> Result<(), CopyError<[Size; 3], [Size; 3]>>
Copy part of a texture to another texture
sourcepub fn update_buffer<T: Pod>(
&mut self,
buf: &Buffer<R, T>,
data: &[T],
offset_elements: usize
) -> Result<(), UpdateError<usize>>
pub fn update_buffer<T: Pod>( &mut self, buf: &Buffer<R, T>, data: &[T], offset_elements: usize ) -> Result<(), UpdateError<usize>>
Update a buffer with a slice of data.
sourcepub fn update_constant_buffer<T: Copy>(&mut self, buf: &Buffer<R, T>, data: &T)
pub fn update_constant_buffer<T: Copy>(&mut self, buf: &Buffer<R, T>, data: &T)
Update a buffer with a single structure.
sourcepub fn update_texture<S, T>(
&mut self,
tex: &Texture<R, T::Surface>,
cube_face: Option<CubeFace>,
img: NewImageInfo,
data: &[S::DataType]
) -> Result<(), UpdateError<[Size; 3]>>where
S: SurfaceTyped,
S::DataType: Copy,
T: Formatted<Surface = S>,
pub fn update_texture<S, T>( &mut self, tex: &Texture<R, T::Surface>, cube_face: Option<CubeFace>, img: NewImageInfo, data: &[S::DataType] ) -> Result<(), UpdateError<[Size; 3]>>where S: SurfaceTyped, S::DataType: Copy, T: Formatted<Surface = S>,
Update the contents of a texture.
sourcepub fn clear<T: RenderFormat>(
&mut self,
view: &RenderTargetView<R, T>,
value: T::View
)where
T::View: Into<ClearColor>,
pub fn clear<T: RenderFormat>( &mut self, view: &RenderTargetView<R, T>, value: T::View )where T::View: Into<ClearColor>,
Clears the supplied RenderTargetView
to the supplied ClearColor
.
sourcepub fn clear_depth<T: DepthFormat>(
&mut self,
view: &DepthStencilView<R, T>,
depth: Depth
)
pub fn clear_depth<T: DepthFormat>( &mut self, view: &DepthStencilView<R, T>, depth: Depth )
Clear a depth view with a specified value.
sourcepub fn clear_stencil<T: StencilFormat>(
&mut self,
view: &DepthStencilView<R, T>,
stencil: Stencil
)
pub fn clear_stencil<T: StencilFormat>( &mut self, view: &DepthStencilView<R, T>, stencil: Stencil )
Clear a stencil view with a specified value.
sourcepub fn clear_raw(&mut self, view: &RawRenderTargetView<R>, value: ClearColor)
pub fn clear_raw(&mut self, view: &RawRenderTargetView<R>, value: ClearColor)
Clears the supplied RawRenderTargetView
to the supplied ClearColor
.
sourcepub fn clear_depth_raw(&mut self, view: &RawDepthStencilView<R>, depth: Depth)
pub fn clear_depth_raw(&mut self, view: &RawDepthStencilView<R>, depth: Depth)
Clear a raw depth view with a specified value.
sourcepub fn clear_stencil_raw(
&mut self,
view: &RawDepthStencilView<R>,
stencil: Stencil
)
pub fn clear_stencil_raw( &mut self, view: &RawDepthStencilView<R>, stencil: Stencil )
Clear a raw stencil view with a specified value.
sourcepub fn draw<D: PipelineData<R>>(
&mut self,
slice: &Slice<R>,
pipeline: &PipelineState<R, D::Meta>,
user_data: &D
)
pub fn draw<D: PipelineData<R>>( &mut self, slice: &Slice<R>, pipeline: &PipelineState<R, D::Meta>, user_data: &D )
Draws a slice::Slice
using a pipeline state object, and its matching Data
structure.
sourcepub fn generate_mipmap<T: BlendFormat>(
&mut self,
view: &ShaderResourceView<R, T>
)
pub fn generate_mipmap<T: BlendFormat>( &mut self, view: &ShaderResourceView<R, T> )
Generate a mipmap chain for the given resource view.
sourcepub fn generate_mipmap_raw(&mut self, view: &RawShaderResourceView<R>)
pub fn generate_mipmap_raw(&mut self, view: &RawShaderResourceView<R>)
Untyped version of mipmap generation.