From f19217479dec659f7cbf429460c054b1cc0bebd4 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:52:37 +0200 Subject: [PATCH] remove `Tracker.add_from_render_bundle` The render bundle resources are already kept alive by the render bundle itself, there is no need to add them. --- wgpu-core/src/command/render.rs | 5 +---- wgpu-core/src/track/mod.rs | 21 --------------------- wgpu-core/src/track/stateless.rs | 24 ------------------------ 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index f42bc0235..251daa7d1 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -2716,9 +2716,7 @@ fn execute_bundle( ) -> Result<(), RenderPassErrorInner> { api_log!("RenderPass::execute_bundle {}", bundle.error_ident()); - // Have to clone the bundle arc, otherwise we keep a mutable reference to the bundle - // while later trying to add the bundle's resources to the tracker. - let bundle = state.tracker.bundles.insert_single(bundle).clone(); + let bundle = state.tracker.bundles.insert_single(bundle); bundle.same_device_as(cmd_buf.as_ref())?; @@ -2769,7 +2767,6 @@ fn execute_bundle( unsafe { state.info.usage_scope.merge_render_bundle(&bundle.used)?; - state.tracker.add_from_render_bundle(&bundle.used)?; }; state.reset_bundle(); Ok(()) diff --git a/wgpu-core/src/track/mod.rs b/wgpu-core/src/track/mod.rs index be3534cdf..5fcebb578 100644 --- a/wgpu-core/src/track/mod.rs +++ b/wgpu-core/src/track/mod.rs @@ -681,25 +681,4 @@ impl Tracker { .set_and_remove_from_usage_scope_sparse(&mut scope.textures, &bind_group.textures) }; } - - /// Tracks the stateless resources from the given renderbundle. It is expected - /// that the stateful resources will get merged into a usage scope first. - /// - /// # Safety - /// - /// The maximum ID given by each bind group resource must be less than the - /// value given to `set_size` - pub unsafe fn add_from_render_bundle( - &mut self, - render_bundle: &RenderBundleScope, - ) -> Result<(), ResourceUsageCompatibilityError> { - self.bind_groups - .add_from_tracker(&*render_bundle.bind_groups.read()); - self.render_pipelines - .add_from_tracker(&*render_bundle.render_pipelines.read()); - self.query_sets - .add_from_tracker(&*render_bundle.query_sets.read()); - - Ok(()) - } } diff --git a/wgpu-core/src/track/stateless.rs b/wgpu-core/src/track/stateless.rs index 91cdc0fa3..b2de45363 100644 --- a/wgpu-core/src/track/stateless.rs +++ b/wgpu-core/src/track/stateless.rs @@ -90,28 +90,4 @@ impl StatelessTracker { unsafe { self.metadata.insert(index, resource) } } - - /// Adds the given resources from the given 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_from_tracker(&mut self, other: &Self) { - let incoming_size = other.metadata.size(); - if incoming_size > self.metadata.size() { - self.set_size(incoming_size); - } - - for index in other.metadata.owned_indices() { - self.tracker_assert_in_bounds(index); - other.tracker_assert_in_bounds(index); - unsafe { - let previously_owned = self.metadata.contains_unchecked(index); - - if !previously_owned { - let other_resource = other.metadata.get_resource_unchecked(index); - self.metadata.insert(index, other_resource.clone()); - } - } - } - } }