From 3d5d7dec0238426f0ad98db99c929fe4b934cdc2 Mon Sep 17 00:00:00 2001 From: XiaoPeng Date: Tue, 25 Jun 2024 19:27:13 +0800 Subject: [PATCH] clear refs to died texture views --- wgpu-core/src/device/life.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/device/life.rs b/wgpu-core/src/device/life.rs index ae16e151d..73f1e2ffc 100644 --- a/wgpu-core/src/device/life.rs +++ b/wgpu-core/src/device/life.rs @@ -595,7 +595,7 @@ impl LifetimeTracker { fn triage_suspected_texture_views(&mut self, trackers: &Mutex>) -> &mut Self { let mut trackers = trackers.lock(); let suspected_texture_views = &mut self.suspected_resources.texture_views; - Self::triage_resources( + let removed_views = Self::triage_resources( suspected_texture_views, self.active.as_mut_slice(), &mut trackers.views, @@ -607,6 +607,12 @@ impl LifetimeTracker { // `LifetimeTracker::suspected_resources` it remains there until it's // actually dropped, which for long-lived textures could be at the end // of execution. + for view in removed_views { + view.parent + .views + .lock() + .retain(|view| view.strong_count() > 1); + } self }