Description
Create a proposal on how to handle resources in user-defined structs. Depends on #175.
Users can define structs with resources, resource arrays, or there can be an array of structs that contain resources.
These structs can also be declared locally or passed as parameters to functions. When local, resource arrays can be assigned to.
struct S {
RWBuffer<float> RA[10];
RWBuffer<float> A;
};
S s : register(u0);
RWBuffer<float> Buf : register(u0, space1);
void foo(S local_s) {
local_s.RA[0] = Buf;
local_s.A = Buf;
}
[numthreads(4,1,1)]
void main() {
foo(s);
s.RA[0] = Buf; // error
s.A = Buf; // error
}
https://godbolt.org/z/G8z1r84dd
A struct instance declared at a global scope can have one or more register
annotations that specify the bindings for resource classes included in the struct. The proposal should also include a section on how to handle these, how to do implicit binding assignments for resources in structs, and whether we should reserve a continuous descriptor rage for resources arrays in structs or threat them as individualy bound resources.
Related doc: Implicit resource binding design.
Some thoughts from @tex3d: https://gist.github.com/tex3d/d08cf4c18eec048fbc8f972dca156474
Metadata
Metadata
Assignees
Labels
Type
Projects
Status