nothing much, just give wildcode a 30% speed boost. Basicly, stop binding

a texture for every single brush poly: due to texsort, they will come in
batches.
This commit is contained in:
Bill Currie 2002-03-16 09:25:06 +00:00
parent 2a3e1869ac
commit 51805ebd92
7 changed files with 25 additions and 21 deletions

View File

@ -161,7 +161,7 @@ void R_TransformPlane (mplane_t *p, float *normal, float *dist);
void R_TransformFrustum (void); void R_TransformFrustum (void);
void R_SetSkyFrame (void); void R_SetSkyFrame (void);
void R_DrawSurfaceBlock (void); void R_DrawSurfaceBlock (void);
texture_t *R_TextureAnimation (texture_t *base); texture_t *R_TextureAnimation (msurface_t *surf);
#ifdef USE_INTEL_ASM #ifdef USE_INTEL_ASM

View File

@ -467,8 +467,11 @@ R_Mirror (void)
color_white[2] = r_mirroralpha->value * 255; color_white[2] = r_mirroralpha->value * 255;
qfglColor4ubv (color_white); qfglColor4ubv (color_white);
s = r_worldentity.model->textures[mirrortexturenum]->texturechain; s = r_worldentity.model->textures[mirrortexturenum]->texturechain;
for (; s; s = s->texturechain) for (; s; s = s->texturechain) {
texture_t *tex = R_TextureAnimation (s);
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
R_RenderBrushPoly (s); R_RenderBrushPoly (s);
}
r_worldentity.model->textures[mirrortexturenum]->texturechain = NULL; r_worldentity.model->textures[mirrortexturenum]->texturechain = NULL;
qfglColor3ubv (color_white); qfglColor3ubv (color_white);
} }

View File

@ -314,8 +314,9 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
Returns the proper texture for a given time and base texture Returns the proper texture for a given time and base texture
*/ */
texture_t * texture_t *
R_TextureAnimation (texture_t *base) R_TextureAnimation (msurface_t *surf)
{ {
texture_t *base = surf->texinfo->texture;
int count, relative; int count, relative;
if (currententity->frame) { if (currententity->frame) {
@ -324,7 +325,7 @@ R_TextureAnimation (texture_t *base)
} }
if (!base->anim_total) if (!base->anim_total)
return base; goto found;
relative = (int) (r_realtime * 10) % base->anim_total; relative = (int) (r_realtime * 10) % base->anim_total;
@ -336,6 +337,11 @@ R_TextureAnimation (texture_t *base)
if (++count > 100) if (++count > 100)
Sys_Error ("R_TextureAnimation: infinite cycle"); Sys_Error ("R_TextureAnimation: infinite cycle");
} }
found:
if (base->gl_fb_texturenum > 0) {
surf->polys->fb_chain = fullbright_polys[base->gl_fb_texturenum];
fullbright_polys[base->gl_fb_texturenum] = surf->polys;
}
return base; return base;
} }
@ -374,7 +380,7 @@ R_DrawMultitexturePoly (msurface_t *s)
{ {
float *v; float *v;
int maps, i; int maps, i;
texture_t *texture = R_TextureAnimation (s->texinfo->texture); texture_t *texture = R_TextureAnimation (s);
c_brush_polys++; c_brush_polys++;
@ -422,10 +428,6 @@ R_DrawMultitexturePoly (msurface_t *s)
qglActiveTexture (gl_mtex_enum + 0); qglActiveTexture (gl_mtex_enum + 0);
qfglEnable (GL_TEXTURE_2D); qfglEnable (GL_TEXTURE_2D);
if (texture->gl_fb_texturenum > 0) {
s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum];
fullbright_polys[texture->gl_fb_texturenum] = s->polys;
}
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
@ -499,12 +501,9 @@ R_RenderBrushPoly (msurface_t *fa)
float *v; float *v;
int maps, smax, tmax, i; int maps, smax, tmax, i;
glRect_t *theRect; glRect_t *theRect;
texture_t *texture = R_TextureAnimation (fa->texinfo->texture);
c_brush_polys++; c_brush_polys++;
qfglBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
qfglBegin (GL_POLYGON); qfglBegin (GL_POLYGON);
v = fa->polys->verts[0]; v = fa->polys->verts[0];
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) { for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
@ -518,10 +517,6 @@ R_RenderBrushPoly (msurface_t *fa)
fa->polys->chain = lightmap_polys[fa->lightmaptexturenum]; fa->polys->chain = lightmap_polys[fa->lightmaptexturenum];
lightmap_polys[fa->lightmaptexturenum] = fa->polys; lightmap_polys[fa->lightmaptexturenum] = fa->polys;
if (texture->gl_fb_texturenum > 0) {
fa->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum];
fullbright_polys[texture->gl_fb_texturenum] = fa->polys;
}
// check for lightmap modification // check for lightmap modification
for (maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++) for (maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++)
if (d_lightstylevalue[fa->styles[maps]] != fa->cached_light[maps]) if (d_lightstylevalue[fa->styles[maps]] != fa->cached_light[maps])
@ -618,6 +613,7 @@ DrawTextureChains (void)
texture_t *tex = r_worldentity.model->textures[i]; texture_t *tex = r_worldentity.model->textures[i];
if (!tex) if (!tex)
continue; continue;
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
for (s = tex->texturechain; s; s = s->texturechain) for (s = tex->texturechain; s; s = s->texturechain)
R_RenderBrushPoly (s); R_RenderBrushPoly (s);
@ -711,6 +707,8 @@ R_DrawBrushModel (entity_t *e)
} else if (gl_mtex_active) { } else if (gl_mtex_active) {
R_DrawMultitexturePoly (psurf); R_DrawMultitexturePoly (psurf);
} else { } else {
texture_t *tex = R_TextureAnimation (psurf);
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
R_RenderBrushPoly (psurf); R_RenderBrushPoly (psurf);
} }
} }
@ -791,7 +789,8 @@ R_RecursiveWorldNode (mnode_t *node)
} else if (gl_mtex_active) { } else if (gl_mtex_active) {
R_DrawMultitexturePoly (surf); R_DrawMultitexturePoly (surf);
} else { } else {
CHAIN_SURF (surf, surf->texinfo->texture->texturechain); texture_t *tex = R_TextureAnimation (surf);
CHAIN_SURF (surf, tex->texturechain);
} }
} }
} }

View File

@ -270,7 +270,7 @@ D_CacheSurface (msurface_t *surface, int miplevel)
surfcache_t *cache; surfcache_t *cache;
// if the surface is animating or flashing, flush the cache // if the surface is animating or flashing, flush the cache
r_drawsurf.texture = R_TextureAnimation (surface->texinfo->texture); r_drawsurf.texture = R_TextureAnimation (surface);
r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]]; r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]]; r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]]; r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];

View File

@ -185,8 +185,9 @@ R_BuildLightMap (void)
Returns the proper texture for a given time and base texture Returns the proper texture for a given time and base texture
*/ */
texture_t * texture_t *
R_TextureAnimation (texture_t *base) R_TextureAnimation (msurface_t *surf)
{ {
texture_t *base = surf->texinfo->texture;
int relative; int relative;
int count; int count;

View File

@ -272,7 +272,7 @@ D_CacheSurface (msurface_t *surface, int miplevel)
surfcache_t *cache; surfcache_t *cache;
// if the surface is animating or flashing, flush the cache // if the surface is animating or flashing, flush the cache
r_drawsurf.texture = R_TextureAnimation (surface->texinfo->texture); r_drawsurf.texture = R_TextureAnimation (surface);
r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]]; r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]]; r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]]; r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];

View File

@ -219,8 +219,9 @@ R_BuildLightMap (void)
Returns the proper texture for a given time and base texture Returns the proper texture for a given time and base texture
*/ */
texture_t * texture_t *
R_TextureAnimation (texture_t *base) R_TextureAnimation (msurface_t *surf)
{ {
texture_t *base = surf->texinfo->texture;
int relative; int relative;
int count; int count;