summaryrefslogtreecommitdiff
path: root/tests/diagnostics
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-04-21 12:46:23 -0600
committerGitHub <noreply@github.com>2025-04-21 18:46:23 +0000
commit62baf92a524a5b57eb465100a5e47c489c049f15 (patch)
tree8f66cd150c1e0f80bf8029ffd48bb8ba6537ff9a /tests/diagnostics
parent5d41a4dbd319c3266b21eee06bb6459adb59c2e7 (diff)
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
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/vk-offset.slang34
1 files changed, 34 insertions, 0 deletions
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;
+}
+