Skip to main content
fixed typos, added code markdown
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

As stated in the title 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 UAVDiffuse0UAVDiffuse0 is a R32UINTR32UINT that is unpacked as RGBA ColorOutRGBA ColorOut. If

If the alpha value is zero (or the Depth not [0<D<1]) I don't need to go further. the 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.

As stated in the title 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;

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.

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.

Source Link
philB
  • 333
  • 2
  • 11

error X3671: loop termination conditions in varying flow control cannot depend on data read from a UAV

As stated in the title 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;

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.