struct State {
trackers: RenderBundleScope,
pipeline: Option<PipelineState>,
bind: ArrayVec<Option<BindState>, { hal::MAX_BIND_GROUPS }>,
vertex: [Option<VertexState>; 16],
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,
}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: RenderBundleScopeResources 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: [Option<VertexState>; 16]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: usizeImplementations§
Source§impl State
impl State
Sourcefn pipeline(&self) -> Result<&PipelineState, RenderBundleErrorInner>
fn pipeline(&self) -> Result<&PipelineState, RenderBundleErrorInner>
Return the current pipeline state. Return an error if none is set.
Sourcefn invalidate_bind_group_from(&mut self, index: usize)
fn invalidate_bind_group_from(&mut self, index: usize)
Mark all non-empty bind group table entries from index onwards as dirty.
fn set_bind_group( &mut self, slot: u32, bind_group: &Arc<BindGroup>, dynamic_offsets: Range<usize>, )
Sourcefn invalidate_bind_groups(
&mut self,
new: &PipelineState,
layout: &PipelineLayout,
)
fn invalidate_bind_groups( &mut self, new: &PipelineState, layout: &PipelineLayout, )
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.
Sourcefn set_index_buffer(
&mut self,
buffer: Arc<Buffer>,
format: IndexFormat,
range: Range<BufferAddress>,
)
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.
Sourcefn flush_index(&mut self)
fn flush_index(&mut self)
Generate a SetIndexBuffer command to prepare for an indexed draw
command, if needed.
fn flush_vertices(&mut self)
Sourcefn flush_binds(
&mut self,
used_bind_groups: usize,
dynamic_offsets: &[DynamicOffset],
)
fn flush_binds( &mut self, used_bind_groups: usize, dynamic_offsets: &[DynamicOffset], )
Generate SetBindGroup commands for any bind groups that need to be updated.