gsdx-ogl: GL_ARB_shading_language_420pack is now mandatory

All API/drivers support it so time to remove the fallback.
This commit is contained in:
Gregory Hainaut 2014-10-01 09:50:59 +02:00
parent aaf3fe8b19
commit d37cc8e1e7
12 changed files with 12 additions and 192 deletions

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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()
{

View File

@ -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"

View File

@ -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()

View File

@ -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()
{

View File

@ -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
{

View File

@ -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)

View File

@ -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;