python3kgae 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.

This PR will not change this.
The padding will only be added when required.
```hlsl
cbuffer {
  float F;
  float2 V;
}
```
will still got
```llvm
type { float, <2 x float>}
```
But 
```hlsl
cbuffer {
  float3 F;
  float2 V;
}
```
will got padding, because it crossed 4dword.
```llvm
type { <3 x float>, [4 x i8],  <2 x float>}
```


https://github.com/llvm/llvm-project/pull/91999
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to