summaryrefslogtreecommitdiffstats
path: root/tests/library/precompiled-spirv-pointer-param.slang
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2024-10-29 16:42:18 -0400
committerGitHub <noreply@github.com>2024-10-29 16:42:18 -0400
commit613a29affe272772dfe0c463d866fb0b8c1d42ee (patch)
treeb4428cdae50e085cf8c7111ea28e8e679590da68 /tests/library/precompiled-spirv-pointer-param.slang
parent99c728f8b3144b1cdfb5e868b304ad2a147d9cc3 (diff)
Precompiled SPIR-V import support (#5048)
* Precompiled SPIR-V import support Adds appropriate linkage and function declaration syntax for SPIR-V functions that are declared, to be imported from another SPIR-V module. Unlike DXIL, stripping the Slang IR for a function down to a declaration requires retaining a block of parameters, as the function declaration must be emitted to SPIR-V with the same parameters as a definition. Because that thwarts the logic in Slang to tell the difference between a declaration and definition, and explicit decoration is introduced to explicitly mark functions which need to be treated as declarations during emit phase. Fixes #4992 Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/library/precompiled-spirv-pointer-param.slang')
-rw-r--r--tests/library/precompiled-spirv-pointer-param.slang31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/library/precompiled-spirv-pointer-param.slang b/tests/library/precompiled-spirv-pointer-param.slang
new file mode 100644
index 000000000..10cd7124b
--- /dev/null
+++ b/tests/library/precompiled-spirv-pointer-param.slang
@@ -0,0 +1,31 @@
+// precompiled-spirv-pointer-param.slang
+
+// A test that uses slang-modules with embedded precompiled SPIRV and a library containing
+// a function with a pointer parameter.
+// The test compiles a library slang (module-library-pointer-param.slang) with -embed-downstream-ir then links the
+// library to entrypoint slang (this file).
+// The test passes if there is no errror thrown.
+// TODO: Check if final linkage used only the precompiled spirv.
+
+//TEST:COMPILE: tests/library/module-library-pointer-param.slang -o tests/library/module-library-pointer-param.slang-module -target spirv -embed-downstream-ir -incomplete-library
+//TEST:COMPILE: tests/library/precompiled-spirv-pointer-param.slang -target spirv -stage anyhit -entry anyhit -o tests/library/linked.spirv
+
+import "module-library-pointer-param";
+
+struct Payload
+{
+ int val;
+}
+
+struct Attributes
+{
+ float2 bary;
+}
+
+[vk::push_constant] int* g_int;
+
+[shader("anyhit")]
+void anyhit(inout Payload payload, Attributes attrib)
+{
+ payload.val = ptrFunc(g_int);
+}