- found out that reading the CPU's real time clock costs a not insignificant amount of time so this is now only done when either the benchmark command is running or the rendertimes are shown.

This commit is contained in:
Christoph Oelckers 2014-08-30 14:33:06 +02:00
parent 49ec7beb8f
commit 6a3cd6378a
4 changed files with 32 additions and 18 deletions

View file

@ -351,11 +351,11 @@ void FGLRenderer::RenderScene(int recursion)
if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE))
{
GLRenderer->mLights->Begin();
gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY);
GLRenderer->mLights->Finish();
@ -379,8 +379,8 @@ void FGLRenderer::RenderScene(int recursion)
gl_RenderState.EnableTexture(gl_texture);
gl_RenderState.EnableBrightmap(true);
gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(pass);
gl_drawinfo->drawlists[GLDL_PLAINFLATS].Draw(pass);
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(pass);
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(pass);
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
@ -390,15 +390,15 @@ void FGLRenderer::RenderScene(int recursion)
gl_RenderState.SetTextureMode(TM_MASK);
}
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].Draw(pass);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].Draw(pass);
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(pass);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(pass);
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
{
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Draw(pass);
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(pass);
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
}
@ -413,10 +413,8 @@ void FGLRenderer::RenderScene(int recursion)
glPolygonOffset(-1.0f, -128.0f);
glDepthMask(false);
for(int i=0; i<GLDL_TRANSLUCENT; i++)
{
gl_drawinfo->drawlists[i].Draw(GLPASS_DECALS);
}
// this is the only geometry type on which decals can possibly appear
gl_drawinfo->drawlists[GLDL_PLAINWALLS].Draw(GLPASS_DECALS);
gl_RenderState.SetTextureMode(TM_MODULATE);
@ -439,8 +437,8 @@ void FGLRenderer::RenderScene(int recursion)
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
RenderAll.Unclock();
}
//-----------------------------------------------------------------------------
@ -821,6 +819,7 @@ void FGLRenderer::RenderView (player_t* player)
OpenGLFrameBuffer* GLTarget = static_cast<OpenGLFrameBuffer*>(screen);
AActor *&LastCamera = GLTarget->LastCamera;
checkBenchActive();
if (player->camera != LastCamera)
{
// If the camera changed don't interpolate

View file

@ -222,3 +222,12 @@ CCMD(bench)
}
C_HideConsole ();
}
bool gl_benching = false;
void checkBenchActive()
{
FStat *stat = FStat::FindStat("rendertimes");
gl_benching = ((stat != NULL && stat->isActive()) || printstats);
}

View file

@ -9,6 +9,7 @@
extern double gl_SecondsPerCycle;
extern double gl_MillisecPerCycle;
extern bool gl_benching;
__forceinline long long GetClockCycle ()
@ -75,13 +76,13 @@ public:
// Not using QueryPerformanceCounter directly, so we don't need
// to pull in the Windows headers for every single file that
// wants to do some profiling.
long long time = GetClockCycle();
long long time = (gl_benching? GetClockCycle() : 0);
Counter -= time;
}
__forceinline void Unclock()
{
long long time = GetClockCycle();
long long time = (gl_benching? GetClockCycle() : 0);
Counter += time;
}
@ -118,6 +119,7 @@ extern int vertexcount, flatvertices, flatprimitives;
void ResetProfilingData();
void CheckBench();
void checkBenchActive();
#endif

View file

@ -267,6 +267,10 @@ public:
virtual FString GetStats () = 0;
void ToggleStat ();
bool isActive() const
{
return m_Active;
}
static void PrintStat ();
static FStat *FindStat (const char *name);