Skip to content

Commit

Permalink
WIP: feat(dx12): enable GPU-based validation for DX12 backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Jan 11, 2024
1 parent bc65d84 commit 7f66322
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion d3d12/src/debug.rs
Original file line number Diff line number Diff line change
@@ -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<d3d12sdklayers::ID3D12Debug>;

Expand Down Expand Up @@ -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::<d3d12sdklayers::ID3D12Debug1>() };
if hr == S_OK {
unsafe { ptr.SetEnableGPUBasedValidation(TRUE) };
true
} else {
false
}
}
}
1 change: 1 addition & 0 deletions wgpu-hal/src/dx12/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl crate::Instance<super::Api> 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);
Expand Down

0 comments on commit 7f66322

Please sign in to comment.