-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
The cbuffer language syntax allows declarations inside cbuffer 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 later on as the contained type of the cbuffer resource handle type and for layout calculations.
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. Layout structs for embedded structures will be added there as well.
For example:
struct Something {
int a;
float f[0];
};
cbuffer CB {
float x;
RWBuffer<float> buf;
Something s;
static float y;
}
The buffer layout should look like this:
; __layout.CB
; {
; float x; ; Offset: 0
; struct __layout.Something
; {
; int a; ; Offset: 16
; } s; ; Offset: 16
; } CB; ; Offset: 0 Size: 20
;
Metadata
Metadata
Assignees
Labels
Type
Projects
Status