[clang] [HLSL] cbuffer: Create host layout struct and add resource handle to AST (PR #122820)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 10:31:43 PST 2025


llvm-beanz wrote:

> I was kind of hoping we might be able to generate the accesses off a handle during codegen when the global is accessed. I'm not sure if that's possible though.

I'm concerned that this will be more complex to make work with the other CBV syntaxes. For example, the implicit globals don't have a bufferdecl to attach to, so we'll need an extra implicit decl to attach them to, and the `ConstantBuffer` type has a similar problem.

If instead we treat CBV as a storage class with an associated address space (similar to `groupshared`), we can emit cbuffer elements as globals in that address space, standalone globals do the same, and `ConstantBuffer<T>` can effectively be an alias something like: `template <typename T> using ConstantBuffer = constant T`, where the `constant` storage class specifier denotes that it is a unique CBV declaration. This would also solve the problem of `ConstantBuffer`'s member expression operator lookup.

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


More information about the cfe-commits mailing list