Skip to content

Commit

Permalink
fixup! 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 30, 2024
1 parent f652549 commit 2ba67bf
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions d3d12/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::com::ComPtr;
use crate::{com::ComPtr, weak_com_inheritance_chain};
#[cfg(any(feature = "libloading", feature = "implicit-link"))]
use winapi::Interface as _;
use winapi::{
shared::{minwindef::TRUE, winerror::S_OK},
um::d3d12sdklayers,
};
use winapi::{shared::minwindef::TRUE, um::d3d12sdklayers};

pub type Debug = ComPtr<d3d12sdklayers::ID3D12Debug>;
weak_com_inheritance_chain! {
pub enum Debug {
Debug(d3d12sdklayers::ID3D12Debug), from_debug, as_debug, debug;
Debug1(d3d12sdklayers::ID3D12Debug1), from_debug1, as_debug1, unwrap_debug1;
}
}

#[cfg(feature = "libloading")]
impl crate::D3D12Lib {
Expand All @@ -16,13 +18,13 @@ impl crate::D3D12Lib {
*mut *mut winapi::ctypes::c_void,
) -> crate::HRESULT;

let mut debug = Debug::null();
let mut debug = ComPtr::<d3d12sdklayers::ID3D12Debug>::null();
let hr = unsafe {
let func: libloading::Symbol<Fun> = self.lib.get(b"D3D12GetDebugInterface")?;
func(&d3d12sdklayers::ID3D12Debug::uuidof(), debug.mut_void())
};

Ok((debug, hr))
Ok((Debug::Debug(debug), hr))
}
}

Expand All @@ -45,9 +47,8 @@ impl Debug {
}

pub fn enable_gpu_based_validation(&self) -> bool {
let (ptr, hr) = unsafe { self.cast::<d3d12sdklayers::ID3D12Debug1>() };
if hr == S_OK {
unsafe { ptr.SetEnableGPUBasedValidation(TRUE) };
if let Some(debug1) = self.as_debug1() {
unsafe { debug1.SetEnableGPUBasedValidation(TRUE) };
true
} else {
false
Expand Down

0 comments on commit 2ba67bf

Please sign in to comment.