Struct gfx::Encoder

source ·
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>

source

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.

source

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.

source

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.

source

pub fn reset(&mut self)

Resets the encoded commands.

source

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

source

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

source

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

source

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

source

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.

source

pub fn update_constant_buffer<T: Copy>(&mut self, buf: &Buffer<R, T>, data: &T)

Update a buffer with a single structure.

source

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.

source

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.

source

pub fn clear_depth<T: DepthFormat>( &mut self, view: &DepthStencilView<R, T>, depth: Depth )

Clear a depth view with a specified value.

source

pub fn clear_stencil<T: StencilFormat>( &mut self, view: &DepthStencilView<R, T>, stencil: Stencil )

Clear a stencil view with a specified value.

source

pub fn clear_raw(&mut self, view: &RawRenderTargetView<R>, value: ClearColor)

Clears the supplied RawRenderTargetView to the supplied ClearColor.

source

pub fn clear_depth_raw(&mut self, view: &RawDepthStencilView<R>, depth: Depth)

Clear a raw depth view with a specified value.

source

pub fn clear_stencil_raw( &mut self, view: &RawDepthStencilView<R>, stencil: Stencil )

Clear a raw stencil view with a specified value.

source

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.

source

pub fn generate_mipmap<T: BlendFormat>( &mut self, view: &ShaderResourceView<R, T> )

Generate a mipmap chain for the given resource view.

source

pub fn generate_mipmap_raw(&mut self, view: &RawShaderResourceView<R>)

Untyped version of mipmap generation.

Trait Implementations§

source§

impl<R: Debug + Resources, C: Debug> Debug for Encoder<R, C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: Resources, C> From<C> for Encoder<R, C>

source§

fn from(combuf: C) -> Encoder<R, C>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<R, C> !RefUnwindSafe for Encoder<R, C>

§

impl<R, C> Send for Encoder<R, C>where C: Send,

§

impl<R, C> Sync for Encoder<R, C>where C: Sync,

§

impl<R, C> Unpin for Encoder<R, C>where C: Unpin, <R as Resources>::Buffer: Unpin, <R as Resources>::DepthStencilView: Unpin, <R as Resources>::RenderTargetView: Unpin, <R as Resources>::Sampler: Unpin, <R as Resources>::ShaderResourceView: Unpin, <R as Resources>::UnorderedAccessView: Unpin,

§

impl<R, C> !UnwindSafe for Encoder<R, C>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

const: unstable · source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.