From f751f70b1e633b1663b6fef83a42c8f961b1273e Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 7 Apr 2016 21:57:54 +0200 Subject: [PATCH] gsdx ogl: GL_ARB_clip_control is now mandatory --- plugins/GSdx/GLLoader.cpp | 2 +- plugins/GSdx/GLLoader.h | 1 - plugins/GSdx/GSDeviceOGL.cpp | 9 +++------ plugins/GSdx/GSDeviceOGL.h | 2 +- plugins/GSdx/GSShaderOGL.cpp | 3 --- plugins/GSdx/GSTextureFXOGL.cpp | 2 +- plugins/GSdx/GSWnd.cpp | 2 +- plugins/GSdx/res/glsl/tfx_vgs.glsl | 18 +----------------- plugins/GSdx/res/glsl_source.h | 18 +----------------- 9 files changed, 9 insertions(+), 48 deletions(-) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index d8122e1aaf..0de2826f02 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -495,7 +495,7 @@ namespace GLLoader { status &= status_and_override(found_GL_ARB_buffer_storage,"GL_ARB_buffer_storage"); status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture"); // GL4.5 - status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control"); + status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control", true); status &= status_and_override(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access"); status &= status_and_override(found_GL_ARB_texture_barrier, "GL_ARB_texture_barrier", true); diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index 72c882dec3..fe3e9e5bd7 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -363,7 +363,6 @@ namespace GLLoader { extern bool found_GL_ARB_shader_image_load_store; extern bool found_GL_ARB_clear_texture; extern bool found_GL_ARB_buffer_storage; - extern bool found_GL_ARB_clip_control; extern bool found_GL_ARB_direct_state_access; extern bool found_GL_EXT_texture_filter_anisotropic; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 7af10383d9..bdc60a805b 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -376,10 +376,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // because of -1 we loose lot of precision for small GS value // This extension allow FS depth to range from -1 to 1. So // gl_position.z could range from [0, 1] - if (GLLoader::found_GL_ARB_clip_control) { - // Change depth convention - glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); - } + // Change depth convention + glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); // **************************************************************** // HW renderer shader @@ -687,10 +685,9 @@ void GSDeviceOGL::Barrier(GLbitfield b) } /* Note: must be here because tfx_glsl is static */ -GLuint GSDeviceOGL::CompileVS(VSSelector sel, int logz) +GLuint GSDeviceOGL::CompileVS(VSSelector sel) { std::string macro = format("#define VS_BPPZ %d\n", sel.bppz) - + format("#define VS_LOGZ %d\n", logz) + format("#define VS_WILDHACK %d\n", sel.wildhack) ; diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 2199bd1d22..2d1756e924 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -527,7 +527,7 @@ class GSDeviceOGL final : public GSDevice void CreateTextureFX(); - GLuint CompileVS(VSSelector sel, int logz); + GLuint CompileVS(VSSelector sel); GLuint CompileGS(GSSelector sel); GLuint CompilePS(PSSelector sel); GLuint CreateSampler(bool bilinear, bool tau, bool tav, bool aniso = false); diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp index c337dfab44..9fc6c31a7a 100644 --- a/plugins/GSdx/GSShaderOGL.cpp +++ b/plugins/GSdx/GSShaderOGL.cpp @@ -210,9 +210,6 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co } else { header += "#define DISABLE_GL42_image\n"; } - if (GLLoader::found_GL_ARB_clip_control) { - header += "#define ZERO_TO_ONE_DEPTH\n"; - } // Stupid GL implementation (can't use GL_ES) // AMD/nvidia define it to 0 diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 4c89ae9647..c6552953c4 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -54,7 +54,7 @@ void GSDeviceOGL::CreateTextureFX() for (uint32 key = 0; key < countof(m_vs); key++) { VSSelector sel(key); - m_vs[key] = CompileVS(sel, !GLLoader::found_GL_ARB_clip_control); + m_vs[key] = CompileVS(sel); } GL_POP(); diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index c501ea8c88..638f983626 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -168,7 +168,7 @@ void GSWndGL::PopulateGlFunction() GL_EXT_LOAD_OPT(glCreateSamplers); GL_EXT_LOAD_OPT(glCreateProgramPipelines); - GL_EXT_LOAD_OPT(glClipControl); + GL_EXT_LOAD(glClipControl); GL_EXT_LOAD(glTextureBarrier); if (glCreateFramebuffers == NULL) { diff --git a/plugins/GSdx/res/glsl/tfx_vgs.glsl b/plugins/GSdx/res/glsl/tfx_vgs.glsl index c89720d644..6c638a8217 100644 --- a/plugins/GSdx/res/glsl/tfx_vgs.glsl +++ b/plugins/GSdx/res/glsl/tfx_vgs.glsl @@ -60,11 +60,7 @@ out gl_PerVertex { #endif }; -#ifdef ZERO_TO_ONE_DEPTH const float exp_min32 = exp2(-32.0f); -#else -const float exp_min31 = exp2(-31.0f); -#endif void texture_coord() { @@ -99,19 +95,7 @@ void vs_main() p.xy = vec2(i_p) - vec2(0.05f, 0.05f); p.xy = p.xy * VertexScale - VertexOffset; p.w = 1.0f; -#ifdef ZERO_TO_ONE_DEPTH - if(VS_LOGZ == 1) { - p.z = max(0.0f, log2(float(z))) / 32.0f; - } else { - p.z = float(z) * exp_min32; - } -#else - if(VS_LOGZ == 1) { - p.z = max(0.0f, log2(float(z))) / 31.0f - 1.0f; - } else { - p.z = float(z) * exp_min31 - 1.0f; - } -#endif + p.z = float(z) * exp_min32; gl_Position = p; diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 2c86638ffb..c2dc7af8d6 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -685,11 +685,7 @@ static const char* tfx_vgs_glsl = "#endif\n" "};\n" "\n" - "#ifdef ZERO_TO_ONE_DEPTH\n" "const float exp_min32 = exp2(-32.0f);\n" - "#else\n" - "const float exp_min31 = exp2(-31.0f);\n" - "#endif\n" "\n" "void texture_coord()\n" "{\n" @@ -724,19 +720,7 @@ static const char* tfx_vgs_glsl = " p.xy = vec2(i_p) - vec2(0.05f, 0.05f);\n" " p.xy = p.xy * VertexScale - VertexOffset;\n" " p.w = 1.0f;\n" - "#ifdef ZERO_TO_ONE_DEPTH\n" - " if(VS_LOGZ == 1) {\n" - " p.z = max(0.0f, log2(float(z))) / 32.0f;\n" - " } else {\n" - " p.z = float(z) * exp_min32;\n" - " }\n" - "#else\n" - " if(VS_LOGZ == 1) {\n" - " p.z = max(0.0f, log2(float(z))) / 31.0f - 1.0f;\n" - " } else {\n" - " p.z = float(z) * exp_min31 - 1.0f;\n" - " }\n" - "#endif\n" + " p.z = float(z) * exp_min32;\n" "\n" " gl_Position = p;\n" "\n"