- on older ATI drivers where the clip planes are broken, only disable the clip planes themselves, but not OpenGL 3.x so that dynamic lights still work as intended.

- only disable clip planes on Windows, but not on Linux or macOS.
- If a driver reports full OpenGL 4.5 support, assume that all features are working properly.
This commit is contained in:
Christoph Oelckers 2016-08-08 12:55:09 +02:00
parent 2ac91f0c5a
commit 9c9edbffdb
7 changed files with 27 additions and 11 deletions

View file

@ -344,12 +344,12 @@ void FRenderState::SetClipHeight(float height, float direction)
mClipHeightDirection = direction; mClipHeightDirection = direction;
#if 1 #if 1
// This still doesn't work... :( // This still doesn't work... :(
if (gl.glslversion < 1.3f) return; if (gl.flags & RFL_NO_CLIP_PLANES) return;
#endif #endif
if (direction != 0.f) if (direction != 0.f)
{ {
/* /*
if (gl.glslversion < 1.3f) if (gl.flags & RFL_NO_CLIP_PLANES)
{ {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();

View file

@ -237,7 +237,7 @@ public:
void EnableSplit(bool on) void EnableSplit(bool on)
{ {
if (gl.glslversion >= 1.3f) if (!(gl.flags & RFL_NO_CLIP_PLANES))
{ {
mSplitEnabled = on; mSplitEnabled = on;
if (on) if (on)
@ -260,7 +260,7 @@ public:
void EnableClipLine(bool on) void EnableClipLine(bool on)
{ {
if (gl.glslversion >= 1.3f) if (!(gl.flags & RFL_NO_CLIP_PLANES))
{ {
mClipLineEnabled = on; mClipLineEnabled = on;
if (on) if (on)

View file

@ -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 && if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright &&
RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) 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; lightlist = NULL;
if (!drawWithXYBillboard && !modelframe) if (!drawWithXYBillboard && !modelframe)

View file

@ -403,7 +403,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent)
(maplightbottomleft<zbottom[0] && maplightbottomright>zbottom[1]) || (maplightbottomleft<zbottom[0] && maplightbottomright>zbottom[1]) ||
(maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[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. // Use hardware clipping if this cannot be done cleanly.
this->lightlist = &lightlist; this->lightlist = &lightlist;

View file

@ -169,6 +169,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
FShaderProgram::PatchVertShader(vp_comb); FShaderProgram::PatchVertShader(vp_comb);
FShaderProgram::PatchFragShader(fp_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); hVertProg = glCreateShader(GL_VERTEX_SHADER);
hFragProg = glCreateShader(GL_FRAGMENT_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER);

View file

@ -192,6 +192,7 @@ void gl_LoadExtensions()
gl.version = 2.11f; gl.version = 2.11f;
gl.glslversion = 0; gl.glslversion = 0;
gl.lightmethod = LM_SOFTWARE; gl.lightmethod = LM_SOFTWARE;
gl.flags |= RFL_NO_CLIP_PLANES;
} }
else if (gl.version < 3.0f) 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_float")) gl.flags |= RFL_NO_RGBA16F;
if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL; if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL;
gl.flags |= RFL_NO_CLIP_PLANES;
} }
else if (gl.version < 4.f) else if (gl.version < 4.f)
{ {
#ifdef _WIN32
if (strstr(gl.vendorstring, "ATI Tech")) if (strstr(gl.vendorstring, "ATI Tech"))
{ {
gl.version = 2.11f; gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows.
gl.glslversion = 1.21f;
gl.lightmethod = LM_SOFTWARE; // do not use uniform buffers with the fallback shader, it may cause problems.
} }
#endif
} }
else else if (gl.version < 4.5f)
{ {
// don't use GL 4.x features when running in GL 3 emulation mode. // don't use GL 4.x features when running in GL 3 emulation mode.
if (CheckExtension("GL_ARB_buffer_storage")) if (CheckExtension("GL_ARB_buffer_storage"))
@ -234,6 +236,13 @@ void gl_LoadExtensions()
gl.version = 3.3f; 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"); const char *lm = Args->CheckValue("-lightmethod");
if (lm != NULL) if (lm != NULL)

View file

@ -22,7 +22,8 @@ enum RenderFlags
RFL_SAMPLER_OBJECTS = 16, RFL_SAMPLER_OBJECTS = 16,
RFL_NO_RGBA16F = 32, RFL_NO_RGBA16F = 32,
RFL_NO_DEPTHSTENCIL = 64 RFL_NO_DEPTHSTENCIL = 64,
RFL_NO_CLIP_PLANES = 128
}; };
enum TexMode enum TexMode