From 9a23a9aab3721828526c921db1e779008e133e8f Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 8 Jun 2024 05:12:49 -0700 Subject: SPIRV `Block` decoration fixes. (#4303) * SPIRV `Block` decoration fixes. - SPIRV does not allow duplicate `Block` decorations. So we shouldn't be generating them. - Also fixes duplication of OpName. - SPIRV and HLSL do not allow ConstantBuffer with trailing unsized arrays. Added a check in the front-end against such code. * Convert failing cross-compile tests to filecheck. --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> --- tests/spirv/block-decoration.slang | 18 ++++++++++++++++++ tests/spirv/varying-out-index.slang | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/spirv/block-decoration.slang (limited to 'tests/spirv') diff --git a/tests/spirv/block-decoration.slang b/tests/spirv/block-decoration.slang new file mode 100644 index 000000000..e6d350dcd --- /dev/null +++ b/tests/spirv/block-decoration.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// Check that we don't produce duplicate `Block` decorations. + +// CHECK: OpDecorate %RWStructuredBuffer Block +// CHECK-NOT: OpDecorate %RWStructuredBuffer Block + +struct Particle { + float4 _m0; +}; + +[[vk::binding(0)]] +RWStructuredBuffer particleOut; + +[shader("fragment")] +float4 main() : SV_TARGET { + return particleOut[0]._m0; +} \ No newline at end of file diff --git a/tests/spirv/varying-out-index.slang b/tests/spirv/varying-out-index.slang index 6448f2266..e4c4400f5 100644 --- a/tests/spirv/varying-out-index.slang +++ b/tests/spirv/varying-out-index.slang @@ -12,9 +12,9 @@ struct PS_OUTPUT }; -// CHECK: OpDecorate %MainPS_vColor Location 0 -// CHECK: OpDecorate %MainPS_vColor2 Location 0 -// CHECK: OpDecorate %MainPS_vColor2 Index 1 +// CHECK: OpDecorate %{{.*}}MainPS_vColor Location 0 +// CHECK: OpDecorate %{{.*}}MainPS_vColor2 Location 0 +// CHECK: OpDecorate %{{.*}}MainPS_vColor2 Index 1 PS_OUTPUT MainPS() { -- cgit v1.2.3