[clang] [HLSL] support packoffset in clang codeGen (PR #91999)

Xiang Li via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 15:21:23 PDT 2024


python3kgae wrote:

> > You can use `type <{ float, <2 x float>}>` if you need the tightly-packed layout.
> 
> I think we need to figure out how we're going to lower this too. Loading from this memory space requires loading 128 bytes at a time, and we need to slice it down to just the parts of the structure we need.
> 
> @bogner is working on the lowering logic, so I'd like to make sure what we capture at the IR level is appropriate for what he needs in the DirectX backend.

For the offset calculation in backend, we already added
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/DirectX/CBufferDataLayout.h#L29

Not sure how spirv side works though.
It will need something to calculate the offset for legacy cbuffer layout as well.

In theory, we could mutate the struct types by add paddings to implement legacy cbuffer layout for data layout. But it is a little hacky since it will need to mutate existing struct types.

This PR doesn't mutate any existing type, since the struct is created for cbuffer layout only.

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


More information about the cfe-commits mailing list