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 17, 2023
1 parent 47d16da commit 564c2a2
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 0 deletions.
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-s.spv
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/in/spv/debug-printf-s.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
18 changes: 18 additions & 0 deletions tests/out/glsl/debug-printf-s.main.Compute.glsl
Original file line number Diff line number Diff line change
@@ -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();
}

14 changes: 14 additions & 0 deletions tests/out/glsl/debug-printf.main.Compute.glsl
Original file line number Diff line number Diff line change
@@ -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;
}

11 changes: 11 additions & 0 deletions tests/out/hlsl/debug-printf-s.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void main_1()
{
printf("%d",42);
return;
}

[numthreads(1, 1, 1)]
void main()
{
main_1();
}
12 changes: 12 additions & 0 deletions tests/out/hlsl/debug-printf-s.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",
),
],
)
23 changes: 23 additions & 0 deletions tests/out/spv/debug-printf.spvasm
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/out/wgsl/debug-printf-s.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main_1() {
debugPrintf("%d",42);
return;
}

@compute @workgroup_size(1, 1, 1)
fn main() {
main_1();
}
5 changes: 5 additions & 0 deletions tests/out/wgsl/debug-printf.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@compute @workgroup_size(1, 1, 1)
fn main() {
debugPrintf("%d",42);
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-s",
false,
Targets::GLSL | Targets::HLSL | Targets::WGSL,
);
}

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

0 comments on commit 564c2a2

Please sign in to comment.