From 01606bb6fb0dbed895a9d730825c4d4598a90d52 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 17 Mar 2018 03:26:01 +0000 Subject: [PATCH] Instrument the code to build without the struct trackers and disable them when the build options eliminate all uses of them (currently USE_OPENGL=0). git-svn-id: https://svn.eduke32.com/eduke32@6769 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 14 +++++++++++++- source/build/src/engine.cpp | 2 ++ source/duke3d/src/m32exec.cpp | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 1532532d0..55bd28e35 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -261,11 +261,19 @@ enum { #endif #ifdef __cplusplus +} +#endif +#if defined __cplusplus && (defined USE_OPENGL || defined POLYMER) +# define STRUCT_TRACKERS_ENABLED +#endif + +#ifdef STRUCT_TRACKERS_ENABLED + +extern "C" { static FORCE_INLINE void sector_tracker_hook(uintptr_t address); static FORCE_INLINE void wall_tracker_hook(uintptr_t address); static FORCE_INLINE void sprite_tracker_hook(uintptr_t address); - } #define TRACKER_NAME_ SectorTracker @@ -585,9 +593,11 @@ EXTERN spritetype sprite[MAXSPRITES]; EXTERN uspritetype tsprite[MAXSPRITESONSCREEN]; #endif +#ifdef STRUCT_TRACKERS_ENABLED EXTERN uint32_t sectorchanged[MAXSECTORS + M32_FIXME_SECTORS]; EXTERN uint32_t wallchanged[MAXWALLS + M32_FIXME_WALLS]; EXTERN uint32_t spritechanged[MAXSPRITES]; +#endif #ifdef NEW_MAP_FORMAT static FORCE_INLINE int16_t yax_getbunch(int16_t i, int16_t cf) @@ -612,6 +622,7 @@ static FORCE_INLINE void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenex } #endif +#ifdef STRUCT_TRACKERS_ENABLED static FORCE_INLINE void sector_tracker_hook(uintptr_t const address) { uintptr_t const usector = address - (uintptr_t)sector; @@ -644,6 +655,7 @@ static FORCE_INLINE void sprite_tracker_hook(uintptr_t const address) ++spritechanged[usprite / sizeof(spritetype)]; } +#endif EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 0a77138ac..23a168c64 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -8978,9 +8978,11 @@ static void prepare_loadboard(int32_t fil, vec3_t *dapos, int16_t *daang, int16_ Bmemset(show2dsector, 0, sizeof(show2dsector)); Bmemset(show2dsprite, 0, sizeof(show2dsprite)); Bmemset(show2dwall, 0, sizeof(show2dwall)); +#ifdef STRUCT_TRACKERS_ENABLED Bmemset(sectorchanged, 0, sizeof(sectorchanged)); Bmemset(spritechanged, 0, sizeof(spritechanged)); Bmemset(wallchanged, 0, sizeof(wallchanged)); +#endif #ifdef USE_OPENGL Polymost_prepare_loadboard(); diff --git a/source/duke3d/src/m32exec.cpp b/source/duke3d/src/m32exec.cpp index 012d0a86d..f8426160b 100644 --- a/source/duke3d/src/m32exec.cpp +++ b/source/duke3d/src/m32exec.cpp @@ -2921,42 +2921,54 @@ dodefault: X_ERROR_INVALIDSP(); vm.pSprite->xrepeat = (uint8_t) Gv_GetVarX(*(insptr-2)); vm.pSprite->yrepeat = (uint8_t) Gv_GetVarX(*(insptr-1)); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_CSTAT: insptr += 2; X_ERROR_INVALIDSP(); vm.pSprite->cstat = (int16_t) *(insptr-1); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_CSTATOR: insptr += 2; X_ERROR_INVALIDSP(); vm.pSprite->cstat |= (int16_t) Gv_GetVarX(*(insptr-1)); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_CLIPDIST: insptr += 2; X_ERROR_INVALIDSP(); vm.pSprite->clipdist = (uint8_t) Gv_GetVarX(*(insptr-1)); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_SPRITEPAL: insptr += 2; X_ERROR_INVALIDSP(); vm.pSprite->pal = Gv_GetVarX(*(insptr-1)); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_CACTOR: insptr += 2; X_ERROR_INVALIDSP(); vm.pSprite->picnum = Gv_GetVarX(*(insptr-1)); +#ifdef STRUCT_TRACKERS_ENABLED if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++; +#endif continue; case CON_SPGETLOTAG: