From 564c2a2c4e28c06e8b2e99d05b52f5685440e75e Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Mon, 16 Oct 2023 13:39:21 -0400 Subject: [PATCH] debug_printf: add tests --- tests/in/debug-printf.wgsl | 4 +++ tests/in/spv/debug-printf-s.spv | Bin 0 -> 348 bytes tests/in/spv/debug-printf-s.spvasm | 28 ++++++++++++++++++ .../out/glsl/debug-printf-s.main.Compute.glsl | 18 +++++++++++ tests/out/glsl/debug-printf.main.Compute.glsl | 14 +++++++++ tests/out/hlsl/debug-printf-s.hlsl | 11 +++++++ tests/out/hlsl/debug-printf-s.ron | 12 ++++++++ tests/out/spv/debug-printf.spvasm | 23 ++++++++++++++ tests/out/wgsl/debug-printf-s.wgsl | 9 ++++++ tests/out/wgsl/debug-printf.wgsl | 5 ++++ tests/snapshots.rs | 9 ++++++ 11 files changed, 133 insertions(+) create mode 100644 tests/in/debug-printf.wgsl create mode 100644 tests/in/spv/debug-printf-s.spv create mode 100644 tests/in/spv/debug-printf-s.spvasm create mode 100644 tests/out/glsl/debug-printf-s.main.Compute.glsl create mode 100644 tests/out/glsl/debug-printf.main.Compute.glsl create mode 100644 tests/out/hlsl/debug-printf-s.hlsl create mode 100644 tests/out/hlsl/debug-printf-s.ron create mode 100644 tests/out/spv/debug-printf.spvasm create mode 100644 tests/out/wgsl/debug-printf-s.wgsl create mode 100644 tests/out/wgsl/debug-printf.wgsl diff --git a/tests/in/debug-printf.wgsl b/tests/in/debug-printf.wgsl new file mode 100644 index 0000000000..1adcf9aa64 --- /dev/null +++ b/tests/in/debug-printf.wgsl @@ -0,0 +1,4 @@ +@compute @workgroup_size(1) +fn main() { + debugPrintf("%d", 42); +} diff --git a/tests/in/spv/debug-printf-s.spv b/tests/in/spv/debug-printf-s.spv new file mode 100644 index 0000000000000000000000000000000000000000..96ca19fdcd161124227d7b84ad9a9b5a48308585 GIT binary patch literal 348 zcmY*Uy9&ZU5FF#%_(be16tPhV7Ak&#prD8tunoRR;RQ7QyB2~oF&5r2?9J}Z>|WC9 zWPt>l07`^T4Hh#%0Xewqt+$wOJQEo2e!A{V=pQ`aoCDTvWTL*=(p@_D@aPOj1L!7h^u=ibYn{Ye(;|w|0}) Io0BHQ2h~|1>Hq)$ literal 0 HcmV?d00001 diff --git a/tests/in/spv/debug-printf-s.spvasm b/tests/in/spv/debug-printf-s.spvasm new file mode 100644 index 0000000000..992f133ff8 --- /dev/null +++ b/tests/in/spv/debug-printf-s.spvasm @@ -0,0 +1,28 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 18 +OpCapability Shader +OpCapability Linkage +OpExtension "SPV_KHR_non_semantic_info" +%1 = OpExtInstImport "GLSL.std.450" +%15 = OpExtInstImport "NonSemantic.DebugPrintf" +OpMemoryModel Logical GLSL450 +%13 = OpString "%d" +%16 = OpString "%v4f" +%2 = OpTypeVoid +%5 = OpTypeFunction %2 +%6 = OpTypeInt 32 1 +%7 = OpConstant %6 42 +%8 = OpTypeFloat 32 +%9 = OpConstant %8 3.3 +%10 = OpTypeVector %8 4 +%11 = OpConstantComposite %10 %9 %9 %9 %9 +%4 = OpFunction %2 None %5 +%3 = OpLabel +OpBranch %12 +%12 = OpLabel +%14 = OpExtInst %2 %15 1 %13 %7 +%17 = OpExtInst %2 %15 1 %16 %11 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/glsl/debug-printf-s.main.Compute.glsl b/tests/out/glsl/debug-printf-s.main.Compute.glsl new file mode 100644 index 0000000000..2cd87e2b25 --- /dev/null +++ b/tests/out/glsl/debug-printf-s.main.Compute.glsl @@ -0,0 +1,18 @@ +#version 310 es +#extension GL_EXT_debug_printf : enable + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + + +void main_1() { + debugPrintfEXT("%d",42); + return; +} + +void main() { + main_1(); +} + diff --git a/tests/out/glsl/debug-printf.main.Compute.glsl b/tests/out/glsl/debug-printf.main.Compute.glsl new file mode 100644 index 0000000000..0923ee6cdc --- /dev/null +++ b/tests/out/glsl/debug-printf.main.Compute.glsl @@ -0,0 +1,14 @@ +#version 310 es +#extension GL_EXT_debug_printf : enable + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + + +void main() { + debugPrintfEXT("%d",42); + return; +} + diff --git a/tests/out/hlsl/debug-printf-s.hlsl b/tests/out/hlsl/debug-printf-s.hlsl new file mode 100644 index 0000000000..638bbf0d9a --- /dev/null +++ b/tests/out/hlsl/debug-printf-s.hlsl @@ -0,0 +1,11 @@ +void main_1() +{ + printf("%d",42); + return; +} + +[numthreads(1, 1, 1)] +void main() +{ + main_1(); +} diff --git a/tests/out/hlsl/debug-printf-s.ron b/tests/out/hlsl/debug-printf-s.ron new file mode 100644 index 0000000000..a07b03300b --- /dev/null +++ b/tests/out/hlsl/debug-printf-s.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/tests/out/spv/debug-printf.spvasm b/tests/out/spv/debug-printf.spvasm new file mode 100644 index 0000000000..d0d9b89abb --- /dev/null +++ b/tests/out/spv/debug-printf.spvasm @@ -0,0 +1,23 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 12 +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%1 = OpExtInstImport "GLSL.std.450" +%11 = OpExtInstImport "NonSemantic.DebugPrintf" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %4 "main" +OpExecutionMode %4 LocalSize 1 1 1 +%9 = OpString "%d" +%2 = OpTypeVoid +%5 = OpTypeFunction %2 +%6 = OpTypeInt 32 1 +%7 = OpConstant %6 42 +%4 = OpFunction %2 None %5 +%3 = OpLabel +OpBranch %8 +%8 = OpLabel +%10 = OpExtInst %2 %11 1 %9 %7 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/debug-printf-s.wgsl b/tests/out/wgsl/debug-printf-s.wgsl new file mode 100644 index 0000000000..b99f6522c9 --- /dev/null +++ b/tests/out/wgsl/debug-printf-s.wgsl @@ -0,0 +1,9 @@ +fn main_1() { + debugPrintf("%d",42); + return; +} + +@compute @workgroup_size(1, 1, 1) +fn main() { + main_1(); +} diff --git a/tests/out/wgsl/debug-printf.wgsl b/tests/out/wgsl/debug-printf.wgsl new file mode 100644 index 0000000000..d0b9c83a76 --- /dev/null +++ b/tests/out/wgsl/debug-printf.wgsl @@ -0,0 +1,5 @@ +@compute @workgroup_size(1, 1, 1) +fn main() { + debugPrintf("%d",42); + return; +} diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 2bc7f45444..3a3768a309 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -781,6 +781,10 @@ fn convert_wgsl() { "const-exprs", Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ), + ( + "debug-printf", + Targets::WGSL | Targets::GLSL | Targets::SPIRV | Targets::HLSL, + ), ]; for &(name, targets) in inputs.iter() { @@ -855,6 +859,11 @@ fn convert_spv_all() { true, Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ); + convert_spv( + "debug-printf-s", + false, + Targets::GLSL | Targets::HLSL | Targets::WGSL, + ); } #[cfg(feature = "glsl-in")]