[clang] [HLSL] support packoffset in clang codeGen (PR #91999)
    Chris B via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Thu May 16 13:02:27 PDT 2024
    
    
  
llvm-beanz wrote:
> Could you explain more about can't put any vectors or matrices into the cbuffer structure type?
Consider this example (regardless of packoffset):
```hlsl
cbuffer {
  float F;
  float2 V;
}
```
The layout for this is basically:
```c
struct {
  float F;
  float Vx; // v.x
  float Vy; // v.y
};
```
These elements are all packed.
If you translate this to an IR struct you get something like:
```llvm
type { float, <2 x float>}
```
The data layout will insert 4-bytes of padding between the float and the vector because the vector needs to be properly aligned.
https://github.com/llvm/llvm-project/pull/91999
    
    
More information about the cfe-commits
mailing list