From 281ee3358b922a596409c3eebad74c7106fa2981 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Tue, 25 Jun 2019 18:34:52 +0000 Subject: [PATCH] Add benchmarkmode cvar which allows putting demo cameras in the map which can be used for automatic benchmarking of performance & correctness testing git-svn-id: https://svn.eduke32.com/eduke32@7729 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 2 ++ source/build/src/engine.cpp | 8 ++++++++ source/duke3d/src/actors.cpp | 5 ++++- source/duke3d/src/game.cpp | 2 ++ source/duke3d/src/game.h | 7 +++++++ source/duke3d/src/osdcmds.cpp | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index bf2305fe1..25a285120 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1369,6 +1369,8 @@ extern int32_t gltexmaxsize; void gltexapplyprops (void); void texcache_invalidate(void); +extern int32_t benchmarkScreenshot; + # ifdef USE_GLEXT extern int32_t r_detailmapping; extern int32_t r_glowmapping; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 432c34df9..dbd359661 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -130,6 +130,8 @@ static uint32_t *distrecip; static int32_t *lookups = NULL; static int32_t beforedrawrooms = 1; +int32_t benchmarkScreenshot = 0; + static int32_t oxdimen = -1, oviewingrange = -1, oxyaspect = -1; // r_usenewaspect is the cvar, newaspect_enable to trigger the new behaviour in the code @@ -10158,6 +10160,12 @@ void videoNextPage(void) } videoEndDrawing(); //}}} + if (benchmarkScreenshot) + { + videoCaptureScreen("reference0000.png", 0); + benchmarkScreenshot = 0; + } + OSD_Draw(); videoShowFrame(0); diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp index 66308d69d..40a452758 100644 --- a/source/duke3d/src/actors.cpp +++ b/source/duke3d/src/actors.cpp @@ -7560,7 +7560,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_27_DEMO_CAM: { - if (pSprite->extra < 1 && (ud.recstat == 0 || !ud.democams)) break; + if (pSprite->extra < 1 && (ud.recstat == 0 || !ud.democams) && g_BenchmarkMode == BENCHMARKMODE_OFF) break; if (klabs(pSprite->extra) == 2) { @@ -7606,6 +7606,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 pData[8] = (((int32_t) getangle(-ksqrt(cameraDirection.x*cameraDirection.x+cameraDirection.y*cameraDirection.y), cameraDirection.z)*(400.f/1024.f)))-300; } } + + //if we are benchmarking, take a screenshot at each waypoint (camera start point/locator) + benchmarkScreenshot = g_BenchmarkMode == BENCHMARKMODE_GENERATE_REFERENCE; } if (pSprite->owner == -1) { diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index d47c160ef..61e348b88 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -90,6 +90,8 @@ char boardfilename[BMAX_PATH] = {0}, currentboardfilename[BMAX_PATH] = {0}; int32_t voting = -1; int32_t vote_map = -1, vote_episode = -1; +int32_t g_BenchmarkMode = BENCHMARKMODE_OFF; + int32_t g_Debug = 0; const char *defaultrtsfilename[GAMECOUNT] = { "DUKE.RTS", "NAM.RTS", "NAPALM.RTS", "WW2GI.RTS" }; diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 6fb7a42d0..dddab807b 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -116,6 +116,12 @@ enum { STATUSBAR_NOMODERN = 0x00000040, }; +enum { + BENCHMARKMODE_OFF = 0x0, + BENCHMARKMODE_PERFORMANCE = 0x1, + BENCHMARKMODE_GENERATE_REFERENCE = 0x2, +}; + void A_DeleteSprite(int spriteNum); static inline int32_t G_GetLogoFlags(void) @@ -312,6 +318,7 @@ extern char ror_protectedsectors[MAXSECTORS]; extern float r_ambientlight; +extern int32_t g_BenchmarkMode; extern int32_t g_Debug; extern int32_t g_Shareware; #if !defined LUNATIC diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index e39f05d40..0e7a26d97 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1552,6 +1552,8 @@ int32_t registerosdcommands(void) { static osdcvardata_t cvars_game[] = { + { "benchmarkmode", "Set the benchmark mode (0: off, 1: performance test, 2: generate reference screenshots for correctness testing)", (void *) &g_BenchmarkMode, CVAR_INT|CVAR_NOSAVE, 0, 2 }, + { "crosshair", "enable/disable crosshair", (void *)&ud.crosshair, CVAR_BOOL, 0, 1 }, { "cl_autoaim", "enable/disable weapon autoaim", (void *)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 3 },