slang
slang copied to clipboard
Heterogeneous shaders with multiple arguments
When a __GPU_FOREACH
is executed, the resulting function is expected to have exactly three arguments: renderer
, gridDims
, and buffer
. In real programs, this last argument could realistically be several arguments, each corresponding to a separate input argument to the target shader. As a result, the following compute shader header does not have the correct heterogeneous header produced:
void computeMain(uniform RWStructuredBuffer<float> ioBuffer,
uniform RWStructuredBuffer<float> ioBuffer2, uint3 dispatchThreadID : SV_DispatchThreadID) {...}
...
__GPU_FOREACH(renderer, uint3(4, 1, 1), LAMBDA(uint3 dispatchThreadID)
{ computeMain(convertBuffer(structuredBuffer), convertBuffer(structuredBuffer2), dispatchThreadID) ; });
In particular, the above header and loop produces the following code:
void computeMain_wrapper(gfx_Renderer_0* renderer, Vector<uint32_t, 3> gridDims,
RWStructuredBuffer<float> buffer) {...}
...
computeMain_wrapper(_S12, _S15, _S16, _S17);
Clearly, the generated wrapper is incorrect, while the call to this wrapper is correct (or at least has the correct number of arguments).