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

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

cbuffer cbSampleOffset : register(b1)
{
  float4 g_avSampleOffsets[16] : packoffset(c0);
}

SamplerState SS_WhiteBorderPoint_s : register(s4);
Texture2D<float4> g_DepthTex : register(t0);


// 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,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = g_avSampleOffsets[0].xy + v1.xy;
  r0.x = g_DepthTex.SampleLevel(SS_WhiteBorderPoint_s, r0.xy, 0).x;
  r0.yz = g_avSampleOffsets[1].xy + v1.xy;
  r0.y = g_DepthTex.SampleLevel(SS_WhiteBorderPoint_s, r0.yz, 0).x;
  r0.z = min(r0.x, r0.y);
  r1.xy = g_avSampleOffsets[2].xy + v1.xy;
  r0.w = g_DepthTex.SampleLevel(SS_WhiteBorderPoint_s, r1.xy, 0).x;
  r1.xy = g_avSampleOffsets[3].xy + v1.xy;
  r1.x = g_DepthTex.SampleLevel(SS_WhiteBorderPoint_s, r1.xy, 0).x;
  r1.y = min(r1.x, r0.w);
  r0.y = r0.y + -r0.w;
  r0.x = -r1.x + r0.x;
  r0.z = min(r1.y, r0.z);
  r0.z = g_vDepthComputeParam.x + -r0.z;
  r0.z = -g_vDepthComputeParam.y / r0.z;
  r1.xyz = float3(65025,255,1) * r0.zzz;
  r1.xy = frac(r1.xy);
  r0.zw = -r1.xy * float2(0.00392156886,0.00392156886) + r1.yz;
  o0.yz = r0.zw;
  o1.w = r0.w;
  o0.x = r1.x;
  o1.z = r1.y;
  o0.w = 1;
  r0.z = r0.x * r0.x + 1.56249985e-010;
  r0.z = sqrt(r0.z);
  r1.x = r0.x / r0.z;
  r0.x = r0.y * r0.y + 1.56249985e-010;
  r0.x = sqrt(r0.x);
  r1.y = r0.y / r0.x;
  o1.xy = r1.xy * float2(2,2) + float2(0.5,0.5);
  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 cbSampleOffset
// {
//
//   float4 g_avSampleOffsets[16];      // Offset:    0 Size:   256
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_WhiteBorderPoint               sampler      NA          NA    4        1
// g_DepthTex                        texture  float4          2d    0        1
// cbSSAOParam                       cbuffer      NA          NA    0        1
// cbSampleOffset                    cbuffer      NA          NA    1        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
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 2
add r0.xy, v1.xyxx, cb1[0].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s4, l(0.000000)
add r0.yz, v1.xxyx, cb1[1].xxyx
sample_l_indexable(texture2d)(float,float,float,float) r0.y, r0.yzyy, t0.yxzw, s4, l(0.000000)
min r0.z, r0.y, r0.x
add r1.xy, v1.xyxx, cb1[2].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r1.xyxx, t0.yzwx, s4, l(0.000000)
add r1.xy, v1.xyxx, cb1[3].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t0.xyzw, s4, l(0.000000)
min r1.y, r0.w, r1.x
add r0.y, -r0.w, r0.y
add r0.x, r0.x, -r1.x
min r0.z, r0.z, r1.y
add r0.z, -r0.z, cb0[0].x
div r0.z, -cb0[0].y, r0.z
mul r1.xyz, r0.zzzz, l(65025.000000, 255.000000, 1.000000, 0.000000)
frc r1.xy, r1.xyxx
mad r0.zw, -r1.xxxy, l(0.000000, 0.000000, 0.003922, 0.003922), r1.yyyz
mov o0.yz, r0.zzwz
mov o1.w, r0.w
mov o0.x, r1.x
mov o1.z, r1.y
mov o0.w, l(1.000000)
mad r0.z, r0.x, r0.x, l(0.000000)
sqrt r0.z, r0.z
div r1.x, r0.x, r0.z
mad r0.x, r0.y, r0.y, l(0.000000)
sqrt r0.x, r0.x
div r1.y, r0.y, r0.x
mad o1.xy, r1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
ret 
// Approximately 31 instruction slots used

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