[llvm] [SPIRV] Support Peeled Array Layouts for HLSL CBuffers (PR #169078)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 10:42:18 PST 2025


================
@@ -0,0 +1,65 @@
+; RUN: llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: %[[FLOAT:[0-9]+]] = OpTypeFloat 32
+; CHECK: %[[STRUCT:[0-9]+]] = OpTypeStruct %[[FLOAT]]
+; CHECK: %[[I8:[0-9]+]] = OpTypeInt 8 0
+; CHECK: %[[STRUCT_PAD:[0-9]+]] = OpTypeStruct %[[STRUCT]] %[[I8]]
+; CHECK: %[[UINT:[0-9]+]] = OpTypeInt 32 0
+; CHECK: %[[CONST_4:[0-9]+]] = OpConstant %[[UINT]] 4
+; CHECK: %[[ARRAY:[0-9]+]] = OpTypeArray %[[STRUCT_PAD]] %[[CONST_4]]
+; CHECK: %[[CBLAYOUT:[0-9]+]] = OpTypeStruct %[[ARRAY]] %[[FLOAT]]
+; CHECK: %[[WRAPPER:[0-9]+]] = OpTypeStruct %[[CBLAYOUT]]
+; CHECK: %[[PTR_WRAPPER:[0-9]+]] = OpTypePointer Uniform %[[WRAPPER]]
+; CHECK: %[[ZERO:[0-9]+]] = OpConstant %[[UINT]] 0
+; CHECK: %[[MYCBUFFER:[0-9]+]] = OpVariable %[[PTR_WRAPPER]] Uniform
+
+%__cblayout_MyCBuffer = type <{ <{ [3 x <{ %OrigType, target("spirv.Padding", 12) }>], %OrigType }>, float }>
+%OrigType = type <{ float }>
----------------
s-perron wrote:

Good catch. I did not check if the other element was padding in my first draft because the padding type was not implemented yet. Then I forgot to update it. This is now fixed.

https://github.com/llvm/llvm-project/pull/169078


More information about the llvm-commits mailing list