small performance tweak.
fix r_remapshader command with sv_cheats on. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4678 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
e2eded8ffe
commit
2401870b7b
5 changed files with 104 additions and 90 deletions
|
@ -35,6 +35,7 @@ void RSpeedShow(void)
|
|||
int i;
|
||||
static int samplerspeeds[RSPEED_MAX];
|
||||
static int samplerquant[RQUANT_MAX];
|
||||
int savedsamplerquant[RQUANT_MAX]; //so we don't count the r_speeds debug spam in draw counts.
|
||||
char *RSpNames[RSPEED_MAX];
|
||||
char *RQntNames[RQUANT_MAX];
|
||||
char *s;
|
||||
|
@ -66,8 +67,9 @@ void RSpeedShow(void)
|
|||
|
||||
memset(RQntNames, 0, sizeof(RQntNames));
|
||||
RQntNames[RQUANT_MSECS] = "Microseconds";
|
||||
RQntNames[RQUANT_EPOLYS] = "Entity Polys";
|
||||
RQntNames[RQUANT_WPOLYS] = "World Polys";
|
||||
#ifdef _DEBUG
|
||||
RQntNames[RQUANT_PRIMITIVES] = "Draw Indicies";
|
||||
#endif
|
||||
RQntNames[RQUANT_DRAWS] = "Draw Calls";
|
||||
RQntNames[RQUANT_2DBATCHES] = "2d Batches";
|
||||
RQntNames[RQUANT_WORLDBATCHES] = "World Batches";
|
||||
|
@ -82,6 +84,7 @@ void RSpeedShow(void)
|
|||
RQntNames[RQUANT_RTLIGHT_CULL_PVS] = "Lights PVS Culled";
|
||||
RQntNames[RQUANT_RTLIGHT_CULL_SCISSOR] = "Lights Scissored";
|
||||
|
||||
memcpy(savedsamplerquant, rquant, sizeof(savedsamplerquant));
|
||||
if (r_speeds.ival > 1)
|
||||
{
|
||||
for (i = 0; i < RSPEED_MAX; i++)
|
||||
|
@ -97,9 +100,10 @@ void RSpeedShow(void)
|
|||
}
|
||||
if (r_speeds.ival > 1)
|
||||
{
|
||||
s = va("%f %-20s", 100000000.0f/(samplerspeeds[RSPEED_TOTALREFRESH]+samplerspeeds[RSPEED_FINISH]), "Framerate");
|
||||
s = va("%f %-20s", 100000000.0f/(samplerspeeds[RSPEED_TOTALREFRESH]+samplerspeeds[RSPEED_FINISH]), "Framerate (refresh only)");
|
||||
Draw_FunString(vid.width-strlen(s)*8, (i+RSPEED_MAX)*8, s);
|
||||
}
|
||||
memcpy(rquant, savedsamplerquant, sizeof(rquant));
|
||||
|
||||
if (++framecount>=100)
|
||||
{
|
||||
|
|
|
@ -582,8 +582,7 @@ extern int rspeeds[RSPEED_MAX];
|
|||
|
||||
enum {
|
||||
RQUANT_MSECS, //old r_speeds
|
||||
RQUANT_EPOLYS,
|
||||
RQUANT_WPOLYS,
|
||||
RQUANT_PRIMITIVES,
|
||||
RQUANT_DRAWS,
|
||||
RQUANT_ENTBATCHES,
|
||||
RQUANT_WORLDBATCHES,
|
||||
|
|
|
@ -874,7 +874,7 @@ void PM_CategorizePosition (void)
|
|||
VectorMA (pmove.origin, 24, flatforward, fwd1);
|
||||
|
||||
pmove.physents[0].model->funcs.NativeTrace(pmove.physents[0].model, 0, 0, NULL, pmove.origin, fwd1, pmove.player_mins, pmove.player_maxs, MASK_PLAYERSOLID, &t);
|
||||
if (t.surface->flags & Q3SURF_LADDER)
|
||||
if (t.surface && t.surface->flags & Q3SURF_LADDER)
|
||||
{
|
||||
pmove.onladder = true;
|
||||
pmove.onground = false; // too steep
|
||||
|
|
|
@ -702,6 +702,7 @@ static void BE_EnableShaderAttributes(unsigned int progattrmask, int usevao)
|
|||
|
||||
shaderstate.sha_attr = progattrmask;
|
||||
|
||||
/*
|
||||
#ifndef FORCESTATE
|
||||
if (shaderstate.currentebo != shaderstate.sourcevbo->indicies.gl.vbo)
|
||||
#endif
|
||||
|
@ -709,6 +710,7 @@ static void BE_EnableShaderAttributes(unsigned int progattrmask, int usevao)
|
|||
shaderstate.currentebo = shaderstate.sourcevbo->indicies.gl.vbo;
|
||||
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, shaderstate.currentebo);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (bitstochange || bitstoendisable)
|
||||
|
@ -2609,105 +2611,110 @@ static void BE_SubmitMeshChain(void)
|
|||
int startv, starti, endv, endi;
|
||||
int m;
|
||||
mesh_t *mesh;
|
||||
int batchtype = GL_TRIANGLES;
|
||||
int batchtype = (shaderstate.flags & BEF_LINES)?GL_LINES:GL_TRIANGLES;
|
||||
|
||||
if (shaderstate.flags & BEF_LINES)
|
||||
batchtype = GL_LINES;
|
||||
if (!shaderstate.streamvbo[0]) //only if we're not forcing vbos elsewhere.
|
||||
{
|
||||
//q3map2 sucks. it splits static meshes randomly rather than with any pvs consistancy, and then splays them out over 1000 different surfaces.
|
||||
//this means we end up needing a boatload of draw calls whenever the batch got split.
|
||||
//so skip all that and splurge out a usable index list on demand.
|
||||
if (shaderstate.meshcount == 1)
|
||||
{
|
||||
GL_SelectEBO(shaderstate.sourcevbo->indicies.gl.vbo);
|
||||
mesh = shaderstate.meshes[0];
|
||||
qglDrawRangeElements(batchtype, mesh->vbofirstvert, mesh->vbofirstvert+mesh->numvertexes, mesh->numindexes, GL_INDEX_TYPE, (index_t*)shaderstate.sourcevbo->indicies.gl.addr + mesh->vbofirstelement);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
RQuantAdd(RQUANT_PRIMITIVES, mesh->numindexes);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
index_t *fte_restrict ilst; //FIXME: this should be cached for multiple-pass shaders.
|
||||
GL_SelectEBO(0);
|
||||
|
||||
#if 0
|
||||
if (!shaderstate.currentebo)
|
||||
{
|
||||
if (shaderstate.meshcount == 1)
|
||||
{
|
||||
mesh = shaderstate.meshes[0];
|
||||
qglDrawRangeElements(batchtype, mesh->vbofirstvert, mesh->vbofirstvert+mesh->numvertexes, mesh->numindexes, GL_INDEX_TYPE, shaderstate.sourcevbo->indicies + mesh->vbofirstelement);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
mesh = shaderstate.meshes[0];
|
||||
startv = mesh->vbofirstvert;
|
||||
endv = startv + mesh->numvertexes;
|
||||
endi = mesh->numindexes;
|
||||
for (m = 1; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
endi += mesh->numindexes;
|
||||
|
||||
if (startv > mesh->vbofirstvert)
|
||||
startv = mesh->vbofirstvert;
|
||||
if (endv < mesh->vbofirstvert+mesh->numvertexes)
|
||||
endv = mesh->vbofirstvert+mesh->numvertexes;
|
||||
}
|
||||
|
||||
ilst = alloca(endi*sizeof(index_t));
|
||||
endi = 0;
|
||||
for (m = 0; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
for (starti = 0; starti < mesh->numindexes; )
|
||||
ilst[endi++] = mesh->vbofirstvert + mesh->indexes[starti++];
|
||||
}
|
||||
qglDrawRangeElements(batchtype, startv, endv, endi, GL_INDEX_TYPE, ilst);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
RQuantAdd(RQUANT_PRIMITIVES, endi);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
index_t *ilst;
|
||||
mesh = shaderstate.meshes[0];
|
||||
startv = mesh->vbofirstvert;
|
||||
endv = startv + mesh->numvertexes;
|
||||
endi = mesh->numindexes;
|
||||
for (m = 1; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
endi += mesh->numindexes;
|
||||
|
||||
if (startv > mesh->vbofirstvert)
|
||||
startv = mesh->vbofirstvert;
|
||||
if (endv < mesh->vbofirstvert+mesh->numvertexes)
|
||||
endv = mesh->vbofirstvert+mesh->numvertexes;
|
||||
}
|
||||
|
||||
|
||||
ilst = alloca(endi*sizeof(index_t));
|
||||
endi = 0;
|
||||
for (m = 0; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
for (starti = 0; starti < mesh->numindexes; )
|
||||
ilst[endi++] = mesh->vbofirstvert + mesh->indexes[starti++];
|
||||
}
|
||||
qglDrawRangeElements(batchtype, startv, endv, endi, GL_INDEX_TYPE, ilst);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
GL_SelectEBO(shaderstate.sourcevbo->indicies.gl.vbo);
|
||||
|
||||
/*
|
||||
if (qglLockArraysEXT)
|
||||
{
|
||||
endv = 0;
|
||||
startv = 0x7fffffff;
|
||||
for (m = 0; m < shaderstate.meshcount; m++)
|
||||
if (qglLockArraysEXT)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
starti = mesh->vbofirstvert;
|
||||
if (starti < startv)
|
||||
startv = starti;
|
||||
endi = mesh->vbofirstvert+mesh->numvertexes;
|
||||
if (endi > endv)
|
||||
endv = endi;
|
||||
endv = 0;
|
||||
startv = 0x7fffffff;
|
||||
for (m = 0; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
starti = mesh->vbofirstvert;
|
||||
if (starti < startv)
|
||||
startv = starti;
|
||||
endi = mesh->vbofirstvert+mesh->numvertexes;
|
||||
if (endi > endv)
|
||||
endv = endi;
|
||||
}
|
||||
qglLockArraysEXT(startv, endv);
|
||||
}
|
||||
qglLockArraysEXT(startv, endv);
|
||||
}
|
||||
*/
|
||||
|
||||
for (m = 0, mesh = shaderstate.meshes[0]; m < shaderstate.meshcount; )
|
||||
{
|
||||
startv = mesh->vbofirstvert;
|
||||
starti = mesh->vbofirstelement;
|
||||
|
||||
endv = startv+mesh->numvertexes;
|
||||
endi = starti+mesh->numindexes;
|
||||
|
||||
//find consecutive surfaces
|
||||
for (++m; m < shaderstate.meshcount; m++)
|
||||
for (m = 0, mesh = shaderstate.meshes[0]; m < shaderstate.meshcount; )
|
||||
{
|
||||
mesh = shaderstate.meshes[m];
|
||||
if (endi == mesh->vbofirstelement)
|
||||
startv = mesh->vbofirstvert;
|
||||
starti = mesh->vbofirstelement;
|
||||
|
||||
endv = startv+mesh->numvertexes;
|
||||
endi = starti+mesh->numindexes;
|
||||
|
||||
//find consecutive surfaces
|
||||
for (++m; m < shaderstate.meshcount; m++)
|
||||
{
|
||||
endv = mesh->vbofirstvert+mesh->numvertexes;
|
||||
endi = mesh->vbofirstelement+mesh->numindexes;
|
||||
mesh = shaderstate.meshes[m];
|
||||
if (endi == mesh->vbofirstelement)
|
||||
{
|
||||
endv = mesh->vbofirstvert+mesh->numvertexes;
|
||||
endi = mesh->vbofirstelement+mesh->numindexes;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
qglDrawRangeElements(batchtype, startv, endv, endi-starti, GL_INDEX_TYPE, (index_t*)shaderstate.sourcevbo->indicies.gl.addr + starti);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
}
|
||||
qglDrawRangeElements(batchtype, startv, endv, endi-starti, GL_INDEX_TYPE, (index_t*)shaderstate.sourcevbo->indicies.gl.addr + starti);
|
||||
RQuantAdd(RQUANT_DRAWS, 1);
|
||||
RQuantAdd(RQUANT_PRIMITIVES, endi-starti);
|
||||
}
|
||||
/*
|
||||
if (qglUnlockArraysEXT)
|
||||
qglUnlockArraysEXT();
|
||||
if (qglUnlockArraysEXT)
|
||||
qglUnlockArraysEXT();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawPass(const shaderpass_t *pass)
|
||||
|
|
|
@ -5103,7 +5103,11 @@ void R_RemapShader(const char *sourcename, const char *destname, float timeoffse
|
|||
if (o)
|
||||
{
|
||||
if (!n)
|
||||
n = o;
|
||||
{
|
||||
n = R_LoadShader (destname, SUF_2D, NULL, NULL);
|
||||
if (!n)
|
||||
n = o;
|
||||
}
|
||||
o->remapto = n;
|
||||
o->remaptime = timeoffset;
|
||||
}
|
||||
|
@ -5115,7 +5119,7 @@ void Shader_RemapShader_f(void)
|
|||
char *destname = Cmd_Argv(2);
|
||||
float timeoffset = atof(Cmd_Argv(3));
|
||||
|
||||
if (!Cmd_FromGamecode() && !atoi(Info_ValueForKey(cl.serverinfo, "*cheats")))
|
||||
if (!Cmd_FromGamecode() && strcmp(Info_ValueForKey(cl.serverinfo, "*cheats"), "ON"))
|
||||
{
|
||||
Con_Printf("%s may only be used from gamecode, or when cheats are enabled\n", Cmd_Argv(0));
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue