From 21858bf5e4ce5bc2508a1e34224c24ae7095c833 Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Fri, 20 Oct 2023 21:04:24 -0400 Subject: [PATCH] debug_printf: Add DEBUG_PRINTF capability --- src/valid/function.rs | 11 +++++++++++ src/valid/mod.rs | 2 ++ tests/in/debug-printf.param.ron | 3 +++ tests/in/spv/debug-printf-s.param.ron | 3 +++ 4 files changed, 19 insertions(+) create mode 100644 tests/in/debug-printf.param.ron create mode 100644 tests/in/spv/debug-printf-s.param.ron diff --git a/src/valid/function.rs b/src/valid/function.rs index 285b2109be..83704f30cd 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -144,6 +144,8 @@ pub enum FunctionError { index: usize, source: ExpressionError, }, + #[error("Capability {0:?} is required")] + MissingCapability(super::Capabilities), #[error( "Required uniformity of control flow for {0:?} in {1:?} is not fulfilled because of {2:?}" )] @@ -925,6 +927,15 @@ impl super::Validator { } } S::DebugPrintf { ref arguments, .. } => { + if !self + .capabilities + .contains(super::Capabilities::DEBUG_PRINTF) + { + return Err(FunctionError::MissingCapability( + super::Capabilities::DEBUG_PRINTF, + ) + .with_span_static(span, "debugPrintf")); + } for (index, &expr) in arguments.iter().enumerate() { context .resolve_type_impl(expr, &self.valid_expression_set) diff --git a/src/valid/mod.rs b/src/valid/mod.rs index f593b87535..6f91465dc8 100644 --- a/src/valid/mod.rs +++ b/src/valid/mod.rs @@ -117,6 +117,8 @@ bitflags::bitflags! { const DUAL_SOURCE_BLENDING = 0x2000; /// Support for arrayed cube textures. const CUBE_ARRAY_TEXTURES = 0x4000; + /// Support for `debugPrintf` + const DEBUG_PRINTF = 0x8000; } } diff --git a/tests/in/debug-printf.param.ron b/tests/in/debug-printf.param.ron new file mode 100644 index 0000000000..a0f37d5325 --- /dev/null +++ b/tests/in/debug-printf.param.ron @@ -0,0 +1,3 @@ +( + god_mode: true, +) diff --git a/tests/in/spv/debug-printf-s.param.ron b/tests/in/spv/debug-printf-s.param.ron new file mode 100644 index 0000000000..a0f37d5325 --- /dev/null +++ b/tests/in/spv/debug-printf-s.param.ron @@ -0,0 +1,3 @@ +( + god_mode: true, +)