From b3490de69d4c0107605e7ff2b28cafd2b2ccaa5a Mon Sep 17 00:00:00 2001 From: Okko Hakola Date: Wed, 24 Jan 2024 13:49:18 +0200 Subject: [PATCH] [d3d12] Avoid panic on instance drop (#5134) --- CHANGELOG.md | 3 +++ wgpu-hal/src/dx12/instance.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbdac26b4c..53a43857bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,9 @@ Bottom level categories: ### Bug Fixes +#### General +- Fix `panic!` when dropping `Instance` without `InstanceFlags::VALIDATION`. By @hakolao in [#5134](https://github.com/gfx-rs/wgpu/pull/5134) + #### WGL - In Surface::configure and Surface::present, fix the current GL context not being unset when releasing the lock that guards access to making the context current. This was causing other threads to panic when trying to make the context current. By @Imberflur in [#5087](https://github.com/gfx-rs/wgpu/pull/5087). diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 7bf5f3ef75..47e4463d2b 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -7,7 +7,9 @@ use std::{mem, sync::Arc}; impl Drop for super::Instance { fn drop(&mut self) { - crate::auxil::dxgi::exception::unregister_exception_handler(); + if self.flags.contains(wgt::InstanceFlags::VALIDATION) { + crate::auxil::dxgi::exception::unregister_exception_handler(); + } } }