From d6f3472467fc2dff8c56ea7f3c1d1e55a5a28eca Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 31 Mar 2022 16:57:28 -0700 Subject: [PATCH] Add logging to LifetimeTracker::triage_suspected. This adds `log::debug` lines reporting the decision to actually free something, for all resource types. --- wgpu-core/src/device/life.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/device/life.rs b/wgpu-core/src/device/life.rs index 21efcb4256..5669e89e1b 100644 --- a/wgpu-core/src/device/life.rs +++ b/wgpu-core/src/device/life.rs @@ -445,6 +445,7 @@ impl LifetimeTracker { while let Some(id) = self.suspected_resources.render_bundles.pop() { if trackers.bundles.remove_abandoned(id) { + log::debug!("Bundle {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyRenderBundle(id.0)); @@ -463,6 +464,7 @@ impl LifetimeTracker { while let Some(id) = self.suspected_resources.bind_groups.pop() { if trackers.bind_groups.remove_abandoned(id) { + log::debug!("Bind group {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyBindGroup(id.0)); @@ -494,6 +496,7 @@ impl LifetimeTracker { let mut list = mem::take(&mut self.suspected_resources.texture_views); for id in list.drain(..) { if trackers.views.remove_abandoned(id) { + log::debug!("Texture view {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyTextureView(id.0)); @@ -520,6 +523,7 @@ impl LifetimeTracker { for id in self.suspected_resources.textures.drain(..) { if trackers.textures.remove_abandoned(id) { + log::debug!("Texture {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyTexture(id.0)); @@ -556,6 +560,7 @@ impl LifetimeTracker { for id in self.suspected_resources.samplers.drain(..) { if trackers.samplers.remove_abandoned(id) { + log::debug!("Sampler {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroySampler(id.0)); @@ -580,11 +585,11 @@ impl LifetimeTracker { for id in self.suspected_resources.buffers.drain(..) { if trackers.buffers.remove_abandoned(id) { + log::debug!("Buffer {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyBuffer(id.0)); } - log::debug!("Buffer {:?} is detached", id); if let Some(res) = hub.buffers.unregister_locked(id.0, &mut *guard) { let submit_index = res.life_guard.life_count(); @@ -608,6 +613,7 @@ impl LifetimeTracker { for id in self.suspected_resources.compute_pipelines.drain(..) { if trackers.compute_pipes.remove_abandoned(id) { + log::debug!("Compute pipeline {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyComputePipeline(id.0)); @@ -632,6 +638,7 @@ impl LifetimeTracker { for id in self.suspected_resources.render_pipelines.drain(..) { if trackers.render_pipes.remove_abandoned(id) { + log::debug!("Render pipeline {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyRenderPipeline(id.0)); @@ -660,6 +667,7 @@ impl LifetimeTracker { { //Note: this has to happen after all the suspected pipelines are destroyed if ref_count.load() == 1 { + log::debug!("Pipeline layout {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyPipelineLayout(id.0)); @@ -684,6 +692,7 @@ impl LifetimeTracker { //Note: same BGL can appear multiple times in the list, but only the last // encounter could drop the refcount to 0. if guard[id].multi_ref_count.dec_and_check_empty() { + log::debug!("Bind group layout {:?} will be destroyed", id); #[cfg(feature = "trace")] if let Some(t) = trace { t.lock().add(trace::Action::DestroyBindGroupLayout(id.0)); @@ -701,6 +710,7 @@ impl LifetimeTracker { for id in self.suspected_resources.query_sets.drain(..) { if trackers.query_sets.remove_abandoned(id) { + log::debug!("Query set {:?} will be destroyed", id); // #[cfg(feature = "trace")] // trace.map(|t| t.lock().add(trace::Action::DestroyComputePipeline(id.0))); if let Some(res) = hub.query_sets.unregister_locked(id.0, &mut *guard) {