Skip to content

Commit

Permalink
gsdx ogl: GL_ARB_clip_control is now mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory38 committed Apr 7, 2016
1 parent dfb4b5a commit f751f70
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 48 deletions.
2 changes: 1 addition & 1 deletion plugins/GSdx/GLLoader.cpp
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion plugins/GSdx/GLLoader.h
Expand Up @@ -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;
}
9 changes: 3 additions & 6 deletions plugins/GSdx/GSDeviceOGL.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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)
;

Expand Down
2 changes: 1 addition & 1 deletion plugins/GSdx/GSDeviceOGL.h
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions plugins/GSdx/GSShaderOGL.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/GSdx/GSTextureFXOGL.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion plugins/GSdx/GSWnd.cpp
Expand Up @@ -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) {
Expand Down
18 changes: 1 addition & 17 deletions plugins/GSdx/res/glsl/tfx_vgs.glsl
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;

Expand Down
18 changes: 1 addition & 17 deletions plugins/GSdx/res/glsl_source.h
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit f751f70

Please sign in to comment.