summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-01-24 15:36:49 -0800
committerGitHub <noreply@github.com>2024-01-24 15:36:49 -0800
commite7b6de334f320429462a0257e2191ccf3cbc9a0d (patch)
tree7e2f6802a2f6fa5217903948efbd994b51e103b7 /tests/spirv
parentdd57306d951dbcaf6471659fcd1d2c37738f36d0 (diff)
[SPIRV] Support `globallycoherent` and `[vk::index()]`. (#3488)
* [SPIRV] Support `globallycoherent` modifier. * Fix. * Disable executable cooperative vector tests. * Update expected failure. * [SPIRV] Emit varying output index decoration. * Add test. * Update tests. * Fix test. * Emit `SpvExecutionModeEarlyFragmentTests`. * Lower `StructuredBuffer<bool>`. * Support globallycoherent on ByteAddressBuffer. --------- Co-authored-by: Yong He <yhe@nvidia.com>
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;
+}