//Interlaced mode fix.
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.16 on Fri Jan 07 21:15:58 2022
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Index:    0 1 2 3          Components:    16 [unused]
//   row_major float3x4 transposeViewMat;// Index:    4 5 6            Components:    12 [unused]
//   row_major float3x4 transposeViewInvMat;// Index:    7 8 9            Components:    12 [unused]
//   float4 projElement[2];             // Index:   10 11             Components:     8 [unused]
//   float4 projInvElements[2];         // Index:   12 13             Components:     8 [unused]
//   row_major float4x4 viewProjInvMat; // Index:   14 15 16 17       Components:    16 [unused]
//   row_major float4x4 prevViewProjMat;// Index:   18 19 20 21       Components:    16 [unused]
//   float3 ZToLinear;                  // Index:   22.xyz            Components:     3
//   float subdivisionLevel;            // Index:   22.w              Components:     1 [unused]
//   float2 screenSize;                 // Index:   23.xy             Components:     2
//   float2 screenInverseSize;          // Index:   23.zw             Components:     2 [unused]
//   float2 cullingHelper;              // Index:   24.xy             Components:     2 [unused]
//   float cameraNearPlane;             // Index:   24.z              Components:     1
//   float cameraFarPlane;              // Index:   24.w              Components:     1
//   float4 viewFrustum[6];             // Index:   25-30             Components:    24 [unused]
//   float4 clipplane;                  // Index:   31.xyzw           Components:     4 [unused]
//
// }
//
// cbuffer Deinterlace
// {
//
//   uint isCurrentEvenFrame;           // Index:    0.x              Components:     1
//   uint isCurrentFrameCount;          // Index:    0.y              Components:     1 [unused]
//   uint isCurrentFrameCount2;         // Index:    0.z              Components:     1 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// HDRImage                          texture  float3          2d    0        1
// PrevHDRImage                      texture  float3          2d    1        1
// PrevPrevHDRImage                  texture  float3          2d    2        1
// Velocity                          texture  float4          2d    3        1
// PrevVelocity                      texture  float4          2d    4        1
// DepthImage                        texture  float4          2d    5        1
// PrevPrevDepthImage                texture  float4          2d    6        1
// HDRImageUAV                           UAV  float3          2d    0        1
// SceneInfo                         cbuffer      NA          NA    0        1
// Deinterlace                       cbuffer      NA          NA    1        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[25], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
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_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_uav_typed_texture2d (float,float,float,float) u0
dcl_input vThreadID.xy
dcl_temps 38
dcl_resource_texture2d (float,float,float,float) t125
dcl_thread_group 8, 8, 1
ld_indexable(texture2d)(float,float,float,float) r25.xyzw, l(0, 0, 0, 0), t125.xyzw
ishr r0.y, vThreadID.x, l(1)
mov r0.z, vThreadID.y
mov r0.w, l(0)
ld_indexable(texture2d)(float,float,float,float) r1.xyz, r0.yzww, t0.xyzw
and r1.w, vThreadID.x, l(1)
movc r1.w, r1.w, l(0), l(1)
xor r1.w, r1.w, cb1[0].x
if_z r1.w
  store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzx
  ret
endif
max r1.w, r1.y, r1.x
max r1.w, r1.z, r1.w
add r1.w, r1.w, l(1.000000)
div r2.xyz, r1.xyzx, r1.wwww
ld_indexable(texture2d)(float,float,float,float) r3.xy, r0.yzww, t3.yzxw

add r3.x, r25.x, r3.x

mul r1.w, r3.x, l(0.500000)
mul r3.zw, r3.xxxy, cb0[23].xxxy
mul r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.250000, -0.500000)
ftoi r3.zw, r3.zzzw
iadd r4.xy, r0.yzyy, r3.zwzz
mov r4.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyzw, t1.xyzw
ld_indexable(texture2d)(float,float,float,float) r3.zw, r0.yzww, t4.xwyz

add r3.z, r25.x, r3.z

mul r5.xy, r3.zwzz, cb0[23].xyxx
mul r5.xy, r5.xyxx, l(0.250000, -0.500000, 0.000000, 0.000000)
ftoi r5.xy, r5.xyxx
iadd r5.xy, r0.yzyy, r5.xyxx
mov r5.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r6.xyz, r5.xyww, t2.xyzw
max r2.w, r6.y, r6.x
max r2.w, r6.z, r2.w
add r2.w, r2.w, l(1.000000)
div r6.xyz, r6.xyzx, r2.wwww
dp3 r2.x, r2.xzyx, l(0.250000, 0.250000, 0.500000, 0.000000)
dp3 r2.y, r6.xzyx, l(0.250000, 0.250000, 0.500000, 0.000000)
add r2.y, -r2.y, r2.x
lt r2.y, l(0.004000), |r2.y|
if_nz r2.y
  mov r2.z, l(0)
endif
if_z r2.y
  mov r2.z, l(-1)
endif
add r2.yw, -r3.zzzw, r3.xxxy
mul r2.y, r2.y, l(0.500000)
add r2.y, |r2.w|, |r2.y|
lt r2.y, l(0.010000), r2.y
if_nz r2.y
  mov r2.w, l(0)
endif
if_z r2.y
  mov r2.w, l(-1)
endif
and r2.y, r2.w, r2.z
max r1.w, |r3.y|, |r1.w|
lt r1.w, r1.w, l(0.005000)
and r1.w, r1.w, r2.y
if_nz r1.w
  ld_indexable(texture2d)(float,float,float,float) r1.w, r0.yzww, t5.yzwx
  mad r1.w, -r1.w, cb0[22].y, cb0[22].x
  div r1.w, cb0[22].z, r1.w
  add r2.y, -cb0[24].z, cb0[24].w
  div r1.w, r1.w, r2.y
  ld_indexable(texture2d)(float,float,float,float) r2.z, r5.xyzw, t6.yzxw
  mad r2.z, -r2.z, cb0[22].y, cb0[22].x
  div r2.z, cb0[22].z, r2.z
  div r2.y, r2.z, r2.y
  add r1.w, r1.w, -r2.y
  mul r2.y, cb0[24].w, l(0.000100)
  lt r1.w, r2.y, |r1.w|
  if_nz r1.w
    mov r2.y, l(0)
  endif
  if_z r1.w
    mov r2.y, l(-1)
  endif
  if_nz r2.y
    store_uav_typed u0.xyzw, vThreadID.xyyy, r4.xyzx
    ret
  endif
endif
max r1.w, r4.y, r4.x
max r1.w, r4.z, r1.w
add r1.w, r1.w, l(1.000000)
div r2.yzw, r4.xxyz, r1.wwww
movc r1.w, cb1[0].x, l(1), l(-1)
iadd r0.x, r0.y, r1.w
ld_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xzww, t0.xyzw
max r0.w, r0.y, r0.x
max r0.w, r0.z, r0.w
add r0.w, r0.w, l(1.000000)
div r3.xyz, r0.xyzx, r0.wwww
dp3 r0.w, r3.xzyx, l(0.250000, 0.250000, 0.500000, 0.000000)
add r0.w, -r0.w, r2.x
lt r0.w, l(0.004000), |r0.w|
if_nz r0.w
  mov r1.w, l(0)
endif
if_z r0.w
  mov r1.w, l(-1)
endif
dp3 r0.w, r2.ywzy, l(0.250000, 0.250000, 0.500000, 0.000000)
add r0.w, -r0.w, r2.x
lt r0.w, l(0.004000), |r0.w|
if_nz r0.w
  mov r2.x, l(0)
endif
if_z r0.w
  mov r2.x, l(-1)
endif
and r0.w, r1.w, r2.x
if_nz r0.w
  store_uav_typed u0.xyzw, vThreadID.xyyy, r4.xyzx
  ret
endif
dp2 r0.w, r1.xzxx, l(0.250000, 0.250000, 0.000000, 0.000000)
mul r1.z, r1.z, l(0.500000)
mad r2.z, r1.y, l(0.500000), r0.w
mad r2.x, r1.y, l(0.500000), -r0.w
mad r2.y, r1.x, l(0.500000), -r1.z
dp2 r0.w, r4.xzxx, l(0.250000, 0.250000, 0.000000, 0.000000)
mul r1.x, r4.z, l(0.500000)
mad r3.x, r4.y, l(0.500000), r0.w
mad r3.y, r4.y, l(0.500000), -r0.w
mad r3.z, r4.x, l(0.500000), -r1.x
dp2 r0.w, r0.xzxx, l(0.250000, 0.250000, 0.000000, 0.000000)
mul r0.z, r0.z, l(0.500000)
mad r1.x, r0.y, l(0.500000), r0.w
mad r1.y, r0.y, l(0.500000), -r0.w
mad r1.z, r0.x, l(0.500000), -r0.z
min r0.xyz, r1.xyzx, r2.zxyz
max r1.xyz, r1.xyzx, r2.zxyz
max r0.w, r0.x, r3.x
min r0.w, r1.x, r0.w
add r3.xyz, -r2.zxyz, r3.xyzx
min r1.w, |r3.y|, |r3.x|
min r1.w, |r3.z|, r1.w
lt r1.w, l(0.000000), r1.w
if_nz r1.w
  add r0.xyz, -r2.zxyz, r0.xyzx
  div r0.xyz, r0.xyzx, r3.xyzx
  add r1.xyz, -r2.zxyz, r1.xyzx
  div r1.xyz, r1.xyzx, r3.xyzx
  max r0.xyz, r0.xyzx, r1.xyzx
  min r0.x, r0.y, r0.x
  min r0.x, r0.z, r0.x
  min r0.x, r0.x, l(1.000000)
  mad r2.xy, r3.yzyy, r0.xxxx, r2.xyxx
endif
add r0.x, r0.w, -r2.x
add r1.xyw, r0.xwxx, r2.yxyy
add r1.z, -r2.y, r0.x
store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzw
ret
// Approximately 155 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.16 on Fri Jan 07 21:15:58 2022
//
// 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);
// }
//
// cbuffer Deinterlace : register(b1)
// {
//   uint isCurrentEvenFrame : packoffset(c0);
//   uint isCurrentFrameCount : packoffset(c0.y);
//   uint isCurrentFrameCount2 : packoffset(c0.z);
// }
//
// Texture2D<float3> HDRImage : register(t0);
// Texture2D<float3> PrevHDRImage : register(t1);
// Texture2D<float3> PrevPrevHDRImage : register(t2);
// Texture2D<float4> Velocity : register(t3);
// Texture2D<float4> PrevVelocity : register(t4);
// Texture2D<float4> DepthImage : register(t5);
// Texture2D<float4> PrevPrevDepthImage : register(t6);
// RWTexture2D<float3> HDRImageUAV : register(u0);
//
//
// // 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
//   float4 r0,r1,r2,r3,r4,r5,r6;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_thread_group 8, 8, 1
//   r0.y = (uint)vThreadID.x >> 1;
//   r0.z = vThreadID.y;
//   r0.w = 0;
//   r1.xyz = HDRImage.Load(r0.yzw).xyz;
//   r1.w = (int)vThreadID.x & 1;
//   r1.w = r1.w ? 0 : 1;
//   r1.w = (int)r1.w ^ isCurrentEvenFrame;
//   if (r1.w == 0) {
//   // No code for instruction (needs manual fix):
//     store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzx
//     return;
//   }
//   r1.w = max(r1.x, r1.y);
//   r1.w = max(r1.w, r1.z);
//   r1.w = 1 + r1.w;
//   r2.xyz = r1.xyz / r1.www;
//   r3.xy = Velocity.Load(r0.yzw).yz;
//   r1.w = 0.5 * r3.x;
//   r3.zw = screenSize.xy * r3.xy;
//   r3.zw = float2(0.25,-0.5) * r3.zw;
//   r3.zw = (int2)r3.zw;
//   r4.xy = (int2)r0.yz + (int2)r3.zw;
//   r4.zw = float2(0,0);
//   r4.xyz = PrevHDRImage.Load(r4.xyz).xyz;
//   r3.zw = PrevVelocity.Load(r0.yzw).yz;
//   r5.xy = screenSize.xy * r3.zw;
//   r5.xy = float2(0.25,-0.5) * r5.xy;
//   r5.xy = (int2)r5.xy;
//   r5.xy = (int2)r0.yz + (int2)r5.xy;
//   r5.zw = float2(0,0);
//   r6.xyz = PrevPrevHDRImage.Load(r5.xyw).xyz;
//   r2.w = max(r6.x, r6.y);
//   r2.w = max(r2.w, r6.z);
//   r2.w = 1 + r2.w;
//   r6.xyz = r6.xyz / r2.www;
//   r2.x = dot(r2.xzy, float3(0.25,0.25,0.5));
//   r2.y = dot(r6.xzy, float3(0.25,0.25,0.5));
//   r2.y = r2.x + -r2.y;
//   r2.y = cmp(0.00400000019 < abs(r2.y));
//   if (r2.y != 0) {
//     r2.z = 0;
//   }
//   if (r2.y == 0) {
//     r2.z = -1;
//   }
//   r2.yw = r3.xy + -r3.zw;
//   r2.y = 0.5 * r2.y;
//   r2.y = abs(r2.y) + abs(r2.w);
//   r2.y = cmp(0.00999999978 < r2.y);
//   if (r2.y != 0) {
//     r2.w = 0;
//   }
//   if (r2.y == 0) {
//     r2.w = -1;
//   }
//   r2.y = (int)r2.w & (int)r2.z;
//   r1.w = max(abs(r1.w), abs(r3.y));
//   r1.w = cmp(r1.w < 0.00499999989);
//   r1.w = r1.w ? r2.y : 0;
//   if (r1.w != 0) {
//     r1.w = DepthImage.Load(r0.yzw).x;
//     r1.w = -r1.w * ZToLinear.y + ZToLinear.x;
//     r1.w = ZToLinear.z / r1.w;
//     r2.y = cameraFarPlane + -cameraNearPlane;
//     r1.w = r1.w / r2.y;
//     r2.z = PrevPrevDepthImage.Load(r5.xyz).x;
//     r2.z = -r2.z * ZToLinear.y + ZToLinear.x;
//     r2.z = ZToLinear.z / r2.z;
//     r2.y = r2.z / r2.y;
//     r1.w = -r2.y + r1.w;
//     r2.y = 9.99999975e-005 * cameraFarPlane;
//     r1.w = cmp(r2.y < abs(r1.w));
//     if (r1.w != 0) {
//       r2.y = 0;
//     }
//     if (r1.w == 0) {
//       r2.y = -1;
//     }
//     if (r2.y != 0) {
//     // No code for instruction (needs manual fix):
//         store_uav_typed u0.xyzw, vThreadID.xyyy, r4.xyzx
//       return;
//     }
//   }
//   r1.w = max(r4.x, r4.y);
//   r1.w = max(r1.w, r4.z);
//   r1.w = 1 + r1.w;
//   r2.yzw = r4.xyz / r1.www;
//   r1.w = isCurrentEvenFrame ? 1 : -1;
//   r0.x = (int)r0.y + (int)r1.w;
//   r0.xyz = HDRImage.Load(r0.xzw).xyz;
//   r0.w = max(r0.x, r0.y);
//   r0.w = max(r0.w, r0.z);
//   r0.w = 1 + r0.w;
//   r3.xyz = r0.xyz / r0.www;
//   r0.w = dot(r3.xzy, float3(0.25,0.25,0.5));
//   r0.w = r2.x + -r0.w;
//   r0.w = cmp(0.00400000019 < abs(r0.w));
//   if (r0.w != 0) {
//     r1.w = 0;
//   }
//   if (r0.w == 0) {
//     r1.w = -1;
//   }
//   r0.w = dot(r2.ywz, float3(0.25,0.25,0.5));
//   r0.w = r2.x + -r0.w;
//   r0.w = cmp(0.00400000019 < abs(r0.w));
//   if (r0.w != 0) {
//     r2.x = 0;
//   }
//   if (r0.w == 0) {
//     r2.x = -1;
//   }
//   r0.w = (int)r1.w & (int)r2.x;
//   if (r0.w != 0) {
//   // No code for instruction (needs manual fix):
//     store_uav_typed u0.xyzw, vThreadID.xyyy, r4.xyzx
//     return;
//   }
//   r0.w = dot(r1.xz, float2(0.25,0.25));
//   r1.z = 0.5 * r1.z;
//   r2.z = r1.y * 0.5 + r0.w;
//   r2.x = r1.y * 0.5 + -r0.w;
//   r2.y = r1.x * 0.5 + -r1.z;
//   r0.w = dot(r4.xz, float2(0.25,0.25));
//   r1.x = 0.5 * r4.z;
//   r3.x = r4.y * 0.5 + r0.w;
//   r3.y = r4.y * 0.5 + -r0.w;
//   r3.z = r4.x * 0.5 + -r1.x;
//   r0.w = dot(r0.xz, float2(0.25,0.25));
//   r0.z = 0.5 * r0.z;
//   r1.x = r0.y * 0.5 + r0.w;
//   r1.y = r0.y * 0.5 + -r0.w;
//   r1.z = r0.x * 0.5 + -r0.z;
//   r0.xyz = min(r2.zxy, r1.xyz);
//   r1.xyz = max(r2.zxy, r1.xyz);
//   r0.w = max(r3.x, r0.x);
//   r0.w = min(r0.w, r1.x);
//   r3.xyz = r3.xyz + -r2.zxy;
//   r1.w = min(abs(r3.x), abs(r3.y));
//   r1.w = min(r1.w, abs(r3.z));
//   r1.w = cmp(0 < r1.w);
//   if (r1.w != 0) {
//     r0.xyz = r0.xyz + -r2.zxy;
//     r0.xyz = r0.xyz / r3.xyz;
//     r1.xyz = r1.xyz + -r2.zxy;
//     r1.xyz = r1.xyz / r3.xyz;
//     r0.xyz = max(r1.xyz, r0.xyz);
//     r0.x = min(r0.x, r0.y);
//     r0.x = min(r0.x, r0.z);
//     r0.x = min(1, r0.x);
//     r2.xy = r3.yz * r0.xx + r2.xy;
//   }
//   r0.x = -r2.x + r0.w;
//   r1.xyw = r2.yxy + r0.xwx;
//   r1.z = r0.x + -r2.y;
// // No code for instruction (needs manual fix):
// store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzw
//   return;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// E:\SteamLibrary\steamapps\common\RESIDENT EVIL 2  BIOHAZARD RE2\ShaderFixes\3261142b7ba09d0f-cs_replace.txt(46,10): error X3000: syntax error: unexpected token ')'
/////////////////////////////////////////////////////////////////////////////
