Commit 6a452a53 authored by Richard Gobeille's avatar Richard Gobeille

engine: add microprofile (https://github.com/zeux/microprofile)

Build with "make MICROPROFILE=1" and browse to http://localhost:1338 to use. A pass over it to fix warnings will probably be in a future commit.
parent 494a1357
......@@ -11,6 +11,7 @@ ifeq ($(FURY),1)
RETAIL_MENU := 1
STANDALONE := 1
USE_LIBVPX := 0
MICROPROFILE := 0
endif
### Platform and Toolchain Configuration
......@@ -772,6 +773,9 @@ ifneq (0,$(USE_PHYSFS))
COMPILERFLAGS += -I$(physfs_inc) -DUSE_PHYSFS
endif
ifneq (0,$(MICROPROFILE))
COMPILERFLAGS += -DMICROPROFILE_ENABLED=1
endif
##### Recipes
......
......@@ -454,6 +454,8 @@
<ClInclude Include="..\..\source\build\include\lz4.h" />
<ClInclude Include="..\..\source\build\include\md4.h" />
<ClInclude Include="..\..\source\build\include\mdsprite.h" />
<ClInclude Include="..\..\source\build\include\microprofile.h" />
<ClInclude Include="..\..\source\build\include\microprofilehtml.h" />
<ClInclude Include="..\..\source\build\include\miniz.h" />
<ClInclude Include="..\..\source\build\include\mmulti.h" />
<ClInclude Include="..\..\source\build\include\mutex.h" />
......@@ -589,4 +591,4 @@ cl /c /MP /GS- /W3 /wd"4996" /wd"4244" /wd"4018" /wd"4267" /Gy /Zc:wchar_t /I"./
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -433,6 +433,12 @@
<ClInclude Include="..\..\source\build\include\rev.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\source\build\include\microprofile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\source\build\include\microprofilehtml.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\source\build\src\polymost1Frag.glsl">
......
......@@ -5,13 +5,13 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;RENDERTYPESDL=1;MIXERTYPESDL=1;SDL_USEFOLDER;SDL_TARGET=2;USE_OPENGL=1;POLYMER=1;STARTUP_WINDOW;USE_LIBVPX;HAVE_VORBIS;HAVE_XMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;RENDERTYPESDL=1;MIXERTYPESDL=1;SDL_USEFOLDER;SDL_TARGET=2;USE_OPENGL=1;POLYMER=1;STARTUP_WINDOW;USE_LIBVPX;HAVE_VORBIS;HAVE_XMP;MICROPROFILE_ENABLED=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./include;./include/vpx/;./include/sdl2/;../../source/build/include;../../source/mact/include;../../source/audiolib/include;../../source/glad/include;../../source/libxmp-lite/include;../../source/libxmp-lite/include/libxmp-lite;../../source/voidwrap/include</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996;4244;4018;4267</DisableSpecificWarnings>
<AdditionalOptions>/J %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>Shlwapi.lib;Comctl32.lib;version.lib;Imm32.lib;libogg.a;libvorbis.a;libvorbisfile.a;libxmp-lite.a;libvpx.a;dxguid.lib;dsound.lib;winmm.lib;ws2_32.lib;libSDL2main.a;libSDL2.a;libcompat-to-msvc.a;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;SetupAPI.Lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Shlwapi.lib;Comctl32.lib;version.lib;Imm32.lib;libogg.a;libvorbis.a;libvorbisfile.a;libxmp-lite.a;libvpx.a;dxguid.lib;dsound.lib;winmm.lib;ws2_32.lib;libSDL2main.a;libSDL2.a;libcompat-to-msvc.a;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;SetupAPI.Lib;uuid.lib;odbc32.lib;odbccp32.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,6 +11,7 @@
#include "baselayer.h"
#include "clip.h"
#include "engine_priv.h"
#include "microprofile.h"
static int16_t clipnum;
static linetype clipit[MAXCLIPNUM];
......@@ -1811,6 +1812,8 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit,
int32_t walldist, uint32_t cliptype)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
if (sectnum < 0)
{
*ceilz = INT32_MIN; *ceilhit = -1;
......
......@@ -13,16 +13,19 @@
#include "build.h"
#include "cache1d.h"
#include "colmatch.h"
#include "communityapi.h"
#include "compat.h"
#include "crc32.h"
#include "editor.h"
#include "engine_priv.h"
#include "lz4.h"
#include "microprofile.h"
#include "osd.h"
#include "palette.h"
#include "pragmas.h"
#include "scriptfile.h"
#include "softsurface.h"
#include "vfs.h"
#ifdef USE_OPENGL
# include "glad/glad.h"
......@@ -35,10 +38,6 @@
# include "polymost.h"
#endif
#include "vfs.h"
#include "communityapi.h"
//////////
// Compilation switches for optional/extended engine features
......@@ -846,6 +845,8 @@ void yax_preparedrawrooms(void)
void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t,int32_t),
int16_t sectnum, int32_t didmirror, int32_t smoothr)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
static uint8_t havebunch[(YAX_MAXBUNCHES+7)>>3];
const fix16_t horiz = global100horiz;
......@@ -6567,6 +6568,8 @@ next_most:
static void renderDrawSprite(int32_t snum)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
switch (videoGetRenderMode())
{
case REND_CLASSIC:
......@@ -6595,6 +6598,8 @@ static void renderDrawSprite(int32_t snum)
//
static void renderDrawMaskedWall(int16_t damaskwallcnt)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
//============================================================================= //POLYMOST BEGINS
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST) { polymost_drawmaskwall(damaskwallcnt); return; }
......@@ -7271,6 +7276,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2,
int32_t uniqid)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
// NOTE: if these are made unsigned (for safety), angled tiles may draw
// incorrectly, showing vertical seams at intervals.
int32_t bx, by;
......@@ -7868,6 +7875,8 @@ static inline void initksqrt(void)
//
static void dosetaspect(void)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
int32_t i, j;
if (xyaspect != oxyaspect)
......@@ -8533,6 +8542,9 @@ int32_t enginePreInit(void)
engineInitClipMaps();
#endif
preinitcalled = 1;
MicroProfileWebServerStart();
return 0;
}
......@@ -8762,6 +8774,8 @@ void set_globalang(fix16_t const ang)
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
fix16_t daang, fix16_t dahoriz, int16_t dacursectnum)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
int32_t i, j, /*cz, fz,*/ closest;
int16_t *shortptr1, *shortptr2;
......@@ -9264,6 +9278,8 @@ static void sortsprites(int const start, int const end)
//
void renderDrawMasks(void)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
#ifdef DEBUG_MASK_DRAWING
static struct {
int16_t di; // &32768: &32767 is tspriteptr[], else thewall[] index
......@@ -9653,6 +9669,8 @@ killsprite:
//
void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
int32_t i, j, k, l;
int32_t x, y;
int32_t s, ox, oy;
......@@ -11084,6 +11102,8 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
//
void videoNextPage(void)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
permfifotype *per;
//char snotbuf[32];
......@@ -11558,6 +11578,8 @@ int32_t cansee_19950829(int32_t xs, int32_t ys, int32_t zs, int16_t sectnums, in
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
if (enginecompatibilitymode == ENGINE_19950829)
return cansee_19950829(x1, y1, z1, sect1, x2, y2, z2, sect2);
int32_t dacnt, danum;
......@@ -12107,6 +12129,8 @@ int findwallbetweensectors(int sect1, int sect2)
//
void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
if (enginecompatibilitymode == ENGINE_EDUKE32)
{
int16_t sect = *sectnum;
......@@ -12177,6 +12201,8 @@ void updatesectorexclude(int32_t const x, int32_t const y, int16_t * const sectn
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
if (enginecompatibilitymode == ENGINE_EDUKE32)
{
int16_t sect = *sectnum;
......
......@@ -14,6 +14,7 @@ Ken Silverman's official web site: http://www.advsys.net/ken
#include "kplib.h"
#include "mdsprite.h"
#include "polymost.h"
#include "microprofile.h"
#include "tilepacker.h"
extern char textfont[2048], smalltextfont[2048];
......@@ -6713,6 +6714,8 @@ static void polymost_initmosts(const float * px, const float * py, int const n)
void polymost_drawrooms()
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
if (videoGetRenderMode() == REND_CLASSIC) return;
polymost_outputGLDebugMessage(3, "polymost_drawrooms()");
......
......@@ -42,6 +42,9 @@
#include "vfs.h"
#include "communityapi.h"
#define MICROPROFILE_IMPL
#include "microprofile.h"
#if SDL_MAJOR_VERSION >= 2
static SDL_version linked;
#else
......@@ -446,6 +449,11 @@ int SDL_main(int argc, char *argv[])
int main(int argc, char *argv[])
#endif
{
MicroProfileOnThreadCreate("Main");
MicroProfileSetForceEnable(true);
MicroProfileSetEnableAllGroups(true);
MicroProfileSetForceMetaCounters(true);
#ifdef __ANDROID__
if (setjmp(eduke32_exit_jmp_buf))
{
......@@ -1421,6 +1429,8 @@ static void destroy_window_resources()
/* We should NOT destroy the window surface. This is done automatically
when SDL_DestroyWindow or SDL_SetVideoMode is called. */
MicroProfileGpuShutdown();
#if SDL_MAJOR_VERSION >= 2
if (sdl_context)
SDL_GL_DeleteContext(sdl_context);
......@@ -1687,6 +1697,8 @@ int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs)
setvideomode_sdlcommonpost(x, y, c, fs, regrab);
MicroProfileGpuInitGL();
return 0;
}
#endif
......@@ -1831,7 +1843,10 @@ void videoShowFrame(int32_t w)
}
if ((r_glfinish == 1 && r_finishbeforeswap == 1) || vsync_renderlayer == 2)
{
MICROPROFILE_SCOPEI("Engine", "glFinish", MP_GREEN);
glFinish();
}
#ifdef _WIN32
if (vsync_renderlayer == 2)
......@@ -1842,7 +1857,10 @@ void videoShowFrame(int32_t w)
// TODO: use timing information to determine swap time and just busy loop ourselves for more timing control
if (swapTime < nextSwapTime)
{
MICROPROFILE_SCOPEI("Engine", "waitForVBlank", MP_GREEN2);
windowsWaitForVBlank();
}
else if (swapTime - nextSwapTime >= swapInterval)
nextSwapTime += swapInterval;
......@@ -1850,10 +1868,18 @@ void videoShowFrame(int32_t w)
}
#endif
SDL_GL_SwapWindow(sdl_window);
{
MICROPROFILE_SCOPEI("Engine", "SDL_GL_SwapWindow", MP_GREEN3);
SDL_GL_SwapWindow(sdl_window);
}
if (r_glfinish == 1 && r_finishbeforeswap == 0 && vsync_renderlayer != 2)
{
MICROPROFILE_SCOPEI("Engine", "glFinish2", MP_GREEN4);
glFinish();
}
MicroProfileFlip();
return;
}
......@@ -1878,6 +1904,8 @@ void videoShowFrame(int32_t w)
sdl_surface = SDL_GetWindowSurface(sdl_window);
SDL_UpdateWindowSurface(sdl_window);
}
MicroProfileFlip();
}
#endif
//
......
......@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
#include "duke3d.h"
#include "microprofile.h"
#if KRANDDEBUG
# define ACTOR_STATIC
......@@ -1679,7 +1680,7 @@ next_sprite:
}
ACTOR_STATIC void G_MoveFallers(void)
{
{
int spriteNum = headspritestat[STAT_FALLER];
while (spriteNum >= 0)
......@@ -1776,7 +1777,7 @@ next_sprite:
}
ACTOR_STATIC void G_MoveStandables(void)
{
{
int spriteNum = headspritestat[STAT_STANDABLE], j, switchPic;
while (spriteNum >= 0)
......@@ -8969,31 +8970,64 @@ void G_MoveWorld(void)
extern double g_moveActorsTime, g_moveWorldTime;
const double worldTime = timerGetHiTicks();
VM_OnEvent(EVENT_PREWORLD);
MICROPROFILE_SCOPEI("Game", "MoveWorld", MP_YELLOW);
VM_OnEvent(EVENT_PREWORLD);
G_DoEventGame(EVENT_PREGAME);
G_RecordOldSpritePos();
G_MoveZombieActors(); //ST 2
G_MoveWeapons(); //ST 4
G_MoveTransports(); //ST 9
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveZombieActors", MP_YELLOW2);
G_MoveZombieActors(); //ST 2
}
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveWeapons", MP_YELLOW3);
G_MoveWeapons(); //ST 4
}
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveTransports", MP_YELLOW4);
G_MoveTransports(); //ST 9
}
{
MICROPROFILE_SCOPEI("MoveWorld", "MovePlayers", MP_YELLOW);
G_MovePlayers(); //ST 10
}
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveFallers", MP_YELLOW2);
G_MoveFallers(); //ST 12
}
G_MovePlayers(); //ST 10
G_MoveFallers(); //ST 12
G_MoveMisc(); //ST 5
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveMisc", MP_YELLOW3);
G_MoveMisc(); //ST 5
}
const double actorsTime = timerGetHiTicks();
G_MoveActors(); //ST 1
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveActors", MP_YELLOW4);
G_MoveActors(); //ST 1
}
g_moveActorsTime = (1-0.033)*g_moveActorsTime + 0.033*(timerGetHiTicks()-actorsTime);
// XXX: Has to be before effectors, in particular movers?
// TODO: lights in moving sectors ought to be interpolated
G_DoEffectorLights();
G_MoveEffectors(); //ST 3
G_MoveStandables(); //ST 6
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveEffectors", MP_YELLOW);
G_MoveEffectors(); //ST 3
}
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveStandables", MP_YELLOW2);
G_MoveStandables(); //ST 6
}
VM_OnEvent(EVENT_WORLD);
......@@ -9002,7 +9036,11 @@ void G_MoveWorld(void)
G_RefreshLights();
G_DoSectorAnimations();
G_MoveFX(); //ST 11
{
MICROPROFILE_SCOPEI("MoveWorld", "MoveFX", MP_YELLOW3);
G_MoveFX(); //ST 11
}
g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime);
}
......@@ -22,25 +22,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define game_c_
#include "duke3d.h"
#include "anim.h"
#include "cheats.h"
#include "cmdline.h"
#include "colmatch.h"
#include "communityapi.h"
#include "compat.h"
#include "renderlayer.h"
#include "osdfuncs.h"
#include "osdcmds.h"
#include "crc32.h"
#include "network.h"
#include "menus.h"
#include "savegame.h"
#include "anim.h"
#include "demo.h"
#include "duke3d.h"
#include "input.h"
#include "colmatch.h"
#include "cheats.h"
#include "menus.h"
#include "microprofile.h"
#include "network.h"
#include "osdcmds.h"
#include "osdfuncs.h"
#include "palette.h"
#include "renderlayer.h"
#include "savegame.h"
#include "sbar.h"
#include "screens.h"
#include "cmdline.h"
#include "palette.h"
#ifdef __ANDROID__
#include "android.h"
......@@ -574,6 +575,8 @@ static void G_SE40(int32_t smoothratio)
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz, int32_t smoothratio)
{
MICROPROFILE_SCOPEI("Game", EDUKE32_FUNCTION, MP_YELLOWGREEN);
if ((gotpic[MIRROR>>3]&pow2char[MIRROR&7])
#ifdef POLYMER
&& (videoGetRenderMode() != REND_POLYMER)
......@@ -707,6 +710,8 @@ static void G_ClearGotMirror()
#ifdef USE_OPENGL
static void G_ReadGLFrame(void)
{
MICROPROFILE_SCOPEI("Game", EDUKE32_FUNCTION, MP_YELLOWGREEN);
// Save OpenGL screenshot with Duke3D palette
// NOTE: maybe need to move this to the engine...
......@@ -746,6 +751,8 @@ static void G_ReadGLFrame(void)
void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
{
MICROPROFILE_SCOPEI("Game", EDUKE32_FUNCTION, MP_YELLOWGREEN);
auto const &thisPlayer = g_player[playerNum];
auto const pPlayer = thisPlayer.ps;
......@@ -3659,6 +3666,8 @@ static inline void G_DoEventAnimSprites(int tspriteNum)
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio)
{
MICROPROFILE_SCOPEI("Game", EDUKE32_FUNCTION, MP_YELLOWGREEN);
UNREFERENCED_PARAMETER(ourz);
int32_t j, frameOffset, playerNum;
intptr_t l;
......@@ -6337,6 +6346,8 @@ void Net_DedicatedServerStdin(void)
void G_DrawFrame(void)
{
MICROPROFILE_SCOPEI("Game", EDUKE32_FUNCTION, MP_YELLOWGREEN);
if (!g_saveRequested)
{
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
......@@ -6353,6 +6364,17 @@ void G_DrawFrame(void)
if (videoGetRenderMode() >= REND_POLYMOST)
G_DrawBackground();
G_DisplayRest(smoothRatio);
#if MICROPROFILE_ENABLED
for (auto &gv : aGameVars)
{
if ((gv.flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0)
{
MICROPROFILE_COUNTER_SET(gv.szLabel, gv.global);
}
}
#endif
videoNextPage();
S_Update();
}
......
......@@ -35,6 +35,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "savegame.h"
#include "vfs.h"
#include "microprofile.h"
#if MICROPROFILE_ENABLED
MicroProfileToken g_eventTokens[MAXEVENTS];
MicroProfileToken g_actorTokens[MAXTILES];
MicroProfileToken g_statnumTokens[MAXSTATUS];
#if 0
MicroProfileToken g_instTokens[CON_END];
#endif
#endif
#define LINE_NUMBER (g_lineNumber << 12)
int32_t g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files
......@@ -6187,6 +6198,19 @@ void scriptInitTables()
inthash_add(&h_actorvar, actorvar.x, actorvar.y, 0);
}
static int C_GetLabelIndex(int32_t val, int type)
{
for (int i=0;i<g_labelCnt;i++)
if (labelcode[i] == val && (labeltype[i] & type) != 0)
return i;
for (int i=0;i<g_labelCnt;i++)
if (labelcode[i] == val)
return i;
return -1;
}
void C_Compile(const char *fileName)
{
Bmemset(apScriptEvents, 0, sizeof(apScriptEvents));
......@@ -6327,6 +6351,42 @@ void C_Compile(const char *fileName)
C_PrintStats();
C_InitQuotes();
#if MICROPROFILE_ENABLED
for (int i=0; i<MAXEVENTS; i++)
{
if (VM_HaveEvent(i))
g_eventTokens[i] = MicroProfileGetToken("CON VM Events", EventNames[i], MP_AUTO, MicroProfileTokenTypeCpu);
}
#if 0
for (int i=0; i<CON_END; i++)
{
Bassert(VM_GetKeywordForID(i) != nullptr);
g_instTokens[i] = MicroProfileGetToken("CON VM Instructions", VM_GetKeywordForID(i), MP_AUTO, MicroProfileTokenTypeCpu);
}
#endif
for (int i=0; i<MAXTILES; i++)
{
if (G_TileHasActor(i))
{
int const index = C_GetLabelIndex(i, LABEL_ACTOR);
if (index != -1)
Bsprintf(tempbuf,"%s (%d)", label+(index<<6), i);
else Bsprintf(tempbuf,"unnamed (%d)", i);
g_actorTokens[i] = MicroProfileGetToken("CON VM Actors", tempbuf, MP_AUTO, MicroProfileTokenTypeCpu);
}
}
for (int i=0; i<MAXSTATUS; i++)
{
Bsprintf(tempbuf,"statnum%d", i);
g_statnumTokens[i] = MicroProfileGetToken("CON VM Actors", tempbuf, MP_AUTO, MicroProfileTokenTypeCpu);
}
#endif
}
void C_ReportError(int error)
......
......@@ -29,10 +29,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamestructures.h"
#include "input.h"
#include "menus.h"
#include "microprofile.h"
#include "osdcmds.h"
#include "savegame.h"
#include "scriplib.h"
#include "vfs.h"
#if KRANDDEBUG
......@@ -43,6 +43,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# define GAMEEXEC_STATIC static
#endif
#if MICROPROFILE_ENABLED
extern MicroProfileToken g_eventTokens[MAXEVENTS];
extern MicroProfileToken g_actorTokens[MAXTILES];
extern MicroProfileToken g_statnumTokens[MAXSTATUS];
#if 0
extern MicroProfileToken g_instTokens[CON_END];
#endif
#endif
vmstate_t vm;
int32_t g_tw;
......@@ -131,6 +140,8 @@ static inline void VM_DummySprite(void)
static FORCE_INLINE int32_t VM_EventInlineInternal__(int const eventNum, int const spriteNum, int const playerNum,
int const playerDist = -1, int32_t returnValue = 0)
{
MICROPROFILE_SCOPE_TOKEN(g_eventTokens[eventNum]);
vmstate_t const newVMstate = { spriteNum, playerNum, playerDist, 0,
&sprite[spriteNum&(MAXSPRITES-1)],
&actor[spriteNum&(MAXSPRITES-1)].t_data[0],
......@@ -411,6 +422,8 @@ void A_GetZLimits(int const spriteNum)
void A_Fall(int const spriteNum)
{
MICROPROFILE_SCOPEI("VM", EDUKE32_FUNCTION, MP_AUTO);
auto const pSprite = &sprite[spriteNum];
int spriteGravity = g_spriteGravity;
......@@ -586,6 +599,8 @@ static int32_t A_GetWaterZOffset(int spritenum);
GAMEEXEC_STATIC void VM_Move(void)
{
MICROPROFILE_SCOPEI("VM", EDUKE32_FUNCTION, MP_AUTO);
auto const movflagsptr = &AC_MOVFLAGS(vm.pSprite, &actor[vm.spriteNum]);
// NOTE: test against -1 commented out and later revived in source history
// XXX: Does its presence/absence break anything? Where are movflags with all bits set created?
......@@ -920,6 +935,8 @@ static int32_t A_GetWaterZOffset(int const spriteNum)
static void VM_Fall(int const spriteNum, spritetype * const pSprite)
{
MICROPROFILE_SCOPEI("VM", EDUKE32_FUNCTION, MP_AUTO);
int spriteGravity = g_spriteGravity;
pSprite->xoffset = pSprite->yoffset = 0;
......@@ -1318,8 +1335,13 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
#endif
int32_t tw = *insptr;
g_tw = tw;
eval(VM_DECODE_INST(tw))
int const decoded = VM_DECODE_INST(tw);
#if 0 && defined CON_USE_COMPUTED_GOTO
// this is broken without CON_USE_COMPUTED_GOTO because it never goes out of scope
MICROPROFILE_SCOPE_TOKEN(g_instTokens[decoded]);
#endif
eval(decoded)
{
vInstruction(CON_LEFTBRACE):
{
......@@ -1363,6 +1385,7 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
aGameVars[*insptr].pValues[vm.playerNum & (MAXPLAYERS-1)] = insptr[1];
insptr