mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- statistics output
This commit is contained in:
parent
a3a8286857
commit
d6e021a63d
9 changed files with 95 additions and 135 deletions
|
@ -95,7 +95,7 @@ int connecthead, connectpoint2[MAXMULTIPLAYERS];
|
|||
int32_t xres = -1, yres = -1, bpp = 0;
|
||||
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
|
||||
|
||||
glcycle_t thinktime, actortime;
|
||||
glcycle_t thinktime, actortime, gameupdatetime, drawtime;
|
||||
|
||||
|
||||
MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts.
|
||||
|
|
|
@ -276,7 +276,7 @@ void GameInterface::MenuClosed()
|
|||
g_cameraDistance = 65536;
|
||||
}
|
||||
|
||||
G_UpdateScreenArea();
|
||||
updateviewport();
|
||||
S_PauseSounds(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,51 @@ BEGIN_DUKE_NS
|
|||
FFont* IndexFont;
|
||||
FFont* DigiFont;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// debug output
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FString GameInterface::GetCoordString()
|
||||
{
|
||||
int snum = screenpeek;
|
||||
FString out;
|
||||
|
||||
out.Format("pos= %d, %d, %d - angle = %2.3f - sector = %d, lotag = %d, hitag = %d",
|
||||
ps[snum].posx, ps[snum].posy, ps[snum].posz, ps[snum].q16ang / 65536., ps[snum].cursectnum,
|
||||
sector[ps[snum].cursectnum].lotag, sector[ps[snum].cursectnum].hitag);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
GameStats GameInterface::getStats()
|
||||
{
|
||||
struct player_struct* p = &ps[myconnectindex];
|
||||
return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC, p->frag };
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FString GameInterface::statFPS()
|
||||
{
|
||||
FString output;
|
||||
|
||||
output.AppendFormat("Actor think time: %.3f ms\n", actortime.TimeMS());
|
||||
output.AppendFormat("Total think time: %.3f ms\n", thinktime.TimeMS());
|
||||
output.AppendFormat("Game Update: %.3f ms\n", gameupdatetime.TimeMS());
|
||||
output.AppendFormat("Draw time: %.3f ms\n", drawtime.TimeMS());
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// game specific command line args go here.
|
||||
|
@ -171,7 +216,8 @@ void genspriteremaps(void)
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// This now redirects the messagew to the console's notification display
|
||||
// which has all the features to reasonably do this in Duke style.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -392,6 +392,11 @@ inline int PlayerInputForwardVel(int pl)
|
|||
return g_player[pl].input->fvel;
|
||||
}
|
||||
|
||||
inline fixed_t PlayerInputAngVel(int pl)
|
||||
{
|
||||
return g_player[pl].input->q16avel;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
kHitTypeMask = 0xC000,
|
||||
|
|
|
@ -2602,12 +2602,12 @@ void processinput_d(int snum)
|
|||
g_player[snum].horizAngleAdjust = 0;
|
||||
g_player[snum].horizSkew = 0;
|
||||
|
||||
if (p->cheat_phase <= 0) sb_snum = g_player[snum].input->bits;// sync[snum].bits;
|
||||
if (p->cheat_phase <= 0) sb_snum = PlayerInputBits(snum, ~0);
|
||||
else sb_snum = 0;
|
||||
|
||||
auto sb_fvel = g_player[snum].input->fvel; // TRANSITIONAL
|
||||
auto sb_svel = g_player[snum].input->svel;
|
||||
auto sb_avel = g_player[snum].input->q16avel;
|
||||
auto sb_fvel = PlayerInputForwardVel(snum);
|
||||
auto sb_svel = PlayerInputSideVel(snum);
|
||||
auto sb_avel = PlayerInputAngVel(snum);
|
||||
|
||||
psect = p->cursectnum;
|
||||
if (psect == -1)
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
# include "namesdyn.h"
|
||||
#include "stats.h"
|
||||
|
||||
extern glcycle_t actortime, thinktime;
|
||||
extern glcycle_t drawtime, actortime, thinktime, gameupdatetime;
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
|
|
@ -2006,7 +2006,8 @@ MAIN_LOOP_RESTART:
|
|||
OSD_DispatchQueued();
|
||||
|
||||
char gameUpdate = false;
|
||||
double const gameUpdateStartTime = timerGetHiTicks();
|
||||
gameupdatetime.Reset();
|
||||
gameupdatetime.Clock();
|
||||
|
||||
while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||
{
|
||||
|
@ -2043,10 +2044,7 @@ MAIN_LOOP_RESTART:
|
|||
}
|
||||
|
||||
gameUpdate = true;
|
||||
g_gameUpdateTime = timerGetHiTicks()-gameUpdateStartTime;
|
||||
if (g_gameUpdateAvgTime < 0.f)
|
||||
g_gameUpdateAvgTime = g_gameUpdateTime;
|
||||
g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES);
|
||||
gameupdatetime.Unclock();
|
||||
|
||||
G_DoCheats();
|
||||
|
||||
|
@ -2071,17 +2069,14 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
int const smoothRatio = calc_smoothratio(totalclock, ototalclock);
|
||||
|
||||
drawtime.Reset();
|
||||
drawtime.Clock();
|
||||
G_DrawRooms(screenpeek, smoothRatio);
|
||||
if (videoGetRenderMode() >= REND_POLYMOST)
|
||||
drawbackground();
|
||||
G_DisplayRest(smoothRatio);
|
||||
drawtime.Unclock();
|
||||
videoNextPage();
|
||||
|
||||
if (gameUpdate)
|
||||
{
|
||||
g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (g_player[myconnectindex].ps->gm&MODE_DEMO)
|
||||
|
|
|
@ -159,121 +159,6 @@ static inline void G_MoveClouds(void)
|
|||
}
|
||||
|
||||
|
||||
FString G_PrintCoords(int32_t snum)
|
||||
{
|
||||
const int32_t x = g_Debug ? 288 : 0;
|
||||
int32_t y = 0;
|
||||
|
||||
auto const ps = g_player[snum].ps;
|
||||
const int32_t sectnum = ps->cursectnum;
|
||||
|
||||
if ((g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR))
|
||||
{
|
||||
if (ud.multimode > 4)
|
||||
y = 32;
|
||||
else if (g_netServer || ud.multimode > 1)
|
||||
y = 24;
|
||||
}
|
||||
FString out;
|
||||
|
||||
out.AppendFormat("XYZ= (%d, %d, %d)\n", ps->pos.x, ps->pos.y, ps->pos.z);
|
||||
char ang[16], horiz[16], horizoff[16];
|
||||
fix16_to_str(ps->q16ang, ang, 2);
|
||||
fix16_to_str(ps->q16horiz, horiz, 2);
|
||||
fix16_to_str(ps->q16horizoff, horizoff, 2);
|
||||
out.AppendFormat("A/H/HO= %s, %s, %s\n", ang, horiz, horizoff);
|
||||
out.AppendFormat("VEL= (%d, %d, %d) + (%d, %d, 0)\n", ps->vel.x >> 14, ps->vel.y >> 14, ps->vel.z, ps->fric.x >> 5, ps->fric.y >> 5);
|
||||
out.AppendFormat("OG= %d SBRIDGE=%d SBS=%d\n", ps->on_ground, ps->spritebridge, ps->sbs);
|
||||
if (sectnum >= 0)
|
||||
out.AppendFormat("SECT= %d (LO=%d EX=%d)\n", sectnum, TrackerCast(sector[sectnum].lotag), TrackerCast(sector[sectnum].extra));
|
||||
else
|
||||
out.AppendFormat("SECT= %d\n", sectnum);
|
||||
|
||||
out.AppendFormat("\nTHOLD= %d ", ps->transporter_hold);
|
||||
out.AppendFormat("GAMETIC= %u, TOTALCLOCK=%d\n", g_moveThingsCount, (int32_t)totalclock);
|
||||
out.AppendFormat("\nVR=%.03f YX=%.03f", (double)dr_viewingrange / 65536.0, (double)dr_yxaspect / 65536.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
FString GameInterface::GetCoordString()
|
||||
{
|
||||
return G_PrintCoords(screenpeek);
|
||||
}
|
||||
|
||||
|
||||
FString GameInterface::statFPS()
|
||||
{
|
||||
FString output;
|
||||
static int32_t frameCount;
|
||||
static double cumulativeFrameDelay;
|
||||
static double lastFrameTime;
|
||||
static float lastFPS, minFPS = FLT_MAX, maxFPS;
|
||||
static double minGameUpdate = DBL_MAX, maxGameUpdate;
|
||||
|
||||
double frameTime = timerGetHiTicks();
|
||||
double frameDelay = frameTime - lastFrameTime;
|
||||
cumulativeFrameDelay += frameDelay;
|
||||
|
||||
if (frameDelay >= 0)
|
||||
{
|
||||
int32_t x = (xdim <= 640);
|
||||
|
||||
//if (r_showfps)
|
||||
{
|
||||
output.AppendFormat("%.1f ms, %5.1f fps\n", frameDelay, lastFPS);
|
||||
|
||||
if (r_showfps > 1)
|
||||
{
|
||||
output.AppendFormat("max: %5.1f fps\n", maxFPS);
|
||||
output.AppendFormat("min: %5.1f fps\n", minFPS);
|
||||
}
|
||||
if (r_showfps > 2)
|
||||
{
|
||||
if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime;
|
||||
if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime;
|
||||
|
||||
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);
|
||||
output.AppendFormat("actor think time: %.3f ms\n", actortime.TimeMS());
|
||||
output.AppendFormat("total think timn: %.3f ms\n", thinktime.TimeMS());
|
||||
}
|
||||
}
|
||||
|
||||
if (cumulativeFrameDelay >= 1000.0)
|
||||
{
|
||||
lastFPS = 1000.f * frameCount / cumulativeFrameDelay;
|
||||
g_frameRate = Blrintf(lastFPS);
|
||||
frameCount = 0;
|
||||
cumulativeFrameDelay = 0.0;
|
||||
|
||||
if (r_showfps > 1)
|
||||
{
|
||||
if (lastFPS > maxFPS) maxFPS = lastFPS;
|
||||
if (lastFPS < minFPS) minFPS = lastFPS;
|
||||
|
||||
static int secondCounter;
|
||||
|
||||
if (++secondCounter >= r_showfpsperiod)
|
||||
{
|
||||
maxFPS = (lastFPS + maxFPS) * .5f;
|
||||
minFPS = (lastFPS + minFPS) * .5f;
|
||||
maxGameUpdate = (g_gameUpdateTime + maxGameUpdate) * 0.5;
|
||||
minGameUpdate = (g_gameUpdateTime + minGameUpdate) * 0.5;
|
||||
secondCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
frameCount++;
|
||||
}
|
||||
lastFrameTime = frameTime;
|
||||
return output;
|
||||
}
|
||||
|
||||
GameStats GameInterface::getStats()
|
||||
{
|
||||
DukePlayer_t* p = g_player[myconnectindex].ps;
|
||||
return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC, p->frag };
|
||||
}
|
||||
|
||||
void displayweapon(int snum);
|
||||
|
||||
|
|
|
@ -415,12 +415,41 @@ void renderFinishScene()
|
|||
//==========================================================================
|
||||
CVAR(Bool, vid_fps, false, 0)
|
||||
|
||||
|
||||
static FString statFPS()
|
||||
{
|
||||
static int32_t frameCount;
|
||||
static double lastFrameTime;
|
||||
static double cumulativeFrameDelay;
|
||||
static double lastFPS;
|
||||
|
||||
FString output;
|
||||
|
||||
double frameTime = I_msTimeF();
|
||||
double frameDelay = frameTime - lastFrameTime;
|
||||
cumulativeFrameDelay += frameDelay;
|
||||
|
||||
if (frameDelay >= 0)
|
||||
{
|
||||
output.AppendFormat("%5.1f fps (%.1f ms)\n", lastFPS, frameDelay);
|
||||
|
||||
if (cumulativeFrameDelay >= 1000.0)
|
||||
{
|
||||
lastFPS = 1000.f * frameCount / cumulativeFrameDelay;
|
||||
frameCount = 0;
|
||||
cumulativeFrameDelay = 0.0;
|
||||
}
|
||||
}
|
||||
lastFrameTime = frameTime;
|
||||
return output;
|
||||
}
|
||||
|
||||
void DrawRateStuff()
|
||||
{
|
||||
// Draws frame time and cumulative fps
|
||||
if (vid_fps)
|
||||
{
|
||||
FString fpsbuff = gi->statFPS();
|
||||
FString fpsbuff = statFPS();
|
||||
|
||||
int textScale = active_con_scale(twod);
|
||||
int rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]);
|
||||
|
|
Loading…
Reference in a new issue