Resources and arrays of resources can be declared as members of user-defined structures or classes in constant buffers. These structs or classes can also be declared locally or passed as parameters to functions.
struct S {
RWBuffer<float> Buf;
StructuredBuffer<float> BufArray[10];
};
S s : register(u2) : register(t5);
RWBuffer<float> Out : register(u0);
void foo(S local_s, uint index) {
local_s.Buf = Out;
local_s.Buf[0] = s.BufArray[0][index] + s.BufArray[2][index];
}
[numthreads(4,1,1)]
void main(uint3 ID : SV_GroupThreadID) {
foo(s, ID.y);
s.Buf[ID.x] = s.BufArray[9][ID.x];
}
Resources and arrays of resources can be declared as members of user-defined structures or classes in constant buffers. These structs or classes can also be declared locally or passed as parameters to functions.
https://godbolt.org/z/qjrch3a7b