mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
feat(dx12): enable GPU-based validation for DX12 backend
Logic for doing this was sourced from <https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-d3d12-debug-layer-gpu-based-validation>.
This commit is contained in:
parent
ecd5836aed
commit
4aab8a8399
@ -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>;
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,9 @@ impl crate::Instance<super::Api> for super::Instance {
|
||||
Ok(pair) => match pair.into_result() {
|
||||
Ok(debug_controller) => {
|
||||
debug_controller.enable_layer();
|
||||
if !debug_controller.enable_gpu_based_validation() {
|
||||
log::warn!("Failed to enable GPU-based validation");
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("Unable to enable D3D12 debug interface: {}", err);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user