summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2025-09-10 21:41:07 +0300
committerGitHub <noreply@github.com>2025-09-10 18:41:07 +0000
commitec42c4a20facbcae441cd172bfd607614e761907 (patch)
treee0fa1af4e12d8cc5324777e380fd1e144d3c763a /tests/spirv
parentb03cbb02c6486274d46865f3995953f2105cefc9 (diff)
Fix pointers and C-like layout in varying parameters (#8425)
Closes #8409, but ended up being more about fixing another bug. While the issue itself seems to only be a simple typo fix (see second commit in this PR), I found out during writing a test that pointers never got correct locations regardless of layout. Their locations were always assigned to zero due to lacking a resource usage entry in `TypeLayout`. They were also missing the `Flat` decoration, so I went ahead and added that too. I can split this up into two separate PRs if that's preferred; both aspects just share a test right now and fix a similar-looking issue in the resulting SPIR-V.
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/c-layout-buffer-3.slang46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/spirv/c-layout-buffer-3.slang b/tests/spirv/c-layout-buffer-3.slang
new file mode 100644
index 000000000..55647f51b
--- /dev/null
+++ b/tests/spirv/c-layout-buffer-3.slang
@@ -0,0 +1,46 @@
+//TEST:SIMPLE(filecheck=SPIRV): -stage fragment -entry fragmentMain -target spirv -fvk-use-c-layout
+struct A {
+ int64_t i;
+ float f;
+};
+
+struct B {
+ A a;
+ float b;
+};
+
+struct FIn
+{
+ Ptr<B> i0;
+ Ptr<B> i1;
+ float c;
+ float d;
+}
+
+struct FOut
+{
+ float4 outputColor : SV_Target0;
+}
+
+StructuredBuffer<Ptr<B>, Std430DataLayout> testBuffer;
+
+[shader("fragment")]
+FOut fragmentMain(FIn input)
+{
+
+ FOut output;
+ output.outputColor = float4(input.i0.a.f, input.i0.b, input.i1.a.f, input.i1.b)+input.c-input.d;
+ output.outputColor += testBuffer[0].b;
+ return output;
+}
+
+// SPIRV: OpDecorate %input_i0 Location 0
+// SPIRV: OpDecorate %input_i0 Flat
+// SPIRV: OpDecorate %input_i1 Location 1
+// SPIRV: OpDecorate %input_i1 Flat
+// SPIRV: OpDecorate %input_c Location 2
+// SPIRV: OpDecorate %input_d Location 3
+// SPIRV: OpMemberDecorate %A_c 0 Offset 0
+// SPIRV: OpMemberDecorate %A_c 1 Offset 8
+// SPIRV: OpMemberDecorate %B_c 0 Offset 0
+// SPIRV: OpMemberDecorate %B_c 1 Offset 16