From 62baf92a524a5b57eb465100a5e47c489c049f15 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Mon, 21 Apr 2025 12:46:23 -0600 Subject: Add `vk::offset` to specify member offsets for push constants (#6797) * Add struct member offset qualifier for SPIRV * Implement for GLSL target and add tests * clean up * fix formatting * fix typo * renamed GLSLStructOffset to VkStructOffset and added emit-spirv-via-glsl test case --- tests/diagnostics/vk-offset.slang | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/diagnostics/vk-offset.slang (limited to 'tests/diagnostics') diff --git a/tests/diagnostics/vk-offset.slang b/tests/diagnostics/vk-offset.slang new file mode 100644 index 000000000..5dbd821c6 --- /dev/null +++ b/tests/diagnostics/vk-offset.slang @@ -0,0 +1,34 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry vertexMain -stage vertex + +// CHECK: error 31002: attribute 'vk_offset' is not valid here +// CHECK-NEXT: [vk::offset(16)]] struct S1 +// CHECK: error 31002: attribute 'vk_offset' is not valid here +// CHECK-NEXT: [vk::offset(8)]] VertexOutput output; + +[[vk::offset(16)]] struct S1 +{ + [[vk::offset(32)]] + float2 a; + + float3 b; + + [[vk::offset(16)]] + float4 c; + } + +[[vk::push_constant]] +S1 pc; + +struct VertexOutput +{ + float3 position : SV_Position; +} + +[shader("vertex")] +VertexOutput vertexMain() +{ + [[vk::offset(8)]] VertexOutput output; + output.position = float3(pc.a.x, pc.b.y, pc.c.z); + return output; +} + -- cgit v1.2.3