- reworked the FPS display to use ZDoom's fstat class to get rid of the microscopic font it used.

- changed time display for rendering to exclude VSync and playsim times to get more meaningful information.
This commit is contained in:
Christoph Oelckers 2019-11-10 11:42:25 +01:00
parent cae710bd59
commit a1a9770b44
18 changed files with 75 additions and 169 deletions

View file

@ -1422,7 +1422,7 @@ RESTART:
if (bDraw) if (bDraw)
{ {
viewDrawScreen(); viewDrawScreen();
g_gameUpdateAndDrawTime = timerGetHiTicks() - gameUpdateStartTime; g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
} }
} }
} }

View file

@ -91,6 +91,7 @@ struct GameInterface : ::GameInterface
void set_hud_layout(int size) override; void set_hud_layout(int size) override;
void set_hud_scale(int size) override; void set_hud_scale(int size) override;
bool mouseInactiveConditional(bool condition) override; bool mouseInactiveConditional(bool condition) override;
FString statFPS() override;
}; };
END_BLD_NS END_BLD_NS

View file

@ -60,6 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "view.h" #include "view.h"
#include "warp.h" #include "warp.h"
#include "weapon.h" #include "weapon.h"
#include "zstring.h"
CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups") CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups")
@ -3569,7 +3570,6 @@ RORHACK:
#endif #endif
viewDrawMapTitle(); viewDrawMapTitle();
viewDrawAimedPlayerName(); viewDrawAimedPlayerName();
viewPrintFPS();
if (gPaused) if (gPaused)
{ {
viewDrawText(1, "PAUSED", 160, 10, 0, 0, 1, 0); viewDrawText(1, "PAUSED", 160, 10, 0, 0, 1, 0);
@ -3740,9 +3740,9 @@ void viewResetCrosshairToDefault(void)
#define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE) #define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE)
void viewPrintFPS(void) FString GameInterface::statFPS(void)
{ {
char tempbuf[128]; FString output;
static int32_t frameCount; static int32_t frameCount;
static double cumulativeFrameDelay; static double cumulativeFrameDelay;
static double lastFrameTime; static double lastFrameTime;
@ -3757,73 +3757,35 @@ void viewPrintFPS(void)
{ {
int32_t x = (xdim <= 640); int32_t x = (xdim <= 640);
if (r_showfps) //if (r_showfps)
{ {
int32_t chars = Bsprintf(tempbuf, "%.1f ms, %5.1f fps", frameDelay, lastFPS); output.AppendFormat("%.1f ms, %5.1f fps\n", frameDelay, lastFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+1+FPS_YOFFSET,
FPS_COLOR(lastFPS < LOW_FPS), -1, tempbuf, x);
if (r_showfps > 1) if (r_showfps > 1)
{ {
chars = Bsprintf(tempbuf, "max: %5.1f fps", maxFPS); output.AppendFormat("max: %5.1f fps\n", maxFPS);
output.AppendFormat("min: %5.1f fps\n", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+10+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+10+FPS_YOFFSET,
FPS_COLOR(maxFPS < LOW_FPS), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "min: %5.1f fps", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+20+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET,
FPS_COLOR(minFPS < LOW_FPS), -1, tempbuf, x);
} }
if (r_showfps > 2) if (r_showfps > 2)
{ {
if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime;
if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime;
chars = Bsprintf(tempbuf, "Game Update: %2.2f ms + draw: %2.2f ms", g_gameUpdateTime, g_gameUpdateAndDrawTime); output.AppendFormat("Game Update: %2.2f ms + draw: %2.2f ms\n", g_gameUpdateTime, g_gameUpdateAndDrawTime - g_gameUpdateTime);
output.AppendFormat("GU min/max/avg: %5.2f/%5.2f/%5.2f ms\n", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x); output.AppendFormat("bufferjitter: %i\n", gBufferJitter);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+FPS_YOFFSET,
FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "GU min/max/avg: %5.2f/%5.2f/%5.2f ms", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+40+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET,
FPS_COLOR(maxGameUpdate >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "bufferjitter: %i", gBufferJitter);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+50+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+50+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
#if 0 #if 0
chars = Bsprintf(tempbuf, "G_MoveActors(): %.3e ms", g_moveActorsTime); output.AppendFormat("G_MoveActors(): %.3f ms\n", g_moveActorsTime);
output.AppendFormat("G_MoveWorld(): %.3f ms\n", g_moveWorldTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+50+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+50+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
chars = Bsprintf(tempbuf, "G_MoveWorld(): %.3e ms", g_moveWorldTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+60+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+60+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
#endif #endif
} }
#if 0 #if 0
// lag meter // lag meter
if (g_netClientPeer) if (g_netClientPeer)
{ {
chars = Bsprintf(tempbuf, "%d +- %d ms", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2, output.AppendFormat("%d +- %d ms\n", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2,
(g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2); (g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+1+FPS_YOFFSET, FPS_COLOR(g_netClientPeer->lastRoundTripTime > 200), -1, tempbuf, x);
} }
#endif #endif
} }
@ -3855,6 +3817,7 @@ void viewPrintFPS(void)
frameCount++; frameCount++;
} }
lastFrameTime = frameTime; lastFrameTime = frameTime;
return output;
} }
#undef FPS_COLOR #undef FPS_COLOR

View file

@ -151,7 +151,6 @@ void viewUpdateDelirium(void);
void viewUpdateShake(void); void viewUpdateShake(void);
void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b); void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b);
void viewResetCrosshairToDefault(void); void viewResetCrosshairToDefault(void);
void viewPrintFPS(void);
void viewSetSystemMessage(const char* pMessage, ...); void viewSetSystemMessage(const char* pMessage, ...);
inline void viewInterpolateSector(int nSector, sectortype *pSector) inline void viewInterpolateSector(int nSector, sectortype *pSector)

View file

@ -13,6 +13,7 @@
#include "c_cvars.h" #include "c_cvars.h"
#include "inputstate.h" #include "inputstate.h"
#include "printf.h" #include "printf.h"
#include "zstring.h"
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
@ -170,9 +171,12 @@ struct GameInterface
virtual void set_hud_layout(int size) = 0; virtual void set_hud_layout(int size) = 0;
virtual void set_hud_scale(int size) = 0; virtual void set_hud_scale(int size) = 0;
virtual bool mouseInactiveConditional(bool condition) { return condition; } virtual bool mouseInactiveConditional(bool condition) { return condition; }
virtual FString statFPS() { return "FPS display not available"; }
}; };
extern GameInterface* gi; extern GameInterface* gi;
extern double g_beforeSwapTime;
void ImGui_Begin_Frame(); void ImGui_Begin_Frame();

View file

@ -10230,6 +10230,8 @@ void videoNextPage(void)
} }
videoEndDrawing(); //}}} videoEndDrawing(); //}}}
g_beforeSwapTime = timerGetHiTicks();
// Draw the ImGui menu on top of the game content, but below the console (if open.) // Draw the ImGui menu on top of the game content, but below the console (if open.)
if (GUICapture & 6) if (GUICapture & 6)
{ {

View file

@ -70,6 +70,7 @@ CVAR(Int, windowy, -1, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
static SDL_version linked; static SDL_version linked;
#endif #endif
double g_beforeSwapTime;
GameInterface* gi; GameInterface* gi;
FArgs* Args; FArgs* Args;
@ -1536,16 +1537,7 @@ void videoShowFrame(int32_t w)
} }
static uint32_t lastSwapTime = 0; static uint32_t lastSwapTime = 0;
#ifdef TIMING
cycle_t clock;
clock.Reset();
clock.Clock();
#endif
glFinish(); glFinish();
#ifdef TIMING
clock.Unclock();
OSD_Printf("glfinish time: %2.3f\n", clock.TimeMS());
#endif
SDL_GL_SwapWindow(sdl_window); SDL_GL_SwapWindow(sdl_window);
lastSwapTime = SDL_GetTicks(); lastSwapTime = SDL_GetTicks();

View file

@ -45,6 +45,7 @@
#include "gamecontrol.h" #include "gamecontrol.h"
#include "m_argv.h" #include "m_argv.h"
#include "rts.h" #include "rts.h"
#include "stats.h"
/* Notes /* Notes
@ -337,9 +338,15 @@ CUSTOM_CVARD(Int, r_drawweapon, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disab
if (self < 0 || self > 2) self = 1; if (self < 0 || self > 2) self = 1;
} }
ADD_STAT(fps)
{
return gi->statFPS();
}
CUSTOM_CVARD(Int, r_showfps, 0, 0, "show the frame rate counter") CUSTOM_CVARD(Int, r_showfps, 0, 0, "show the frame rate counter")
{ {
if (self < 0 || self > 3) self = 1; if (self < 0 || self > 3) self = 1;
FStat::EnableStat("fps", self != 0);
} }
CUSTOM_CVARD(Int, r_showfpsperiod, 0, 0, "time in seconds before averaging min and max stats for r_showfps 2+") CUSTOM_CVARD(Int, r_showfpsperiod, 0, 0, "time in seconds before averaging min and max stats for r_showfps 2+")

View file

@ -80,6 +80,15 @@ void FStat::ToggleStat (const char *name)
Printf ("Unknown stat: %s\n", name); Printf ("Unknown stat: %s\n", name);
} }
void FStat::EnableStat(const char* name, bool on)
{
FStat* stat = FindStat(name);
if (stat)
stat->m_Active = on;
else
Printf("Unknown stat: %s\n", name);
}
void FStat::ToggleStat () void FStat::ToggleStat ()
{ {
m_Active = !m_Active; m_Active = !m_Active;

View file

@ -226,6 +226,7 @@ public:
static void PrintStat (); static void PrintStat ();
static FStat *FindStat (const char *name); static FStat *FindStat (const char *name);
static void ToggleStat (const char *name); static void ToggleStat (const char *name);
static void EnableStat(const char* name, bool on);
static void DumpRegisteredStats (); static void DumpRegisteredStats ();
private: private:

View file

@ -666,10 +666,7 @@ void G_DoCheats(void)
return; return;
case CHEAT_RATE: case CHEAT_RATE:
r_showfps = r_showfps+1; r_showfps = clamp(*r_showfps+1, 0, 3);
if (r_showfps > 3)
r_showfps = 0;
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;

View file

@ -152,6 +152,7 @@ struct GameInterface : ::GameInterface
void set_hud_layout(int size) override; void set_hud_layout(int size) override;
void set_hud_scale(int size) override; void set_hud_scale(int size) override;
bool mouseInactiveConditional(bool condition) override; bool mouseInactiveConditional(bool condition) override;
FString statFPS() override;
}; };
END_DUKE_NS END_DUKE_NS

View file

@ -6432,6 +6432,8 @@ MAIN_LOOP_RESTART:
bool gameUpdate = false; bool gameUpdate = false;
double gameUpdateStartTime = timerGetHiTicks(); double gameUpdateStartTime = timerGetHiTicks();
auto beforeMoveClock = ototalclock;
if (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME) if (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME)
{ {
do do
@ -6509,7 +6511,7 @@ MAIN_LOOP_RESTART:
videoNextPage(); videoNextPage();
if (gameUpdate) if (gameUpdate)
g_gameUpdateAndDrawTime = timerGetHiTicks()-gameUpdateStartTime; g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
frameJustDrawn = true; frameJustDrawn = true;
} }

View file

@ -680,8 +680,9 @@ static void G_PrintCoords(int32_t snum)
#define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE) #define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE)
static void G_PrintFPS(void) FString GameInterface::statFPS(void)
{ {
FString output;
static int32_t frameCount; static int32_t frameCount;
static double cumulativeFrameDelay; static double cumulativeFrameDelay;
static double lastFrameTime; static double lastFrameTime;
@ -696,66 +697,31 @@ static void G_PrintFPS(void)
{ {
int32_t x = (xdim <= 640); int32_t x = (xdim <= 640);
if (r_showfps) //if (r_showfps)
{ {
int32_t chars = Bsprintf(tempbuf, "%.1f ms, %5.1f fps", frameDelay, lastFPS); output.AppendFormat("%.1f ms, %5.1f fps\n", frameDelay, lastFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+1+FPS_YOFFSET,
FPS_COLOR(lastFPS < LOW_FPS), -1, tempbuf, x);
if (r_showfps > 1) if (r_showfps > 1)
{ {
chars = Bsprintf(tempbuf, "max: %5.1f fps", maxFPS); output.AppendFormat("max: %5.1f fps\n", maxFPS);
output.AppendFormat("min: %5.1f fps\n", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+10+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+10+FPS_YOFFSET,
FPS_COLOR(maxFPS < LOW_FPS), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "min: %5.1f fps", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+20+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET,
FPS_COLOR(minFPS < LOW_FPS), -1, tempbuf, x);
} }
if (r_showfps > 2) if (r_showfps > 2)
{ {
if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime;
if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime;
chars = Bsprintf(tempbuf, "Game Update: %2.2f ms + draw: %2.2f ms", g_gameUpdateTime, g_gameUpdateAndDrawTime); output.AppendFormat("Game Update: %2.2f ms + draw: %2.2f ms\n", g_gameUpdateTime, g_gameUpdateAndDrawTime - g_gameUpdateTime);
output.AppendFormat("GU min/max/avg: %5.2f/%5.2f/%5.2f ms\n", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x); output.AppendFormat("G_MoveActors(): %.3f ms\n", g_moveActorsTime);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+FPS_YOFFSET, output.AppendFormat("G_MoveWorld(): %.3f ms\n", g_moveWorldTime);
FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "GU min/max/avg: %5.2f/%5.2f/%5.2f ms", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+40+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET,
FPS_COLOR(maxGameUpdate >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "G_MoveActors(): %.3e ms", g_moveActorsTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+50+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+50+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
chars = Bsprintf(tempbuf, "G_MoveWorld(): %.3e ms", g_moveWorldTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+60+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+60+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
} }
// lag meter // lag meter
if (g_netClientPeer) if (g_netClientPeer)
{ {
chars = Bsprintf(tempbuf, "%d +- %d ms", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2, output.AppendFormat("%d +- %d ms\n", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2,
(g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2); (g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+1+FPS_YOFFSET, FPS_COLOR(g_netClientPeer->lastRoundTripTime > 200), -1, tempbuf, x);
} }
} }
@ -786,6 +752,7 @@ static void G_PrintFPS(void)
frameCount++; frameCount++;
} }
lastFrameTime = frameTime; lastFrameTime = frameTime;
return output;
} }
#undef FPS_COLOR #undef FPS_COLOR
@ -1119,8 +1086,6 @@ void G_DisplayRest(int32_t smoothratio)
mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2)); mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
#endif #endif
G_PrintFPS();
// JBF 20040124: display level stats in screen corner // JBF 20040124: display level stats in screen corner
if (ud.overhead_on != 2 && hud_stats && VM_OnEvent(EVENT_DISPLAYLEVELSTATS, g_player[screenpeek].ps->i, screenpeek) == 0) if (ud.overhead_on != 2 && hud_stats && VM_OnEvent(EVENT_DISPLAYLEVELSTATS, g_player[screenpeek].ps->i, screenpeek) == 0)
{ {

View file

@ -673,10 +673,7 @@ void G_DoCheats(void)
return; return;
case CHEAT_RATE: case CHEAT_RATE:
r_showfps = r_showfps+1; r_showfps = clamp(*r_showfps+1, 0, 3);
if (r_showfps > 3)
r_showfps = 0;
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;

View file

@ -156,6 +156,7 @@ struct GameInterface : ::GameInterface
void set_hud_layout(int size) override; void set_hud_layout(int size) override;
void set_hud_scale(int size) override; void set_hud_scale(int size) override;
bool mouseInactiveConditional(bool condition) override; bool mouseInactiveConditional(bool condition) override;
FString statFPS() override;
}; };
END_RR_NS END_RR_NS

View file

@ -7942,7 +7942,7 @@ MAIN_LOOP_RESTART:
if (gameUpdate) if (gameUpdate)
{ {
g_gameUpdateAndDrawTime = timerGetHiTicks()-gameUpdateStartTime; g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
} }
} }

View file

@ -676,8 +676,9 @@ static void G_PrintCoords(int32_t snum)
#define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE) #define FPS_COLOR(x) ((x) ? COLOR_RED : COLOR_WHITE)
static void G_PrintFPS(void) FString GameInterface::statFPS()
{ {
FString output;
static int32_t frameCount; static int32_t frameCount;
static double cumulativeFrameDelay; static double cumulativeFrameDelay;
static double lastFrameTime; static double lastFrameTime;
@ -692,66 +693,31 @@ static void G_PrintFPS(void)
{ {
int32_t x = (xdim <= 640); int32_t x = (xdim <= 640);
if (r_showfps) //if (r_showfps)
{ {
int32_t chars = Bsprintf(tempbuf, "%.1f ms, %5.1f fps", frameDelay, lastFPS); output.AppendFormat("%.1f ms, %5.1f fps\n", frameDelay, lastFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+1+FPS_YOFFSET,
FPS_COLOR(lastFPS < LOW_FPS), -1, tempbuf, x);
if (r_showfps > 1) if (r_showfps > 1)
{ {
chars = Bsprintf(tempbuf, "max: %5.1f fps", maxFPS); output.AppendFormat("max: %5.1f fps\n", maxFPS);
output.AppendFormat("min: %5.1f fps\n", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+10+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+10+FPS_YOFFSET,
FPS_COLOR(maxFPS < LOW_FPS), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "min: %5.1f fps", minFPS);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+20+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET,
FPS_COLOR(minFPS < LOW_FPS), -1, tempbuf, x);
} }
if (r_showfps > 2) if (r_showfps > 2)
{ {
if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime;
if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime; if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime;
chars = Bsprintf(tempbuf, "Game Update: %2.2f ms + draw: %2.2f ms", g_gameUpdateTime, g_gameUpdateAndDrawTime); output.AppendFormat("Game Update: %2.2f ms + draw: %2.2f ms\n", g_gameUpdateTime, g_gameUpdateAndDrawTime - g_gameUpdateTime);
output.AppendFormat("GU min/max/avg: %5.2f/%5.2f/%5.2f ms\n", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x); output.AppendFormat("G_MoveActors(): %.3f ms\n", g_moveActorsTime);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+FPS_YOFFSET, output.AppendFormat("G_MoveWorld(): %.3f ms\n", g_moveWorldTime);
FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "GU min/max/avg: %5.2f/%5.2f/%5.2f ms", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+40+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET,
FPS_COLOR(maxGameUpdate >= SLOW_FRAME_TIME), -1, tempbuf, x);
chars = Bsprintf(tempbuf, "G_MoveActors(): %.3e ms", g_moveActorsTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+50+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+50+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
chars = Bsprintf(tempbuf, "G_MoveWorld(): %.3e ms", g_moveWorldTime);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+60+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+60+FPS_YOFFSET,
COLOR_WHITE, -1, tempbuf, x);
} }
// lag meter // lag meter
if (g_netClientPeer) if (g_netClientPeer)
{ {
chars = Bsprintf(tempbuf, "%d +- %d ms", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2, output.AppendFormat("%d +- %d ms\n", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2,
(g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance) / 2); (g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance) / 2);
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x);
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+1+FPS_YOFFSET, FPS_COLOR(g_netClientPeer->lastRoundTripTime > 200), -1, tempbuf, x);
} }
} }
@ -782,6 +748,7 @@ static void G_PrintFPS(void)
frameCount++; frameCount++;
} }
lastFrameTime = frameTime; lastFrameTime = frameTime;
return output;
} }
#undef FPS_COLOR #undef FPS_COLOR
@ -1123,8 +1090,6 @@ void G_DisplayRest(int32_t smoothratio)
mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2)); mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
#endif #endif
G_PrintFPS();
// JBF 20040124: display level stats in screen corner // JBF 20040124: display level stats in screen corner
if (ud.overhead_on != 2 && hud_stats) if (ud.overhead_on != 2 && hud_stats)
{ {