diff --git a/d3d12/src/debug.rs b/d3d12/src/debug.rs index 3a6abc46b7e..f321d878d8a 100644 --- a/d3d12/src/debug.rs +++ b/d3d12/src/debug.rs @@ -1,7 +1,10 @@ use crate::com::ComPtr; -use winapi::um::d3d12sdklayers; #[cfg(any(feature = "libloading", feature = "implicit-link"))] use winapi::Interface as _; +use winapi::{ + shared::{minwindef::TRUE, winerror::S_OK}, + um::d3d12sdklayers, +}; pub type Debug = ComPtr; @@ -40,4 +43,14 @@ impl Debug { pub fn enable_layer(&self) { unsafe { self.EnableDebugLayer() } } + + pub fn enable_gpu_based_validation(&self) -> bool { + let (ptr, hr) = unsafe { self.cast::() }; + if hr == S_OK { + unsafe { ptr.SetEnableGPUBasedValidation(TRUE) }; + true + } else { + false + } + } } diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 7bf5f3ef755..1ec7730b26f 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -24,6 +24,7 @@ impl crate::Instance for super::Instance { Ok(pair) => match pair.into_result() { Ok(debug_controller) => { debug_controller.enable_layer(); + debug_controller.enable_gpu_based_validation(); } Err(err) => { log::warn!("Unable to enable D3D12 debug interface: {}", err);