Navigation Menu

Skip to content

Commit

Permalink
- removed the no-clip-plane handling for OpenGL 3 ATI cards.
Browse files Browse the repository at this point in the history
Right now these cards make up 0.9% of the user base, but the hacks needed to support these cards prevent a complete separation of geometry generation and rendering which is necessary to eliminate the QuadDrawer hack or run the sprite sorter in a background thread.

A card with a broken driver will just show a glitched display now, any user still stuck with such a card will have to use the vintage build for the next release based on this branch.
  • Loading branch information
coelckers committed Aug 15, 2018
1 parent e63346c commit 13e96cc
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 260 deletions.
15 changes: 6 additions & 9 deletions src/gl/data/gl_viewpointbuffer.cpp
Expand Up @@ -118,16 +118,13 @@ int GLViewpointBuffer::Bind(unsigned int index)

// Update the viewpoint-related clip plane setting.
auto *vp = (HWViewpointUniforms*)(((char*)mBufferPointer) + mUploadIndex * mBlockAlign);
if (!(gl.flags & RFL_NO_CLIP_PLANES))
if (index > 0 && (vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f))
{
if (index > 0 && (vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f))
{
glEnable(GL_CLIP_DISTANCE0);
}
else
{
glDisable(GL_CLIP_DISTANCE0);
}
glEnable(GL_CLIP_DISTANCE0);
}
else
{
glDisable(GL_CLIP_DISTANCE0);
}
}
return index;
Expand Down
21 changes: 9 additions & 12 deletions src/gl/renderer/gl_renderstate.h
Expand Up @@ -252,19 +252,16 @@ class FRenderState

void EnableSplit(bool on)
{
if (!(gl.flags & RFL_NO_CLIP_PLANES))
mSplitEnabled = on;
if (on)
{
mSplitEnabled = on;
if (on)
{
glEnable(GL_CLIP_DISTANCE3);
glEnable(GL_CLIP_DISTANCE4);
}
else
{
glDisable(GL_CLIP_DISTANCE3);
glDisable(GL_CLIP_DISTANCE4);
}
glEnable(GL_CLIP_DISTANCE3);
glEnable(GL_CLIP_DISTANCE4);
}
else
{
glDisable(GL_CLIP_DISTANCE3);
glDisable(GL_CLIP_DISTANCE4);
}
}

Expand Down
14 changes: 4 additions & 10 deletions src/gl/scene/gl_drawinfo.cpp
Expand Up @@ -135,17 +135,11 @@ void FDrawInfo::DrawSorted(int listindex)
GLRenderer->mVBO->Unmap();
}
gl_RenderState.ClearClipSplit();
if (!(gl.flags & RFL_NO_CLIP_PLANES))
{
glEnable(GL_CLIP_DISTANCE1);
glEnable(GL_CLIP_DISTANCE2);
}
glEnable(GL_CLIP_DISTANCE1);
glEnable(GL_CLIP_DISTANCE2);
DoDrawSorted(dl, dl->sorted);
if (!(gl.flags & RFL_NO_CLIP_PLANES))
{
glDisable(GL_CLIP_DISTANCE1);
glDisable(GL_CLIP_DISTANCE2);
}
glDisable(GL_CLIP_DISTANCE1);
glDisable(GL_CLIP_DISTANCE2);
gl_RenderState.ClearClipSplit();
}

Expand Down
1 change: 0 additions & 1 deletion src/gl/scene/gl_drawinfo.h
Expand Up @@ -74,7 +74,6 @@ struct FDrawInfo : public HWDrawInfo

// Flat drawer
void DrawFlat(GLFlat *flat, int pass, bool trans) override; // trans only has meaning for GLPASS_LIGHTSONLY
void DrawSkyboxSector(GLFlat *flat, int pass);
void DrawSubsectors(GLFlat *flat, int pass, bool istrans);

// Sprite drawer
Expand Down
2 changes: 1 addition & 1 deletion src/gl/scene/gl_flats.cpp
Expand Up @@ -66,7 +66,7 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool istrans)

gl_RenderState.ApplyLightIndex(flat->dynlightindex);

if (vcount > 0 && !ClipLineShouldBeActive())
if (vcount > 0)
{
drawcalls.Clock();
glDrawElements(GL_TRIANGLES, vcount, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + iboindex);
Expand Down
3 changes: 2 additions & 1 deletion src/gl/scene/gl_sprite.cpp
Expand Up @@ -252,7 +252,8 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
FVector3 v[4];
gl_RenderState.SetNormal(0, 0, 0);

if (sprite->CalculateVertices(this, v, &vp.Pos))
sprite->polyoffset = sprite->CalculateVertices(this, v, &vp.Pos);
if (sprite->polyoffset)
{
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
Expand Down
7 changes: 0 additions & 7 deletions src/gl/shaders/gl_shader.cpp
Expand Up @@ -263,13 +263,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
fp_comb << pp_data.GetString().GetChars() << "\n";
}

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

Expand Down
6 changes: 0 additions & 6 deletions src/gl_load/gl_interface.cpp
Expand Up @@ -172,12 +172,6 @@ void gl_LoadExtensions()
gl.buffermethod = BM_DEFERRED;
if (gl_version < 4.f)
{
#ifdef _WIN32
if (strstr(gl.vendorstring, "ATI Tech"))
{
gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. (TBD: Relegate to vintage build? Maybe after the next survey.)
}
#endif
gl.glslversion = 3.31f; // Force GLSL down to 3.3.
}
else if (gl_version < 4.5f)
Expand Down
5 changes: 0 additions & 5 deletions src/hwrenderer/scene/hw_drawinfo.h
Expand Up @@ -220,11 +220,6 @@ struct HWDrawInfo
VPUniforms.mClipHeight = 0;
}

bool ClipLineShouldBeActive()
{
return (screen->hwcaps & RFL_NO_CLIP_PLANES) && VPUniforms.mClipLine.X > -1000000.f;
}

IPortal * FindPortal(const void * src);
void RenderBSPNode(void *node);

Expand Down
39 changes: 0 additions & 39 deletions src/hwrenderer/scene/hw_drawlist.cpp
Expand Up @@ -278,27 +278,6 @@ void HWDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort)
GLWall *w = NewWall();
*w = *ws;

// Splitting is done in the shader with clip planes, if available
if (screen->hwcaps & RFL_NO_CLIP_PLANES)
{
ws->vertcount = 0; // invalidate current vertices.
float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);

// I make the very big assumption here that translucent walls in sloped sectors
// and 3D-floors never coexist in the same level. If that were the case this
// code would become extremely more complicated.
if (!ceiling)
{
ws->ztop[1] = w->zbottom[1] = ws->ztop[0] = w->zbottom[0] = fh->z;
ws->tcs[GLWall::UPRGT].v = w->tcs[GLWall::LORGT].v = ws->tcs[GLWall::UPLFT].v = w->tcs[GLWall::LOLFT].v = newtexv;
}
else
{
w->ztop[1] = ws->zbottom[1] = w->ztop[0] = ws->zbottom[0] = fh->z;
w->tcs[GLWall::UPLFT].v = ws->tcs[GLWall::LOLFT].v = w->tcs[GLWall::UPRGT].v = ws->tcs[GLWall::LORGT].v = newtexv;
}
}

SortNode * sort2 = SortNodes.GetNew();
memset(sort2, 0, sizeof(SortNode));
sort2->itemindex = drawitems.Size() - 1;
Expand Down Expand Up @@ -338,24 +317,6 @@ void HWDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort)
GLSprite *s = NewSprite();
*s = *ss;

// Splitting is done in the shader with clip planes, if available.
// The fallback here only really works for non-y-billboarded sprites.
if (screen->hwcaps & RFL_NO_CLIP_PLANES)
{
float newtexv = ss->vt + ((ss->vb - ss->vt) / (ss->z2 - ss->z1))*(fh->z - ss->z1);

if (!ceiling)
{
ss->z1 = s->z2 = fh->z;
ss->vt = s->vb = newtexv;
}
else
{
s->z1 = ss->z2 = fh->z;
s->vt = ss->vb = newtexv;
}
}

SortNode * sort2 = SortNodes.GetNew();
memset(sort2, 0, sizeof(SortNode));
sort2->itemindex = drawitems.Size() - 1;
Expand Down
1 change: 0 additions & 1 deletion src/hwrenderer/scene/hw_drawstructs.h
Expand Up @@ -202,7 +202,6 @@ class GLWall
void CheckTexturePosition(FTexCoordInfo *tci);

void Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent);
bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright);
void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent);

void SetupLights(HWDrawInfo *di, FDynLightData &lightdata);
Expand Down
62 changes: 1 addition & 61 deletions src/hwrenderer/scene/hw_sprites.cpp
Expand Up @@ -238,55 +238,6 @@ inline void GLSprite::PutSprite(HWDrawInfo *di, bool translucent)
//
//==========================================================================

void GLSprite::SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent)
{
GLSprite copySprite;
double lightbottom;
unsigned int i;
bool put=false;
TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;

for(i=0;i<lightlist.Size();i++)
{
// Particles don't go through here so we can safely assume that actor is not nullptr
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor);
else lightbottom=frontsector->floorplane.ZatPoint(actor);

if (lightbottom<z2) lightbottom=z2;

if (lightbottom<z1)
{
copySprite=*this;
copySprite.lightlevel = hw_ClampLight(*lightlist[i].p_lightlevel);
copySprite.Colormap.CopyLight(lightlist[i].extra_colormap);

if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
{
copySprite.Colormap.Decolorize();
}

if (!ThingColor.isWhite())
{
copySprite.Colormap.LightColor.r = (copySprite.Colormap.LightColor.r*ThingColor.r) >> 8;
copySprite.Colormap.LightColor.g = (copySprite.Colormap.LightColor.g*ThingColor.g) >> 8;
copySprite.Colormap.LightColor.b = (copySprite.Colormap.LightColor.b*ThingColor.b) >> 8;
}

z1=copySprite.z2=lightbottom;
vt=copySprite.vb=copySprite.vt+
(lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1);
copySprite.PutSprite(di, translucent);
put=true;
}
}
}

//==========================================================================
//
//
//
//==========================================================================

void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight)
{
const float NO_VAL = 100000000.0f;
Expand Down Expand Up @@ -816,18 +767,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
if (thing->Sector->e->XFloor.lightlist.Size() != 0 && !di->isFullbrightScene() && !fullbright &&
RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub)
{
if (screen->hwcaps & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited...
{
lightlist = nullptr;
if (!drawWithXYBillboard && !modelframe)
{
SplitSprite(di, thing->Sector, hw_styleflags != STYLEHW_Solid);
}
}
else
{
lightlist = &thing->Sector->e->XFloor.lightlist;
}
lightlist = &thing->Sector->e->XFloor.lightlist;
}
else
{
Expand Down

0 comments on commit 13e96cc

Please sign in to comment.