r_brush.c: small optimization in R_DrawSequentialPoly; move the drawing of fullbrights to a separate function, and draw them in a separate pass through the polys of the brush mode. This reduces the amount of texture binding. The extreme case would be, e.g. 1000 polys with one texture (with fullbrights), before would require 2000 binds, after would require 2 binds. This gets part way to the performance of https://sourceforge.net/p/quakespasm/patches/14/ with much less code change

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@968 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Eric Wasylishen 2014-08-17 21:12:54 +00:00
parent 9894c0b00d
commit 0824c53967

View file

@ -467,6 +467,41 @@ void R_DrawSequentialPoly (msurface_t *s)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor3f(1, 1, 1);
}
fullbrights:
return; // ericw - optimization: moved to a separate pass through the polys
// so we're not constantly thrashing the texture bound in TEXTURE0
}
/*
================
R_DrawSequentialPoly_Fullbrights -- ericw - moved from R_DrawSequentialPoly
================
*/
void R_DrawSequentialPoly_Fullbrights (msurface_t *s)
{
texture_t *t;
float entalpha;
t = R_TextureAnimation (s->texinfo->texture, currententity->frame);
entalpha = ENTALPHA_DECODE(currententity->alpha);
// drawflat
if (r_drawflat_cheatsafe)
return;
// fullbright
if ((r_fullbright_cheatsafe) && !(s->flags & SURF_DRAWTILED))
goto fullbrights;
// other cases
if (r_lightmap_cheatsafe
|| s->flags & SURF_DRAWSKY
|| s->flags & SURF_DRAWTURB
|| s->flags & SURF_NOTEXTURE)
return;
// lightmapped poly
fullbrights:
if (gl_fullbrights.value && t->fullbright)
@ -573,6 +608,20 @@ void R_DrawBrushModel (entity_t *e)
}
}
// ericw -- second pass to draw the fullbrights
psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
for (i=0 ; i<clmodel->nummodelsurfaces ; i++, psurf++)
{
pplane = psurf->plane;
dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
{
R_DrawSequentialPoly_Fullbrights (psurf);
}
}
if (r_drawflat_cheatsafe) //johnfitz
glEnable(GL_TEXTURE_2D);