I have a problem with converting my pixel shader to compute shader. The error is in this piece of code:
[numthreads(32,32,1)]
void CS_PostDeferredReflex( uint3 nGid : SV_GroupID,
uint3 nDTid : SV_DispatchThreadID, uint3 nGTid : SV_GroupThreadID )
{
if (any(nDTid.xy >= float2(SM_SCREENX, SM_SCREENY))) return;
uint Output = UAVDiffuse0[nDTid.xy];
float4 ColorOut = float4(Output&0x000000FF, (Output&0x0000FF00)>>8,
(Output&0x00FF0000)>>16, (Output&0xFF000000)>>24)*INV255;
float D = txDepth1.Load(uint3(nDTid.xy,0), 0);D=(D==1)0:D;
if (ColorOut.a*D == 0) return;
Which gives the following:
error X3671: loop termination conditions in varying flow control cannot depend on data read from a UAV
Here the UAV UAVDiffuse0
is a R32UINT
that is unpacked as RGBA ColorOut
.
If the alpha value is zero (or the Depth not [0<D<1]) I don't need to go further. The compiler is unhappy with the last line where the exit is based on the UAV read. I don't understand why we have this limitation.
for
loops have the option of an[allow_uav_condition]
attribute, but I don't see a similar attribute that can be applied toif
statements. \$\endgroup\$