diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 865053b41..84badd07b 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -344,12 +344,12 @@ void FRenderState::SetClipHeight(float height, float direction) mClipHeightDirection = direction; #if 1 // This still doesn't work... :( - if (gl.glslversion < 1.3f) return; + if (gl.flags & RFL_NO_CLIP_PLANES) return; #endif if (direction != 0.f) { /* - if (gl.glslversion < 1.3f) + if (gl.flags & RFL_NO_CLIP_PLANES) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 2ad611ab2..12671c2a6 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -237,7 +237,7 @@ public: void EnableSplit(bool on) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { mSplitEnabled = on; if (on) @@ -260,7 +260,7 @@ public: void EnableClipLine(bool on) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { mClipLineEnabled = on; if (on) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 98e0fb8d5..76796adf9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -972,7 +972,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright && RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) { - if (gl.glslversion < 1.3) // on old hardware we are rather limited... + if (gl.flags & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited... { lightlist = NULL; if (!drawWithXYBillboard && !modelframe) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 6f1f02d86..d8cef9771 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -403,7 +403,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent) (maplightbottomleftzbottom[1]) || (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) { - if (gl.glslversion >= 1.3f) + if (!(gl.flags & RFL_NO_CLIP_PLANES)) { // Use hardware clipping if this cannot be done cleanly. this->lightlist = &lightlist; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index f2b4c7ebd..cce8c6563 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -169,6 +169,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShaderProgram::PatchVertShader(vp_comb); FShaderProgram::PatchFragShader(fp_comb); } + else if (gl.flags & RFL_NO_CLIP_PLANES) + { + // On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken. + // This will cause some glitches and regressions but is the only way to avoid total display garbage. + vp_comb.Substitute("gl_ClipDistance", "//"); + } hVertProg = glCreateShader(GL_VERTEX_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER); diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 6b1105ee4..6176a2be9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -192,6 +192,7 @@ void gl_LoadExtensions() gl.version = 2.11f; gl.glslversion = 0; gl.lightmethod = LM_SOFTWARE; + gl.flags |= RFL_NO_CLIP_PLANES; } else if (gl.version < 3.0f) { @@ -200,17 +201,18 @@ void gl_LoadExtensions() if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; + gl.flags |= RFL_NO_CLIP_PLANES; } else if (gl.version < 4.f) { +#ifdef _WIN32 if (strstr(gl.vendorstring, "ATI Tech")) { - gl.version = 2.11f; - gl.glslversion = 1.21f; - gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems. + gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. } +#endif } - else + else if (gl.version < 4.5f) { // don't use GL 4.x features when running in GL 3 emulation mode. if (CheckExtension("GL_ARB_buffer_storage")) @@ -234,6 +236,13 @@ void gl_LoadExtensions() gl.version = 3.3f; } } + else + { + // Assume that everything works without problems on GL 4.5 drivers where these things are core features. + gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } const char *lm = Args->CheckValue("-lightmethod"); if (lm != NULL) diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d43252ebc..fbe4e09c8 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -22,7 +22,8 @@ enum RenderFlags RFL_SAMPLER_OBJECTS = 16, RFL_NO_RGBA16F = 32, - RFL_NO_DEPTHSTENCIL = 64 + RFL_NO_DEPTHSTENCIL = 64, + RFL_NO_CLIP_PLANES = 128 }; enum TexMode