summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-05-05 15:53:29 -0400
committerGitHub <noreply@github.com>2022-05-05 15:53:29 -0400
commitb915ae662b2e4bcaaeb6da62eb964356d0a978b4 (patch)
tree94aa29d7c112bde36557371bed906411f22a7adc /tests
parent3088d901fee6447b6d80fa67f258626ece4408dc (diff)
Support for HLSL `export` (#2223)
* #include an absolute path didn't work - because paths were taken to always be relative. * Add support for HLSL `export`. * Test for using `export` keyword.
Diffstat (limited to 'tests')
-rw-r--r--tests/library/export-library.slang14
-rw-r--r--tests/library/export-test.slang27
-rw-r--r--tests/library/export-test.slang.expected.txt4
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/library/export-library.slang b/tests/library/export-library.slang
new file mode 100644
index 000000000..f96b1e143
--- /dev/null
+++ b/tests/library/export-library.slang
@@ -0,0 +1,14 @@
+//TEST_IGNORE_FILE:
+
+// export-library.slang
+
+int doThing(int b)
+{
+ return b + b + 1;
+}
+
+export int foo(int a)
+{
+ return a * a + 1 + doThing(a + 2);
+}
+
diff --git a/tests/library/export-test.slang b/tests/library/export-test.slang
new file mode 100644
index 000000000..a85396126
--- /dev/null
+++ b/tests/library/export-test.slang
@@ -0,0 +1,27 @@
+// export-test.slang
+
+// A test to try out the basics of using libraries that can be linked (by downstream tools), via the HLSL `export` keyword.
+// (This is in contrast to Slang modules and Slangs own linkage mechanisms)
+
+// This didn't work for lib_6_2 when compiling via DXC (!). Even though it's stated elsewhere the feature is available from 6.1
+
+//TEST:COMPILE: tests/library/export-library.slang -profile lib_6_3 -target dxil -o tests/library/export-library.dxil
+//TEST:COMPILE: tests/library/export-test.slang -entry computeMain -profile cs_6_3 -target dxil -r tests/library/export-library.dxil -o tests/library/export-test.dxil
+
+// Test the produced kernel.
+
+//TEST:COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_3 -dx12 -use-dxil -shaderobj -Xslang... -r tests/library/export-library.dxil -X.
+
+extern int foo(int a);
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[shader("compute")]
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = (int)dispatchThreadID.x;
+
+ outputBuffer[index] = foo(index);
+}
diff --git a/tests/library/export-test.slang.expected.txt b/tests/library/export-test.slang.expected.txt
new file mode 100644
index 000000000..c0e0beb96
--- /dev/null
+++ b/tests/library/export-test.slang.expected.txt
@@ -0,0 +1,4 @@
+6
+9
+E
+15