[clang] [HLSL] Define CBuffer field alignment for matrix types (PR #179836)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 09:00:47 PST 2026


================
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -fsyntax-only -verify -verify-ignore-unexpected=warning
+
+cbuffer MatArr0Pass {
+  float2x4 A0p[2] : packoffset(c0.x);
+  float    a0tail : packoffset(c4.x);
+}
+
+cbuffer MatArr0Fail {
+  float2x4 A0f[2] : packoffset(c0.x);
+  float    a0bad  : packoffset(c1.w);
----------------
farzonl wrote:

I think c7.y is a bit off. Don't see it triggering the error. These are the tightest bounds I could come up with:

Case | Old offset | New offset | Boundary tested
-- | -- | -- | --
MatArr0Fail | c1.w (28) | c3.z (60) | float2x4[2] ends at byte 64
MatStruct0Fail | c0.y (4) | c2.y (36) | MS0 ends at byte 40
MatNested0Fail | c3.y (56) | c3.z (60) | Outer0 ends at byte 64
MatArrStruct0Fail | c4.z (72) | c5.y (84) | AMS0[2] ends at byte 88



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


More information about the cfe-commits mailing list