mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-21 03:11:03 +00:00
Perfstats averaging and refactor
This commit is contained in:
parent
2d8230cb27
commit
77ecfb9cdc
17 changed files with 840 additions and 555 deletions
|
@ -4974,16 +4974,23 @@ void TryRunTics(tic_t realtics)
|
|||
// run the count * tics
|
||||
while (neededtic > gametic)
|
||||
{
|
||||
boolean update_stats = !(paused || P_AutoPause());
|
||||
|
||||
DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic));
|
||||
|
||||
ps_tictime = I_GetPreciseTime();
|
||||
if (update_stats)
|
||||
PS_START_TIMING(ps_tictime);
|
||||
|
||||
G_Ticker((gametic % NEWTICRATERATIO) == 0);
|
||||
ExtraDataTicker();
|
||||
gametic++;
|
||||
consistancy[gametic%BACKUPTICS] = Consistancy();
|
||||
|
||||
ps_tictime = I_GetPreciseTime() - ps_tictime;
|
||||
if (update_stats)
|
||||
{
|
||||
PS_STOP_TIMING(ps_tictime);
|
||||
PS_UpdateTickStats();
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
|
14
src/d_main.c
14
src/d_main.c
|
@ -476,7 +476,7 @@ static void D_Display(void)
|
|||
|
||||
if (!automapactive && !dedicated && cv_renderview.value)
|
||||
{
|
||||
ps_rendercalltime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_rendercalltime);
|
||||
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD)
|
||||
{
|
||||
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
|
||||
|
@ -523,7 +523,7 @@ static void D_Display(void)
|
|||
if (postimgtype2)
|
||||
V_DoPostProcessor(1, postimgtype2, postimgparam2);
|
||||
}
|
||||
ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime;
|
||||
PS_STOP_TIMING(ps_rendercalltime);
|
||||
}
|
||||
|
||||
if (lastdraw)
|
||||
|
@ -537,7 +537,7 @@ static void D_Display(void)
|
|||
lastdraw = false;
|
||||
}
|
||||
|
||||
ps_uitime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_uitime);
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
|
@ -550,7 +550,7 @@ static void D_Display(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
ps_uitime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_uitime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ static void D_Display(void)
|
|||
|
||||
CON_Drawer();
|
||||
|
||||
ps_uitime = I_GetPreciseTime() - ps_uitime;
|
||||
PS_STOP_TIMING(ps_uitime);
|
||||
|
||||
//
|
||||
// wipe update
|
||||
|
@ -678,9 +678,9 @@ static void D_Display(void)
|
|||
M_DrawPerfStats();
|
||||
}
|
||||
|
||||
ps_swaptime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_swaptime);
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
ps_swaptime = I_GetPreciseTime() - ps_swaptime;
|
||||
PS_STOP_TIMING(ps_swaptime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "m_cond.h"
|
||||
#include "m_anigif.h"
|
||||
#include "md5.h"
|
||||
#include "m_perfstats.h"
|
||||
|
||||
#ifdef NETGAME_DEVMODE
|
||||
#define CV_RESTRICT CV_NETVAR
|
||||
|
@ -374,7 +375,14 @@ consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL)
|
|||
|
||||
static CV_PossibleValue_t perfstats_cons_t[] = {
|
||||
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}};
|
||||
consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL);
|
||||
consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange);
|
||||
static CV_PossibleValue_t ps_samplesize_cons_t[] = {
|
||||
{1, "MIN"}, {1000, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_ps_samplesize = CVAR_INIT ("ps_samplesize", "1", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange);
|
||||
static CV_PossibleValue_t ps_descriptor_cons_t[] = {
|
||||
{1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}};
|
||||
consvar_t cv_ps_descriptor = CVAR_INIT ("ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL);
|
||||
|
||||
consvar_t cv_freedemocamera = CVAR_INIT("freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL);
|
||||
|
||||
char timedemo_name[256];
|
||||
|
@ -867,6 +875,8 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_soundtest);
|
||||
|
||||
CV_RegisterVar(&cv_perfstats);
|
||||
CV_RegisterVar(&cv_ps_samplesize);
|
||||
CV_RegisterVar(&cv_ps_descriptor);
|
||||
|
||||
// ingame object placing
|
||||
COM_AddCommand("objectplace", Command_ObjectPlace_f);
|
||||
|
|
|
@ -110,6 +110,8 @@ extern consvar_t cv_skipmapcheck;
|
|||
extern consvar_t cv_sleep;
|
||||
|
||||
extern consvar_t cv_perfstats;
|
||||
extern consvar_t cv_ps_samplesize;
|
||||
extern consvar_t cv_ps_descriptor;
|
||||
|
||||
extern char timedemo_name[256];
|
||||
extern boolean timedemo_csv;
|
||||
|
|
|
@ -245,13 +245,16 @@ void HWR_RenderBatches(void)
|
|||
currently_batching = false;// no longer collecting batches
|
||||
if (!polygonArraySize)
|
||||
{
|
||||
ps_hw_numpolys = ps_hw_numcalls = ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 0;
|
||||
ps_hw_numpolys.value.i = ps_hw_numcalls.value.i = ps_hw_numshaders.value.i
|
||||
= ps_hw_numtextures.value.i = ps_hw_numpolyflags.value.i
|
||||
= ps_hw_numcolors.value.i = 0;
|
||||
return;// nothing to draw
|
||||
}
|
||||
// init stats vars
|
||||
ps_hw_numpolys = polygonArraySize;
|
||||
ps_hw_numcalls = ps_hw_numverts = 0;
|
||||
ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 1;
|
||||
ps_hw_numpolys.value.i = polygonArraySize;
|
||||
ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0;
|
||||
ps_hw_numshaders.value.i = ps_hw_numtextures.value.i
|
||||
= ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1;
|
||||
// init polygonIndexArray
|
||||
for (i = 0; i < polygonArraySize; i++)
|
||||
{
|
||||
|
@ -259,12 +262,12 @@ void HWR_RenderBatches(void)
|
|||
}
|
||||
|
||||
// sort polygons
|
||||
ps_hw_batchsorttime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_hw_batchsorttime);
|
||||
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_GetPreciseTime() - ps_hw_batchsorttime;
|
||||
PS_STOP_TIMING(ps_hw_batchsorttime);
|
||||
// sort order
|
||||
// 1. shader
|
||||
// 2. texture
|
||||
|
@ -272,7 +275,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_GetPreciseTime();
|
||||
PS_START_TIMING(ps_hw_batchdrawtime);
|
||||
|
||||
currentShader = polygonArray[polygonIndexArray[0]].shader;
|
||||
currentTexture = polygonArray[polygonIndexArray[0]].texture;
|
||||
|
@ -408,8 +411,8 @@ void HWR_RenderBatches(void)
|
|||
// execute draw call
|
||||
HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
|
||||
// update stats
|
||||
ps_hw_numcalls++;
|
||||
ps_hw_numverts += finalIndexWritePos;
|
||||
ps_hw_numcalls.value.i++;
|
||||
ps_hw_numverts.value.i += finalIndexWritePos;
|
||||
// reset write positions
|
||||
finalVertexWritePos = 0;
|
||||
finalIndexWritePos = 0;
|
||||
|
@ -426,7 +429,7 @@ void HWR_RenderBatches(void)
|
|||
currentShader = nextShader;
|
||||
changeShader = false;
|
||||
|
||||
ps_hw_numshaders++;
|
||||
ps_hw_numshaders.value.i++;
|
||||
}
|
||||
if (changeTexture)
|
||||
{
|
||||
|
@ -435,21 +438,21 @@ void HWR_RenderBatches(void)
|
|||
currentTexture = nextTexture;
|
||||
changeTexture = false;
|
||||
|
||||
ps_hw_numtextures++;
|
||||
ps_hw_numtextures.value.i++;
|
||||
}
|
||||
if (changePolyFlags)
|
||||
{
|
||||
currentPolyFlags = nextPolyFlags;
|
||||
changePolyFlags = false;
|
||||
|
||||
ps_hw_numpolyflags++;
|
||||
ps_hw_numpolyflags.value.i++;
|
||||
}
|
||||
if (changeSurfaceInfo)
|
||||
{
|
||||
currentSurfaceInfo = nextSurfaceInfo;
|
||||
changeSurfaceInfo = false;
|
||||
|
||||
ps_hw_numcolors++;
|
||||
ps_hw_numcolors.value.i++;
|
||||
}
|
||||
// and that should be it?
|
||||
}
|
||||
|
@ -457,7 +460,7 @@ void HWR_RenderBatches(void)
|
|||
polygonArraySize = 0;
|
||||
unsortedVertexArraySize = 0;
|
||||
|
||||
ps_hw_batchdrawtime = I_GetPreciseTime() - ps_hw_batchdrawtime;
|
||||
PS_STOP_TIMING(ps_hw_batchdrawtime);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -147,22 +147,22 @@ static angle_t gl_aimingangle;
|
|||
static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox);
|
||||
|
||||
// Render stats
|
||||
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;
|
||||
ps_metric_t ps_hw_skyboxtime = {0};
|
||||
ps_metric_t ps_hw_nodesorttime = {0};
|
||||
ps_metric_t ps_hw_nodedrawtime = {0};
|
||||
ps_metric_t ps_hw_spritesorttime = {0};
|
||||
ps_metric_t ps_hw_spritedrawtime = {0};
|
||||
|
||||
// Render stats for batching
|
||||
int ps_hw_numpolys = 0;
|
||||
int ps_hw_numverts = 0;
|
||||
int ps_hw_numcalls = 0;
|
||||
int ps_hw_numshaders = 0;
|
||||
int ps_hw_numtextures = 0;
|
||||
int ps_hw_numpolyflags = 0;
|
||||
int ps_hw_numcolors = 0;
|
||||
precise_t ps_hw_batchsorttime = 0;
|
||||
precise_t ps_hw_batchdrawtime = 0;
|
||||
ps_metric_t ps_hw_numpolys = {0};
|
||||
ps_metric_t ps_hw_numverts = {0};
|
||||
ps_metric_t ps_hw_numcalls = {0};
|
||||
ps_metric_t ps_hw_numshaders = {0};
|
||||
ps_metric_t ps_hw_numtextures = {0};
|
||||
ps_metric_t ps_hw_numpolyflags = {0};
|
||||
ps_metric_t ps_hw_numcolors = {0};
|
||||
ps_metric_t ps_hw_batchsorttime = {0};
|
||||
ps_metric_t ps_hw_batchdrawtime = {0};
|
||||
|
||||
boolean gl_init = false;
|
||||
boolean gl_maploaded = false;
|
||||
|
@ -3235,7 +3235,7 @@ static void HWR_Subsector(size_t num)
|
|||
}
|
||||
|
||||
// for render stats
|
||||
ps_numpolyobjects += numpolys;
|
||||
ps_numpolyobjects.value.i += numpolys;
|
||||
|
||||
// Sort polyobjects
|
||||
R_SortPolyObjects(sub);
|
||||
|
@ -3343,7 +3343,7 @@ static void HWR_RenderBSPNode(INT32 bspnum)
|
|||
// Decide which side the view point is on
|
||||
INT32 side;
|
||||
|
||||
ps_numbspcalls++;
|
||||
ps_numbspcalls.value.i++;
|
||||
|
||||
// Found a subsector?
|
||||
if (bspnum & NF_SUBSECTOR)
|
||||
|
@ -4718,7 +4718,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_GetPreciseTime();
|
||||
PS_START_TIMING(ps_hw_nodesorttime);
|
||||
|
||||
for (i = 0; i < numplanes; i++, p++)
|
||||
{
|
||||
|
@ -4738,7 +4738,7 @@ static void HWR_CreateDrawNodes(void)
|
|||
sortindex[p] = p;
|
||||
}
|
||||
|
||||
ps_numdrawnodes = p;
|
||||
ps_numdrawnodes.value.i = p;
|
||||
|
||||
// p is the number of stuff to sort
|
||||
|
||||
|
@ -4773,9 +4773,9 @@ static void HWR_CreateDrawNodes(void)
|
|||
}
|
||||
}
|
||||
|
||||
ps_hw_nodesorttime = I_GetPreciseTime() - ps_hw_nodesorttime;
|
||||
PS_STOP_TIMING(ps_hw_nodesorttime);
|
||||
|
||||
ps_hw_nodedrawtime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_hw_nodedrawtime);
|
||||
|
||||
// Okay! Let's draw it all! Woo!
|
||||
HWD.pfnSetTransform(&atransform);
|
||||
|
@ -4812,7 +4812,7 @@ static void HWR_CreateDrawNodes(void)
|
|||
}
|
||||
}
|
||||
|
||||
ps_hw_nodedrawtime = I_GetPreciseTime() - ps_hw_nodedrawtime;
|
||||
PS_STOP_TIMING(ps_hw_nodedrawtime);
|
||||
|
||||
numwalls = 0;
|
||||
numplanes = 0;
|
||||
|
@ -6095,10 +6095,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_GetPreciseTime();
|
||||
PS_START_TIMING(ps_hw_skyboxtime);
|
||||
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_GetPreciseTime() - ps_hw_skyboxtime;
|
||||
PS_STOP_TIMING(ps_hw_skyboxtime);
|
||||
|
||||
{
|
||||
// do we really need to save player (is it not the same)?
|
||||
|
@ -6208,9 +6208,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
|||
// Reset the shader state.
|
||||
HWR_SetShaderState();
|
||||
|
||||
ps_numbspcalls = 0;
|
||||
ps_numpolyobjects = 0;
|
||||
ps_bsptime = I_GetPreciseTime();
|
||||
ps_numbspcalls.value.i = 0;
|
||||
ps_numpolyobjects.value.i = 0;
|
||||
PS_START_TIMING(ps_bsptime);
|
||||
|
||||
validcount++;
|
||||
|
||||
|
@ -6248,7 +6248,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
|||
}
|
||||
#endif
|
||||
|
||||
ps_bsptime = I_GetPreciseTime() - ps_bsptime;
|
||||
PS_STOP_TIMING(ps_bsptime);
|
||||
|
||||
if (cv_glbatching.value)
|
||||
HWR_RenderBatches();
|
||||
|
@ -6263,22 +6263,22 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
|||
#endif
|
||||
|
||||
// Draw MD2 and sprites
|
||||
ps_numsprites = gl_visspritecount;
|
||||
ps_hw_spritesorttime = I_GetPreciseTime();
|
||||
ps_numsprites.value.i = gl_visspritecount;
|
||||
PS_START_TIMING(ps_hw_spritesorttime);
|
||||
HWR_SortVisSprites();
|
||||
ps_hw_spritesorttime = I_GetPreciseTime() - ps_hw_spritesorttime;
|
||||
ps_hw_spritedrawtime = I_GetPreciseTime();
|
||||
PS_STOP_TIMING(ps_hw_spritesorttime);
|
||||
PS_START_TIMING(ps_hw_spritedrawtime);
|
||||
HWR_DrawSprites();
|
||||
ps_hw_spritedrawtime = I_GetPreciseTime() - ps_hw_spritedrawtime;
|
||||
PS_STOP_TIMING(ps_hw_spritedrawtime);
|
||||
|
||||
#ifdef NEWCORONAS
|
||||
//Hurdler: they must be drawn before translucent planes, what about gl fog?
|
||||
HWR_DrawCoronas();
|
||||
#endif
|
||||
|
||||
ps_numdrawnodes = 0;
|
||||
ps_hw_nodesorttime = 0;
|
||||
ps_hw_nodedrawtime = 0;
|
||||
ps_numdrawnodes.value.i = 0;
|
||||
ps_hw_nodesorttime.value.p = 0;
|
||||
ps_hw_nodedrawtime.value.p = 0;
|
||||
if (numplanes || numpolyplanes || numwalls) //Hurdler: render 3D water and transparent walls after everything
|
||||
{
|
||||
HWR_CreateDrawNodes();
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "../d_player.h"
|
||||
#include "../r_defs.h"
|
||||
|
||||
#include "../m_perfstats.h"
|
||||
|
||||
// Startup & Shutdown the hardware mode renderer
|
||||
void HWR_Startup(void);
|
||||
void HWR_Switch(void);
|
||||
|
@ -116,22 +118,22 @@ extern FTransform atransform;
|
|||
|
||||
|
||||
// Render stats
|
||||
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;
|
||||
extern ps_metric_t ps_hw_skyboxtime;
|
||||
extern ps_metric_t ps_hw_nodesorttime;
|
||||
extern ps_metric_t ps_hw_nodedrawtime;
|
||||
extern ps_metric_t ps_hw_spritesorttime;
|
||||
extern ps_metric_t ps_hw_spritedrawtime;
|
||||
|
||||
// Render stats for batching
|
||||
extern int ps_hw_numpolys;
|
||||
extern int ps_hw_numverts;
|
||||
extern int ps_hw_numcalls;
|
||||
extern int ps_hw_numshaders;
|
||||
extern int ps_hw_numtextures;
|
||||
extern int ps_hw_numpolyflags;
|
||||
extern int ps_hw_numcolors;
|
||||
extern precise_t ps_hw_batchsorttime;
|
||||
extern precise_t ps_hw_batchdrawtime;
|
||||
extern ps_metric_t ps_hw_numpolys;
|
||||
extern ps_metric_t ps_hw_numverts;
|
||||
extern ps_metric_t ps_hw_numcalls;
|
||||
extern ps_metric_t ps_hw_numshaders;
|
||||
extern ps_metric_t ps_hw_numtextures;
|
||||
extern ps_metric_t ps_hw_numpolyflags;
|
||||
extern ps_metric_t ps_hw_numcolors;
|
||||
extern ps_metric_t ps_hw_batchsorttime;
|
||||
extern ps_metric_t ps_hw_batchdrawtime;
|
||||
|
||||
extern boolean gl_init;
|
||||
extern boolean gl_maploaded;
|
||||
|
|
|
@ -505,7 +505,7 @@ static int call_hooks
|
|||
calls += call_mobj_type_hooks(hook, MT_NULL);
|
||||
calls += call_mobj_type_hooks(hook, hook->mobj_type);
|
||||
|
||||
ps_lua_mobjhooks += calls;
|
||||
ps_lua_mobjhooks.value.i += calls;
|
||||
}
|
||||
else
|
||||
calls += call_mapped(hook, &hookIds[hook->hook_type]);
|
||||
|
@ -868,7 +868,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
|
|||
LUA_PushUserdata(gL, line, META_LINE);
|
||||
LUA_PushUserdata(gL, mo, META_MOBJ);
|
||||
LUA_PushUserdata(gL, sector, META_SECTOR);
|
||||
ps_lua_mobjhooks += call_hooks(&hook, 0, res_none);
|
||||
ps_lua_mobjhooks.value.i += call_hooks(&hook, 0, res_none);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1074
src/m_perfstats.c
1074
src/m_perfstats.c
File diff suppressed because it is too large
Load diff
|
@ -16,26 +16,45 @@
|
|||
#include "lua_script.h"
|
||||
#include "p_local.h"
|
||||
|
||||
extern precise_t ps_tictime;
|
||||
|
||||
extern precise_t ps_playerthink_time;
|
||||
extern precise_t ps_thinkertime;
|
||||
|
||||
extern precise_t ps_thlist_times[];
|
||||
|
||||
extern int ps_checkposition_calls;
|
||||
|
||||
extern precise_t ps_lua_thinkframe_time;
|
||||
extern int ps_lua_mobjhooks;
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
precise_t p;
|
||||
INT32 i;
|
||||
} value;
|
||||
void *history;
|
||||
} ps_metric_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
precise_t time_taken;
|
||||
ps_metric_t time_taken;
|
||||
char short_src[LUA_IDSIZE];
|
||||
} ps_hookinfo_t;
|
||||
|
||||
#define PS_START_TIMING(metric) metric.value.p = I_GetPreciseTime()
|
||||
#define PS_STOP_TIMING(metric) metric.value.p = I_GetPreciseTime() - metric.value.p
|
||||
|
||||
extern ps_metric_t ps_tictime;
|
||||
|
||||
extern ps_metric_t ps_playerthink_time;
|
||||
extern ps_metric_t ps_thinkertime;
|
||||
|
||||
extern ps_metric_t ps_thlist_times[];
|
||||
|
||||
extern ps_metric_t ps_checkposition_calls;
|
||||
|
||||
extern ps_metric_t ps_lua_thinkframe_time;
|
||||
extern ps_metric_t ps_lua_mobjhooks;
|
||||
|
||||
extern ps_metric_t ps_otherlogictime;
|
||||
|
||||
void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
|
||||
|
||||
void PS_UpdateTickStats(void);
|
||||
|
||||
void M_DrawPerfStats(void);
|
||||
|
||||
void PS_PerfStats_OnChange(void);
|
||||
void PS_SampleSize_OnChange(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2029,7 +2029,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
subsector_t *newsubsec;
|
||||
boolean blockval = true;
|
||||
|
||||
ps_checkposition_calls++;
|
||||
ps_checkposition_calls.value.i++;
|
||||
|
||||
I_Assert(thing != NULL);
|
||||
#ifdef PARANOIA
|
||||
|
|
20
src/p_tick.c
20
src/p_tick.c
|
@ -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_GetPreciseTime();
|
||||
PS_START_TIMING(ps_thlist_times[i]);
|
||||
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_GetPreciseTime() - ps_thlist_times[i];
|
||||
PS_STOP_TIMING(ps_thlist_times[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -653,16 +653,16 @@ void P_Ticker(boolean run)
|
|||
}
|
||||
}
|
||||
|
||||
ps_lua_mobjhooks = 0;
|
||||
ps_checkposition_calls = 0;
|
||||
ps_lua_mobjhooks.value.i = 0;
|
||||
ps_checkposition_calls.value.i = 0;
|
||||
|
||||
LUA_HOOK(PreThinkFrame);
|
||||
|
||||
ps_playerthink_time = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_playerthink_time);
|
||||
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_GetPreciseTime() - ps_playerthink_time;
|
||||
PS_STOP_TIMING(ps_playerthink_time);
|
||||
}
|
||||
|
||||
// Keep track of how long they've been playing!
|
||||
|
@ -677,18 +677,18 @@ void P_Ticker(boolean run)
|
|||
|
||||
if (run)
|
||||
{
|
||||
ps_thinkertime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_thinkertime);
|
||||
P_RunThinkers();
|
||||
ps_thinkertime = I_GetPreciseTime() - ps_thinkertime;
|
||||
PS_STOP_TIMING(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_GetPreciseTime();
|
||||
PS_START_TIMING(ps_lua_thinkframe_time);
|
||||
LUA_HookThinkFrame();
|
||||
ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time;
|
||||
PS_STOP_TIMING(ps_lua_thinkframe_time);
|
||||
}
|
||||
|
||||
// Run shield positioning
|
||||
|
|
|
@ -804,7 +804,7 @@ static void R_AddPolyObjects(subsector_t *sub)
|
|||
}
|
||||
|
||||
// for render stats
|
||||
ps_numpolyobjects += numpolys;
|
||||
ps_numpolyobjects.value.i += numpolys;
|
||||
|
||||
// sort polyobjects
|
||||
R_SortPolyObjects(sub);
|
||||
|
@ -1239,7 +1239,7 @@ void R_RenderBSPNode(INT32 bspnum)
|
|||
node_t *bsp;
|
||||
INT32 side;
|
||||
|
||||
ps_numbspcalls++;
|
||||
ps_numbspcalls.value.i++;
|
||||
|
||||
while (!(bspnum & NF_SUBSECTOR)) // Found a subsector?
|
||||
{
|
||||
|
|
49
src/r_main.c
49
src/r_main.c
|
@ -101,21 +101,22 @@ extracolormap_t *extra_colormaps = NULL;
|
|||
|
||||
// Render stats
|
||||
precise_t ps_prevframetime = 0;
|
||||
precise_t ps_rendercalltime = 0;
|
||||
precise_t ps_uitime = 0;
|
||||
precise_t ps_swaptime = 0;
|
||||
ps_metric_t ps_rendercalltime = {0};
|
||||
ps_metric_t ps_otherrendertime = {0};
|
||||
ps_metric_t ps_uitime = {0};
|
||||
ps_metric_t ps_swaptime = {0};
|
||||
|
||||
precise_t ps_bsptime = 0;
|
||||
ps_metric_t ps_bsptime = {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;
|
||||
ps_metric_t ps_sw_spritecliptime = {0};
|
||||
ps_metric_t ps_sw_portaltime = {0};
|
||||
ps_metric_t ps_sw_planetime = {0};
|
||||
ps_metric_t ps_sw_maskedtime = {0};
|
||||
|
||||
int ps_numbspcalls = 0;
|
||||
int ps_numsprites = 0;
|
||||
int ps_numdrawnodes = 0;
|
||||
int ps_numpolyobjects = 0;
|
||||
ps_metric_t ps_numbspcalls = {0};
|
||||
ps_metric_t ps_numsprites = {0};
|
||||
ps_metric_t ps_numdrawnodes = {0};
|
||||
ps_metric_t ps_numpolyobjects = {0};
|
||||
|
||||
static CV_PossibleValue_t drawdist_cons_t[] = {
|
||||
{256, "256"}, {512, "512"}, {768, "768"},
|
||||
|
@ -1496,11 +1497,11 @@ void R_RenderPlayerView(player_t *player)
|
|||
mytotal = 0;
|
||||
ProfZeroTimer();
|
||||
#endif
|
||||
ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0;
|
||||
ps_bsptime = I_GetPreciseTime();
|
||||
ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0;
|
||||
PS_START_TIMING(ps_bsptime);
|
||||
R_RenderBSPNode((INT32)numnodes - 1);
|
||||
ps_bsptime = I_GetPreciseTime() - ps_bsptime;
|
||||
ps_numsprites = visspritecount;
|
||||
PS_STOP_TIMING(ps_bsptime);
|
||||
ps_numsprites.value.i = visspritecount;
|
||||
#ifdef TIMING
|
||||
RDMSR(0x10, &mycount);
|
||||
mytotal += mycount; // 64bit add
|
||||
|
@ -1510,9 +1511,9 @@ void R_RenderPlayerView(player_t *player)
|
|||
//profile stuff ---------------------------------------------------------
|
||||
Mask_Post(&masks[nummasks - 1]);
|
||||
|
||||
ps_sw_spritecliptime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_sw_spritecliptime);
|
||||
R_ClipSprites(drawsegs, NULL);
|
||||
ps_sw_spritecliptime = I_GetPreciseTime() - ps_sw_spritecliptime;
|
||||
PS_STOP_TIMING(ps_sw_spritecliptime);
|
||||
|
||||
|
||||
// Add skybox portals caused by sky visplanes.
|
||||
|
@ -1520,7 +1521,7 @@ void R_RenderPlayerView(player_t *player)
|
|||
Portal_AddSkyboxPortals();
|
||||
|
||||
// Portal rendering. Hijacks the BSP traversal.
|
||||
ps_sw_portaltime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_sw_portaltime);
|
||||
if (portal_base)
|
||||
{
|
||||
portal_t *portal;
|
||||
|
@ -1560,17 +1561,17 @@ void R_RenderPlayerView(player_t *player)
|
|||
Portal_Remove(portal);
|
||||
}
|
||||
}
|
||||
ps_sw_portaltime = I_GetPreciseTime() - ps_sw_portaltime;
|
||||
PS_STOP_TIMING(ps_sw_portaltime);
|
||||
|
||||
ps_sw_planetime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_sw_planetime);
|
||||
R_DrawPlanes();
|
||||
ps_sw_planetime = I_GetPreciseTime() - ps_sw_planetime;
|
||||
PS_STOP_TIMING(ps_sw_planetime);
|
||||
|
||||
// draw mid texture and sprite
|
||||
// And now 3D floors/sides!
|
||||
ps_sw_maskedtime = I_GetPreciseTime();
|
||||
PS_START_TIMING(ps_sw_maskedtime);
|
||||
R_DrawMasked(masks, nummasks);
|
||||
ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime;
|
||||
PS_STOP_TIMING(ps_sw_maskedtime);
|
||||
|
||||
free(masks);
|
||||
}
|
||||
|
|
26
src/r_main.h
26
src/r_main.h
|
@ -17,6 +17,7 @@
|
|||
#include "d_player.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "m_perfstats.h" // ps_metric_t
|
||||
|
||||
//
|
||||
// POV related.
|
||||
|
@ -79,21 +80,22 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
|
|||
// Render stats
|
||||
|
||||
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 ps_metric_t ps_rendercalltime;
|
||||
extern ps_metric_t ps_otherrendertime;
|
||||
extern ps_metric_t ps_uitime;
|
||||
extern ps_metric_t ps_swaptime;
|
||||
|
||||
extern precise_t ps_bsptime;
|
||||
extern ps_metric_t ps_bsptime;
|
||||
|
||||
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 ps_metric_t ps_sw_spritecliptime;
|
||||
extern ps_metric_t ps_sw_portaltime;
|
||||
extern ps_metric_t ps_sw_planetime;
|
||||
extern ps_metric_t ps_sw_maskedtime;
|
||||
|
||||
extern int ps_numbspcalls;
|
||||
extern int ps_numsprites;
|
||||
extern int ps_numdrawnodes;
|
||||
extern int ps_numpolyobjects;
|
||||
extern ps_metric_t ps_numbspcalls;
|
||||
extern ps_metric_t ps_numsprites;
|
||||
extern ps_metric_t ps_numdrawnodes;
|
||||
extern ps_metric_t ps_numpolyobjects;
|
||||
|
||||
//
|
||||
// REFRESH - the actual rendering functions.
|
||||
|
|
|
@ -2745,7 +2745,7 @@ static drawnode_t *R_CreateDrawNode(drawnode_t *link)
|
|||
node->ffloor = NULL;
|
||||
node->sprite = NULL;
|
||||
|
||||
ps_numdrawnodes++;
|
||||
ps_numdrawnodes.value.i++;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ enum
|
|||
// Tags < PU_LEVEL are not purged until freed explicitly.
|
||||
PU_STATIC = 1, // static entire execution time
|
||||
PU_LUA = 2, // static entire execution time -- used by lua so it doesn't get caught in loops forever
|
||||
PU_PERFSTATS = 3, // static between changes to ps_samplesize cvar
|
||||
|
||||
PU_SOUND = 11, // static while playing
|
||||
PU_MUSIC = 12, // static while playing
|
||||
|
|
Loading…
Reference in a new issue