Struct wgpu_core::track::buffer::BufferUsageScope
source · pub(crate) struct BufferUsageScope {
state: Vec<BufferUses>,
metadata: ResourceMetadata<Arc<Buffer>>,
}
Expand description
Stores all buffer state within a single usage scope.
Fields§
§state: Vec<BufferUses>
§metadata: ResourceMetadata<Arc<Buffer>>
Implementations§
source§impl BufferUsageScope
impl BufferUsageScope
fn tracker_assert_in_bounds(&self, index: usize)
pub fn clear(&mut self)
sourcepub fn set_size(&mut self, size: usize)
pub fn set_size(&mut self, size: usize)
Sets the size of all the vectors inside the tracker.
Must be called with the highest possible Buffer ID before all unsafe functions are called.
sourcefn allow_index(&mut self, index: usize)
fn allow_index(&mut self, index: usize)
Extend the vectors to let the given index be valid.
sourcepub unsafe fn merge_bind_group(
&mut self,
bind_group: &BufferBindGroupState,
) -> Result<(), ResourceUsageCompatibilityError>
pub unsafe fn merge_bind_group( &mut self, bind_group: &BufferBindGroupState, ) -> Result<(), ResourceUsageCompatibilityError>
Merge the list of buffer states in the given bind group into this usage scope.
If any of the resulting states is invalid, stops the merge and returns a usage conflict with the details of the invalid state.
Because bind groups do not check if the union of all their states is valid, this method is allowed to return Err on the first bind group bound.
§Safety
Self::set_size
must be called with the maximum possible Buffer ID before this
method is called.
sourcepub fn merge_usage_scope(
&mut self,
scope: &Self,
) -> Result<(), ResourceUsageCompatibilityError>
pub fn merge_usage_scope( &mut self, scope: &Self, ) -> Result<(), ResourceUsageCompatibilityError>
Merge the list of buffer states in the given usage scope into this UsageScope.
If any of the resulting states is invalid, stops the merge and returns a usage conflict with the details of the invalid state.
If the given tracker uses IDs higher than the length of internal vectors, the vectors will be extended. A call to set_size is not needed.
sourcepub fn merge_single(
&mut self,
buffer: &Arc<Buffer>,
new_state: BufferUses,
) -> Result<(), ResourceUsageCompatibilityError>
pub fn merge_single( &mut self, buffer: &Arc<Buffer>, new_state: BufferUses, ) -> Result<(), ResourceUsageCompatibilityError>
Merge a single state into the UsageScope.
If the resulting state is invalid, returns a usage conflict with the details of the invalid state.
If the ID is higher than the length of internal vectors, the vectors will be extended. A call to set_size is not needed.
sourceunsafe fn insert_or_merge(
&mut self,
index32: u32,
index: usize,
state_provider: BufferStateProvider<'_>,
metadata_provider: ResourceMetadataProvider<'_, Arc<Buffer>>,
) -> Result<(), ResourceUsageCompatibilityError>
unsafe fn insert_or_merge( &mut self, index32: u32, index: usize, state_provider: BufferStateProvider<'_>, metadata_provider: ResourceMetadataProvider<'_, Arc<Buffer>>, ) -> Result<(), ResourceUsageCompatibilityError>
Does an insertion operation if the index isn’t tracked in the current metadata, otherwise merges the given state with the current state. If the merging would cause a conflict, returns that usage conflict.
§Safety
Indexes must be valid indexes into all arrays passed in to this function, either directly or via metadata or provider structs.