From 86b8757aee72e54e86eaab29d720d1e4f925ca03 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 00:37:58 -0700 Subject: [PATCH] devmode render: display skybox portal, visplane and drawseg counts on HUD - Skybox portal count moved from console print to HUD - Displays visplane count and drawseg count --- src/r_main.cpp | 4 ++++ src/r_main.h | 9 +++++++++ src/r_plane.cpp | 3 +++ src/r_portal.c | 2 +- src/r_segs.cpp | 2 ++ src/st_stuff.c | 33 ++++++++++++++++++++++++++++++--- 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 377350568..67db9e553 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -131,6 +131,8 @@ int ps_numsprites = 0; int ps_numdrawnodes = 0; int ps_numpolyobjects = 0; +struct RenderStats g_renderstats; + static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -1508,6 +1510,8 @@ void R_RenderPlayerView(void) framecount++; validcount++; + memset(&g_renderstats, 0, sizeof g_renderstats); + // Clear buffers. R_ClearPlanes(); if (viewmorph[viewssnum].use) diff --git a/src/r_main.h b/src/r_main.h index 1a150abeb..92df1e605 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -109,6 +109,15 @@ extern int ps_numsprites; extern int ps_numdrawnodes; extern int ps_numpolyobjects; +struct RenderStats +{ + size_t visplanes; + size_t drawsegs; + size_t skybox_portals; +}; + +extern struct RenderStats g_renderstats; + // // REFRESH - the actual rendering functions. // diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ab32da9ae..6bd04392c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -328,6 +328,9 @@ static visplane_t *new_visplane(unsigned hash) } check->next = visplanes[hash]; visplanes[hash] = check; + + g_renderstats.visplanes++; + return check; } diff --git a/src/r_portal.c b/src/r_portal.c index 0a4a645e1..03c99d0a4 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -313,5 +313,5 @@ void Portal_AddSkyboxPortals (void) } } - CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count); + g_renderstats.skybox_portals = count; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index c9d057eac..5145d3bb7 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -3059,4 +3059,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->bsilheight = twosidedmidtexture ? INT32_MAX: INT32_MIN; } ds_p++; + + g_renderstats.drawsegs++; } diff --git a/src/st_stuff.c b/src/st_stuff.c index 08488d7ac..5c077a78a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -366,7 +366,12 @@ static INT32 SCR(INT32 r) // Devmode information -/*static void ST_pushDebugString(INT32 *height, const char *string) +static void ST_pushRow(INT32 *height) +{ + *height -= 4; +} + +static void ST_pushDebugString(INT32 *height, const char *string) { V_DrawRightAlignedString(320, *height, V_MONOSPACE, string); *height -= 8; @@ -418,9 +423,21 @@ static void ST_drawMusicDebug(INT32 *height) } ST_pushDebugString(height, va(" Song: %8s", mname)); -}*/ +} -static void ST_drawDebugInfo(void) +static void ST_drawRenderDebug(INT32 *height) +{ + const struct RenderStats *i = &g_renderstats; + + ST_pushDebugString(height, va(" Visplanes: %4s", sizeu1(i->visplanes))); + ST_pushDebugString(height, va(" Drawsegs: %4s", sizeu1(i->drawsegs))); + + ST_pushRow(height); + + ST_pushDebugString(height, va("Skybox Portals: %4s", sizeu1(i->skybox_portals))); +} + +void ST_drawDebugInfo(void) { INT32 height = 192; @@ -480,6 +497,16 @@ static void ST_drawDebugInfo(void) height -= 32; } + /*if (cv_debug & DBG_MUSIC) + { + ST_drawMusicDebug(&height); + }*/ + + if (cv_debug & DBG_RENDER) + { + ST_drawRenderDebug(&height); + } + if (cv_debug & DBG_MEMORY) V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); }