- move models into their own draw list to avoid frequent buffer changes.

- same for SKYHACK walls. Although rare, they would get in the way of optimizing the draw calls if not being separated out.
This commit is contained in:
Christoph Oelckers 2014-07-15 21:16:59 +02:00
parent b8bcbe819b
commit 6b9d6787d9
6 changed files with 39 additions and 27 deletions

View file

@ -15,8 +15,8 @@ enum DrawListType
{
GLDL_PLAIN,
GLDL_MASKED,
GLDL_FOG,
GLDL_FOGMASKED,
GLDL_MASKEDOFS,
GLDL_MODELS,
GLDL_TRANSLUCENT,
GLDL_TRANSLUCENTBORDER,
@ -96,6 +96,11 @@ public:
Reset();
}
unsigned int Size()
{
return drawitems.Size();
}
void AddWall(GLWall * wall);
void AddFlat(GLFlat * flat);
void AddSprite(GLSprite * sprite);

View file

@ -376,6 +376,18 @@ void FGLRenderer::RenderScene(int recursion)
gl_drawinfo->drawlists[GLDL_MASKED].Sort();
gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass);
// this list is empty most of the time so only waste time on it when in use.
if (gl_drawinfo->drawlists[GLDL_MASKEDOFS].Size() > 0)
{
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort();
gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(pass);
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
}
gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -315,13 +315,9 @@ inline void GLSprite::PutSprite(bool translucent)
{
list = GLDL_TRANSLUCENT;
}
else if ((!gl_isBlack (Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE))
{
list = GLDL_FOGMASKED;
}
else
{
list = GLDL_MASKED;
list = GLDL_MODELS;
}
gl_drawinfo->drawlists[list].AddSprite(this);
}

View file

@ -97,11 +97,9 @@ public:
//GLWF_CLAMPX=1, use GLT_* for these!
//GLWF_CLAMPY=2,
GLWF_SKYHACK=4,
GLWF_FOGGY=8,
GLWF_GLOW=16, // illuminated by glowing flats
GLWF_NOSHADER=32, // cannot be drawn with shaders.
GLWF_NOSPLITUPPER=64,
GLWF_NOSPLITLOWER=128,
GLWF_GLOW=8, // illuminated by glowing flats
GLWF_NOSPLITUPPER=16,
GLWF_NOSPLITLOWER=32,
};
enum

View file

@ -148,14 +148,22 @@ void GLWall::PutWall(bool translucent)
bool masked;
masked = passflag[type]==1? false : (gltexture && gltexture->isMasked());
if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S))
{
list = GLDL_MASKEDOFS;
}
else
{
list = masked ? GLDL_MASKED : GLDL_PLAIN;
}
gl_drawinfo->drawlists[list].AddWall(this);
}
else switch (type)
{
case RENDERWALL_COLORLAYER:
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this);
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this);
break;
// portals don't go into the draw list.

View file

@ -369,15 +369,11 @@ void GLWall::Draw(int pass)
#endif
// This allows mid textures to be drawn on lines that might overlap a sky wall
if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER)
{
if (pass != GLPASS_DECALS)
if (type == RENDERWALL_COLORLAYER)
{
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
}
}
switch (pass)
{
@ -426,12 +422,9 @@ void GLWall::Draw(int pass)
}
}
if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER)
{
if (pass!=GLPASS_DECALS)
if (type == RENDERWALL_COLORLAYER)
{
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
}
}
}