fix(dxgi): DX12 exception handler lifetime based on device not adapter (#6828)

This commit is contained in:
Benjamin Frye
2024-12-27 03:06:50 +11:00
committed by GitHub
parent 7c75ac7aa2
commit 4772cd8c63
4 changed files with 14 additions and 11 deletions

View File

@@ -141,9 +141,6 @@ pub fn create_factory(
if let Ok(Some(_)) = lib_dxgi.debug_interface1() {
factory_flags |= Dxgi::DXGI_CREATE_FACTORY_DEBUG;
}
// Intercept `OutputDebugString` calls
super::exception::register_exception_handler();
}
let factory4 = match lib_dxgi.create_factory4(factory_flags) {

View File

@@ -37,6 +37,13 @@ impl super::Device {
library: &Arc<D3D12Lib>,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
) -> Result<Self, crate::DeviceError> {
if private_caps
.instance_flags
.contains(wgt::InstanceFlags::VALIDATION)
{
auxil::dxgi::exception::register_exception_handler();
}
let mem_allocator = super::suballocation::create_allocator_wrapper(&raw, memory_hints)?;
let idle_fence: Direct3D12::ID3D12Fence = unsafe {

View File

@@ -12,14 +12,6 @@ use windows::{
use super::SurfaceTarget;
use crate::{auxil, dx12::D3D12Lib};
impl Drop for super::Instance {
fn drop(&mut self) {
if self.flags.contains(wgt::InstanceFlags::VALIDATION) {
auxil::dxgi::exception::unregister_exception_handler();
}
}
}
impl crate::Instance for super::Instance {
type A = super::Api;

View File

@@ -605,6 +605,13 @@ pub struct Device {
impl Drop for Device {
fn drop(&mut self) {
self.rtv_pool.lock().free_handle(self.null_rtv_handle);
if self
.private_caps
.instance_flags
.contains(wgt::InstanceFlags::VALIDATION)
{
auxil::dxgi::exception::unregister_exception_handler();
}
}
}