[HLSL] cbuffer
: Create host layout struct and add resource handle to AST
#122553
Labels
HLSL
HLSL Language Support
The
cbuffer
language syntax allows declarations insidecbuffer
context that do not contribute to the constant buffer layout, such as static variables, function definitions, declarations of classes and namespaces, resources, or empty struct and zero-sized arrays. As part of semantic analysis we need to create a "layout struct" for the constant buffer that will only include elements that affect the buffer memory layout. This layout struct will be used as the contained type of thecbuffer
resource handle type and for layout calculations in codegen.If the constant buffer includes a struct that contains any of the above undesirable declarations, a new version of this struct should be created with these declarations filtered out as well.
The buffer layout struct will be declared within the HLSLBufferDecl context and will be followed by 'cbuffer` resource handle declaration that will reference the layout struct as its contained type.
For example:
The buffer layout should look like this:
And the resource handle added to the
HLSLBufferDecl
will look like this:https://godbolt.org/z/j37r1Tede
The text was updated successfully, but these errors were encountered: