From d37cc8e1e7a135a61e6a957479be7de2bd5c6d82 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 1 Oct 2014 09:50:59 +0200 Subject: [PATCH] gsdx-ogl: GL_ARB_shading_language_420pack is now mandatory All API/drivers support it so time to remove the fallback. --- plugins/GSdx/GLLoader.cpp | 21 ++++------ plugins/GSdx/GLLoader.h | 7 ---- plugins/GSdx/GSShaderOGL.cpp | 70 ++------------------------------ plugins/GSdx/GSShaderOGL.h | 4 -- plugins/GSdx/GSWnd.cpp | 4 -- plugins/GSdx/res/convert.glsl | 4 -- plugins/GSdx/res/glsl_source.h | 49 ---------------------- plugins/GSdx/res/interlace.glsl | 8 ---- plugins/GSdx/res/merge.glsl | 8 ---- plugins/GSdx/res/old_fxaa.fx | 8 ---- plugins/GSdx/res/shadeboost.glsl | 8 ---- plugins/GSdx/res/tfx.glsl | 13 ------ 12 files changed, 12 insertions(+), 192 deletions(-) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index 3c7729c3b2..bb745bab26 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -98,10 +98,6 @@ PFNGLGETPROGRAMPIPELINEINFOLOGPROC gl_GetProgramPipelineInfoLog = NU PFNGLUSEPROGRAMPROC gl_UseProgram = NULL; PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL; PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i = NULL; -// NO GL4.2 -PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex = NULL; -PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding = NULL; -PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation = NULL; // GL4.3 PFNGLCOPYIMAGESUBDATAPROC gl_CopyImageSubData = NULL; // GL4.2 @@ -159,7 +155,7 @@ namespace GLLoader { bool in_replayer = false; // Optional - bool found_GL_ARB_separate_shader_objects = false; + bool found_GL_ARB_separate_shader_objects = false; // Issue with Mesa and Catalyst... bool found_geometry_shader = true; // we require GL3.3 so geometry must be supported by default bool found_GL_ARB_clear_texture = false; // Don't know if GL3 GPU can support it bool found_GL_ARB_buffer_storage = false; @@ -175,21 +171,22 @@ namespace GLLoader { bool found_GL_ARB_clip_control = false; bool found_GL_ARB_direct_state_access = false; - - // Mandatory for FULL GL (but optional for GLES) - bool found_GL_ARB_shading_language_420pack = false; // GLES 3.1 ??? - // Mandatory for opengl ES (allow to use GL code) bool found_GL_EXT_shader_io_blocks = false; // Mandatory bool found_GL_ARB_texture_storage = false; + bool found_GL_ARB_shading_language_420pack = false; static bool status_and_override(bool& found, const std::string& name, bool mandatory = false) { if (!found) { - fprintf(stderr, "INFO: %s is NOT SUPPORTED\n", name.c_str()); - if(mandatory) return false; + if(mandatory) { + fprintf(stderr, "ERROR: %s is NOT SUPPORTED\n", name.c_str()); + return false; + } else { + fprintf(stderr, "INFO: %s is NOT SUPPORTED\n", name.c_str()); + } } else { fprintf(stderr, "INFO: %s is available\n", name.c_str()); } @@ -320,7 +317,7 @@ namespace GLLoader { status &= status_and_override(found_GL_ARB_shader_subroutine,"GL_ARB_shader_subroutine"); // GL4.2 status &= status_and_override(found_GL_ARB_shader_image_load_store,"GL_ARB_shader_image_load_store"); - status &= status_and_override(found_GL_ARB_shading_language_420pack,"GL_ARB_shading_language_420pack"); // Mostly mandatory. Some Nvidia driver failed to report it correctly + status &= status_and_override(found_GL_ARB_shading_language_420pack,"GL_ARB_shading_language_420pack", true); status &= status_and_override(found_GL_ARB_texture_storage, "GL_ARB_texture_storage", true); // GL4.3 status &= status_and_override(found_GL_ARB_explicit_uniform_location,"GL_ARB_explicit_uniform_location"); diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index d5916e70bb..d0e555f1d2 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -282,10 +282,6 @@ extern PFNGLGETPROGRAMPIPELINEINFOLOGPROC gl_GetProgramPipelineInfoLog; extern PFNGLUSEPROGRAMPROC gl_UseProgram; extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog; extern PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i; -// NO GL4.2 -extern PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex; -extern PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding; -extern PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation; // GL4.2 extern PFNGLBINDIMAGETEXTUREPROC gl_BindImageTexture; extern PFNGLMEMORYBARRIERPROC gl_MemoryBarrier; @@ -403,9 +399,6 @@ extern PFNGLCLIPCONTROLPROC gl_ClipControl; #define gl_GetShaderInfoLog glGetShaderInfoLog #define gl_ProgramUniform1i glProgramUniform1i -#define gl_GetUniformBlockIndex glGetUniformBlockIndex -#define gl_UniformBlockBinding glUniformBlockBinding -#define gl_GetUniformLocation glGetUniformLocation #endif diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp index 30a8731303..2a7b171bc8 100644 --- a/plugins/GSdx/GSShaderOGL.cpp +++ b/plugins/GSdx/GSShaderOGL.cpp @@ -129,29 +129,6 @@ void GSShaderOGL::GS(GLuint s) } } -void GSShaderOGL::SetUniformBinding(GLuint prog, const GLchar* name, GLuint binding) -{ - GLuint index; - index = gl_GetUniformBlockIndex(prog, name); - if (index != GL_INVALID_INDEX) { - gl_UniformBlockBinding(prog, index, binding); - } -} - -void GSShaderOGL::SetSamplerBinding(GLuint prog, const GLchar* name, GLuint binding) -{ - GLint loc = gl_GetUniformLocation(prog, name); - if (loc != -1) { - if (GLLoader::found_GL_ARB_separate_shader_objects) { -#ifndef ENABLE_GLES - gl_ProgramUniform1i(prog, loc, binding); -#endif - } else { - gl_Uniform1i(loc, binding); - } - } -} - void GSShaderOGL::SetupRessources() { #ifndef ENABLE_GLES @@ -172,37 +149,6 @@ void GSShaderOGL::SetupRessources() #endif } -void GSShaderOGL::SetupUniform() -{ - if (GLLoader::found_GL_ARB_shading_language_420pack) return; - - if (GLLoader::found_GL_ARB_separate_shader_objects) { - SetUniformBinding(GLState::vs, "cb20", 20); - SetUniformBinding(GLState::ps, "cb21", 21); - - SetUniformBinding(GLState::ps, "cb10", 10); - SetUniformBinding(GLState::ps, "cb11", 11); - SetUniformBinding(GLState::ps, "cb12", 12); - SetUniformBinding(GLState::ps, "cb13", 13); - - SetSamplerBinding(GLState::ps, "TextureSampler", 0); - SetSamplerBinding(GLState::ps, "PaletteSampler", 1); - //SetSamplerBinding(GLState::ps, "RTCopySampler", 2); - } else { - SetUniformBinding(GLState::program, "cb20", 20); - SetUniformBinding(GLState::program, "cb21", 21); - - SetUniformBinding(GLState::program, "cb10", 10); - SetUniformBinding(GLState::program, "cb11", 11); - SetUniformBinding(GLState::program, "cb12", 12); - SetUniformBinding(GLState::program, "cb13", 13); - - SetSamplerBinding(GLState::program, "TextureSampler", 0); - SetSamplerBinding(GLState::program, "PaletteSampler", 1); - //SetSamplerBinding(GLState::program, "RTCopySampler", 2); - } -} - void GSShaderOGL::SetupSubroutineUniform() { #ifndef ENABLE_GLES @@ -326,9 +272,6 @@ void GSShaderOGL::UseProgram() ValidateProgram(GLState::program); gl_UseProgram(GLState::program); - - // warning it must be done after the "setup" of the program - SetupUniform(); } else { GLuint prog = it->second; if (prog != GLState::program) { @@ -339,8 +282,6 @@ void GSShaderOGL::UseProgram() } else { ValidatePipeline(m_pipeline); - - SetupUniform(); } } @@ -356,12 +297,8 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co std::string header; #ifndef ENABLE_GLES header = "#version 330 core\n"; - if (GLLoader::found_GL_ARB_shading_language_420pack) { - // Need GL version 420 - header += "#extension GL_ARB_shading_language_420pack: require\n"; - } else { - header += "#define DISABLE_GL42\n"; - } + // Need GL version 420 + header += "#extension GL_ARB_shading_language_420pack: require\n"; if (GLLoader::found_GL_ARB_separate_shader_objects) { // Need GL version 410 header += "#extension GL_ARB_separate_shader_objects: require\n"; @@ -395,8 +332,7 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co #else // ENABLE_GLES header = "#version 310 es\n"; header += "#extension GL_EXT_shader_io_blocks: require\n"; - // Disable full GL features - header += "#define DISABLE_GL42\n"; + // Disable full GL features (actually GLES3.1 could support it) header += "#define DISABLE_GL42_image\n"; #endif diff --git a/plugins/GSdx/GSShaderOGL.h b/plugins/GSdx/GSShaderOGL.h index b98a362af5..364858ad3b 100644 --- a/plugins/GSdx/GSShaderOGL.h +++ b/plugins/GSdx/GSShaderOGL.h @@ -32,12 +32,8 @@ class GSShaderOGL { GLuint m_ps_sub[5]; void SetupSubroutineUniform(); - void SetupUniform(); void SetupRessources(); - void SetUniformBinding(GLuint prog, const GLchar* name, GLuint binding); - void SetSamplerBinding(GLuint prog, const GLchar* name, GLuint binding); - bool ValidateShader(GLuint p); bool ValidateProgram(GLuint p); bool ValidatePipeline(GLuint p); diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 90da398811..7eef4a7b2e 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -101,10 +101,6 @@ void GSWndGL::PopulateGlFunction() *(void**)&(gl_UseProgram) = GetProcAddress("glUseProgram"); *(void**)&(gl_GetShaderInfoLog) = GetProcAddress("glGetShaderInfoLog"); *(void**)&(gl_LinkProgram) = GetProcAddress("glLinkProgram"); - // NO GL4.2 - *(void**)&(gl_GetUniformBlockIndex) = GetProcAddress("glGetUniformBlockIndex"); - *(void**)&(gl_UniformBlockBinding) = GetProcAddress("glUniformBlockBinding"); - *(void**)&(gl_GetUniformLocation) = GetProcAddress("glGetUniformLocation"); // GL4.2 *(void**)&(gl_BindImageTexture) = GetProcAddress("glBindImageTexture", true); *(void**)&(gl_MemoryBarrier) = GetProcAddress("glMemoryBarrier", true); diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index f280b26cbc..d96068db5e 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -67,12 +67,8 @@ layout(location = 0) out vec4 SV_Target0; #ifdef ENABLE_BINDLESS_TEX layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; #endif -#endif vec4 sample_c() { diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index e4b237d2ff..b0ec8c10ea 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -92,12 +92,8 @@ static const char* convert_glsl = "#ifdef ENABLE_BINDLESS_TEX\n" "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" - "#endif\n" "\n" "vec4 sample_c()\n" "{\n" @@ -275,11 +271,7 @@ static const char* interlace_glsl = "\n" "layout(location = 0) out vec4 SV_Target0;\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb11\n" - "#else\n" "layout(std140, binding = 11) uniform cb11\n" - "#endif\n" "{\n" " vec2 ZrH;\n" " float hH;\n" @@ -288,12 +280,8 @@ static const char* interlace_glsl = "#ifdef ENABLE_BINDLESS_TEX\n" "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" - "#endif\n" "\n" "// TODO ensure that clip (discard) is < 0 and not <= 0 ???\n" "void ps_main0()\n" @@ -357,11 +345,7 @@ static const char* merge_glsl = "\n" "layout(location = 0) out vec4 SV_Target0;\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb10\n" - "#else\n" "layout(std140, binding = 10) uniform cb10\n" - "#endif\n" "{\n" " vec4 BGColor;\n" "};\n" @@ -369,12 +353,8 @@ static const char* merge_glsl = "#ifdef ENABLE_BINDLESS_TEX\n" "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" - "#endif\n" "\n" "void ps_main0()\n" "{\n" @@ -421,11 +401,7 @@ static const char* shadeboost_glsl = "\n" "layout(location = 0) out vec4 SV_Target0;\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb12\n" - "#else\n" "layout(std140, binding = 12) uniform cb12\n" - "#endif\n" "{\n" " vec4 BGColor;\n" "};\n" @@ -433,12 +409,8 @@ static const char* shadeboost_glsl = "#ifdef ENABLE_BINDLESS_TEX\n" "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" - "#endif\n" "\n" "// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% \n" "vec4 ContrastSaturationBrightness(vec4 color)\n" @@ -554,11 +526,7 @@ static const char* tfx_glsl = "#endif\n" "};\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb20\n" - "#else\n" "layout(std140, binding = 20) uniform cb20\n" - "#endif\n" "{\n" " vec2 VertexScale;\n" " vec2 VertexOffset;\n" @@ -794,14 +762,9 @@ static const char* tfx_glsl = "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "layout(bindless_sampler, location = 1) uniform sampler2D PaletteSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "uniform sampler2D PaletteSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "layout(binding = 1) uniform sampler2D PaletteSampler;\n" "#endif\n" - "#endif\n" "\n" "#ifndef DISABLE_GL42_image\n" "#if PS_DATE > 0\n" @@ -820,11 +783,7 @@ static const char* tfx_glsl = "#endif\n" "#endif\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb21\n" - "#else\n" "layout(std140, binding = 21) uniform cb21\n" - "#endif\n" "{\n" " vec3 FogColor;\n" " float AREF;\n" @@ -1638,11 +1597,7 @@ static const char* old_fxaa_fx = " vec2 t;\n" "};\n" "\n" - "#ifdef DISABLE_GL42\n" - "layout(std140) uniform cb13\n" - "#else\n" "layout(std140, binding = 13) uniform cb13\n" - "#endif\n" "{\n" " vec4 _rcpFrame;\n" " vec4 _rcpFrameOpt;\n" @@ -1651,12 +1606,8 @@ static const char* old_fxaa_fx = "#ifdef ENABLE_BINDLESS_TEX\n" "layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n" "#else\n" - "#ifdef DISABLE_GL42\n" - "uniform sampler2D TextureSampler;\n" - "#else\n" "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" - "#endif\n" "\n" "in SHADER\n" "{\n" diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 2a5e08a0dd..3e089c4b15 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -19,11 +19,7 @@ in SHADER layout(location = 0) out vec4 SV_Target0; -#ifdef DISABLE_GL42 -layout(std140) uniform cb11 -#else layout(std140, binding = 11) uniform cb11 -#endif { vec2 ZrH; float hH; @@ -32,12 +28,8 @@ layout(std140, binding = 11) uniform cb11 #ifdef ENABLE_BINDLESS_TEX layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; #endif -#endif // TODO ensure that clip (discard) is < 0 and not <= 0 ??? void ps_main0() diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index 0bce2489ee..c36030dbe2 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -19,11 +19,7 @@ in SHADER layout(location = 0) out vec4 SV_Target0; -#ifdef DISABLE_GL42 -layout(std140) uniform cb10 -#else layout(std140, binding = 10) uniform cb10 -#endif { vec4 BGColor; }; @@ -31,12 +27,8 @@ layout(std140, binding = 10) uniform cb10 #ifdef ENABLE_BINDLESS_TEX layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; #endif -#endif void ps_main0() { diff --git a/plugins/GSdx/res/old_fxaa.fx b/plugins/GSdx/res/old_fxaa.fx index b9e88cce4e..48c4ad96c9 100644 --- a/plugins/GSdx/res/old_fxaa.fx +++ b/plugins/GSdx/res/old_fxaa.fx @@ -71,11 +71,7 @@ struct vertex_basic vec2 t; }; -#ifdef DISABLE_GL42 -layout(std140) uniform cb13 -#else layout(std140, binding = 13) uniform cb13 -#endif { vec4 _rcpFrame; vec4 _rcpFrameOpt; @@ -84,12 +80,8 @@ layout(std140, binding = 13) uniform cb13 #ifdef ENABLE_BINDLESS_TEX layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; #endif -#endif in SHADER { diff --git a/plugins/GSdx/res/shadeboost.glsl b/plugins/GSdx/res/shadeboost.glsl index 17c58d58ee..8e61e7912f 100644 --- a/plugins/GSdx/res/shadeboost.glsl +++ b/plugins/GSdx/res/shadeboost.glsl @@ -25,11 +25,7 @@ in SHADER layout(location = 0) out vec4 SV_Target0; -#ifdef DISABLE_GL42 -layout(std140) uniform cb12 -#else layout(std140, binding = 12) uniform cb12 -#endif { vec4 BGColor; }; @@ -37,12 +33,8 @@ layout(std140, binding = 12) uniform cb12 #ifdef ENABLE_BINDLESS_TEX layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; #endif -#endif // For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% vec4 ContrastSaturationBrightness(vec4 color) diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index c28e185582..f0072c4cde 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -75,11 +75,7 @@ out gl_PerVertex { #endif }; -#ifdef DISABLE_GL42 -layout(std140) uniform cb20 -#else layout(std140, binding = 20) uniform cb20 -#endif { vec2 VertexScale; vec2 VertexOffset; @@ -315,14 +311,9 @@ layout(location = 0, index = 1) out vec4 SV_Target1; layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler; layout(bindless_sampler, location = 1) uniform sampler2D PaletteSampler; #else -#ifdef DISABLE_GL42 -uniform sampler2D TextureSampler; -uniform sampler2D PaletteSampler; -#else layout(binding = 0) uniform sampler2D TextureSampler; layout(binding = 1) uniform sampler2D PaletteSampler; #endif -#endif #ifndef DISABLE_GL42_image #if PS_DATE > 0 @@ -341,11 +332,7 @@ layout(pixel_center_integer) in vec4 gl_FragCoord; #endif #endif -#ifdef DISABLE_GL42 -layout(std140) uniform cb21 -#else layout(std140, binding = 21) uniform cb21 -#endif { vec3 FogColor; float AREF;