//DMC5 decals CS 5. TAA part 2.
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.15-re2_workaround on Sat Mar 16 00:10:44 2019
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Offset:    0 Size:    64 [unused]
//   row_major float3x4 transposeViewMat;// Offset:   64 Size:    48 [unused]
//   row_major float3x4 transposeViewInvMat;// Offset:  112 Size:    48 [unused]
//   float4 projElement[2];             // Offset:  160 Size:    32 [unused]
//   float4 projInvElements[2];         // Offset:  192 Size:    32 [unused]
//   row_major float4x4 viewProjInvMat; // Offset:  224 Size:    64
//   row_major float4x4 prevViewProjMat;// Offset:  288 Size:    64
//   float3 ZToLinear;                  // Offset:  352 Size:    12 [unused]
//   float subdivisionLevel;            // Offset:  364 Size:     4 [unused]
//   float2 screenSize;                 // Offset:  368 Size:     8
//   float2 screenInverseSize;          // Offset:  376 Size:     8
//   float2 cullingHelper;              // Offset:  384 Size:     8 [unused]
//   float cameraNearPlane;             // Offset:  392 Size:     4 [unused]
//   float cameraFarPlane;              // Offset:  396 Size:     4 [unused]
//   float4 viewFrustum[6];             // Offset:  400 Size:    96 [unused]
//   float4 clipplane;                  // Offset:  496 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// ReadonlyDepth                     texture   float          2d    0        1
// RWVelocity                            UAV  float4          2d    0        1
// RWHiZ0                                UAV   float          2d    1        1
// RWHiZ1                                UAV   float          2d    2        1
// RWHiZ2                                UAV   float          2d    3        1
// RWHiZ3                                UAV   float          2d    4        1
// SceneInfo                         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[24], immediateIndexed
dcl_resource_texture2d (float,float,float,float) t0
dcl_uav_typed_texture2d (float,float,float,float) u0
dcl_uav_typed_texture2d (float,float,float,float) u1
dcl_uav_typed_texture2d (float,float,float,float) u2
dcl_uav_typed_texture2d (float,float,float,float) u3
dcl_uav_typed_texture2d (float,float,float,float) u4
dcl_input vThreadGroupID.xy
dcl_input vThreadIDInGroup.x
dcl_temps 40
dcl_resource_texture2d (float,float,float,float) t125
ld_indexable(texture2d)(float,float,float,float) r28.xyzw, l(0, 0, 0, 0), t125.xyzw
dcl_resource_texture1d (float,float,float,float) t120
dcl_tgsm_structured g0, 4, 71
dcl_tgsm_structured g1, 4, 71
dcl_thread_group 256, 1, 1
ubfe r0.xyzw, l(1, 1, 1, 1), l(1, 2, 3, 4), vThreadIDInGroup.xxxx
bfi r1.x, l(31), l(1), r0.y, vThreadIDInGroup.x
imad r0.x, r0.z, l(2), r0.x
ubfe r1.yz, l(0, 1, 1, 0), l(0, 5, 6, 0), vThreadIDInGroup.xxxx
imad r0.z, r0.w, l(4), r1.x
imad r0.x, r1.y, l(4), r0.x
ushr r1.x, vThreadIDInGroup.x, l(7)
imad r2.x, r1.z, l(8), r0.z
imad r2.yzw, r1.xxxx, l(0, 8, 8, 8), r0.xxxx
imad r3.xyzw, vThreadGroupID.xyyy, l(16, 16, 16, 16), r2.xwww
add r0.xz, cb0[23].xxyx, l(-1.000000, 0.000000, -1.000000, 0.000000)
utof r1.xy, r3.xwxx
min r0.xz, r0.xxzx, r1.xxyx
ftoi r4.xy, r0.xzxx
mov r4.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.x, r4.xyzw, t0.xyzw
imad r0.z, r2.w, l(9), r2.x
or r1.w, r2.w, r2.x
ult r4.xyz, r1.wwww, l(8, 4, 2, 0)
if_nz r4.x
  store_structured g0.x, r0.z, l(0), l(0)
  store_structured g1.x, r0.z, l(0), l(0)
endif
ge r4.w, l(0.000000), r0.x
if_nz r4.w
  mul r1.xy, r1.xyxx, cb0[23].zwzz
  mad r1.xy, r1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
  mad r1.xy, cb0[23].zwzz, l(0.500000, 0.500000, 0.000000, 0.000000), r1.xyxx
  
  mul r29.xyzw, r1.yyyy, cb0[15].xyzw
  mad r29.xyzw, r1.xxxx, cb0[14].xyzw, r29.xyzw
  mad r29.xyzw, r0.xxxx, cb0[16].xyzw, r29.xyzw
  add r29.xyzw, r29.xyzw, cb0[17].xyzw
  add r1.x, -r28.x, r1.x
  
  //mul r35.xyzw, r1.yyyy, cb0[15].xyzw
  //mad r35.xyzw, r1.xxxx, cb0[14].xyzw, r35.xyzw
  //mad r35.xyzw, r0.xxxx, cb0[16].xyzw, r35.xyzw
  //add r35.xyzw, r35.xyzw, cb0[17].xyzw
  
  mul r25.w, r28.x, r28.y
  mad r1.x, r25.w, r29.w, r1.x
  
  mul r5.xyzw, r1.yyyy, cb0[15].xyzw
  mad r5.xyzw, r1.xxxx, cb0[14].xyzw, r5.xyzw
  mad r5.xyzw, r0.xxxx, cb0[16].xyzw, r5.xyzw
  add r5.xyzw, r5.xyzw, cb0[17].xyzw
  
  mul r6.xyz, r5.yyyy, cb0[19].xywx
  mad r6.xyz, r5.xxxx, cb0[18].xywx, r6.xyzx
  mad r5.xyz, r5.zzzz, cb0[20].xywx, r6.xyzx
  mad r5.xyz, r5.wwww, cb0[21].xywx, r5.xyzx
  
  mad r5.x, -r28.x, r5.z, r5.x
  
  div r5.xy, r5.xyxx, r5.zzzz
  add r5.yz, -r1.xxyx, r5.xxyx
  mov r5.xw, l(1.000000,0,0,1.000000)
  store_uav_typed u0.xyzw, r3.xyzw, r5.xyzw
endif
sync_g_t
ushr r1.xy, r2.xwxx, l(1, 1, 0, 0)
ishl r3.x, vThreadIDInGroup.x, l(1)
bfi r0.y, l(31), l(2), r0.y, r3.x
imad r0.y, r0.w, l(8), r0.y
imad r0.y, r1.z, l(16), r0.y
imad r0.y, r2.w, l(18), r0.y
iadd r0.w, r0.y, l(1)
iadd r3.xy, r0.wwww, l(8, 9, 0, 0)
ishl r3.zw, vThreadGroupID.xxxy, l(0, 0, 3, 3)
imad r1.x, r1.y, l(9), r1.x
mov r1.y, l(0)
atomic_umax g0, r1.xyxx, r0.x
sync_g_t
if_nz r4.x
  ld_structured r0.x, r0.z, l(0), g0.xxxx
  iadd r5.xyzw, r2.xwww, r3.zwww
  store_uav_typed u1.xyzw, r5.xyzw, r0.xxxx
  ushr r3.zw, r3.zzzw, l(0, 0, 1, 1)
endif
sync_g_t
if_nz r4.y
  ld_structured r0.x, r0.y, l(0), g0.xxxx
  ld_structured r1.x, r0.w, l(0), g0.xxxx
  umax r0.x, r0.x, r1.x
  ld_structured r1.x, r3.x, l(0), g0.xxxx
  ld_structured r1.y, r3.y, l(0), g0.xxxx
  umax r1.x, r1.y, r1.x
  umax r0.x, r0.x, r1.x
  store_structured g1.x, r0.z, l(0), r0.x
  iadd r5.xyzw, r2.xwww, r3.zwww
  store_uav_typed u2.xyzw, r5.xyzw, r0.xxxx
  ushr r3.zw, r3.zzzw, l(0, 0, 1, 1)
endif
sync_g_t
if_nz r4.z
  ld_structured r0.x, r0.y, l(0), g1.xxxx
  ld_structured r1.x, r0.w, l(0), g1.xxxx
  umax r0.x, r0.x, r1.x
  ld_structured r1.x, r3.x, l(0), g1.xxxx
  ld_structured r1.y, r3.y, l(0), g1.xxxx
  umax r1.x, r1.y, r1.x
  umax r0.x, r0.x, r1.x
  store_structured g0.x, r0.z, l(0), r0.x
  iadd r4.xyzw, r2.xwww, r3.zwww
  store_uav_typed u3.xyzw, r4.xyzw, r0.xxxx
  ushr r3.zw, r3.zzzw, l(0, 0, 1, 1)
endif
sync_g_t
if_z r1.w
  ld_structured r0.x, r0.y, l(0), g0.xxxx
  ld_structured r0.y, r0.w, l(0), g0.xxxx
  umax r0.x, r0.y, r0.x
  ld_structured r0.y, r3.x, l(0), g0.xxxx
  ld_structured r0.w, r3.y, l(0), g0.xxxx
  umax r0.y, r0.w, r0.y
  umax r0.x, r0.y, r0.x
  store_structured g1.x, r0.z, l(0), r0.x
  iadd r0.xyzw, r2.xyzw, r3.zwww
  ld_structured r1.x, l(0), l(0), g1.xxxx
  store_uav_typed u4.xyzw, r0.xyzw, r1.xxxx
endif
ret
// Approximately 104 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.15-re2_workaround on Sat Mar 16 00:10:44 2019
// groupshared struct { float val[1]; } g1[71];
// groupshared struct { float val[1]; } g0[71];
//
// cbuffer SceneInfo : register(b0)
// {
//   row_major float4x4 viewProjMat : packoffset(c0);
//   row_major float3x4 transposeViewMat : packoffset(c4);
//   row_major float3x4 transposeViewInvMat : packoffset(c7);
//   float4 projElement[2] : packoffset(c10);
//   float4 projInvElements[2] : packoffset(c12);
//   row_major float4x4 viewProjInvMat : packoffset(c14);
//   row_major float4x4 prevViewProjMat : packoffset(c18);
//   float3 ZToLinear : packoffset(c22);
//   float subdivisionLevel : packoffset(c22.w);
//   float2 screenSize : packoffset(c23);
//   float2 screenInverseSize : packoffset(c23.z);
//   float2 cullingHelper : packoffset(c24);
//   float cameraNearPlane : packoffset(c24.z);
//   float cameraFarPlane : packoffset(c24.w);
//   float4 viewFrustum[6] : packoffset(c25);
//   float4 clipplane : packoffset(c31);
// }
//
// Texture2D<float> ReadonlyDepth : register(t0);
// RWTexture2D<float4> RWVelocity : register(u0);
// RWTexture2D<float> RWHiZ0 : register(u1);
// RWTexture2D<float> RWHiZ1 : register(u2);
// RWTexture2D<float> RWHiZ2 : register(u3);
// RWTexture2D<float> RWHiZ3 : register(u4);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Texture2D<float4> StereoParams : register(t125);
//
//
// void main)
// {
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_uav_typed_texture2d (float,float,float,float) u0
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_uav_typed_texture2d (float,float,float,float) u1
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_uav_typed_texture2d (float,float,float,float) u2
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_uav_typed_texture2d (float,float,float,float) u3
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_uav_typed_texture2d (float,float,float,float) u4
//   float4 r0,r1,r2,r3,r4,r5,r6;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_thread_group 256, 1, 1
//   if (1 == 0) r0.x = 0; else if (1+1 < 32) {   r0.x = (uint)vThreadIDInGroup.x << (32-(1 + 1)); r0.x = (uint)r0.x >> (32-1);  } else r0.x = (uint)vThreadIDInGroup.x >> 1;
//   if (1 == 0) r0.y = 0; else if (1+2 < 32) {   r0.y = (uint)vThreadIDInGroup.x << (32-(1 + 2)); r0.y = (uint)r0.y >> (32-1);  } else r0.y = (uint)vThreadIDInGroup.x >> 2;
//   if (1 == 0) r0.z = 0; else if (1+3 < 32) {   r0.z = (uint)vThreadIDInGroup.x << (32-(1 + 3)); r0.z = (uint)r0.z >> (32-1);  } else r0.z = (uint)vThreadIDInGroup.x >> 3;
//   if (1 == 0) r0.w = 0; else if (1+4 < 32) {   r0.w = (uint)vThreadIDInGroup.x << (32-(1 + 4)); r0.w = (uint)r0.w >> (32-1);  } else r0.w = (uint)vThreadIDInGroup.x >> 4;
//   bitmask.x = ((~(-1 << 31)) << 1) & 0xffffffff;  r1.x = (((uint)r0.y << 1) & bitmask.x) | ((uint)vThreadIDInGroup.x & ~bitmask.x);
//   r0.x = mad((int)r0.z, 2, (int)r0.x);
//   if (1 == 0) r1.y = 0; else if (1+5 < 32) {   r1.y = (uint)vThreadIDInGroup.x << (32-(1 + 5)); r1.y = (uint)r1.y >> (32-1);  } else r1.y = (uint)vThreadIDInGroup.x >> 5;
//   if (1 == 0) r1.z = 0; else if (1+6 < 32) {   r1.z = (uint)vThreadIDInGroup.x << (32-(1 + 6)); r1.z = (uint)r1.z >> (32-1);  } else r1.z = (uint)vThreadIDInGroup.x >> 6;
//   r0.z = mad((int)r0.w, 4, (int)r1.x);
//   r0.x = mad((int)r1.y, 4, (int)r0.x);
//   r1.x = (uint)vThreadIDInGroup.x >> 7;
//   r2.x = mad((int)r1.z, 8, (int)r0.z);
//   r2.yzw = mad((int3)r1.xxx, int3(8,8,8), (int3)r0.xxx);
//   r3.xyzw = mad((int4)vThreadGroupID.xyyy, int4(16,16,16,16), (int4)r2.xwww);
//   r0.xz = float2(-1,-1) + screenSize.xy;
//   r1.xy = (uint2)r3.xw;
//   r0.xz = min(r1.xy, r0.xz);
//   r4.xy = (int2)r0.xz;
//   r4.zw = float2(0,0);
//   r0.x = ReadonlyDepth.Load(r4.xyz).x;
//   r0.z = mad((int)r2.w, 9, (int)r2.x);
//   r1.w = (int)r2.w | (int)r2.x;
//   r4.xyz = cmp((uint3)r1.www < int3(8,4,2));
//   if (r4.x != 0) {
//     g0[r0.z].val[0/4] = 0;
//     g1[r0.z].val[0/4] = 0;
//   }
//   r4.w = cmp(0 >= r0.x);
//   if (r4.w != 0) {
//     r1.xy = screenInverseSize.xy * r1.xy;
//     r1.xy = r1.xy * float2(2,-2) + float2(-1,1);
//     r1.xy = screenInverseSize.xy * float2(0.5,0.5) + r1.xy;
//     r5.xyzw = viewProjInvMat._m10_m11_m12_m13 * r1.yyyy;
//     r5.xyzw = r1.xxxx * viewProjInvMat._m00_m01_m02_m03 + r5.xyzw;
//     r5.xyzw = r0.xxxx * viewProjInvMat._m20_m21_m22_m23 + r5.xyzw;
//     r5.xyzw = viewProjInvMat._m30_m31_m32_m33 + r5.xyzw;
//     r6.xyz = prevViewProjMat._m10_m11_m13 * r5.yyy;
//     r6.xyz = r5.xxx * prevViewProjMat._m00_m01_m03 + r6.xyz;
//     r5.xyz = r5.zzz * prevViewProjMat._m20_m21_m23 + r6.xyz;
//     r5.xyz = r5.www * prevViewProjMat._m30_m31_m33 + r5.xyz;
//     r5.xy = r5.xy / r5.zz;
//     r5.yz = r5.xy + -r1.xy;
//     r5.xw = float2(1,1);
//   // No code for instruction (needs manual fix):
//     store_uav_typed u0.xyzw, r3.xyzw, r5.xyzw
//   }
//   GroupMemoryBarrierWithGroupSync();
//   r1.xy = (uint2)r2.xw >> int2(1,1);
//   r3.x = (uint)vThreadIDInGroup.x << 1;
//   bitmask.y = ((~(-1 << 31)) << 2) & 0xffffffff;  r0.y = (((uint)r0.y << 2) & bitmask.y) | ((uint)r3.x & ~bitmask.y);
//   r0.y = mad((int)r0.w, 8, (int)r0.y);
//   r0.y = mad((int)r1.z, 16, (int)r0.y);
//   r0.y = mad((int)r2.w, 18, (int)r0.y);
//   r0.w = (int)r0.y + 1;
//   r3.xy = (int2)r0.ww + int2(8,9);
//   r3.zw = (uint2)vThreadGroupID.xy << int2(3,3);
//   r1.x = mad((int)r1.y, 9, (int)r1.x);
//   r1.y = 0;
//   // Needs manual fix for instruction:
// atomic_umax g0, r1.xyxx, r0.x
//   InterlockedMax(dest, value, orig_value);
//   GroupMemoryBarrierWithGroupSync();
//   if (r4.x != 0) {
//     r0.x = g0[r0.z].val[0/4];
//     r5.xyzw = (int4)r2.xwww + (int4)r3.zwww;
//   // No code for instruction (needs manual fix):
//     store_uav_typed u1.xyzw, r5.xyzw, r0.xxxx
//     r3.zw = (uint2)r3.zw >> int2(1,1);
//   }
//   GroupMemoryBarrierWithGroupSync();
//   if (r4.y != 0) {
//     r0.x = g0[r0.y].val[0/4];
//     r1.x = g0[r0.w].val[0/4];
//     r0.x = max((uint)r1.x, (uint)r0.x);
//     r1.x = g0[r3.x].val[0/4];
//     r1.y = g0[r3.y].val[0/4];
//     r1.x = max((uint)r1.x, (uint)r1.y);
//     r0.x = max((uint)r1.x, (uint)r0.x);
//     g1[r0.z].val[0/4] = r0.x;
//     r5.xyzw = (int4)r2.xwww + (int4)r3.zwww;
//   // No code for instruction (needs manual fix):
//     store_uav_typed u2.xyzw, r5.xyzw, r0.xxxx
//     r3.zw = (uint2)r3.zw >> int2(1,1);
//   }
//   GroupMemoryBarrierWithGroupSync();
//   if (r4.z != 0) {
//     r0.x = g1[r0.y].val[0/4];
//     r1.x = g1[r0.w].val[0/4];
//     r0.x = max((uint)r1.x, (uint)r0.x);
//     r1.x = g1[r3.x].val[0/4];
//     r1.y = g1[r3.y].val[0/4];
//     r1.x = max((uint)r1.x, (uint)r1.y);
//     r0.x = max((uint)r1.x, (uint)r0.x);
//     g0[r0.z].val[0/4] = r0.x;
//     r4.xyzw = (int4)r2.xwww + (int4)r3.zwww;
//   // No code for instruction (needs manual fix):
//     store_uav_typed u3.xyzw, r4.xyzw, r0.xxxx
//     r3.zw = (uint2)r3.zw >> int2(1,1);
//   }
//   GroupMemoryBarrierWithGroupSync();
//   if (r1.w == 0) {
//     r0.x = g0[r0.y].val[0/4];
//     r0.y = g0[r0.w].val[0/4];
//     r0.x = max((uint)r0.x, (uint)r0.y);
//     r0.y = g0[r3.x].val[0/4];
//     r0.w = g0[r3.y].val[0/4];
//     r0.y = max((uint)r0.y, (uint)r0.w);
//     r0.x = max((uint)r0.x, (uint)r0.y);
//     g1[r0.z].val[0/4] = r0.x;
//     r0.xyzw = (int4)r2.xyzw + (int4)r3.zwww;
//     r1.x = g1[0].val[0/4];
//   // No code for instruction (needs manual fix):
//     store_uav_typed u4.xyzw, r0.xyzw, r1.xxxx
//   }
//   return;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// E:\SteamLibrary\steamapps\common\Devil May Cry 5\ShaderFixes\3ebdccb121ce64fa-cs_replace.txt(39,10): error X3000: syntax error: unexpected token ')'
/////////////////////////////////////////////////////////////////////////////
