remove StatelessTracker.add_single

This commit is contained in:
teoxoy 2024-07-02 18:35:23 +02:00 committed by Teodor Tanasoaia
parent 39a268c624
commit dbcb273188
3 changed files with 18 additions and 31 deletions

View File

@ -618,11 +618,9 @@ fn set_bind_group<A: HalApi>(
bind_group_id: id::Id<id::markers::BindGroup>,
) -> Result<(), RenderBundleErrorInner> {
let bind_group = bind_group_guard
.get(bind_group_id)
.get_owned(bind_group_id)
.map_err(|_| RenderCommandError::InvalidBindGroupId(bind_group_id))?;
state.trackers.bind_groups.write().add_single(bind_group);
bind_group.same_device(&state.device)?;
let max_bind_groups = state.device.limits.max_bind_groups;
@ -655,6 +653,7 @@ fn set_bind_group<A: HalApi>(
offsets_range,
);
unsafe { state.trackers.merge_bind_group(&bind_group.used)? };
state.trackers.bind_groups.write().insert_single(bind_group);
// Note: stateless trackers are not merged: the lifetime reference
// is held to the bind group itself.
Ok(())
@ -669,11 +668,9 @@ fn set_pipeline<A: HalApi>(
pipeline_id: id::Id<id::markers::RenderPipeline>,
) -> Result<(), RenderBundleErrorInner> {
let pipeline = pipeline_guard
.get(pipeline_id)
.get_owned(pipeline_id)
.map_err(|_| RenderCommandError::InvalidPipelineId(pipeline_id))?;
state.trackers.render_pipelines.write().add_single(pipeline);
pipeline.same_device(&state.device)?;
context
@ -687,7 +684,7 @@ fn set_pipeline<A: HalApi>(
return Err(RenderCommandError::IncompatibleStencilAccess(pipeline.error_ident()).into());
}
let pipeline_state = PipelineState::new(pipeline);
let pipeline_state = PipelineState::new(&pipeline);
state
.commands
@ -700,6 +697,12 @@ fn set_pipeline<A: HalApi>(
state.invalidate_bind_groups(&pipeline_state, &pipeline.layout);
state.pipeline = Some(pipeline_state);
state
.trackers
.render_pipelines
.write()
.insert_single(pipeline);
Ok(())
}

View File

@ -231,7 +231,7 @@ pub(super) fn validate_and_begin_occlusion_query<A: HalApi>(
let needs_reset = reset_state.is_none();
query_set.validate_query(SimplifiedQueryType::Occlusion, query_index, reset_state)?;
tracker.add_single(&query_set);
tracker.insert_single(query_set.clone());
if let Some((_old, old_idx)) = active_query.take() {
return Err(QueryUseError::AlreadyStarted {
@ -282,7 +282,7 @@ pub(super) fn validate_and_begin_pipeline_statistics_query<A: HalApi>(
reset_state,
)?;
tracker.add_single(&query_set);
tracker.insert_single(query_set.clone());
if let Some((_old, old_idx)) = active_query.take() {
return Err(QueryUseError::AlreadyStarted {
@ -346,12 +346,12 @@ impl Global {
let raw_encoder = encoder.open()?;
let query_set_guard = hub.query_sets.read();
let query_set = query_set_guard
let query_set = hub
.query_sets
.get(query_set_id)
.map_err(|_| QueryError::InvalidQuerySetId(query_set_id))?;
tracker.query_sets.add_single(query_set);
let query_set = tracker.query_sets.insert_single(query_set);
query_set.validate_and_write_timestamp(raw_encoder, query_index, None)?;
@ -393,12 +393,12 @@ impl Global {
return Err(QueryError::Resolve(ResolveError::BufferOffsetAlignment));
}
let query_set_guard = hub.query_sets.read();
let query_set = query_set_guard
let query_set = hub
.query_sets
.get(query_set_id)
.map_err(|_| QueryError::InvalidQuerySetId(query_set_id))?;
tracker.query_sets.add_single(query_set);
let query_set = tracker.query_sets.insert_single(query_set);
query_set.same_device_as(cmd_buf.as_ref())?;

View File

@ -171,22 +171,6 @@ impl<T: Trackable> StatelessTracker<T> {
unsafe { self.metadata.insert(index, resource) }
}
/// Adds the given resource to the tracker.
///
/// If the ID is higher than the length of internal vectors,
/// the vectors will be extended. A call to set_size is not needed.
pub fn add_single(&mut self, resource: &Arc<T>) {
let index = resource.tracker_index().as_usize();
self.allow_index(index);
self.tracker_assert_in_bounds(index);
unsafe {
self.metadata.insert(index, resource.clone());
}
}
/// Adds the given resources from the given tracker.
///
/// If the ID is higher than the length of internal vectors,