summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/atomic-t/atomic-0.slang14
-rw-r--r--tests/wgsl/inout.slang32
2 files changed, 32 insertions, 14 deletions
diff --git a/tests/language-feature/atomic-t/atomic-0.slang b/tests/language-feature/atomic-t/atomic-0.slang
index 6f2ce6418..591de490c 100644
--- a/tests/language-feature/atomic-t/atomic-0.slang
+++ b/tests/language-feature/atomic-t/atomic-0.slang
@@ -12,46 +12,32 @@ void computeMain()
bool result = true;
if (outputBuffer[0].add(1) != 0)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].sub(1) != 1)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].max(2) != 0)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].min(1) != 2)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].or(3) != 1)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].and(2) != 3)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].xor(3) != 2)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].exchange(4) != 1)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].compareExchange(4, 5) != 4)
{} //result = false; // for some reason this fails on Metal Github CI, so disabling.
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].load() != 5)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].increment() != 5)
result = false;
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].decrement() != 6)
result = false;
- AllMemoryBarrierWithGroupSync();
// CHECK: 6
outputBuffer[0].store(6);
- AllMemoryBarrierWithGroupSync();
if (outputBuffer[0].load() != 6)
result = false;
- AllMemoryBarrierWithGroupSync();
// CHECK: 1
if (result)
outputBuffer[1].store(1);
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];
+}