State

Struct State 

Source
struct State {
    trackers: RenderBundleScope,
    pipeline: Option<Arc<RenderPipeline>>,
    vertex: VertexState,
    index: Option<IndexState>,
    flat_dynamic_offsets: Vec<DynamicOffset>,
    device: Arc<Device>,
    commands: Vec<ArcRenderCommand>,
    buffer_memory_init_actions: Vec<BufferInitTrackerAction>,
    texture_memory_init_actions: Vec<TextureInitTrackerAction>,
    next_dynamic_offset: usize,
    binder: Binder,
    immediate_slots_set: ImmediateSlots,
}
Expand description

The state of a single vertex buffer slot during render bundle encoding.

RenderBundleEncoder::finish uses this to drop redundant SetVertexBuffer commands from the final RenderBundle. It records one vertex buffer slot’s state changes here, and then calls this type’s flush method just before any draw command to produce a SetVertexBuffer commands if one is necessary.

Binding ranges must be validated against the size of the buffer before being stored in VertexState.

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

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

§pipeline: Option<Arc<RenderPipeline>>

The currently set pipeline, if any.

§vertex: VertexState

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.

§device: Arc<Device>§commands: Vec<ArcRenderCommand>§buffer_memory_init_actions: Vec<BufferInitTrackerAction>§texture_memory_init_actions: Vec<TextureInitTrackerAction>§next_dynamic_offset: usize§binder: Binder§immediate_slots_set: ImmediateSlots

A bitmask, tracking which 4-byte slots have been written via set_immediates. Checked against the pipeline’s required slots before each draw call.

Implementations§

Source§

impl State

Source

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

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

Source

fn flush_index(&mut self)

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

Source

fn flush_vertex_buffers(&mut self)

Source

fn is_ready(&mut self, family: DrawCommandFamily) -> Result<(), DrawError>

Validation for a draw command.

This should be further deduplicated with similar validation on render/compute passes.

Source

fn flush_bindings(&mut self)

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

This should be further deduplicated with similar code on render/compute passes.

Trait Implementations§

Source§

impl Debug for State

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,