Skip to content

Commit

Permalink
debug_printf: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
exrook committed Oct 16, 2023
1 parent eac5294 commit df15635
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/in/debug-printf.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(
)
4 changes: 4 additions & 0 deletions tests/in/debug-printf.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@compute @workgroup_size(1)
fn main() {
debugPrintf("%d", 42);
}
Binary file added tests/in/spv/debug-printf.spv
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/in/spv/debug-printf.spvasm
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/out/glsl/debug-printf.main.Compute.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#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);
debugPrintfEXT("%v4f",vec4(3.3));
return;
}

7 changes: 7 additions & 0 deletions tests/out/hlsl/debug-printf.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void main()
{
printf("%d",42);
printf("%v4f",(3.3).xxxx);
return;
}
12 changes: 12 additions & 0 deletions tests/out/hlsl/debug-printf.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(
vertex:[
],
fragment:[
],
compute:[
(
entry_point:"main",
target_profile:"cs_5_1",
),
],
)
29 changes: 29 additions & 0 deletions tests/out/spv/debug-printf.spvasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 18
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%1 = OpExtInstImport "GLSL.std.450"
%15 = OpExtInstImport "NonSemantic.DebugPrintf"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %4 "main"
OpExecutionMode %4 LocalSize 1 1 1
%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
6 changes: 6 additions & 0 deletions tests/out/wgsl/debug-printf.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@compute @workgroup_size(1, 1, 1)
fn main() {
debugPrintf("%d",42);
debugPrintf("%v4f",vec4(3.3));
return;
}
9 changes: 9 additions & 0 deletions tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -855,6 +859,11 @@ fn convert_spv_all() {
true,
Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
);
convert_spv(
"debug-printf",
false,
Targets::GLSL | Targets::HLSL | Targets::WGSL,
);
}

#[cfg(feature = "glsl-in")]
Expand Down

0 comments on commit df15635

Please sign in to comment.