VideoCommon: Fix stereoscopic 3D on OpenGL < 4.3 (macOS)

This commit is contained in:
TellowKrinkle 2022-12-11 01:15:15 -06:00
parent ba3c38a63f
commit f25a0b43b6
7 changed files with 19 additions and 2 deletions

View File

@ -528,6 +528,10 @@ bool PopulateConfig(GLContext* m_main_gl_context)
glEnable(GL_PROGRAM_POINT_SIZE); glEnable(GL_PROGRAM_POINT_SIZE);
} }
// Supported by all GS-supporting ES and 4.3+
g_Config.backend_info.bSupportsGLLayerInFS = g_Config.backend_info.bSupportsGeometryShaders &&
g_ogl_config.eSupportedGLSLVersion >= Glsl430;
g_Config.backend_info.bSupportsBBox = g_Config.backend_info.bSupportsFragmentStoresAndAtomics; g_Config.backend_info.bSupportsBBox = g_Config.backend_info.bSupportsFragmentStoresAndAtomics;
// Either method can do early-z tests. See PixelShaderGen for details. // Either method can do early-z tests. See PixelShaderGen for details.

View File

@ -122,6 +122,8 @@ ShaderCode GenerateGeometryShaderCode(APIType api_type, const ShaderHostConfig&
ShaderStage::Geometry); ShaderStage::Geometry);
out.Write("}} ps;\n"); out.Write("}} ps;\n");
if (stereo && !host_config.backend_gl_layer_in_fs)
out.Write("flat out int layer;");
out.Write("void main()\n{{\n"); out.Write("void main()\n{{\n");
} }
@ -348,6 +350,8 @@ static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
{ {
out.Write("\tps.layer = eye;\n"); out.Write("\tps.layer = eye;\n");
} }
if (!host_config.backend_gl_layer_in_fs)
out.Write("\tlayer = eye;\n");
} }
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)

View File

@ -866,6 +866,8 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
GetInterpolationQualifier(msaa, ssaa, true, true), ShaderStage::Pixel); GetInterpolationQualifier(msaa, ssaa, true, true), ShaderStage::Pixel);
out.Write("}};\n"); out.Write("}};\n");
if (stereo && !host_config.backend_gl_layer_in_fs)
out.Write("flat in int layer;");
} }
else else
{ {
@ -923,6 +925,7 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
if (host_config.backend_geometry_shaders && stereo) if (host_config.backend_geometry_shaders && stereo)
{ {
if (host_config.backend_gl_layer_in_fs)
out.Write("\tint layer = gl_Layer;\n"); out.Write("\tint layer = gl_Layer;\n");
} }
else else

View File

@ -46,6 +46,7 @@ ShaderHostConfig ShaderHostConfig::GetCurrent()
bits.backend_sampler_lod_bias = g_ActiveConfig.backend_info.bSupportsLodBiasInSampler; bits.backend_sampler_lod_bias = g_ActiveConfig.backend_info.bSupportsLodBiasInSampler;
bits.backend_dynamic_vertex_loader = g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader; bits.backend_dynamic_vertex_loader = g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader;
bits.backend_vs_point_line_expand = g_ActiveConfig.UseVSForLinePointExpand(); bits.backend_vs_point_line_expand = g_ActiveConfig.UseVSForLinePointExpand();
bits.backend_gl_layer_in_fs = g_ActiveConfig.backend_info.bSupportsGLLayerInFS;
return bits; return bits;
} }

View File

@ -179,6 +179,7 @@ union ShaderHostConfig
BitField<26, 1, bool, u32> backend_sampler_lod_bias; BitField<26, 1, bool, u32> backend_sampler_lod_bias;
BitField<27, 1, bool, u32> backend_dynamic_vertex_loader; BitField<27, 1, bool, u32> backend_dynamic_vertex_loader;
BitField<28, 1, bool, u32> backend_vs_point_line_expand; BitField<28, 1, bool, u32> backend_vs_point_line_expand;
BitField<29, 1, bool, u32> backend_gl_layer_in_fs;
static ShaderHostConfig GetCurrent(); static ShaderHostConfig GetCurrent();
}; };

View File

@ -135,6 +135,8 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
GetInterpolationQualifier(msaa, ssaa, true, true), ShaderStage::Pixel); GetInterpolationQualifier(msaa, ssaa, true, true), ShaderStage::Pixel);
out.Write("}};\n\n"); out.Write("}};\n\n");
if (stereo && !host_config.backend_gl_layer_in_fs)
out.Write("flat in int layer;");
} }
else else
{ {
@ -532,6 +534,7 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
if (host_config.backend_geometry_shaders && stereo) if (host_config.backend_geometry_shaders && stereo)
{ {
if (host_config.backend_gl_layer_in_fs)
out.Write("\tint layer = gl_Layer;\n"); out.Write("\tint layer = gl_Layer;\n");
} }
else else

View File

@ -271,6 +271,7 @@ struct VideoConfig final
bool bSupportsPartialMultisampleResolve = false; bool bSupportsPartialMultisampleResolve = false;
bool bSupportsDynamicVertexLoader = false; bool bSupportsDynamicVertexLoader = false;
bool bSupportsVSLinePointExpand = false; bool bSupportsVSLinePointExpand = false;
bool bSupportsGLLayerInFS = true;
} backend_info; } backend_info;
// Utility // Utility