Struct wgpu_core::command::bundle::State

source ·
struct State<A: HalApi> {
    trackers: RenderBundleScope<A>,
    pipeline: Option<PipelineState>,
    bind: ArrayVec<Option<BindState>, { hal::MAX_BIND_GROUPS }>,
    vertex: ArrayVec<Option<VertexState>, { hal::MAX_VERTEX_BUFFERS }>,
    index: Option<IndexState>,
    flat_dynamic_offsets: Vec<DynamicOffset>,
}
Expand description

State for analyzing and cleaning up bundle command streams.

To minimize state updates, RenderBundleEncoder::finish actually just applies commands like SetBindGroup and SetIndexBuffer to the simulated state stored here, and then calls the flush_foo methods before draw calls to produce the update commands we actually need.

Fields§

§trackers: RenderBundleScope<A>

Resources used by this bundle. This will become RenderBundle::used.

§pipeline: Option<PipelineState>

The currently set pipeline, if any.

§bind: ArrayVec<Option<BindState>, { hal::MAX_BIND_GROUPS }>

The bind group set at each index, if any.

§vertex: ArrayVec<Option<VertexState>, { hal::MAX_VERTEX_BUFFERS }>

The state of each vertex buffer slot.

§index: Option<IndexState>

The current index buffer, if one has been set. We flush this state before indexed draw commands.

§flat_dynamic_offsets: Vec<DynamicOffset>

Dynamic offset values used by the cleaned-up command sequence.

This becomes the final RenderBundle’s [BasePass]’s dynamic_offsets list.

Implementations§

source§

impl<A: HalApi> State<A>

source

fn vertex_limits(&self, pipeline: &PipelineState) -> VertexLimitState

source

fn pipeline_id(&self) -> Option<RenderPipelineId>

Return the id of the current pipeline, if any.

source

fn pipeline( &self, scope: PassErrorScope ) -> Result<&PipelineState, RenderBundleError>

Return the current pipeline state. Return an error if none is set.

source

fn invalidate_bind_group_from(&mut self, index: usize)

Mark all non-empty bind group table entries from index onwards as dirty.

source

fn set_bind_group( &mut self, slot: u32, bind_group_id: BindGroupId, layout_id: Valid<BindGroupLayoutId>, dynamic_offsets: Range<usize> )

source

fn invalidate_bind_groups( &mut self, new: &PipelineState, layout: &PipelineLayout<A> )

Determine which bind group slots need to be re-set after a pipeline change.

Given that we are switching from the current pipeline state to new, whose layout is layout, mark all the bind group slots that we need to emit new SetBindGroup commands for as dirty.

According to wgpu_hal’s rules:

  • If the layout of any bind group slot changes, then that slot and all following slots must have their bind groups re-established.

  • Changing the push constant ranges at all requires re-establishing all bind groups.

source

fn set_index_buffer( &mut self, buffer: BufferId, format: IndexFormat, range: Range<BufferAddress> )

Set the bundle’s current index buffer and its associated parameters.

source

fn flush_index(&mut self) -> Option<RenderCommand>

Generate a SetIndexBuffer command to prepare for an indexed draw command, if needed.

source

fn flush_vertices(&mut self) -> impl Iterator<Item = RenderCommand> + '_

source

fn flush_binds( &mut self, used_bind_groups: usize, dynamic_offsets: &[DynamicOffset] ) -> impl Iterator<Item = RenderCommand> + '_

Generate SetBindGroup commands for any bind groups that need to be updated.

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for State<A>

§

impl<A> Send for State<A>where A: Send,

§

impl<A> Sync for State<A>where A: Sync,

§

impl<A> Unpin for State<A>where A: Unpin, <A as Api>::BindGroup: Unpin, <A as Api>::QuerySet: Unpin, <A as Api>::RenderPipeline: Unpin, <A as Api>::Sampler: Unpin, <A as Api>::TextureView: Unpin,

§

impl<A> !UnwindSafe for State<A>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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.
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.
source§

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

Performs the conversion.
source§

impl<T> WasmNotSend for Twhere T: Send,

source§

impl<T> WasmNotSync for Twhere T: Sync,