summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-12-02 09:29:38 -0500
committerGitHub <noreply@github.com>2022-12-02 09:29:38 -0500
commit92ae4949fe1af28ef31331fd4116c8111c057420 (patch)
treebe4ea011fb7bcd891223a94b3bbd235382afbe5f /tests
parent30b5335fed9524101d980618b0749dcaf546c319 (diff)
Inline functions with string param/return for GPU targets (#2544)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP inlining of functions that take or return string related types on GPU targets. * Small fixes. * Added a test. * Add checking for any getStringHash insts are valid. * Support getStringHash on CUDA. * Tweak diagnostic.
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/string-inline.slang33
-rw-r--r--tests/bugs/string-inline.slang.expected.txt4
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/string-inline.slang b/tests/bugs/string-inline.slang
new file mode 100644
index 000000000..dee30f17d
--- /dev/null
+++ b/tests/bugs/string-inline.slang
@@ -0,0 +1,33 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+
+RWStructuredBuffer<float> outputBuffer;
+
+interface IPrintable
+{
+ int getHash();
+};
+
+extension String : IPrintable
+{
+ int getHash() { return getStringHash(this); }
+}
+
+int getHash(IPrintable p) { return p.getHash(); }
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int hash = getHash("Hello World!");
+
+ float inVal = float(tid) + hash;
+
+ outputBuffer[tid] = inVal;
+} \ No newline at end of file
diff --git a/tests/bugs/string-inline.slang.expected.txt b/tests/bugs/string-inline.slang.expected.txt
new file mode 100644
index 000000000..92c249efc
--- /dev/null
+++ b/tests/bugs/string-inline.slang.expected.txt
@@ -0,0 +1,4 @@
+4EDB7059
+4EDB7059
+4EDB7059
+4EDB7059