mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Slightly revise framerate limiter and r_showfps 2 display
git-svn-id: https://svn.eduke32.com/eduke32@7304 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1d74f4e944
commit
6ca492918e
7 changed files with 43 additions and 39 deletions
|
@ -117,7 +117,7 @@ int32_t g_levelTextTime = 0;
|
||||||
|
|
||||||
int32_t r_maxfps = 60;
|
int32_t r_maxfps = 60;
|
||||||
int32_t r_maxfpsoffset = 0;
|
int32_t r_maxfpsoffset = 0;
|
||||||
uint64_t g_frameDelay = 17;
|
double g_frameDelay = 0.0;
|
||||||
|
|
||||||
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
|
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
|
||||||
extern char forcegl;
|
extern char forcegl;
|
||||||
|
@ -1272,7 +1272,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
|
||||||
|
|
||||||
|
|
||||||
int32_t newSprite;
|
int32_t newSprite;
|
||||||
|
|
||||||
#ifdef NETCODE_DISABLE
|
#ifdef NETCODE_DISABLE
|
||||||
newSprite = insertsprite(whatsect, s_ss);
|
newSprite = insertsprite(whatsect, s_ss);
|
||||||
#else
|
#else
|
||||||
|
@ -6130,7 +6130,7 @@ void G_MaybeAllocPlayer(int32_t pnum)
|
||||||
|
|
||||||
int G_FPSLimit(void)
|
int G_FPSLimit(void)
|
||||||
{
|
{
|
||||||
static uint64_t nextPageTicks = 0;
|
static auto nextPageTicks = (double)timerGetTicksU64();
|
||||||
static unsigned frameWaiting = 0;
|
static unsigned frameWaiting = 0;
|
||||||
|
|
||||||
if (frameWaiting)
|
if (frameWaiting)
|
||||||
|
@ -6139,7 +6139,7 @@ int G_FPSLimit(void)
|
||||||
videoNextPage();
|
videoNextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t const frameTicks = timerGetTicksU64();
|
auto const frameTicks = (double)timerGetTicksU64();
|
||||||
|
|
||||||
if (!r_maxfps || frameTicks >= nextPageTicks)
|
if (!r_maxfps || frameTicks >= nextPageTicks)
|
||||||
{
|
{
|
||||||
|
@ -6556,6 +6556,7 @@ int app_main(int argc, char const * const * argv)
|
||||||
ud.setup.bpp = bpp;
|
ud.setup.bpp = bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset);
|
||||||
videoSetPalette(ud.brightness>>2, myplayer.palette, 0);
|
videoSetPalette(ud.brightness>>2, myplayer.palette, 0);
|
||||||
S_MusicStartup();
|
S_MusicStartup();
|
||||||
S_SoundStartup();
|
S_SoundStartup();
|
||||||
|
@ -6613,8 +6614,8 @@ MAIN_LOOP_RESTART:
|
||||||
{
|
{
|
||||||
OSD_Printf("Waiting for initial snapshot...");
|
OSD_Printf("Waiting for initial snapshot...");
|
||||||
Net_WaitForInitialSnapshot();
|
Net_WaitForInitialSnapshot();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||||
|
@ -6734,7 +6735,7 @@ MAIN_LOOP_RESTART:
|
||||||
OSD_DispatchQueued();
|
OSD_DispatchQueued();
|
||||||
|
|
||||||
char gameUpdate = false;
|
char gameUpdate = false;
|
||||||
uint32_t gameUpdateStartTime = timerGetTicks();
|
double const gameUpdateStartTime = timerGetHiTicks();
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||||
|
@ -6779,7 +6780,7 @@ MAIN_LOOP_RESTART:
|
||||||
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME);
|
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME);
|
||||||
|
|
||||||
gameUpdate = true;
|
gameUpdate = true;
|
||||||
g_gameUpdateTime = timerGetTicks()-gameUpdateStartTime;
|
g_gameUpdateTime = timerGetHiTicks()-gameUpdateStartTime;
|
||||||
if (g_gameUpdateAvgTime < 0.f)
|
if (g_gameUpdateAvgTime < 0.f)
|
||||||
g_gameUpdateAvgTime = g_gameUpdateTime;
|
g_gameUpdateAvgTime = g_gameUpdateTime;
|
||||||
g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES);
|
g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES);
|
||||||
|
@ -6816,7 +6817,7 @@ MAIN_LOOP_RESTART:
|
||||||
|
|
||||||
if (gameUpdate)
|
if (gameUpdate)
|
||||||
{
|
{
|
||||||
g_gameUpdateAndDrawTime = timerGetTicks()-gameUpdateStartTime;
|
g_gameUpdateAndDrawTime = timerGetHiTicks()-gameUpdateStartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,8 @@ extern int32_t MAXCACHE1DSIZE;
|
||||||
extern palette_t CrosshairColors;
|
extern palette_t CrosshairColors;
|
||||||
extern palette_t DefaultCrosshairColors;
|
extern palette_t DefaultCrosshairColors;
|
||||||
|
|
||||||
extern uint64_t g_frameDelay;
|
extern double g_frameDelay;
|
||||||
|
static inline double calcFrameDelay(int maxFPS) { return maxFPS ? ((double)timerGetFreqU64() / (double)(maxFPS)) : 0.0; }
|
||||||
|
|
||||||
int32_t A_CheckInventorySprite(spritetype *s);
|
int32_t A_CheckInventorySprite(spritetype *s);
|
||||||
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
|
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
|
||||||
|
|
|
@ -90,7 +90,7 @@ int32_t g_gametypeFlags[MAXGAMETYPES] =
|
||||||
GAMETYPE_TDMSPAWN,
|
GAMETYPE_TDMSPAWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
float g_gameUpdateAvgTime = -1.f;
|
double g_gameUpdateAvgTime = 0.001;
|
||||||
|
|
||||||
int32_t g_actorRespawnTime = 768;
|
int32_t g_actorRespawnTime = 768;
|
||||||
int32_t g_bouncemineRadius = 2500;
|
int32_t g_bouncemineRadius = 2500;
|
||||||
|
|
|
@ -160,10 +160,10 @@ G_EXTERN projectile_t SpriteProjectile[MAXSPRITES];
|
||||||
G_EXTERN sound_t g_sounds[MAXSOUNDS];
|
G_EXTERN sound_t g_sounds[MAXSOUNDS];
|
||||||
G_EXTERN uint32_t everyothertime;
|
G_EXTERN uint32_t everyothertime;
|
||||||
G_EXTERN uint32_t g_moveThingsCount;
|
G_EXTERN uint32_t g_moveThingsCount;
|
||||||
G_EXTERN uint32_t g_gameUpdateTime;
|
G_EXTERN double g_gameUpdateTime;
|
||||||
G_EXTERN uint32_t g_gameUpdateAndDrawTime;
|
G_EXTERN double g_gameUpdateAndDrawTime;
|
||||||
#define GAMEUPDATEAVGTIMENUMSAMPLES 100
|
#define GAMEUPDATEAVGTIMENUMSAMPLES 100
|
||||||
extern float g_gameUpdateAvgTime;
|
extern double g_gameUpdateAvgTime;
|
||||||
|
|
||||||
#ifndef global_c_
|
#ifndef global_c_
|
||||||
extern char CheatKeys[2];
|
extern char CheatKeys[2];
|
||||||
|
|
|
@ -3220,9 +3220,7 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entry == &ME_VIDEOSETUP_FRAMELIMIT)
|
else if (entry == &ME_VIDEOSETUP_FRAMELIMIT)
|
||||||
{
|
g_frameDelay = calcFrameDelay(newOption + r_maxfpsoffset);
|
||||||
g_frameDelay = (newOption + r_maxfpsoffset) ? (timerGetFreqU64()/(newOption + r_maxfpsoffset)) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (g_currentMenu)
|
switch (g_currentMenu)
|
||||||
{
|
{
|
||||||
|
@ -3330,7 +3328,7 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue)
|
||||||
else if (entry == &ME_JOYSTICKAXIS_SATU)
|
else if (entry == &ME_JOYSTICKAXIS_SATU)
|
||||||
joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue);
|
joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue);
|
||||||
else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET)
|
else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET)
|
||||||
g_frameDelay = (r_maxfps + newValue) ? (timerGetFreqU64()/(r_maxfps + newValue)) : 0;
|
g_frameDelay = calcFrameDelay(r_maxfps + newValue);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
|
||||||
else if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset"))
|
else if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset"))
|
||||||
{
|
{
|
||||||
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);
|
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);
|
||||||
g_frameDelay = r_maxfps ? (timerGetFreqU64()/(r_maxfps + r_maxfpsoffset)) : 0;
|
g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset);
|
||||||
}
|
}
|
||||||
else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
|
else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -773,7 +773,7 @@ static void G_ShowCacheLocks(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOW_FPS 60
|
#define LOW_FPS ((videoGetRenderMode() == REND_CLASSIC) ? 35 : 50)
|
||||||
#define SLOW_FRAME_TIME 20
|
#define SLOW_FRAME_TIME 20
|
||||||
|
|
||||||
#if defined GEKKO
|
#if defined GEKKO
|
||||||
|
@ -786,12 +786,14 @@ static void G_ShowCacheLocks(void)
|
||||||
|
|
||||||
static void G_PrintFPS(void)
|
static void G_PrintFPS(void)
|
||||||
{
|
{
|
||||||
static int32_t frameCount = 0, lastFPS = 0, lastFrameTime = 0, cumulativeFrameDelay = 0;
|
static int32_t frameCount;
|
||||||
static int32_t minFPS = -1, maxFPS = 0;
|
static double cumulativeFrameDelay;
|
||||||
static uint32_t minGameUpdate = -1, maxGameUpdate = 0;
|
static double lastFrameTime;
|
||||||
|
static float lastFPS, minFPS = FLT_MAX, maxFPS;
|
||||||
|
static double minGameUpdate = DBL_MAX, maxGameUpdate;
|
||||||
|
|
||||||
int32_t frameTime = timerGetTicks();
|
double frameTime = timerGetHiTicks();
|
||||||
int32_t frameDelay = frameTime - lastFrameTime;
|
double frameDelay = frameTime - lastFrameTime;
|
||||||
cumulativeFrameDelay += frameDelay;
|
cumulativeFrameDelay += frameDelay;
|
||||||
|
|
||||||
if (frameDelay >= 0)
|
if (frameDelay >= 0)
|
||||||
|
@ -800,7 +802,7 @@ static void G_PrintFPS(void)
|
||||||
|
|
||||||
if (ud.showfps)
|
if (ud.showfps)
|
||||||
{
|
{
|
||||||
int32_t chars = Bsprintf(tempbuf, "%d ms (%3d fps)", frameDelay, lastFPS);
|
int32_t chars = Bsprintf(tempbuf, "%.1f ms, %5.1f fps", frameDelay, lastFPS);
|
||||||
|
|
||||||
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+2+FPS_YOFFSET, 0, -1, tempbuf, x);
|
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,
|
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+1+FPS_YOFFSET,
|
||||||
|
@ -808,13 +810,13 @@ static void G_PrintFPS(void)
|
||||||
|
|
||||||
if (ud.showfps > 1)
|
if (ud.showfps > 1)
|
||||||
{
|
{
|
||||||
chars = Bsprintf(tempbuf, "max fps: %3d", maxFPS);
|
chars = Bsprintf(tempbuf, "max: %5.1f fps", maxFPS);
|
||||||
|
|
||||||
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+10+2+FPS_YOFFSET, 0, -1, tempbuf, x);
|
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,
|
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+10+FPS_YOFFSET,
|
||||||
FPS_COLOR(maxFPS < LOW_FPS), -1, tempbuf, x);
|
FPS_COLOR(maxFPS < LOW_FPS), -1, tempbuf, x);
|
||||||
|
|
||||||
chars = Bsprintf(tempbuf, "min fps: %3d", minFPS);
|
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))+1, windowxy1.y+20+2+FPS_YOFFSET, 0, -1, tempbuf, x);
|
||||||
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET,
|
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET,
|
||||||
|
@ -825,13 +827,13 @@ static void G_PrintFPS(void)
|
||||||
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: %2u ms + draw: %2u ms", g_gameUpdateTime, g_gameUpdateAndDrawTime);
|
chars = Bsprintf(tempbuf, "Game Update: %2.2f ms + draw: %2.2f ms", g_gameUpdateTime, g_gameUpdateAndDrawTime);
|
||||||
|
|
||||||
printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x);
|
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+FPS_YOFFSET,
|
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+FPS_YOFFSET,
|
||||||
FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x);
|
FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x);
|
||||||
|
|
||||||
chars = Bsprintf(tempbuf, "GU min/max/avg: %2u/%2u/%5.2f ms", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime);
|
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))+1, windowxy1.y+40+2+FPS_YOFFSET, 0, -1, tempbuf, x);
|
||||||
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET,
|
printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET,
|
||||||
|
@ -861,24 +863,26 @@ static void G_PrintFPS(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cumulativeFrameDelay >= 1000)
|
if (cumulativeFrameDelay >= 1000.0)
|
||||||
{
|
{
|
||||||
g_frameRate = lastFPS = tabledivide32_noinline(1000*frameCount, cumulativeFrameDelay);
|
lastFPS = 1000.f * frameCount / cumulativeFrameDelay;
|
||||||
|
g_frameRate = Blrintf(lastFPS);
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
cumulativeFrameDelay = 0;
|
cumulativeFrameDelay = 0.0;
|
||||||
|
|
||||||
if (ud.showfps > 1)
|
if (ud.showfps > 1)
|
||||||
{
|
{
|
||||||
if (lastFPS > maxFPS) maxFPS = lastFPS;
|
if (lastFPS > maxFPS) maxFPS = lastFPS;
|
||||||
if ((unsigned) lastFPS < (unsigned) minFPS) minFPS = lastFPS;
|
if (lastFPS < minFPS) minFPS = lastFPS;
|
||||||
|
|
||||||
static int secondCounter;
|
static int secondCounter;
|
||||||
|
|
||||||
if (++secondCounter == 3)
|
if (++secondCounter == 1)
|
||||||
{
|
{
|
||||||
maxFPS = (lastFPS + maxFPS) >> 1;
|
maxFPS = (lastFPS + maxFPS) * .5f;
|
||||||
minFPS = (lastFPS + minFPS) >> 1;
|
minFPS = (lastFPS + minFPS) * .5f;
|
||||||
maxGameUpdate = (g_gameUpdateTime + maxGameUpdate) >> 1;
|
maxGameUpdate = (g_gameUpdateTime + maxGameUpdate) * 0.5;
|
||||||
minGameUpdate = (g_gameUpdateTime + minGameUpdate) >> 1;
|
minGameUpdate = (g_gameUpdateTime + minGameUpdate) * 0.5;
|
||||||
secondCounter = 0;
|
secondCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue