summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-03-22 00:57:35 -0400
committerGitHub <noreply@github.com>2025-03-22 04:57:35 +0000
commit0d7d6468dfcabb759ec40921e5da3a8598f1c770 (patch)
tree13b86dc66318fe95c6f4b0a4f36ea00736f708e5
parent7f72256bcf3e9a33feec641ce8bc98bc750b6297 (diff)
Add debugPrintfEXT support (#6659)
-rw-r--r--source/slang/glsl.meta.slang7
-rw-r--r--tests/glsl-intrinsic/debug-printf.slang15
2 files changed, 21 insertions, 1 deletions
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang
index 9e6c6c3cc..de5a3fb66 100644
--- a/source/slang/glsl.meta.slang
+++ b/source/slang/glsl.meta.slang
@@ -9412,4 +9412,9 @@ __intrinsic_op($(kIROp_NonUniformResourceIndex))
[require(cpp_cuda_glsl_hlsl_spirv, nonuniformqualifier)]
public T nonuniformEXT(T index);
-
+/// Debug output printing
+[ForceInline]
+public void debugPrintfEXT<each T>(NativeString format, expand each T args)
+{
+ printf(format, args);
+}
diff --git a/tests/glsl-intrinsic/debug-printf.slang b/tests/glsl-intrinsic/debug-printf.slang
new file mode 100644
index 000000000..4146eab04
--- /dev/null
+++ b/tests/glsl-intrinsic/debug-printf.slang
@@ -0,0 +1,15 @@
+//TEST:SIMPLE(filecheck=CHECK_SPIRV): -target spirv -stage compute -entry main -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage compute -entry main -allow-glsl
+
+void main()
+{
+ debugPrintfEXT("test");
+ debugPrintfEXT(R"(test1 "%d %d")", 5, 6);
+
+ // CHECK_SPIRV: %[[SET:[0-9]+]] = OpExtInstImport "NonSemantic.DebugPrintf"
+ // CHECK_SPIRV: {{.*}} = OpExtInst %{{[a-zA-Z0-9_]+}} %[[SET]] 1 %{{[a-zA-Z0-9_]+}}
+ // CHECK_SPIRV: {{.*}} = OpExtInst %{{[a-zA-Z0-9_]+}} %[[SET]] 1 %{{[a-zA-Z0-9_]+}} %int_5 %int_6
+
+ // CHECK_GLSL: debugPrintfEXT("test")
+ // CHECK_GLSL: debugPrintfEXT("test1 \"%d %d\"", 5, 6);
+}