summaryrefslogtreecommitdiffstats
path: root/tests/wgsl
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-09-20 20:21:18 -0700
committerGitHub <noreply@github.com>2024-09-20 20:21:18 -0700
commit53684ed919ff2f5f3656aed2e95a111207452392 (patch)
treecf6926f21797d99534f22da121beceb085b6035a /tests/wgsl
parentc42b5e24b5b9d6b03352d809e0a49485d361154f (diff)
Fix handling of pointer logic in wgsl backend. (#5129)
Diffstat (limited to 'tests/wgsl')
-rw-r--r--tests/wgsl/inout.slang32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/wgsl/inout.slang b/tests/wgsl/inout.slang
new file mode 100644
index 000000000..57f55ae3f
--- /dev/null
+++ b/tests/wgsl/inout.slang
@@ -0,0 +1,32 @@
+//TEST:SIMPLE(filecheck=CHECK): -target wgsl
+
+RWStructuredBuffer<float> outputBuffer;
+
+// CHECK: fn inner{{.*}}( x{{.*}} : ptr<function, f32>)
+// CHECK: (*x{{.*}}) = (*x{{.*}}) + 1.0
+void inner(inout float x)
+{
+ x = x + 1;
+}
+
+// CHECK: fn test{{.*}}( x{{.*}} : ptr<function, f32>)
+void test(inout float x)
+{
+ inner(x);
+}
+
+struct MyType
+{
+ float myField[3];
+}
+
+[numthreads(1,1,1)]
+void computeMain(int id : SV_DispatchThreadID)
+{
+ MyType v;
+ v.myField[id] = 0.0f;
+ // CHECK: test{{.*}}(&({{.*}}));
+ test(v.myField[id]);
+ v.myField[1] = 2.0;
+ outputBuffer[0] = v.myField[id];
+}