Issue 129106
Summary [HLSL] Report error when only some elements in `cbuffer` have `packoffset` annotation
Labels HLSL
Assignees
Reporter hekota
    DXC has been reporting a warning on the code below for a while. The layout it produces is inconsistent between DXIL and SPIRV. We should make this an error in Clang.

```
cbuffer CB {
  float f;
  float g : packoffset(c0.z);
}
```
`warning: cannot mix packoffset elements with nonpackoffset elements in a cbuffer`

DXC places the elements without `packoffset` after the elements with explicit layout:
```
;   struct CB
; {
;
;       float f;                                      ; Offset: 12
;       float g;                                      ; Offset:    8
; 
;   } CB;                                             ; Offset:    0 Size: 16
```

SPIR-V does it differently - the offset of the first element is 0:
```
  OpMemberDecorate %type_CB 0 Offset 0
  OpMemberDecorate %type_CB 1 Offset 8
```
https://godbolt.org/z/Wq7EhKxEE
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to