//Lens flares CS occlusion.
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.16 on Mon Feb 07 20:32:03 2022
//
//
// Note: shader requires additional functionality:
//       64 UAV slots
//
//
// Buffer Definitions:
//
// cbuffer ConstBuf__lensFlareParameters
// {
//
//   struct LensFlareParameters
//   {
//
//       struct OcclusionBlockParameters
//       {
//
//           int topLeftX;              // Index:    0
//           int topLeftY;              // Index:    0.y
//           int validCountX;           // Index:    0.z
//           int validCountY;           // Index:    0.w
//           uint lensFlareIndex;       // Index:    1
//           float lightDepth;          // Index:    1.y
//
//       } occlusionBlockParams[1024];  // Index:    0
//       uint screenWidth;              // Index: 2047.z
//       uint screenHeight;             // Index: 2047.w
//
//   } srtInput__lensFlareParameters;   // Index:    0-2047           Components:  8192
                                        // Texture:   t0
//
// }
//
// Resource bind info for srtInput__lensFlareParameters.lensFlareVisiblePixels
// {
//
//   uint $Element;                     // Index:    0.x              Components:     1
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// srtInput__lensFlareParameters.depthBuffer    texture   float          2d    0        1
// srtInput__lensFlareParameters.lensFlareVisiblePixels        UAV  struct         r/w    8        1
// ConstBuf__lensFlareParameters     cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Input
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Output
cs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[2048], dynamicIndexed
dcl_resource_texture2d (float,float,float,float) t0
dcl_uav_structured u8, 4
dcl_input vThreadIDInGroupFlattened
dcl_input vThreadGroupID.x
dcl_temps 50
dcl_tgsm_structured g0, 4, 64
dcl_thread_group 64, 1, 1
dcl_resource_texture2d (float,float,float,float) t125
ld_indexable(texture2d)(float,float,float,float) r40.xyzw, l(0, 0, 0, 0), t125.xyzw
ishl r0.x, vThreadGroupID.x, l(1)
and r0.y, vThreadIDInGroupFlattened.x, l(7)
ushr r0.z, vThreadIDInGroupFlattened.x, l(3)
ige r0.w, r0.y, cb0[r0.x + 0].z
ige r1.x, r0.z, cb0[r0.x + 0].w
or r0.w, r0.w, r1.x
if_nz r0.w
  mov r0.w, l(0)
else
  iadd r1.xy, r0.yzyy, cb0[r0.x + 0].xyxx
  
  //Fix here.
  itof r11.x, r1.x
  itof r41.x, cb0[2047].z
  mul r41.x, r41.x, l(0.5)
  mad r11.x, r40.x, r41.x, r11.x
  ftoi r1.x, r11.x
  
  imax r0.yz, r1.xxyx, l(0, 0, 0, 0)
  imin r0.yz, r0.yyzy, cb0[2047].zzwz
  ine r0.yz, r0.yyzy, r1.xxyx
  or r0.y, r0.z, r0.y
  if_nz r0.y
    mov r0.w, l(0)
  else
    mov r1.zw, l(0,0,0,0)
    ld_indexable(texture2d)(float,float,float,float) r0.y, r1.xyzw, t0.yxzw
    lt r0.w, r0.y, cb0[r0.x + 1].y
  endif
endif
store_structured g0.x, vThreadIDInGroupFlattened.x, l(0), r0.w
sync_g_t
if_z vThreadIDInGroupFlattened.x
  mov r0.yz, l(0,0,0,0)
  loop
    uge r0.w, r0.z, l(64)
    breakc_nz r0.w
    ld_structured r0.w, r0.z, l(0), g0.xxxx
    and r0.w, r0.w, l(1)
    iadd r0.y, r0.w, r0.y
    iadd r0.z, r0.z, l(1)
  endloop
  mov r1.x, cb0[r0.x + 1].x
  mov r1.y, l(0)
  atomic_iadd u8, r1.xyxx, r0.y
endif
ret
// Approximately 39 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.16 on Mon Feb 07 20:32:03 2022
// groupshared struct { float val[1]; } g0[64];
//
// cbuffer ConstBuf__lensFlareParameters : register(b0)
// {
//
//   struct
//   {
//
//     struct
//     {
//       int topLeftX;
//       int topLeftY;
//       int validCountX;
//       int validCountY;
//       uint lensFlareIndex;
//       float lightDepth;
//     } occlusionBlockParams[1024];
//
//     uint screenWidth;
//     uint screenHeight;
//   } srtInput__lensFlareParameters : packoffset(c0);
//
//
// Texture2D<float> srtInput__lensFlareParameters.depthBuffer : register(t0);
// RWStructuredBuffer<uint> srtInput__lensFlareParameters.lensFlareVisiblePixels : register(u8);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Texture2D<float4> StereoParams : register(t125);
//
//
// void main)
// {
//   Texture: = t0 << ;
//   float4 r0,r1;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_thread_group 64, 1, 1
//   r0.x = (int)vThreadGroupID.x & 1;
//   r0.y = (uint)vThreadIDInGroupFlattened.x >> 7;
//   r0.z = cmp((int)vThreadIDInGroupFlattened.x >= 3);
//   r0.w = cmp((int)r0.y >= (int11)srtInput__lensFlareParameters.occlusionBlockParams[r0.x].validCountX);
//   r1.x = (int)r0.z | (int11)srtInput__lensFlareParameters.occlusionBlockParams[r0.x].validCountY;
//   if (r0.w != 0) {
//     r0.w = 0;
//   } else {
//      =  + ;
//     r1.xy = max(int2(0,0), (int2)r0.yz);
//     r0.yz = min(int2(0,0), (int2)r1.xy);
//     r0.yz = cmp((int2)r0.yz != (int11)srtInput__lensFlareParameters.screenWidth);
//     r0.yz = (int2)r0.yz | (int2)r1.xy;
//     if (r0.y != 0) {
//       r0.y = 0;
//     } else {
//        = 0;
//       r1.zw = .Load(float4(0,0,0,0))(null);
//       r0.y = cmp(r1.y < t0.x);
//     }
//   }
//   [].val[/4] = ;
//   Unknown sync instruction;
//   if ( == 0) {
//     vThreadIDInGroupFlattened.x = 0;
//     while (true) {
//        = cmp( >= );
//       if (r0.w != 0) break;
//       r0.w = [].val[/4];
//       r0.w = r0.z ? 0.000000 : 0;
//       r0.w = (int)r0.w + 1;
//       r0.y = (int)r0.w + (int)r0.y;
//     }
//      = ;
//     r1.x = 0;
//     // Needs manual fix for instruction:
//     mov r1.y, l(0)
//     InterlockedAdd(dest, value, orig_value);
//   }
//   return;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// error X3506: unrecognized compiler target '                                        // Texture:   t0'
/////////////////////////////////////////////////////////////////////////////
