// PreFix
// ---- Created with 3Dmigoto v1.2.29 on Wed Apr 13 14:28:43 2016

cbuffer static_globals : register(b0)
{
  row_major float3x4 m_V : packoffset(c0);
  row_major float4x4 m_P : packoffset(c3);
  row_major float4x4 m_VP : packoffset(c7);
  float4 timers : packoffset(c11);
  float4 fog_plane : packoffset(c12);
  float4 fog_params : packoffset(c13);
  float4 fog_color : packoffset(c14);
  float4 L_ambient : packoffset(c15);
  float3 L_sun_color : packoffset(c16);
  float3 L_sun_dir_w : packoffset(c17);
  float4 L_hemi_color : packoffset(c18);
  float3 eye_position : packoffset(c19);
  float4 pos_decompression_params : packoffset(c20);
  float4 pos_decompression_params2 : packoffset(c21);
}

SamplerState smp_rtlinear_s : register(s0);
Texture2DMS<float4,4> s_position : register(t0);
Texture2D<float4> s_bloom : register(t1);
Texture2D<float4> s_image : register(t2);


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


void main( 
  float2 v0 : TEXCOORD0,
  float2 w0 : TEXCOORD1,
  float2 v1 : TEXCOORD2,
  float2 w1 : TEXCOORD3,
  float4 v2 : TEXCOORD4,
  float4 v3 : TEXCOORD5,
  float4 v4 : TEXCOORD6,
  float4 v5 : SV_Position0,
  out float4 o0 : SV_Target0,
  out float oDepth : SV_Depth)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = s_image.Sample(smp_rtlinear_s, v0.xy).xyz;
  r1.xyzw = s_bloom.Sample(smp_rtlinear_s, v0.xy).xyzw;
  o0.xyz = r1.xyz * r1.www + r0.xyz;
  o0.w = 1;
  r0.xy = (int2)v5.xy;
  r0.zw = float2(0,0);
  r0.z = s_position.Load(r0.xy, 0).z;
  r1.xy = v5.xy * pos_decompression_params.zw + -pos_decompression_params.xy;
  r0.xy = r1.xy * r0.zz;
float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);
r0.x -= stereo.x * (r0.z - stereo.y)/m_P._m00;
  r0.w = 1;
  r1.x = dot(m_P._m20_m21_m22_m23, r0.xyzw);
  r0.x = dot(m_P._m30_m31_m32_m33, r0.xyzw);
  r0.y = r1.x / r0.x;
  r0.x = cmp(r0.x == 0.000000);
  oDepth = r0.x ? 1 : r0.y;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//
// Buffer Definitions: 
//
// cbuffer static_globals
// {
//
//   row_major float3x4 m_V;            // Offset:    0 Size:    48 [unused]
//   row_major float4x4 m_P;            // Offset:   48 Size:    64
//   row_major float4x4 m_VP;           // Offset:  112 Size:    64 [unused]
//   float4 timers;                     // Offset:  176 Size:    16 [unused]
//   float4 fog_plane;                  // Offset:  192 Size:    16 [unused]
//   float4 fog_params;                 // Offset:  208 Size:    16 [unused]
//   float4 fog_color;                  // Offset:  224 Size:    16 [unused]
//   float4 L_ambient;                  // Offset:  240 Size:    16 [unused]
//   float3 L_sun_color;                // Offset:  256 Size:    12 [unused]
//   float3 L_sun_dir_w;                // Offset:  272 Size:    12 [unused]
//   float4 L_hemi_color;               // Offset:  288 Size:    16 [unused]
//   float3 eye_position;               // Offset:  304 Size:    12 [unused]
//   float4 pos_decompression_params;   // Offset:  320 Size:    16
//   float4 pos_decompression_params2;  // Offset:  336 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// smp_rtlinear                      sampler      NA          NA    0        1
// s_position                        texture  float4       2dMS4    0        1
// s_bloom                           texture  float4          2d    1        1
// s_image                           texture  float4          2d    2        1
// static_globals                    cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1     zw        0     NONE   float       
// TEXCOORD                 2   xy          1     NONE   float       
// TEXCOORD                 3     zw        1     NONE   float       
// TEXCOORD                 4   xy          2     NONE   float       
// TEXCOORD                 5   xyzw        3     NONE   float       
// TEXCOORD                 6   xyzw        4     NONE   float       
// SV_Position              0   xyzw        5      POS   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Depth                 0    N/A   oDepth    DEPTH   float    YES
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[21], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2dms(4) (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_input_ps linear v0.xy
dcl_input_ps_siv linear noperspective v5.xy, position
dcl_output o0.xyzw
dcl_output oDepth
dcl_temps 2
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v0.xyxx, t2.xyzw, s0
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v0.xyxx, t1.xyzw, s0
mad o0.xyz, r1.xyzx, r1.wwww, r0.xyzx
mov o0.w, l(1.000000)
ftoi r0.xy, v5.xyxx
mov r0.zw, l(0,0,0,0)
ldms_indexable(texture2dms)(float,float,float,float) r0.z, r0.xyzw, t0.xyzw, l(0)
mad r1.xy, v5.xyxx, cb0[20].zwzz, -cb0[20].xyxx
mul r0.xy, r0.zzzz, r1.xyxx
mov r0.w, l(1.000000)
dp4 r1.x, cb0[5].xyzw, r0.xyzw
dp4 r0.x, cb0[6].xyzw, r0.xyzw
div r0.y, r1.x, r0.x
eq r0.x, r0.x, l(0.000000)
movc oDepth, r0.x, l(1.000000), r0.y
ret 
// Approximately 16 instruction slots used

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


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recompiled ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20789
//
//   using 3Dmigoto v1.2.29 on Wed Apr 13 14:28:43 2016
//
//
// Buffer Definitions: 
//
// cbuffer static_globals
// {
//
//   row_major float3x4 m_V;            // Offset:    0 Size:    48 [unused]
//   row_major float4x4 m_P;            // Offset:   48 Size:    64
//   row_major float4x4 m_VP;           // Offset:  112 Size:    64 [unused]
//   float4 timers;                     // Offset:  176 Size:    16 [unused]
//   float4 fog_plane;                  // Offset:  192 Size:    16 [unused]
//   float4 fog_params;                 // Offset:  208 Size:    16 [unused]
//   float4 fog_color;                  // Offset:  224 Size:    16 [unused]
//   float4 L_ambient;                  // Offset:  240 Size:    16 [unused]
//   float3 L_sun_color;                // Offset:  256 Size:    12 [unused]
//   float3 L_sun_dir_w;                // Offset:  272 Size:    12 [unused]
//   float4 L_hemi_color;               // Offset:  288 Size:    16 [unused]
//   float3 eye_position;               // Offset:  304 Size:    12 [unused]
//   float4 pos_decompression_params;   // Offset:  320 Size:    16
//   float4 pos_decompression_params2;  // Offset:  336 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// smp_rtlinear_s                    sampler      NA          NA    0        1
// s_position                        texture  float4       2dMS4    0        1
// s_bloom                           texture  float4          2d    1        1
// s_image                           texture  float4          2d    2        1
// static_globals                    cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1     zw        0     NONE   float       
// TEXCOORD                 2   xy          1     NONE   float       
// TEXCOORD                 3     zw        1     NONE   float       
// TEXCOORD                 4   xyzw        2     NONE   float       
// TEXCOORD                 5   xyzw        3     NONE   float       
// TEXCOORD                 6   xyzw        4     NONE   float       
// SV_Position              0   xyzw        5      POS   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Depth                 0    N/A   oDepth    DEPTH   float    YES
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[21], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2dms(4) (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_input_ps linear v0.xy
dcl_input_ps_siv linear noperspective v5.xy, position
dcl_output o0.xyzw
dcl_output oDepth
dcl_temps 2
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v0.xyxx, t2.xyzw, s0
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v0.xyxx, t1.xyzw, s0
mad o0.xyz, r1.xyzx, r1.wwww, r0.xyzx
mov o0.w, l(1.000000)
round_z r0.xy, v5.xyxx
ftoi r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms_indexable(texture2dms)(float,float,float,float) r0.z, r0.xyzw, t0.xyzw, l(0)
mad r1.xy, v5.xyxx, cb0[20].zwzz, -cb0[20].xyxx
mul r0.xy, r0.zzzz, r1.xyxx
mov r0.w, l(1.000000)
dp4 r1.x, cb0[5].xyzw, r0.xyzw
dp4 r0.x, cb0[6].xyzw, r0.xyzw
div r0.y, r1.x, r0.x
eq r0.x, r0.x, l(0.000000)
movc oDepth, r0.x, l(1.000000), r0.y
ret 
// Approximately 17 instruction slots used

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