//lighs may clip
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.11 on Sun Nov 18 11:56:17 2018
//
//
// Buffer Definitions:
//
// cbuffer TiledLightBuffer_CB
// {
//
//   struct tShLightData
//   {
//
//       float3 mPosition;              // Offset:    0
//       float mRadiusInv;              // Offset:   12
//       uint mRegion;                  // Offset:   16
//       float mL00_luminance;          // Offset:   20
//       float mdL00_dy_luminance;      // Offset:   24
//       float mGradStrength;           // Offset:   28
//       float4 mShCoeff[3];            // Offset:   32
//       float4 mShGradCoeff[3];        // Offset:   80
//
//   } TiledLightBuffer[512];           // Offset:    0 Size: 65536
//
// }
//
// cbuffer TiledLightCountBuffer_CB
// {
//
//   struct tLightCountData
//   {
//
//       uint mNumLights;               // Offset:    0
//       uint mNumXTiles;               // Offset:    4
//       uint mNumYTiles;               // Offset:    8
//       uint mSHScalesReflectionFlag;  // Offset:   12
//
//   } TiledLightCountBuffer;           // Offset:    0 Size:    16
//
// }
//
// Resource bind info for Light2DBounds
// {
//
//   struct t2DBounds
//   {
//
//       int mLeft;                     // Offset:    0
//       int mRight;                    // Offset:    4
//       int mTop;                      // Offset:    8
//       int mBottom;                   // Offset:   12
//
//   } $Element;                        // Offset:    0 Size:    16
//
// }
//
// Resource bind info for input_frustum_spheres_near
// {
//
//   struct tFrustumSphere
//   {
//
//       float3 mPosition;              // Offset:    0
//       float mRadius;                 // Offset:   12
//
//   } $Element;                        // Offset:    0 Size:    16
//
// }
//
// Resource bind info for input_frustum_spheres_far
// {
//
//   struct tFrustumSphere
//   {
//
//       float3 mPosition;              // Offset:    0
//       float mRadius;                 // Offset:   12
//
//   } $Element;                        // Offset:    0 Size:    16
//
// }
//
// Resource bind info for output_lights_per_tile
// {
//
//   uint $Element;                     // Offset:    0 Size:     4
//
// }
//
// Resource bind info for output_num_lights_per_tile
// {
//
//   uint $Element;                     // Offset:    0 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// Light2DBounds                     texture  struct         r/o    0        1
// input_frustum_spheres_near        texture  struct         r/o    1        1
// input_frustum_spheres_far         texture  struct         r/o    2        1
// output_lights_per_tile                UAV  struct         r/w    0        1
// output_num_lights_per_tile            UAV  struct         r/w    1        1
// TiledLightBuffer_CB               cbuffer      NA          NA    1        1
// TiledLightCountBuffer_CB          cbuffer      NA          NA    2        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 cb1[4089], dynamicIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_resource_structured t0, 16
dcl_resource_structured t1, 16
dcl_resource_structured t2, 16
dcl_uav_structured u0, 4
dcl_uav_structured u1, 4
dcl_input vThreadID.xy

dcl_temps 18
dcl_resource_texture2d (float,float,float,float) t80

dcl_thread_group 8, 32, 1
bufinfo_indexable(structured_buffer, stride=16)(mixed,mixed,mixed,mixed) r0.x, t1.xyzw
uge r0.y, vThreadID.x, cb2[0].x
uge r0.x, vThreadID.y, r0.x
or r0.x, r0.x, r0.y
if_nz r0.x
  ret
endif
udiv r0.x, r1.x, vThreadID.y, cb2[0].y
ld_structured_indexable(structured_buffer, stride=16)(mixed,mixed,mixed,mixed) r2.xyzw, vThreadID.x, l(0), t0.xyzw
ige r0.y, r1.x, r2.x
ige r0.z, r2.y, r1.x
and r0.y, r0.z, r0.y
ige r0.z, r0.x, r2.z
and r0.y, r0.z, r0.y
ige r0.x, r2.w, r0.x
and r0.x, r0.x, r0.y
if_z r0.x
  ret
endif
ld_structured_indexable(structured_buffer, stride=16)(mixed,mixed,mixed,mixed) r0.xyzw, vThreadID.y, l(0), t1.xyzw
lt r1.x, r0.w, l(0.000000)
if_nz r1.x
  mov r1.x, l(0)
else
  ishl r1.y, vThreadID.x, l(3)
  div r1.z, l(1.000000, 1.000000, 1.000000, 1.000000), cb1[r1.y + 0].w
  

  add r0.xyz, r0.xyzx, -cb1[r1.y + 0].xyzx
 

//ld_indexable(texture2d)(float,float,float,float) r7.xyzw, l(0, 0, 0, 0), t80.xyzw
//add r7.w, r0.x, -r7.y
//mul r7.w, r7.w, r7.x
//add r7.w, r7.w, l(1080.0)
//add r0.x, r0.x, -r7.w

  dp3 r0.x, r0.xyzx, r0.xyzx


//ld_indexable(texture2d)(float,float,float,float) r7.xyzw, l(0, 0, 0, 0), t80.xyzw
//mul r8.w, r8.w, r7.y
//add r8.w, r8.w, l(-1.000000)
//mul r8.w, r8.w, l(1080.0)
//mul r8.w, r8.w, l(0.890000)
//mad r0.x, r7.x, r8.w, r0.x



  sqrt r0.z, r0.x
  mad r0.x, -r0.y, r0.y, r0.x
  max r0.x, r0.x, l(0.000000)
  sqrt r1.w, r0.x
  max r2.x, r0.y, l(0.000000)
  min r2.x, r1.z, r2.x
  add r0.y, r0.y, -r2.x
  mad r0.x, r0.y, r0.y, r0.x
  ge r0.y, r1.w, l(0.000000)
  add r1.w, r0.w, r1.z
  ge r0.z, r1.w, r0.z
  mul r0.w, r0.w, r0.w
  ge r0.x, r0.w, r0.x
  and r0.y, r0.z, r0.y
  or r0.x, r0.x, r0.y
  ieq r0.x, r0.x, l(-1)
  if_nz r0.x
    mov r1.x, l(-1)
  else
    ld_structured_indexable(structured_buffer, stride=16)(mixed,mixed,mixed,mixed) r0.xyzw, vThreadID.y, l(0), t2.xyzw
    add r0.xyz, r0.xyzx, -cb1[r1.y + 0].xyzx
    dp3 r0.x, r0.xyzx, r0.xyzx
    sqrt r0.z, r0.x
    mad r0.x, -r0.y, r0.y, r0.x
    
  endif
endif
if_z r1.x
  ret
endif
mov r0.x, vThreadID.y
mov r0.y, l(0)
imm_atomic_iadd r0.x, u1, r0.xyxx, l(1)
ishl r0.y, vThreadID.y, l(8)
iadd r0.x, r0.x, r0.y
store_structured u0.x, r0.x, l(0), vThreadID.x
ret
// Approximately 77 instruction slots used
