From 11b51693d3dc883b55b5ec0e30c340e43e6fac50 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 7 Dec 2024 22:17:12 +0100 Subject: [PATCH] Fix dropping Device if not using indirect validation (#6681) --- CHANGELOG.md | 1 + wgpu-core/src/device/resource.rs | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b932428d3b..27043042a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148] - Check that begin and end indices are not equal. - Check that at least one index is specified. - Reject destroyed buffers in query set resolution. By @ErichDonGubler in [#6579](https://github.com/gfx-rs/wgpu/pull/6579). +- Fix panic when dropping `Device` on some environments. By @Dinnerbone in [#6681](https://github.com/gfx-rs/wgpu/pull/6681). #### Naga diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 7b8f011c64..cf5ed7038b 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -154,10 +154,9 @@ impl Drop for Device { // SAFETY: We are in the Drop impl and we don't use self.fence anymore after this point. let fence = unsafe { ManuallyDrop::take(&mut self.fence.write()) }; #[cfg(feature = "indirect-validation")] - self.indirect_validation - .take() - .unwrap() - .dispose(self.raw.as_ref()); + if let Some(indirect_validation) = self.indirect_validation.take() { + indirect_validation.dispose(self.raw.as_ref()); + } unsafe { self.raw.destroy_buffer(zero_buffer); self.raw.destroy_fence(fence);