summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/coherent-2.slang15
-rw-r--r--tests/spirv/coherent.slang20
-rw-r--r--tests/spirv/varying-out-index.slang25
3 files changed, 60 insertions, 0 deletions
diff --git a/tests/spirv/coherent-2.slang b/tests/spirv/coherent-2.slang
new file mode 100644
index 000000000..cd7eab8c3
--- /dev/null
+++ b/tests/spirv/coherent-2.slang
@@ -0,0 +1,15 @@
+// Test that globallycoherent works on arrays of uavs.
+
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -emit-spirv-directly
+
+globallycoherent RWByteAddressBuffer buffer[];
+
+RWStructuredBuffer<float> output;
+[numthreads(4,1,1)]
+void main(int tid : SV_DispatchThreadID)
+{
+ buffer[NonUniformResourceIndex(0)].InterlockedAdd(0, 1);
+ AllMemoryBarrier();
+ output[tid] = buffer[0].Load(0);
+ // CHECK-DAG: OpDecorate %buffer Coherent
+}
diff --git a/tests/spirv/coherent.slang b/tests/spirv/coherent.slang
new file mode 100644
index 000000000..ba58b713b
--- /dev/null
+++ b/tests/spirv/coherent.slang
@@ -0,0 +1,20 @@
+// Test that globallycoherent works.
+
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -emit-spirv-directly
+
+struct S
+{
+ globallycoherent int member;
+}
+globallycoherent RWStructuredBuffer<S> buffer;
+
+RWStructuredBuffer<float> output;
+[numthreads(4,1,1)]
+void main(int tid : SV_DispatchThreadID)
+{
+ InterlockedAdd(buffer[0].member, 1);
+ AllMemoryBarrier();
+ output[tid] = buffer[0].member;
+ // CHECK-DAG: OpMemberDecorate {{.*}} 0 Coherent
+ // CHECK-DAG: OpDecorate %buffer Coherent
+}
diff --git a/tests/spirv/varying-out-index.slang b/tests/spirv/varying-out-index.slang
new file mode 100644
index 000000000..6448f2266
--- /dev/null
+++ b/tests/spirv/varying-out-index.slang
@@ -0,0 +1,25 @@
+// Test that explicit binding of varying output works.
+
+//TEST:SIMPLE(filecheck=CHECK): -stage fragment -entry MainPS -target spirv -emit-spirv-directly
+
+struct PS_OUTPUT
+{
+ [[vk::location(0) vk::index(0)]]
+ float4 vColor : SV_Target0 ;
+
+ [[vk::location(0) vk::index(1)]]
+ float4 vColor2 : SV_Target1 ;
+
+};
+
+// CHECK: OpDecorate %MainPS_vColor Location 0
+// CHECK: OpDecorate %MainPS_vColor2 Location 0
+// CHECK: OpDecorate %MainPS_vColor2 Index 1
+
+PS_OUTPUT MainPS()
+{
+ PS_OUTPUT output;
+ output.vColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
+ output.vColor2 = float4(0.0f, 1.0f, 0.0f, 1.0f);
+ return output;
+}