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

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 4 18:02:10 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 {
----------------
farzonl wrote:

I think I have this right in my head for these tests but mostly just copied  clang/test/CodeGenHLSL/resources/cbuffer_align.hlsl but varied the constant registers more because those test were just against c0 and c1.

```
c0 -> the first constant register
c1 -> the second
c5 -> the sixth
c10 -> the eleventh
…and so on.
```

After the register index, the .x/.y/.z/.w suffix picks a component within the 4-component register:
```
c5.x  -> the first 32-bit component (lowest) of register c5
c1.w  -> the fourth component of register c1
c0.y  -> the second component of register c0
c4.z  -> the third component of register c4
```

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


More information about the cfe-commits mailing list