Commit b72789b0 by James R.

Huge perfstats refactor

I needed to update it to make it functional with the precise timer. But I also got sick of looking at the mess of sprintf followed by draw call.
parent e5f37523
......@@ -5445,14 +5445,14 @@ void TryRunTics(tic_t realtics)
{
DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic));
ps_tictime = I_GetTimeMicros();
ps_tictime = I_GetPreciseTime();
G_Ticker((gametic % NEWTICRATERATIO) == 0);
ExtraDataTicker();
gametic++;
consistancy[gametic%BACKUPTICS] = Consistancy();
ps_tictime = I_GetTimeMicros() - ps_tictime;
ps_tictime = I_GetPreciseTime() - ps_tictime;
// Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame.
if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value)
......
......@@ -436,7 +436,7 @@ static void D_Display(void)
if (!automapactive && !dedicated && cv_renderview.value)
{
ps_rendercalltime = I_GetTimeMicros();
ps_rendercalltime = I_GetPreciseTime();
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD)
{
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
......@@ -483,7 +483,7 @@ static void D_Display(void)
if (postimgtype2)
V_DoPostProcessor(1, postimgtype2, postimgparam2);
}
ps_rendercalltime = I_GetTimeMicros() - ps_rendercalltime;
ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime;
}
if (lastdraw)
......@@ -497,7 +497,7 @@ static void D_Display(void)
lastdraw = false;
}
ps_uitime = I_GetTimeMicros();
ps_uitime = I_GetPreciseTime();
if (gamestate == GS_LEVEL)
{
......@@ -510,7 +510,7 @@ static void D_Display(void)
}
else
{
ps_uitime = I_GetTimeMicros();
ps_uitime = I_GetPreciseTime();
}
}
......@@ -552,7 +552,7 @@ static void D_Display(void)
CON_Drawer();
ps_uitime = I_GetTimeMicros() - ps_uitime;
ps_uitime = I_GetPreciseTime() - ps_uitime;
//
// wipe update
......@@ -638,9 +638,9 @@ static void D_Display(void)
M_DrawPerfStats();
}
ps_swaptime = I_GetTimeMicros();
ps_swaptime = I_GetPreciseTime();
I_FinishUpdate(); // page flip or blit buffer
ps_swaptime = I_GetTimeMicros() - ps_swaptime;
ps_swaptime = I_GetPreciseTime() - ps_swaptime;
}
needpatchflush = false;
......
......@@ -248,12 +248,12 @@ void HWR_RenderBatches(void)
}
// sort polygons
ps_hw_batchsorttime = I_GetTimeMicros();
ps_hw_batchsorttime = I_GetPreciseTime();
if (cv_glshaders.value && gl_shadersavailable)
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons);
else
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders);
ps_hw_batchsorttime = I_GetTimeMicros() - ps_hw_batchsorttime;
ps_hw_batchsorttime = I_GetPreciseTime() - ps_hw_batchsorttime;
// sort order
// 1. shader
// 2. texture
......@@ -261,7 +261,7 @@ void HWR_RenderBatches(void)
// 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters
ps_hw_batchdrawtime = I_GetTimeMicros();
ps_hw_batchdrawtime = I_GetPreciseTime();
currentShader = polygonArray[polygonIndexArray[0]].shader;
currentTexture = polygonArray[polygonIndexArray[0]].texture;
......@@ -446,7 +446,7 @@ void HWR_RenderBatches(void)
polygonArraySize = 0;
unsortedVertexArraySize = 0;
ps_hw_batchdrawtime = I_GetTimeMicros() - ps_hw_batchdrawtime;
ps_hw_batchdrawtime = I_GetPreciseTime() - ps_hw_batchdrawtime;
}
......
......@@ -146,11 +146,11 @@ static angle_t gl_aimingangle;
static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox);
// Render stats
int ps_hw_skyboxtime = 0;
int ps_hw_nodesorttime = 0;
int ps_hw_nodedrawtime = 0;
int ps_hw_spritesorttime = 0;
int ps_hw_spritedrawtime = 0;
precise_t ps_hw_skyboxtime = 0;
precise_t ps_hw_nodesorttime = 0;
precise_t ps_hw_nodedrawtime = 0;
precise_t ps_hw_spritesorttime = 0;
precise_t ps_hw_spritedrawtime = 0;
// Render stats for batching
int ps_hw_numpolys = 0;
......@@ -160,8 +160,8 @@ int ps_hw_numshaders = 0;
int ps_hw_numtextures = 0;
int ps_hw_numpolyflags = 0;
int ps_hw_numcolors = 0;
int ps_hw_batchsorttime = 0;
int ps_hw_batchdrawtime = 0;
precise_t ps_hw_batchsorttime = 0;
precise_t ps_hw_batchdrawtime = 0;
boolean gl_shadersavailable = true;
......@@ -4503,7 +4503,7 @@ static void HWR_CreateDrawNodes(void)
// that is already lying around. This should all be in some sort of linked list or lists.
sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL);
ps_hw_nodesorttime = I_GetTimeMicros();
ps_hw_nodesorttime = I_GetPreciseTime();
for (i = 0; i < numplanes; i++, p++)
{
......@@ -4558,9 +4558,9 @@ static void HWR_CreateDrawNodes(void)
}
}
ps_hw_nodesorttime = I_GetTimeMicros() - ps_hw_nodesorttime;
ps_hw_nodesorttime = I_GetPreciseTime() - ps_hw_nodesorttime;
ps_hw_nodedrawtime = I_GetTimeMicros();
ps_hw_nodedrawtime = I_GetPreciseTime();
// Okay! Let's draw it all! Woo!
HWD.pfnSetTransform(&atransform);
......@@ -4597,7 +4597,7 @@ static void HWR_CreateDrawNodes(void)
}
}
ps_hw_nodedrawtime = I_GetTimeMicros() - ps_hw_nodedrawtime;
ps_hw_nodedrawtime = I_GetPreciseTime() - ps_hw_nodedrawtime;
numwalls = 0;
numplanes = 0;
......@@ -5778,10 +5778,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
if (viewnumber == 0) // Only do it if it's the first screen being rendered
HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
ps_hw_skyboxtime = I_GetTimeMicros();
ps_hw_skyboxtime = I_GetPreciseTime();
if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox
HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind
ps_hw_skyboxtime = I_GetTimeMicros() - ps_hw_skyboxtime;
ps_hw_skyboxtime = I_GetPreciseTime() - ps_hw_skyboxtime;
{
// do we really need to save player (is it not the same)?
......@@ -5894,7 +5894,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
ps_numbspcalls = 0;
ps_numpolyobjects = 0;
ps_bsptime = I_GetTimeMicros();
ps_bsptime = I_GetPreciseTime();
validcount++;
......@@ -5932,7 +5932,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
}
#endif
ps_bsptime = I_GetTimeMicros() - ps_bsptime;
ps_bsptime = I_GetPreciseTime() - ps_bsptime;
if (cv_glbatching.value)
HWR_RenderBatches();
......@@ -5948,12 +5948,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
// Draw MD2 and sprites
ps_numsprites = gl_visspritecount;
ps_hw_spritesorttime = I_GetTimeMicros();
ps_hw_spritesorttime = I_GetPreciseTime();
HWR_SortVisSprites();
ps_hw_spritesorttime = I_GetTimeMicros() - ps_hw_spritesorttime;
ps_hw_spritedrawtime = I_GetTimeMicros();
ps_hw_spritesorttime = I_GetPreciseTime() - ps_hw_spritesorttime;
ps_hw_spritedrawtime = I_GetPreciseTime();
HWR_DrawSprites();
ps_hw_spritedrawtime = I_GetTimeMicros() - ps_hw_spritedrawtime;
ps_hw_spritedrawtime = I_GetPreciseTime() - ps_hw_spritedrawtime;
#ifdef NEWCORONAS
//Hurdler: they must be drawn before translucent planes, what about gl fog?
......
......@@ -113,11 +113,11 @@ extern FTransform atransform;
// Render stats
extern int ps_hw_skyboxtime;
extern int ps_hw_nodesorttime;
extern int ps_hw_nodedrawtime;
extern int ps_hw_spritesorttime;
extern int ps_hw_spritedrawtime;
extern precise_t ps_hw_skyboxtime;
extern precise_t ps_hw_nodesorttime;
extern precise_t ps_hw_nodedrawtime;
extern precise_t ps_hw_spritesorttime;
extern precise_t ps_hw_spritedrawtime;
// Render stats for batching
extern int ps_hw_numpolys;
......@@ -127,8 +127,8 @@ extern int ps_hw_numshaders;
extern int ps_hw_numtextures;
extern int ps_hw_numpolyflags;
extern int ps_hw_numcolors;
extern int ps_hw_batchsorttime;
extern int ps_hw_batchdrawtime;
extern precise_t ps_hw_batchsorttime;
extern precise_t ps_hw_batchdrawtime;
extern boolean gl_shadersavailable;
......
......@@ -25,7 +25,7 @@
#include "m_perfstats.h"
#include "d_netcmd.h" // for cv_perfstats
#include "i_system.h" // I_GetTimeMicros
#include "i_system.h" // I_GetPreciseTime
static UINT8 hooksAvailable[(hook_MAX/8)+1];
......@@ -480,7 +480,7 @@ void LUAh_ThinkFrame(void)
continue;
if (cv_perfstats.value == 3)
time_taken = I_GetTimeMicros();
time_taken = I_GetPreciseTime();
PushHook(gL, hookp);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
......@@ -491,7 +491,7 @@ void LUAh_ThinkFrame(void)
if (cv_perfstats.value == 3)
{
lua_Debug ar;
time_taken = I_GetTimeMicros() - time_taken;
time_taken = I_GetPreciseTime() - time_taken;
// we need the function, let's just retrieve it again
PushHook(gL, hookp);
lua_getinfo(gL, ">S", &ar);
......
......@@ -16,17 +16,17 @@
#include "lua_script.h"
#include "p_local.h"
extern int ps_tictime;
extern precise_t ps_tictime;
extern int ps_playerthink_time;
extern int ps_thinkertime;
extern precise_t ps_playerthink_time;
extern precise_t ps_thinkertime;
extern int ps_thlist_times[];
extern precise_t ps_thlist_times[];
extern int ps_checkposition_calls;
extern int ps_checkposition_calls;
extern int ps_lua_thinkframe_time;
extern int ps_lua_mobjhooks;
extern precise_t ps_lua_thinkframe_time;
extern int ps_lua_mobjhooks;
typedef struct
{
......
......@@ -22,7 +22,7 @@
#include "lua_script.h"
#include "lua_hook.h"
#include "m_perfstats.h"
#include "i_system.h" // I_GetTimeMicros
#include "i_system.h" // I_GetPreciseTime
// Object place
#include "m_cheat.h"
......@@ -323,7 +323,7 @@ static inline void P_RunThinkers(void)
size_t i;
for (i = 0; i < NUM_THINKERLISTS; i++)
{
ps_thlist_times[i] = I_GetTimeMicros();
ps_thlist_times[i] = I_GetPreciseTime();
for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next)
{
#ifdef PARANOIA
......@@ -331,7 +331,7 @@ static inline void P_RunThinkers(void)
#endif
currentthinker->function.acp1(currentthinker);
}
ps_thlist_times[i] = I_GetTimeMicros() - ps_thlist_times[i];
ps_thlist_times[i] = I_GetPreciseTime() - ps_thlist_times[i];
}
}
......@@ -650,11 +650,11 @@ void P_Ticker(boolean run)
LUAh_PreThinkFrame();
ps_playerthink_time = I_GetTimeMicros();
ps_playerthink_time = I_GetPreciseTime();
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerThink(&players[i]);
ps_playerthink_time = I_GetTimeMicros() - ps_playerthink_time;
ps_playerthink_time = I_GetPreciseTime() - ps_playerthink_time;
}
// Keep track of how long they've been playing!
......@@ -669,18 +669,18 @@ void P_Ticker(boolean run)
if (run)
{
ps_thinkertime = I_GetTimeMicros();
ps_thinkertime = I_GetPreciseTime();
P_RunThinkers();
ps_thinkertime = I_GetTimeMicros() - ps_thinkertime;
ps_thinkertime = I_GetPreciseTime() - ps_thinkertime;
// Run any "after all the other thinkers" stuff
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]);
ps_lua_thinkframe_time = I_GetTimeMicros();
ps_lua_thinkframe_time = I_GetPreciseTime();
LUAh_ThinkFrame();
ps_lua_thinkframe_time = I_GetTimeMicros() - ps_lua_thinkframe_time;
ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time;
}
// Run shield positioning
......
......@@ -34,7 +34,7 @@
#include "m_random.h" // quake camera shake
#include "r_portal.h"
#include "r_main.h"
#include "i_system.h" // I_GetTimeMicros
#include "i_system.h" // I_GetPreciseTime
#ifdef HWRENDER
#include "hardware/hw_main.h"
......@@ -100,17 +100,17 @@ lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
extracolormap_t *extra_colormaps = NULL;
// Render stats
int ps_prevframetime = 0;
int ps_rendercalltime = 0;
int ps_uitime = 0;
int ps_swaptime = 0;
precise_t ps_prevframetime = 0;
precise_t ps_rendercalltime = 0;
precise_t ps_uitime = 0;
precise_t ps_swaptime = 0;
int ps_bsptime = 0;
precise_t ps_bsptime = 0;
int ps_sw_spritecliptime = 0;
int ps_sw_portaltime = 0;
int ps_sw_planetime = 0;
int ps_sw_maskedtime = 0;
precise_t ps_sw_spritecliptime = 0;
precise_t ps_sw_portaltime = 0;
precise_t ps_sw_planetime = 0;
precise_t ps_sw_maskedtime = 0;
int ps_numbspcalls = 0;
int ps_numsprites = 0;
......@@ -1491,9 +1491,9 @@ void R_RenderPlayerView(player_t *player)
ProfZeroTimer();
#endif
ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0;
ps_bsptime = I_GetTimeMicros();
ps_bsptime = I_GetPreciseTime();
R_RenderBSPNode((INT32)numnodes - 1);
ps_bsptime = I_GetTimeMicros() - ps_bsptime;
ps_bsptime = I_GetPreciseTime() - ps_bsptime;
ps_numsprites = visspritecount;
#ifdef TIMING
RDMSR(0x10, &mycount);
......@@ -1504,9 +1504,9 @@ void R_RenderPlayerView(player_t *player)
//profile stuff ---------------------------------------------------------
Mask_Post(&masks[nummasks - 1]);
ps_sw_spritecliptime = I_GetTimeMicros();
ps_sw_spritecliptime = I_GetPreciseTime();
R_ClipSprites(drawsegs, NULL);
ps_sw_spritecliptime = I_GetTimeMicros() - ps_sw_spritecliptime;
ps_sw_spritecliptime = I_GetPreciseTime() - ps_sw_spritecliptime;
// Add skybox portals caused by sky visplanes.
......@@ -1514,7 +1514,7 @@ void R_RenderPlayerView(player_t *player)
Portal_AddSkyboxPortals();
// Portal rendering. Hijacks the BSP traversal.
ps_sw_portaltime = I_GetTimeMicros();
ps_sw_portaltime = I_GetPreciseTime();
if (portal_base)
{
portal_t *portal;
......@@ -1554,20 +1554,20 @@ void R_RenderPlayerView(player_t *player)
Portal_Remove(portal);
}
}
ps_sw_portaltime = I_GetTimeMicros() - ps_sw_portaltime;
ps_sw_portaltime = I_GetPreciseTime() - ps_sw_portaltime;
ps_sw_planetime = I_GetTimeMicros();
ps_sw_planetime = I_GetPreciseTime();
R_DrawPlanes();
#ifdef FLOORSPLATS
R_DrawVisibleFloorSplats();
#endif
ps_sw_planetime = I_GetTimeMicros() - ps_sw_planetime;
ps_sw_planetime = I_GetPreciseTime() - ps_sw_planetime;
// draw mid texture and sprite
// And now 3D floors/sides!
ps_sw_maskedtime = I_GetTimeMicros();
ps_sw_maskedtime = I_GetPreciseTime();
R_DrawMasked(masks, nummasks);
ps_sw_maskedtime = I_GetTimeMicros() - ps_sw_maskedtime;
ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime;
free(masks);
}
......
......@@ -78,17 +78,17 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
// Render stats
extern int ps_prevframetime;// time when previous frame was rendered
extern int ps_rendercalltime;
extern int ps_uitime;
extern int ps_swaptime;
extern precise_t ps_prevframetime;// time when previous frame was rendered
extern precise_t ps_rendercalltime;
extern precise_t ps_uitime;
extern precise_t ps_swaptime;
extern int ps_bsptime;
extern precise_t ps_bsptime;
extern int ps_sw_spritecliptime;
extern int ps_sw_portaltime;
extern int ps_sw_planetime;
extern int ps_sw_maskedtime;
extern precise_t ps_sw_spritecliptime;
extern precise_t ps_sw_portaltime;
extern precise_t ps_sw_planetime;
extern precise_t ps_sw_maskedtime;
extern int ps_numbspcalls;
extern int ps_numsprites;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment