//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.16 on Fri Jan 14 20:06:33 2022
//
//
// Note: shader requires additional functionality:
//       64 UAV slots
//
//
// Buffer Definitions:
//
// cbuffer ConstBuf__constants
// {
//
//   struct SSReflectionsConstants
//   {
//
//       int enable;                    // Index:    0
//       int filterSize;                // Index:    0.y
//       float temporalMotionScale;     // Index:    0.z
//       float2 motionRescale;          // Index:    1
//       float minGlossScale;           // Index:    1.z
//       float minGlossBias;            // Index:    1.w
//       float borderScale;             // Index:    2
//       float borderBias;              // Index:    2.y
//       float temporalMaxConvergence;  // Index:    2.z
//       float temporalBaseStrength;    // Index:    2.w
//       float temporalHoleFillingStrength;// Index:    3
//       float temporalMotionRejection; // Index:    3.y
//
//   } srtInput__constants;             // Index:    0-3.y            Components:    14
                                        // Textures:  t0-t6
//
// }
//
// cbuffer ConstBuf__tileConstants
// {
//
//   struct SSReflectionsTileConstants
//   {
//
//       uint tilesHorz;                // Index:    0
//       uint tilesVert;                // Index:    0.y
//       uint permutationOffset;        // Index:    0.z
//       uint firstGroupOffset;         // Index:    0.w
//
//   } srtInput__tileConstants;         // Index:    0.xyzw           Components:     4
//
// }
//
// cbuffer ConstBuf__gbuffers
// {
//
//   struct GBufferStruct
//   {
//
//       float4x4 invViewProjNoZReproj; // Index:    0
//       float4x4 directionProjMatrix;  // Index:    4
//       float2 viewportScale;          // Index:    8
//       float2 viewportBias;           // Index:    8.z
//       float2 invViewportSize;        // Index:    9
//       float2 viewportSize;           // Index:    9.z
//       uint2 viewportSizeUint;        // Index:   10
//       float3 eyePos;                 // Index:   11
//
//   } srtInput__gbuffers;              // Index:    0-11.z           Components:    47
                                        // Textures:  t7-t10
//
// }
//
// Resource bind info for srtInput__constants.inOffsets
// {
//
//   uint $Element;                     // Index:    0.x              Components:     1
//
// }
//
// Resource bind info for srtInput__constants.texLightsFlattened
// {
//
//   uint $Element;                     // Index:    0.x              Components:     1
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// srtInput__constants__smpLinearClamp    sampler      NA          NA    0        1
// srtInput__constants.InputSSRRayColor    texture  float3          2d    0        1
// srtInput__constants.InputSSRRayInfo    texture  float4          2d    1        1
// srtInput__constants.InputMotionVectorsDilated    texture  float2          2d    2        1
// srtInput__constants.InputSSRResolvedTemporal    texture  float4          2d    3        1
// srtInput__constants.inOffsets     texture  struct         r/o    4        1
// srtInput__constants.texLightsFlattened    texture  struct         r/o    6        1
// srtInput__gbuffers.linearDepthTexture    texture   float          2d    7        1
// srtInput__gbuffers.normalTexture    texture  float4          2d    9        1
// srtInput__gbuffers.propertiesTexture    texture  float4          2d   10        1
// srtInput__constants.OutputSSRResolved        UAV  float4          2d    8        1
// ConstBuf__constants               cbuffer      NA          NA    0        1
// ConstBuf__tileConstants           cbuffer      NA          NA    1        1
// ConstBuf__gbuffers                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_immediateConstantBuffer { { 0.356642, 0, 0, 0},
                              { 0.239400, 0, 0, 0},
                              { 0.072410, 0, 0, 0},
                              { 0.009869, 0, 0, 0} }
dcl_constantbuffer cb0[4], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[12], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_structured t4, 4
dcl_resource_structured t6, 4
dcl_resource_texture2d (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_uav_typed_texture2d (float,float,float,float) u8
dcl_input vThreadIDInGroupFlattened
dcl_input vThreadGroupID.x
dcl_temps 50
dcl_tgsm_structured g0, 16, 64
dcl_tgsm_structured g1, 16, 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
iadd r0.x, vThreadGroupID.x, cb1[0].w
ushr r0.y, r0.x, l(2)
and r1.x, r0.x, l(1)
ubfe r1.y, l(1), l(1), r0.x
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r0.x, cb1[0].z, l(0), t4.xxxx
iadd r0.x, r0.y, r0.x
imul null, r0.x, r0.x, l(3)
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r0.x, r0.x, l(0), t6.xxxx
and r2.x, r0.x, l(1023)
ubfe r2.y, l(10), l(10), r0.x
and r0.x, vThreadIDInGroupFlattened.x, l(7)
ushr r0.y, vThreadIDInGroupFlattened.x, l(3)
ishl r0.zw, r1.xxxy, l(0, 0, 3, 3)
imad r0.zw, r2.xxxy, l(0, 0, 16, 16), r0.zzzw
iadd r3.xy, r0.zwzz, r0.xyxx
ieq r0.z, l(0), cb0[0].x
if_z cb0[0].x
  store_uav_typed u8.xyzw, r3.xyyy, l(0,0,0,0)
endif
if_z r0.z
  ishl r0.zw, r1.xxxy, l(0, 0, 2, 2)
  imad r0.zw, r2.xxxy, l(0, 0, 8, 8), r0.zzzw
  iadd r0.xz, r0.xxyx, r0.zzwz
  iadd r1.xy, r0.xzxx, l(-2, -2, 0, 0)
  mov r1.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xyww, t1.xyzw
  store_structured g0.xyzw, vThreadIDInGroupFlattened.x, l(0), r2.xyzw
  ld_indexable(texture2d)(float,float,float,float) r0.xzw, r1.xyzw, t0.xwyz
  store_structured g1.xyz, vThreadIDInGroupFlattened.x, l(0), r0.xzwx
  utof r0.xz, r3.xxyx
  add r0.xz, r0.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
  ftoi r1.xy, r0.xzxx
  mad r2.xy, r0.xzxx, cb2[8].xyxx, cb2[8].zwzz
  mul r2.zw, r0.xxxz, cb2[9].xxxy
  mov r1.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r4.z, r1.xyww, t7.yzxw
  mul r4.xy, r2.xyxx, r4.zzzz
  mov r4.w, l(1.000000)
  
  //Disabled with new TAA fix.
  add r40.w, r4.z, -r40.y
  //mad r4.x, -r40.x, r40.w, r4.x
  
  dp4 r5.x, r4.xyzw, cb2[0].xyzw
  dp4 r5.y, r4.xyzw, cb2[1].xyzw
  dp4 r5.z, r4.xyzw, cb2[2].xyzw
  ld_indexable(texture2d)(float,float,float,float) r4.xyz, r1.xyww, t9.xyzw
  mad r4.xyz, r4.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
  dp3 r0.w, r4.xyzx, r4.xyzx
  rsq r0.w, r0.w
  mul r4.xyz, r0.wwww, r4.xyzx
  ld_indexable(texture2d)(float,float,float,float) r0.w, r1.xyzw, t10.xywz
  add r1.xyz, -r5.xyzx, cb2[11].xyzx
  
  //Specular CS.
  mul r41.x, r40.y, cb2[0].x
  mul r41.y, r40.y, cb2[1].x
  mul r41.z, r40.y, cb2[2].x
  mad r1.x, r40.x, r41.x, r1.x
  mad r1.y, r40.x, r41.y, r1.y
  mad r1.z, r40.x, r41.z, r1.z
  
  dp3 r1.w, r1.xyzx, r1.xyzx
  rsq r1.w, r1.w
  add r2.x, -r0.w, l(1.000000)
  mul r2.x, r2.x, r2.x
  max r2.x, r2.x, l(0.001000)
  add r5.xyz, r5.xyzx, -cb2[11].xyzx
  ubfe r2.y, l(2), l(1), vThreadIDInGroupFlattened.x
  ushr r0.y, r0.y, l(1)
  imad r0.y, r0.y, l(8), r2.y
  iadd r0.y, r0.y, l(18)
  sync_g_t
  ineg r2.y, cb0[0].y
  mul r4.w, r2.x, r2.x
  mad r2.x, r2.x, r2.x, l(-1.000000)
  mov r6.w, l(1.000000)
  mov r5.w, l(0)
  mov r7.xyzw, l(0,0,0,0)
  mov r8.x, l(1.000000012E-007)
  mov r8.y, r2.y
  loop
    ilt r8.z, cb0[0].y, r8.y
    breakc_nz r8.z
    ishl r8.z, r8.y, l(3)
    iadd r8.z, r0.y, r8.z
    imax r8.w, -r8.y, r8.y
    mov r9.xyz, r7.xyzx
    mov r9.w, r5.w
    mov r10.x, r7.w
    mov r10.y, r8.x
    mov r10.z, r2.y
    loop
      ilt r10.w, cb0[0].y, r10.z
      breakc_nz r10.w
      iadd r10.w, r8.z, r10.z
      ld_structured r11.xyzw, r10.w, l(0), g0.xyzw
      imax r12.x, -r10.z, r10.z
      mad r10.y, icb[r12.x + 0].x, icb[r8.w + 0].x, r10.y
      lt r12.y, l(0.000000), r11.w
      if_nz r12.y
        add r11.xyz, -r5.xyzx, r11.xyzx
        dp3 r12.y, r11.xyzx, r11.xyzx
        rsq r12.y, r12.y
        mul r11.xyz, r11.xyzx, r12.yyyy
        dp3_sat r12.y, r4.xyzx, r11.xyzx
        lt r12.z, l(0.000000), r12.y
        if_nz r12.z
          mad r11.xyz, r1.xyzx, r1.wwww, r11.xyzx
          dp3 r12.z, r11.xyzx, r11.xyzx
          rsq r12.z, r12.z
          mul r11.xyz, r11.xyzx, r12.zzzz
          dp3 r11.x, r4.xyzx, r11.xyzx
          mul r11.x, r11.x, r11.x
          mad r11.x, r11.x, r2.x, l(1.000000)
          mul r11.x, r11.x, r11.x
          div r11.x, r4.w, r11.x
          mul r11.x, r11.x, r12.y
          mul r11.x, r11.w, r11.x
          ld_structured r6.xyz, r10.w, l(0), g1.xyzx
          mad r9.xyzw, r6.xyzw, r11.xxxx, r9.xyzw
          mad r10.x, icb[r12.x + 0].x, icb[r8.w + 0].x, r10.x
        endif
      endif
      iadd r10.z, r10.z, l(1)
    endloop
    mov r7.xyz, r9.xyzx
    mov r5.w, r9.w
    mov r7.w, r10.x
    mov r8.x, r10.y
    iadd r8.y, r8.y, l(1)
  endloop
  lt r0.y, l(0.000000), r5.w
  div r1.xyz, r7.xyzx, r5.wwww
  movc r1.xyz, r0.yyyy, r1.xyzx, r7.xyzx
  div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r8.x
  dp2 r0.y, r7.wwww, r0.yyyy
  add_sat r1.w, r0.y, l(-0.250000)
  mov r3.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r2.xy, r3.xyzw, t2.xyzw
  
  //Disabled with new TAA fix.
  //mad r2.x, r40.x, l(0.5), r2.x
  
  mul r2.xy, r2.xyxx, cb0[1].xyxx
  mad r0.xy, r0.xzxx, cb2[9].xyxx, r2.xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r4.xyzw, r0.xyxx, t3.xyzw, s0, l(0.000000)
  add r0.x, -r1.w, r4.w
  add r0.x, r0.x, l(1.000000)
  mul r0.x, r0.x, cb0[3].x
  mad_sat r0.x, cb0[2].w, r1.w, r0.x
  dp2 r0.y, r2.xyxx, r2.xyxx
  mul r0.y, r0.y, cb0[0].z
  mad_sat r0.y, -r0.y, cb0[3].y, l(1.000000)
  mul r0.x, r0.y, r0.x
  mul r0.x, r0.x, cb0[2].z
  add r4.xyzw, -r1.xyzw, r4.xyzw
  mad r1.xyzw, r0.xxxx, r4.xyzw, r1.xyzw
  mad r0.xy, r2.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
  max r0.x, |r0.y|, |r0.x|
  mad_sat r0.x, r0.x, cb0[2].x, cb0[2].y
  mul r0.y, r0.x, r0.x
  mad r0.x, -r0.x, l(2.000000), l(3.000000)
  mul r0.x, r0.x, r0.y
  mul r0.x, r0.x, r1.w
  mad_sat r0.y, r0.w, cb0[1].z, cb0[1].w
  mul r1.w, r0.y, r0.x
  max r0.xyzw, r1.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
  store_uav_typed u8.xyzw, r3.xyyy, r0.xyzw
endif
ret
// Approximately 153 instruction slots used
