// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:30:28 2016

cbuffer cbSSAOParam : register(b0)
{
  float4 g_vDepthComputeParam : packoffset(c0);
  float4 g_vAOScaleOffset : packoffset(c1);
  float4 g_vBlendScale : packoffset(c2);
}

cbuffer cbSSAOParam2 : register(b2)
{
  float4x4 g_mInvProj : packoffset(c0);
  float4 g_vScreenSize : packoffset(c4);
  float4x4 g_mView : packoffset(c5);
  float4 g_vAOScaleOffset2 : packoffset(c9);
  float4 g_vSampleRangeParam : packoffset(c10);
  float4x4 g_mCurToPrevScreen : packoffset(c11);
  float4 g_vPrevFrameStrengh : packoffset(c15);
  float4 g_vMiscParam : packoffset(c16);
  float4 g_vDepthRangeParam : packoffset(c17);
}

SamplerState SS_ClampPoint_s : register(s2);
SamplerState SS_WhiteBorderPoint_s : register(s4);
Texture2D<float4> g_DepthTex : register(t0);
Texture2D<float4> g_SrcAOTex : register(t1);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : SV_Position0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.z = g_vScreenSize.z * 0.5 + v1.x;
  r0.xyw = -g_vScreenSize.zww * float3(0.5,0.5,0.5) + v1.xyy;
  r1.xyzw = g_SrcAOTex.SampleLevel(SS_ClampPoint_s, r0.zw, 0).xyzw;
  r0.xyzw = g_SrcAOTex.SampleLevel(SS_ClampPoint_s, r0.xy, 0).xyzw;
  r1.y = dot(r1.yzw, float3(1.53787005e-005,0.00392156886,1));
  r1.z = g_DepthTex.Sample(SS_WhiteBorderPoint_s, v1.xy).x;
  r1.z = g_vDepthComputeParam.x + -r1.z;
  r1.z = -g_vDepthComputeParam.y / r1.z;
  r1.z = 1 / r1.z;
  r1.y = r1.y * r1.z + -1;
  r1.y = 0.00999999978 + abs(r1.y);
  r1.y = 1 / r1.y;
  r2.xy = g_vScreenSize.xy * v1.xy;
  r2.xy = frac(r2.xy);
  r2.zw = float2(1,1) + -r2.yx;
  r1.w = dot(r2.xz, r2.xz);
  r1.w = sqrt(r1.w);
  r1.w = 1 / r1.w;
  r1.y = r1.y * r1.w;
  r1.x = r1.x * r1.y;
  r0.y = dot(r0.yzw, float3(1.53787005e-005,0.00392156886,1));
  r0.y = r0.y * r1.z + -1;
  r0.y = 0.00999999978 + abs(r0.y);
  r0.y = 1 / r0.y;
  r0.zw = float2(1,1) + -r2.xy;
  r0.z = dot(r0.zw, r0.zw);
  r0.z = sqrt(r0.z);
  r0.z = 1 / r0.z;
  r0.w = r0.y * r0.z;
  r0.y = r0.y * r0.z + r1.y;
  r0.x = r0.x * r0.w + r1.x;
  r0.zw = r2.xy * float2(-1,1) + float2(1,0);
  r0.z = dot(r2.wy, r0.zw);
  r0.w = dot(r2.xy, r2.xy);
  r0.zw = sqrt(r0.zw);
  r0.w = 1 / r0.w;
  r0.z = 1 / r0.z;
  r2.x = -g_vScreenSize.z * 0.5 + v1.x;
  r2.yzw = g_vScreenSize.wzw * float3(0.5,0.5,0.5) + v1.yxy;
  r3.xyzw = g_SrcAOTex.SampleLevel(SS_ClampPoint_s, r2.xy, 0).xyzw;
  r2.xyzw = g_SrcAOTex.SampleLevel(SS_ClampPoint_s, r2.zw, 0).xyzw;
  r1.x = dot(r3.yzw, float3(1.53787005e-005,0.00392156886,1));
  r1.x = r1.x * r1.z + -1;
  r1.x = 0.00999999978 + abs(r1.x);
  r1.x = 1 / r1.x;
  r1.y = r1.x * r0.z;
  r0.y = r1.x * r0.z + r0.y;
  r0.x = r3.x * r1.y + r0.x;
  r0.z = dot(r2.yzw, float3(1.53787005e-005,0.00392156886,1));
  r0.z = r0.z * r1.z + -1;
  r0.z = 0.00999999978 + abs(r0.z);
  r0.z = 1 / r0.z;
  r1.x = r0.z * r0.w;
  r0.y = r0.z * r0.w + r0.y;
  r0.x = r2.x * r1.x + r0.x;
  o0.xyzw = r0.xxxx / r0.yyyy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbSSAOParam
// {
//
//   float4 g_vDepthComputeParam;       // Offset:    0 Size:    16
//   float4 g_vAOScaleOffset;           // Offset:   16 Size:    16 [unused]
//   float4 g_vBlendScale;              // Offset:   32 Size:    16 [unused]
//
// }
//
// cbuffer cbSSAOParam2
// {
//
//   float4x4 g_mInvProj;               // Offset:    0 Size:    64 [unused]
//   float4 g_vScreenSize;              // Offset:   64 Size:    16
//   float4x4 g_mView;                  // Offset:   80 Size:    64 [unused]
//   float4 g_vAOScaleOffset2;          // Offset:  144 Size:    16 [unused]
//   float4 g_vSampleRangeParam;        // Offset:  160 Size:    16 [unused]
//   float4x4 g_mCurToPrevScreen;       // Offset:  176 Size:    64 [unused]
//   float4 g_vPrevFrameStrengh;        // Offset:  240 Size:    16 [unused]
//   float4 g_vMiscParam;               // Offset:  256 Size:    16 [unused]
//   float4 g_vDepthRangeParam;         // Offset:  272 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_ClampPoint                     sampler      NA          NA    2        1
// SS_WhiteBorderPoint               sampler      NA          NA    4        1
// g_DepthTex                        texture  float4          2d    0        1
// g_SrcAOTex                        texture  float4          2d    1        1
// cbSSAOParam                       cbuffer      NA          NA    0        1
// cbSSAOParam2                      cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb2[5], immediateIndexed
dcl_sampler s2, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 4
mad r0.z, cb2[4].z, l(0.500000), v1.x
mad r0.xyw, -cb2[4].zwzw, l(0.500000, 0.500000, 0.000000, 0.500000), v1.xyxy
sample_l_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.zwzz, t1.xyzw, s2, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t1.xyzw, s2, l(0.000000)
dp3 r1.y, r1.yzwy, l(0.000015, 0.003922, 1.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r1.z, v1.xyxx, t0.yzxw, s4
add r1.z, -r1.z, cb0[0].x
div r1.z, -cb0[0].y, r1.z
div r1.z, l(1.000000, 1.000000, 1.000000, 1.000000), r1.z
mad r1.y, r1.y, r1.z, l(-1.000000)
add r1.y, |r1.y|, l(0.010000)
div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y
mul r2.xy, v1.xyxx, cb2[4].xyxx
frc r2.xy, r2.xyxx
add r2.zw, -r2.yyyx, l(0.000000, 0.000000, 1.000000, 1.000000)
dp2 r1.w, r2.xzxx, r2.xzxx
sqrt r1.w, r1.w
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
mul r1.y, r1.w, r1.y
mul r1.x, r1.y, r1.x
dp3 r0.y, r0.yzwy, l(0.000015, 0.003922, 1.000000, 0.000000)
mad r0.y, r0.y, r1.z, l(-1.000000)
add r0.y, |r0.y|, l(0.010000)
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
add r0.zw, -r2.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000)
dp2 r0.z, r0.zwzz, r0.zwzz
sqrt r0.z, r0.z
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mul r0.w, r0.z, r0.y
mad r0.y, r0.y, r0.z, r1.y
mad r0.x, r0.x, r0.w, r1.x
mad r0.zw, r2.xxxy, l(0.000000, 0.000000, -1.000000, 1.000000), l(0.000000, 0.000000, 1.000000, 0.000000)
dp2 r0.z, r2.wyww, r0.zwzz
dp2 r0.w, r2.xyxx, r2.xyxx
sqrt r0.zw, r0.zzzw
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mad r2.x, -cb2[4].z, l(0.500000), v1.x
mad r2.yzw, cb2[4].wwzw, l(0.000000, 0.500000, 0.500000, 0.500000), v1.yyxy
sample_l_indexable(texture2d)(float,float,float,float) r3.xyzw, r2.xyxx, t1.xyzw, s2, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.zwzz, t1.xyzw, s2, l(0.000000)
dp3 r1.x, r3.yzwy, l(0.000015, 0.003922, 1.000000, 0.000000)
mad r1.x, r1.x, r1.z, l(-1.000000)
add r1.x, |r1.x|, l(0.010000)
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
mul r1.y, r0.z, r1.x
mad r0.y, r1.x, r0.z, r0.y
mad r0.x, r3.x, r1.y, r0.x
dp3 r0.z, r2.yzwy, l(0.000015, 0.003922, 1.000000, 0.000000)
mad r0.z, r0.z, r1.z, l(-1.000000)
add r0.z, |r0.z|, l(0.010000)
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mul r1.x, r0.w, r0.z
mad r0.y, r0.z, r0.w, r0.y
mad r0.x, r2.x, r1.x, r0.x
div o0.xyzw, r0.xxxx, r0.yyyy
ret 
// Approximately 57 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
