Using allow_uav_condition loop attribute in HLSL

Memo

  • When I tried to set the loop termination condition based on UAV, the following HLSL shader error occured.
HLSL Error message:
Loop termination conditions in varying flow control
cannot depend on data read from a UAV
  • If you want to determine the loop termination condition based on UAV read, you have to set [allow_uav_condition] as a loop attribute.
  • But I cannot use flow control with UAV at my notebook PC with NVidia driver. So, I used some workaround based on this article. ( "Counting Quads @ Self Shadow" )
  • In Japanese: UAV の値に応じて HLSL の制御ループの停止条件を書こうとしたら, シェーダのコンパイルエラーが出ました. その際, 制御ループの属性に [allow_uav_condition] を指定する必要がありました
  • (追記) しかし僕のノート PC の NVidia ドライバだと, どうも UAV を使ったフロー制御ができなかったので 上の記事に載っていた一時対応で対処しました.