summaryrefslogtreecommitdiffstats
path: root/tests/spirv/c-layout-buffer-2.slang
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2025-08-21 08:47:18 +0300
committerGitHub <noreply@github.com>2025-08-21 05:47:18 +0000
commit35f8e092f2aa3ed5e3cf03387e712f798ff4850e (patch)
treebdafc75e4df90157568758ebf7b8128ecd066f0c /tests/spirv/c-layout-buffer-2.slang
parent05f0f5603561daed2c134e13bc64649362759968 (diff)
Introduce CDataLayout & -fvk-use-c-layout (#8136)
Closes #8112. ~~The issue asks for a "C layout", but in this PR I use the term "CPU layout" because this naming was pre-existing in the codebase as `kCPULayoutRulesImpl_`. The primary purpose of this layout is to match CPU-side struct definitions with the shader side. I'm open to better naming suggestions, though.~~ Edit: switched back to using `CDataLayout` & `-fvk-use-c-layout`, as the CPU target depends on the object layout rules of existing CPU layout rules, but they're incompatible with actual shaders. So a new `kCLayoutRulesImpl_` was needed anyway. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tests/spirv/c-layout-buffer-2.slang')
-rw-r--r--tests/spirv/c-layout-buffer-2.slang57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/spirv/c-layout-buffer-2.slang b/tests/spirv/c-layout-buffer-2.slang
new file mode 100644
index 000000000..0d388d095
--- /dev/null
+++ b/tests/spirv/c-layout-buffer-2.slang
@@ -0,0 +1,57 @@
+//TEST:SIMPLE(filecheck=SPIRV): -stage closesthit -entry chit -target spirv -fvk-use-c-layout
+struct RayPayload
+{
+ float3 color;
+};
+
+struct A {
+ int64_t a1;
+ int32_t a2;
+};
+
+struct B {
+ A a;
+ uint32_t b;
+};
+
+struct Push {
+ B *p;
+};
+
+[[vk::push_constant]] Push push;
+
+struct C {
+ int i;
+ A a;
+};
+
+struct D {
+ C c;
+ int j;
+};
+
+[[vk::shader_record]]
+cbuffer ShaderRecord
+{
+ D d;
+}
+
+[[shader("closesthit")]]
+void chit(inout RayPayload payload : SV_RayPayload, in float2 barys_yz : SV_IntersectionAttributes) {
+ let barys = float3(1.0 - barys_yz.x - barys_yz.y, barys_yz);
+ payload.color = barys;
+
+ push.p->b = d.j + d.c.i;
+}
+
+// SPIRV: OpMemberDecorate %A_c 0 Offset 0
+// SPIRV: OpMemberDecorate %A_c 1 Offset 8
+// SPIRV: OpMemberDecorate %C_c 0 Offset 0
+// SPIRV: OpMemberDecorate %C_c 1 Offset 8
+// SPIRV: OpMemberDecorate %D_c 0 Offset 0
+// SPIRV: OpMemberDecorate %D_c 1 Offset 24
+// SPIRV: OpMemberDecorate %B_c 0 Offset 0
+// SPIRV: OpMemberDecorate %B_c 1 Offset 16
+
+// SPIRV: %_ptr_PushConstant_Push_c = OpTypePointer PushConstant %Push_c
+// SPIRV: %_ptr_ShaderRecordBufferKHR_SLANG_ParameterGroup_ShaderRecord_c = OpTypePointer ShaderRecordBufferKHR %SLANG_ParameterGroup_ShaderRecord_c