#version 460
 #extension GL_EXT_multiview : enable
// Vk3DVision SinglePass
///////////////////////////////////////////////////////////////////////////////

#define STEREO 1


#define VIEW gl_WorkGroupID.z / (gl_NumWorkGroups.z / 2)
#define NumWorkGroups uvec3(gl_NumWorkGroups.x, gl_NumWorkGroups.y, gl_NumWorkGroups.z/ 2)
#define WorkGroupID uvec3(gl_WorkGroupID.x, gl_WorkGroupID.y, (gl_WorkGroupID.z < (gl_WorkGroupID.z + 1) / 2 ? gl_WorkGroupID.z : gl_WorkGroupID.z - (gl_WorkGroupID.z + 1) / 2))
#define GlobalInvocationID uvec3(WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID)

// Stereo and Mono Texture Sampling
#if(STEREO == 1)
	#define SAMPLER_2D sampler2DArray
	#define USAMPLER_2D usampler2DArray
	#define ISAMPLER_2D isampler2DArray
	#define IMAGE_2D image2DArray
	#define UIMAGE_2D uimage2DArray
	#define TEXTURE_2D texture2DArray
	#define UTEXTURE_2D utexture2DArray
	#define SAMPLE_TEXTURE(Sampler, uv) texture(Sampler, vec3(uv, VIEW))
	#define SAMPLE_TEXTURE1(Sampler, uv, bias) texture(Sampler, vec3(uv, VIEW), bias)
	#define IMAGE_LOAD(Image2D, pos) imageLoad(Image2D, ivec3(pos, VIEW))
	#define IMAGE_STORE(Image2D, pos, result) imageStore(Image2D, ivec3(pos, VIEW), result)
	#define TEXEL_FETCH(Sampler, uv, lod) texelFetch(Sampler, ivec3(uv, VIEW), lod)
	#define TEXEL_FETCH_OFFSET(Sampler, uv, lod, offset) texelFetchOffset(Sampler, ivec3(uv, VIEW), lod, offset)
	#define TEXTURE_LOD(Sampler, uv, lod) textureLod(Sampler, vec3(uv, VIEW), lod)
	#define TEXTURE_LOD_OFFSET(Sampler, uv, lod, offset) textureLodOffset(Sampler, vec3(uv, VIEW), lod, offset)
	#define TEXTURE_GATHER(Sampler, uv, comp) textureGather(Sampler, vec3(uv, VIEW), comp)
	#define TEXTURE_GATHER1(Sampler, uv) textureGather(Sampler, vec3(uv, VIEW))
	#define TEXTURE_GATHER_OFFSET(Sampler, uv, offset, comp) textureGatherOffset(Sampler, vec3(uv, VIEW), offset, comp)
	#define TEXTURE_GATHER_OFFSETS(Sampler, uv, offset) textureGatherOffsets(Sampler, vec3(uv, VIEW), offset)
	#define TEXTURE_GATHER_OFFSETS1(Sampler, uv, offset, comp) textureGatherOffsets(Sampler, vec3(uv, VIEW), offset, comp)
	#define TEXTURE_SIZE(Sampler, lod) textureSize(Sampler, lod).xy
	#define TEXTURE_GRAD(Sampler, P, dPdx, dPdy) textureGrad(Sampler, vec3(P, VIEW), dPdx, dPdy)
#else
	#define SAMPLER_2D sampler2D
	#define USAMPLER_2D usampler2D
	#define ISAMPLER_2D isampler2D
	#define IMAGE_2D image2D
	#define UIMAGE_2D uimage2D
	#define TEXTURE_2D texture2D
	#define UTEXTURE_2D utexture2D
	#define SAMPLE_TEXTURE(Sampler, uv) texture(Sampler, uv)
	#define SAMPLE_TEXTURE1(Sampler, uv, bias) texture(Sampler, uv, bias)
	#define IMAGE_LOAD(Image2D, pos) imageLoad(Image2D, pos)
	#define IMAGE_STORE(Image2D, pos, result) imageStore(Image2D, pos, result)
	#define TEXEL_FETCH(Sampler, uv, lod) texelFetch(Sampler, uv, lod)
	#define TEXEL_FETCH_OFFSET(Sampler, uv, lod, offset) texelFetchOffset(Sampler, uv, lod, offset)
	#define TEXTURE_LOD(Sampler, uv, lod) textureLod(Sampler, uv, lod)
	#define TEXTURE_LOD_OFFSET(Sampler, uv, lod, offset) textureLodOffset(Sampler, uv, lod, offset)
	#define TEXTURE_GATHER(Sampler, uv, comp) textureGather(Sampler, uv, comp)
	#define TEXTURE_GATHER1(Sampler, uv, comp) textureGather(Sampler, uv, comp)
	#define TEXTURE_GATHER_OFFSET(Sampler, uv, offset, comp) textureGatherOffset(Sampler, uv, offset, comp)
	#define TEXTURE_GATHER_OFFSETS(Sampler, uv, offset) textureGatherOffsets(Sampler, uv, offset)
	#define TEXTURE_GATHER_OFFSETS1(Sampler, uv, offset, comp) textureGatherOffsets(Sampler, uv, offset, comp)
	#define TEXTURE_SIZE(Sampler, lod) textureSize(Sampler, lod)
	#define TEXTURE_GRAD(Sampler, P, dPdx, dPdy) textureGrad(Sampler, P, dPdx, dPdy)
#endif 
 ///////////////////////////////////////////////////////////////////////////////
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(set = 1, binding = 0, std140) uniform _49_51
{
    vec4 _m0;
} _51;

layout(set = 0, binding = 1, std140) uniform _179_181
{
    vec4 _m0[64];
} _181;

layout(set = 0, binding = 0, std140) uniform _184_186
{
    vec4 _m0;
    vec4 _m1;
    vec4 _m2;
    float _m3;
    float _m4;
    float _m5;
    float _m6;
    float _m7;
    float _m8;
    float _m9;
    float _m10;
    float _m11;
    float _m12;
    float _m13;
    float _m14;
    float _m15;
    float _m16;
    float _m17;
    float _m18;
    float _m19;
    float _m20;
    uint _m21;
    float _m22;
    float _m23;
    float _m24;
    float _m25[2];
} _186;

layout(set = 0, binding = 2) uniform UTEXTURE_2D _91;
layout(set = 0, binding = 3) uniform sampler _95;
layout(set = 1, binding = 1, r8) uniform writeonly IMAGE_2D _168;

uint _8;
uint _10;
uint _12;
uint _14;
uint _16;
uint _18;
uint _20;
uint _21;
uint _23;
uint _24;
uint _26;
uint _28;
uint _30;
uint _32;
uint _34;
uint _36;
uint _38;
uint _40;
uint _42;

void main()
{
    _8 = 2147483648u;
    _10 = 1073741824u;
    _12 = 0u;
    _14 = 268435456u;
    _16 = 536870912u;
    _18 = 805306368u;
    _20 = 1073741824u;
    _21 = 1342177280u;
    _23 = 0u;
    _24 = 16777216u;
    _26 = 33554432u;
    _28 = 50331648u;
    _30 = 67108864u;
    _32 = 83886080u;
    _34 = 100663296u;
    _36 = 117440512u;
    _38 = 134217728u;
    _40 = 150994944u;
    _42 = 167772160u;
    vec2 _47 = _51._m0.xy;
    ivec2 _60 = ivec2(GlobalInvocationID.xy);
    ivec2 _68 = ivec2((vec2(_60) + vec2(0.5)) * _47);
    ivec2 _77 = ivec2(_68.x << 1, _68.y);
    uint _88 = TEXEL_FETCH(USAMPLER_2D(_91, _95), _77, 0).x;
    ivec2 _104 = ivec2((_68.x << 1) + 1, _68.y);
    uint _112 = TEXEL_FETCH(USAMPLER_2D(_91, _95), _104, 0).x;
    uint _120 = _88 & 112u;
    uint _124 = uint((_120 >= 16u) && (_120 <= 80u));
    _120 |= (_124 * 112u);
    _120 |= (_88 & 128u);
    uint _143 = _112 & 112u;
    _124 = uint((_143 >= 16u) && (_143 <= 80u));
    _143 |= (_124 * 112u);
    _143 |= (_112 & 128u);
    uint _160 = _143 | (_120 >> uint(4));
    IMAGE_STORE(_168, _60, vec4(float(_160) / 255.0, 0.0, 0.0, 0.0));
}

