From e4ef3b401a271425261c18843e764f8d9570d8a7 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 13 Feb 2024 17:42:02 +0100 Subject: [PATCH] Add an advanced_debugging preset including wgpu base validation (#5248) Co-authored-by: Erich Gubler --- CHANGELOG.md | 2 +- tests/src/init.rs | 2 +- tests/tests/device.rs | 2 +- wgpu-types/src/lib.rs | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 272c5fde1..999e221f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,7 +91,7 @@ Bottom level categories: - `wgpu-core`'s `serial-pass` feature has been removed. Use `serde` instead. By @KirmesBude in [#5149](https://github.com/gfx-rs/wgpu/pull/5149) - Added `InstanceFlags::GPU_BASED_VALIDATION`, which enables GPU-based validation for shaders. This is currently only supported on the DX12 and Vulkan backends; other platforms ignore this flag, for now. - When set, this flag implies `InstanceFlags::VALIDATION`. - - This has been added to the set of flags set by `InstanceFlags::debugging` and `InstanceFlags::from_build_config`. If you notice your graphics workloads running more slowly, this may be the culprit. + - This has been added to the set of flags set by `InstanceFlags::advanced_debugging`. Since the overhead is potentially very large, the flag is not enabled by default in debug builds when using `InstanceFlags::from_build_config`. - As with other instance flags, this flag can be changed in calls to `InstanceFlags::with_env` with the new `WGPU_GPU_BASED_VALIDATION` environment variable. By @ErichDonGubler in [#5146](https://github.com/gfx-rs/wgpu/pull/5146), [#5046](https://github.com/gfx-rs/wgpu/pull/5046). diff --git a/tests/src/init.rs b/tests/src/init.rs index 9a21c9847..8284a0362 100644 --- a/tests/src/init.rs +++ b/tests/src/init.rs @@ -31,7 +31,7 @@ pub fn initialize_instance() -> Instance { let gles_minor_version = wgpu::util::gles_minor_version_from_env().unwrap_or_default(); Instance::new(wgpu::InstanceDescriptor { backends, - flags: wgpu::InstanceFlags::debugging().with_env(), + flags: wgpu::InstanceFlags::advanced_debugging().with_env(), dx12_shader_compiler, gles_minor_version, }) diff --git a/tests/tests/device.rs b/tests/tests/device.rs index 5d3a10223..f6c42736a 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -38,7 +38,7 @@ fn device_lifetime_check() { backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()), dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(), - flags: wgpu::InstanceFlags::debugging().with_env(), + flags: wgpu::InstanceFlags::advanced_debugging().with_env(), }); let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index c8df9fcb0..61cc9630b 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -941,7 +941,12 @@ impl Default for InstanceFlags { impl InstanceFlags { /// Enable recommended debugging and validation flags. pub fn debugging() -> Self { - InstanceFlags::DEBUG | InstanceFlags::VALIDATION | InstanceFlags::GPU_BASED_VALIDATION + InstanceFlags::DEBUG | InstanceFlags::VALIDATION + } + + /// Enable advanced debugging and validation flags (potentially very slow). + pub fn advanced_debugging() -> Self { + Self::debugging() | InstanceFlags::GPU_BASED_VALIDATION } /// Infer good defaults from the build type