summaryrefslogtreecommitdiffstats
path: root/tests/wgsl
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2025-01-17 07:23:31 +0200
committerGitHub <noreply@github.com>2025-01-16 21:23:31 -0800
commitdfb369e87dd7638e84efe8feb9e7069e5238b44c (patch)
treeec1d8ffb4b295cd5c0d1a042255e77ecd9ae8ce7 /tests/wgsl
parent1b7c242bc9ebf649708836f5ed03363f5f0e3969 (diff)
Move global variable initialization into entry points for WGSL (#6106)
* Add test that reproduces the issue in #5986 * Call moveGlobalVarInitializationToEntryPoints for WGSL as well This closes #5986. --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/wgsl')
-rw-r--r--tests/wgsl/global-call.slang20
-rw-r--r--tests/wgsl/global-call.slang.expected.txt4
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/wgsl/global-call.slang b/tests/wgsl/global-call.slang
new file mode 100644
index 000000000..7b67f2139
--- /dev/null
+++ b/tests/wgsl/global-call.slang
@@ -0,0 +1,20 @@
+//TEST(compute):COMPARE_COMPUTE:-shaderobj
+
+//TEST_INPUT:ubuffer(data=[3 7 8 10], stride=4):name=inputBuffer
+RWStructuredBuffer<uint> inputBuffer;
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+uint f(uint a)
+{
+ return a*inputBuffer[0];
+}
+
+static uint b = f(2);
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ outputBuffer[0] = b;
+} \ No newline at end of file
diff --git a/tests/wgsl/global-call.slang.expected.txt b/tests/wgsl/global-call.slang.expected.txt
new file mode 100644
index 000000000..e20d75ba3
--- /dev/null
+++ b/tests/wgsl/global-call.slang.expected.txt
@@ -0,0 +1,4 @@
+6
+0
+0
+0