From 78d9ee84aa82e614cce967daf7a9f2695a3e40d2 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 11 Oct 2023 15:43:13 +0200 Subject: [PATCH] Default to enabling debugging flags if debug_assertions --- wgpu-types/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 33117f50ae7..9c0c989c0f2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -822,8 +822,10 @@ bitflags::bitflags! { /// Instance debugging flags. /// /// These are not part of the webgpu standard. + /// + /// Defaults to enabling debugging-related flags if the build configuration has `debug_assertions`. #[repr(transparent)] - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct InstanceFlags: u32 { /// Generate debug information in shaders and objects. const DEBUG = 1 << 0; @@ -832,10 +834,16 @@ bitflags::bitflags! { } } +impl Default for InstanceFlags { + fn default() -> Self { + Self::from_build_config() + } +} + impl InstanceFlags { /// Enable debugging and validation flags. pub fn debugging() -> Self { - InstanceFlags::default() | InstanceFlags::DEBUG | InstanceFlags::VALIDATION + InstanceFlags::DEBUG | InstanceFlags::VALIDATION } /// Infer good defaults from the build type @@ -846,7 +854,7 @@ impl InstanceFlags { return InstanceFlags::debugging(); } - InstanceFlags::default() + InstanceFlags::empty() } /// Returns this set of flags, affected by environment variables.