Skip to content

Debug overlay

The Dear ImGui debug window draws at window resolution over the running game. The renderer sizes its own target from the window and render settings.

openbloodmoney <disc image or extracted disc directory> [Option=Value ...]

The window starts closed. Use F10 or Shift+F1 to open it.

Performance

  • Current and average frame rate, frame time and the renderer's frame budget.
  • A 240-frame graph of frame times, plus a second graph of the engine update cost and of the draw-list submission. The engine update is ZEngineDataBase::MainLoop minus the flip it performs, so it excludes both the submission and the frame-limiter wait.
  • A table of the engine update, main loop total, render submit, swapchain wait, frame-limiter wait, script calls, draw calls, vertices, indices, uniforms and passes, live GPU textures and cached GPU meshes.
  • Game heap use (the heap size g_lGlacierMemSize and what the DEFAULT_MEM allocator has free) and the engine frame counter.

The numbers come from port/engine/debug/_sdl/debugstats.cpp, which the renderer and the main loop feed every frame; the collector also runs when the window is closed, so opening it shows the frames that preceded it.

Render submit includes the time Present spends waiting for the swapchain, so on a GPU-bound scene it is the largest entry; Swapchain wait is that part on its own (SDL_WaitAndAcquireGPUSwapchainTexture: the display's refresh, or the GPU when it is the slower side). Frame limit wait is the pacing delay in ZRenderSDL::WaitForNextFrame, and Main loop total contains both because the engine's MainLoop calls Flip.

OPENBLOOD_PERF_LOG=N logs the same numbers averaged over every N frames (perf: lines), for comparing builds from the command line:

perf: 600 frames, 16.67 ms a frame (60.0 fps, worst 17.73), update 2.92, overlay 0.43, render 0.87 (swapchain 0.03), wait 12.43, cpu 4.21 ms, 505 calls, 5720 vertices

update runs from the end of one flip to the start of the next (the engine's work for the frame, input and the mod frame hooks included), overlay is DebugUiBeginFrame (the debug window and the mods' HUD drawing), render is Present with its swapchain wait, wait the frame limiter, and cpu the frame less both waits: what the frame costs the main thread whatever the display's refresh. A frame three times the recent average and over 20 ms is logged as a perf: hitch line with the same parts. With OPENBLOOD_DETERMINISTIC=1 the clock is virtual and the scripts' time budget (ZScheduledUpdate::m_lMaxCyclesToRun) is counted in clock reads, so update is lower than in real time; compare runs in the same mode.

Profiling

OPENBLOOD_DETERMINISTIC=1 with --frames N also makes the best benchmark: every run plays the same frames (the same draw calls and vertices in each perf: line), and the frame limiter does not wait, so the perf: lines are the frame's whole cost. In real time the scripts' scheduler (ZScheduledUpdate::ScheduleEvents) runs scripts until its time budget is spent, so its share of update changes little when the rest gets faster.

On Windows, OPENBLOOD_PROFILE=FILE samples the main thread's call stack (port/engine/debug/_sdl/profilersdl.cpp): it starts after OPENBLOOD_PROFILE_DELAY seconds (20 by default, to skip loading), samples for OPENBLOOD_PROFILE_SECONDS (30) at up to OPENBLOOD_PROFILE_HZ (1000) samples a second, and writes FILE while the game runs on, logging profiler: lines. Run it long enough to finish, as the samples are lost if the game quits first. tools/port/profile_report.py folds the file into self and inclusive time, a function's callers or callees, or its own samples by source line; it names the executable's functions with llvm-symbolizer, from the profiled openbloodmoney.exe and the openbloodmoney.pdb beside it:

OPENBLOOD_DETERMINISTIC=1 OPENBLOOD_PERF_LOG=500 OPENBLOOD_PROFILE=prof.txt \
  OPENBLOOD_PROFILE_DELAY=12 OPENBLOOD_PROFILE_SECONDS=12 \
  openbloodmoney.exe --pc-install "C:/.../Hitman Blood Money" --mission M06 --play --no-movies --frames 40000
python3 tools/port/profile_report.py prof.txt --exe openbloodmoney.exe
python3 tools/port/profile_report.py prof.txt --exe openbloodmoney.exe --callees EmitSkinnedMesh
python3 tools/port/profile_report.py prof.txt --exe openbloodmoney.exe --lines LightVertex

Measured this way on 2 December 2026 (Ryzen 7 9700X, RTX 3070, 1920 x 1080, M06's hotel lobby, 15,000 frames) the main thread's frame went from 1.66 to 1.28 ms (from 2.40 to 2.10 ms in real time at 240 fps):

  • Most of the skinning was the street's crowd, which the lobby's walls hide but the crowd's map-cell culling keeps: about 250 people and 36,000 of the frame's 45,000 vertices, skinned and lit on the CPU. The people share about 70 mesh and pose pairs, so DrawBoneArrays skins each pair once a frame and lights each person from the cached normals, four vertices at a time with SSE2. OPENBLOOD_CHECK_SKIN_CACHE=1 found no vertex that differs from the uncached path in 180 million (per-vertex, per-pixel and PC-material lighting), and frames captured from both builds are the same to the byte. Skinning fell from 41% to 25% of the frame.
  • The UCRT's _stricmp, which MinGW's strcasecmp is, compares through the locale once any setlocale call has been made, and the game makes them (the menus' setlocale(0, "danish")); every case-insensitive name lookup then went through towlower_l, among them a configuration read each frame (ZHapticsBase::HapticsEnabled, VibrationMode). The Windows build defines its own ASCII strcasecmp and strncasecmp (port/engine/system/_sdl/strcasecmpsdl.cpp): 3.5% of the frame.

A second pass on 3 December 2026, the same machine and recipe (M01's courtyard, M05 and M06; 1920 x 1080; the frame rate held at twice the display's 144 Hz, so these are the main thread's cpu times): M01 from 1.69 to 1.40 ms, M05 from 1.54 to 1.22 ms, M06 from 1.33 to 1.22 ms. Frames captured from both builds in all three missions are the same to the byte, and OPENBLOOD_CHECK_SKIN_CACHE=1 found no differing vertex in 61 million.

  • Each PC material draw keyed its lit vertices (InstanceBuffer, zoldviewpcmaterialsdl.cpp) by an FNV hash of the whole light set, twelve lights of which most were unused, a byte at a time: an eighth of M01's main thread. The key now takes the lights in use, eight bytes at a time.
  • Characters lit per pixel carry their normal in the vertex colour (EncodeNormal, zoldviewbonessdl.cpp): a square root, a division and three clamps a vertex, a tenth of M01's main thread. Four normals are encoded at a time with SSE2 (EncodeNormals4), with the scalar code's operations and rounding.

The launcher, the same day (3840 x 2160, borderless, without vsync: OPENBLOOD_LAUNCHER_FRAMES=1500 OPENBLOOD_PERF_LOG=500 OPENBLOOD_LAUNCHER_UNCAPPED=1): the main page from 12.1 to 2.7 ms a frame, nearly all of it the GPU's. The settings pages, without the model, took 0.5 ms.

  • The model's depth of field (PSLauncherDof, enhance.hlsl) took 11 ms: 64 taps on every pixel of the picture, each with a square root, a sine and a cosine. The passes now cover only the rectangle the model can reach.
  • Two tile passes (PSLauncherDofTile, PSLauncherDofTileReach) record for each 8 x 8 block whether any geometry, and how much near blur, lies within the taps' reach. Background with no geometry in reach and sharp pixels with no near blur in reach keep their colour without the taps. The taps' offsets fold to constants, turned by the jitter angle. Against the old passes, 777 of the 8.3 million pixels differ, by at most 3 of 255; the skipped pixels are unchanged.

Scenarios

  • Scene: the list is read from SCENES on the mounted disc (ISO 9660 or an extracted directory) at first use, so it contains the level scenes (M00/M00_main, M01/M01_main, the _premission, _postmission, _news, _intro and _albino scenes, HIDEOUT/hideout_main) and the front-end scenes (bootmenu, attractmode, HitmanBloodMoney, saveandcontinue). Pick one and press Load selected scene; the action is queued and applied at the start of the next game frame, where the engine normally changes scenes. Each archive contributes the base name of its own .SUP member, which is the long scene name the engine loads; the disc only stores the archive under its shortened 8.3 name (M01_PREM.ZIP is M01/M01_premission), and loading the short name fails DoLoadScene's .sup lookup and hits a ZDebugBreak. The loader-sequence and error-screen archives are not levels and are left out.
  • Player: hitpoints (slider plus Full), God mode (ZPlayer::SetGodMode) and Infinite ammo (ZEngineDataBase::m_bInfAmmo). These write plain fields, so they apply immediately.
  • Items and weapons: Give default weapons (ZHM3GameData:: GiveDefaultWeapons) and every item template of the current scene (ZHM3GameData::GetItemTemplate) with a Give button that adds it to the player's inventory (ZHitman3::AddItemToInventory). Item creation adds geoms, so it is queued for the next frame start.
  • Engine: pause and freeze toggles (m_bPause, m_bFrozen).

Save states

A debug save state is the engine's own save game plus a small text record:

<user dir>/mc0/savestates/<name>.control   fixed 0x6400 bytes, zero padded
<user dir>/mc0/savestates/<name>.data      fixed 0xa8400 bytes, zero padded
<user dir>/mc0/savestates/<name>.txt       openblood-savestate 1, name, label,
                                           scene, frame, time

The fixed block sizes come from the engine's loader (AllocSequence reads the whole control and data blocks), so the streams are padded exactly as the PlayStation 2 memory card files are. Saving calls ZEngineDataBase::SaveGame; loading installs a ZLoadGameInfoPS2 with the two file names and asks the engine to load the recorded scene. The scene load reads the streams from inside AllocSequence, restores the engine and game data, and then destroys the load info itself.

The list shows every state in the directory with its scene, the frame it was taken on and its size. Load and Delete are queued like the scene actions. States survive restarts of the port and are meant to be attached to bug reports: the scene name makes a state self-contained.

Limitations:

  • Save states are gameplay saves. Saving requires a loaded scene with a player, and the front-end scenes (boot menu, attract mode, title) are refused: the engine cannot reload a save taken there. OPENBLOOD_SAVE_TEST_FRAME with the engine's own save test crashes the same way, so this is an engine limitation rather than one of the overlay.
  • A state stores the scene's file name, so it loads whatever scene it was saved in. References to disc data are by name, not by absolute path.
  • With DisableScripts=1, script state is absent from the save, exactly as it is in the game's save at that point.

Tabs from mods

A Lua mod can add tabs of its own with obm.debug.add_tab(title, fn) (docs/modding/README.md); they sit between Save states and Mods, and obm.debug.open(title) opens the overlay on one. The Cheats tab is one: the built-in mod port/builtin_mods/cheats (CHEAT MENU on the launcher's Gameplay tab) draws the PC version's cheat menu there, and the game's cheat-menu key (C) opens it.

Mods

What each running Lua mod costs (port/engine/mods/_sdl/modluaconsole.cpp, ModRuntimeDebugPanel; docs/modding/README.md documents the mods):

  • ms and peak: the mod's own Lua time per game frame, averaged and at most over the last 120 frames. Every call from the engine into the mod is timed with the performance counter (events such as frame and hud_draw, script hooks, actions, replaced scripts); time spent in a nested call into another mod is charged to that mod, so the rows add up.
  • calls: the engine's calls into the mod per frame.
  • heap KB: the mod's live Lua memory. Each Lua allocation is tagged with the mod whose code made it, so a table one mod builds counts against it even when another mod holds it.
  • errors: errors the mod has raised since it loaded.
  • history: the time per frame over the last 120 frames, all rows on one scale.

Opening a mod's row lists its callers (frame, hud_draw, init, scripts.hook_api and so on) with a moving average of each. Mod runtime (C++) is the runtime's own work around the Lua each frame: the frame loop (ghosts, projectiles, patrols, weather, AI tags) and the HUD and UI passes, less the Lua they call; its heap is the shared library and environment tables. The models, props, lights and shaders mods ask for are drawn by the renderer and count in the Performance tab's render times, not here. The timings are collected whether or not the window is open.

Log

Everything the port logs with SDL_Log (port/engine/debug/_sdl/logcapturesdl.cpp, debugpanellog.cpp): the last 4,096 lines, newest at the bottom, warnings in yellow and errors in red. Follow keeps the newest line in view while the list is scrolled to the bottom; scrolled up, it stays put. The level box shows all lines, warnings and errors, or errors only, and the filter keeps the lines that contain its text (case-insensitive). Copy puts the shown lines on the clipboard and Clear empties the list. Text the game writes with printf (a few of the recovered functions' own messages) does not pass through SDL_Log and is not listed.

On Windows the executable is a GUI program, so a desktop launch opens no terminal and this tab is where the log is read. The lines still go where the process's output was redirected (the test tools' log files and pipes) or to the console it was started with. --console (or OPENBLOOD_CONSOLE=1) attaches the log, stdout and stderr to the terminal the game was started from, or opens a console window when there is none. A GUI program does not hold the terminal, so the prompt comes back at once; start /wait openbloodmoney --console in cmd waits for the game. A crash report also goes to crash.txt in the user directory (Crash reports, below).

Environment variables

Variable Meaning
OPENBLOOD_DEBUG_UI=0 Disable the debug window. Active mod HUD elements can still draw.
OPENBLOOD_DEBUG_UI=1 Open the debug window when the game starts.
OPENBLOOD_DEBUG_UI=closed Start with the debug window closed, as it does by default.
OPENBLOOD_DEBUG_UI_TAB=<0-4> Tab in front the first time the window is drawn (0 performance, 1 scenarios, 2 save states, 3 mods, 4 log), including when opened with F10 or Shift+F1.
OPENBLOOD_CONSOLE=1 Windows: as --console, show the log in a terminal (Log, above).
OPENBLOOD_DEBUG_UI_TRACE=1 Log every action result with SDL_Log. Also enables the four test hooks below (scene, state, item, weapon).
OPENBLOOD_DEBUG_SCENE_TEST=<scene>[,<scene>...] With tracing on, load the first scene on frame 60 and the next one every OPENBLOOD_DEBUG_SCENE_TEST_FRAMES frames (600 by default), starting over after the last; a single scene is reloaded at that period for as long as the run lasts.
OPENBLOOD_DEBUG_STATE_TEST=<name> With tracing on, save a state named <name> on frame 60 and load it back on frame 180. load:<name> loads an existing state on frame 60 instead, and cycle saves a state named cycle every 600 frames from frame 60 and loads it back 120 frames later (tools/port/stress_port.py uses it).
OPENBLOOD_DEBUG_ITEM_TEST=1 With tracing on, give one item template every 600 frames from frame 300: the scene's templates in turn, skipping the ones 47 already carries.
OPENBLOOD_DEBUG_WEAPON_TEST=1 With tracing on, give the default weapons every 900 frames.
OPENBLOOD_PERF_LOG=<frames> Log the performance numbers averaged over every N frames, and every hitch (Performance, above).
OPENBLOOD_PROFILE=<file> Windows: sample the main thread's stack and write the samples to <file> (Profiling, above).
OPENBLOOD_CHECK_SKIN_CACHE=1 Skin and light every crowd instance drawn from the skin cache the uncached way too and compare the vertices bit for bit, logging skin cache: totals and any instance that differs (zoldviewbonessdl.cpp).
OPENBLOOD_POOL_STATS=1 Print every pool allocator's current, size and peak bytes at each scene unload and every 300 frames.
OPENBLOOD_PCANIM_TEST=airrifle Without tracing or the overlay: once 47 is in play, list the air rifles in the scene (frame 90 of play), give him the air rifle and its darts (frame 100 of play), put it in his hands (175), empty and reload it (300) and switch to the first-person camera (520), logging pcanim test: lines with the reload and first-person animations the game picks and whether the scene's templates have them (port/engine/debug/_sdl/pcanimtestsdl.cpp; pc_animations).

The hooks drive the same queued-action path as the window, which makes them usable from a script without synthetic mouse input:

build/port/cmake/openbloodmoney "Hitman - Blood Money (Europe).iso" \
    DisableScripts=1 DefaultScene=M00/M00_Main \
    OPENBLOOD_DEBUG_UI_TRACE=1 OPENBLOOD_DEBUG_STATE_TEST=smoke

Crash reports

The port installs handlers for SIGSEGV, SIGBUS, SIGILL, SIGFPE and SIGABRT that write, to stderr and to <user dir>/crash.txt:

  • the signal and the fault address (SA_SIGINFO);
  • the current scene, frame and game time;
  • the last 64 user-visible actions (scene loads, state saves and loads, item gives) from engine/system/_sdl/crashcontext.cpp;
  • the running script and its object, the last script message id and the five most frequent message ids;
  • a backtrace with the binary's symbols.

The Performance tab's Last crash report section shows that file's tail, so a crash from a normal launch can be read inside the game. The file is overwritten by the next crash.

Implementation

Path Purpose
port/engine/debug/_sdl/debugui.{h,cpp} ImGui context and backends, the window and tabs, the action queue and its application.
port/engine/debug/_sdl/debugstats.{h,cpp} Per-frame timing and draw statistics ring buffer.
port/engine/debug/_sdl/debugpanelperformance.cpp Performance tab.
port/engine/debug/_sdl/debugpanelscenario.cpp Scenario tab, disc scene enumeration and player/item controls.
port/engine/debug/_sdl/debugstate.{h,cpp} Save-state files, metadata and the load-info lifetime.
port/engine/debug/_sdl/debugpanelstates.cpp Save-state tab.
port/engine/debug/_sdl/pctexttestsdl.cpp, modelstestsdl.cpp, pcanimtestsdl.cpp, pclayouttestsdl.cpp, pctuningtestsdl.cpp, scenefxtestsdl.cpp, pcfixestestsdl.cpp Scripted test runs of the PC-version work, each started by its own environment variable and run once a frame from DebugUiApplyPending.

The scripted test runs and the pages that describe them:

Driver Variable Described in
pctexttestsdl.cpp OPENBLOOD_PCTEXT_TEST=news pc-assets.md
modelstestsdl.cpp OPENBLOOD_MODELS_TEST=closeup pc-assets.md, "PC character models in a disc run"
pcanimtestsdl.cpp OPENBLOOD_PCANIM_TEST=airrifle the table above
pclayouttestsdl.cpp OPENBLOOD_PCLAYOUT_TEST enhancements.md, gui-and-input.md
pctuningtestsdl.cpp OPENBLOOD_PCTUNING_TEST enhancements.md
scenefxtestsdl.cpp OPENBLOOD_SCENEFX_TEST, _AT, _WALK, _LOG pc-data.md
pcfixestestsdl.cpp OPENBLOOD_PCFIXES_TEST enhancements.md, frame-rate.md

Each counts the frames 47 is in play and starts over at 0 when he is not (a restart, a scene change). Pointers a driver keeps between frames (the climb guide of pctuning climb, the actor order of models closeup) are found again on each run, and OPENBLOOD_SCENEFX_WALK walks from the OPENBLOOD_SCENEFX_AT place on each run rather than from where the last run ended; before 26 November 2026 a second run in the same session used the first scene's freed objects.

Hooks in the existing port code:

  • ZRenderSDL::Flip (port/engine/drawing/old/_sdl/rendersdl.cpp) finalizes the frame statistics and builds the ImGui frame before Present.
  • GpuEndFrame (gpusdl.cpp) composites the game frame, then draws ImGui into the acquired swapchain texture and submits.
  • InputHandleEvent and ReadKeyboard (sysinputsdl.cpp) forward SDL events to ImGui and stop the game from reading the keyboard while an ImGui text field has focus.
  • ZSysInterfaceSDL::NormalMainLoop (sysinterfacesdl.cpp) applies queued actions at the start of the frame and times ZEngineDataBase::MainLoop.
  • ScriptDispatch (port/engine/zstdlib/_sdl/scriptcallsdl.cpp) counts script interface calls; the performance tab shows the per-frame delta.
  • disc.cpp gained DiscListDirectory, the scene enumeration both disc backends share.

Dear ImGui is pinned in port/port.json (imgui.version, url, sha256) and installed under tools/third_party/port/imgui-<version> by make port-setup; CMake builds it as the openblood_imgui static library with the SDL3 and SDL_GPU backends. ImGui needs C++11, so the platform sources build as gnu++14; the game translation units keep the original gnu++98.

Test hooks

  • OPENBLOOD_PROMPTS=keyboard or pad fixes the prompt style without changing input handling. An OPENBLOOD_INPUT_SCRIPT line naming keyboard or pad switches the input handling for its frames, one naming mouseleft, mouseright or mousemiddle holds that mouse button, and one naming mousex or mousey with a value moves the mouse by that many counts each game frame, before mouse_sensitivity (1500 2000 mousex 10); scripted runs otherwise use the pad. For the menus and the pause map, mouseposx and mouseposy with a value place the cursor in the game's 512 by 448 picture (the position holds until another such line moves it: 1400 1500 mouseposx 256), and mousewheel with 1 or -1 turns the wheel one notch up or down on each tick it is active, so give it a period and a pulse (1600 1700 mousewheel 1 20 1). A line is FROM TO NAME [VALUE [PERIOD PULSE]] in ticks of the script, one per update of the pad: about one per game frame in play, two while the pause map runs at 60 frames a second, and many more while a menu pauses the game. OPENBLOOD_TRACE_INPUT_SCRIPT=1 logs the tick at which each line starts. Key lines take SDL key names without spaces (J, F5); a binding on a key whose name has a space, such as Left Alt, cannot be pressed from a script. OPENBLOOD_TRACE_GUIDE_MODELS=1 logs, when a level's climbable windows and drainpipes are first asked for (obm.world.traversal_guides), each guide's box and the level models matched to it (guide models: lines). With the modern controller layout a script's pad buttons are the controller's buttons, so they go through the layout (SModernPadSDL), with or without a controller connected; OPENBLOOD_TRACE_MODERN=1 logs each change of the buttons it reads and holds (bit masks in EPadButton order), its requests and its context (modern pad: lines), the Reprisal camera (normal or shoulder), its distance, side and drop offsets, look factor, aim assist target and lock, angles and wall-check distance while it moves and every 15 frames otherwise (modern cam:), and each lock taken or dropped (modern aim:), getting on and off a ladder, drainpipe or climbing wall and its lean (modern climb:), a throw released or called off (modern throw:) and each pulse of the M13 heartbeat (modern rumble:).
  • OPENBLOOD_TRACE_PCMOUSE=1 logs what the PC mouse controls do (pc mouse: lines: map drags and zooms, the weapon details' turns, pans and zooms, the keys the keyboard configuration binds and takes). OPENBLOOD_MENU_TEST_WINDOW=<window> opens a window of the scene's menu XML (ButtonConfiguration, the keyboard configuration) after OPENBLOOD_MENU_TEST_FRAME frames (600 by default) and logs the input script's tick then.
  • OPENBLOOD_LAUNCHER_CAPTURE=FILE.png draws a few frames, writes the last one as a PNG and quits.
  • OPENBLOOD_LAUNCHER_MODEL_ANGLE=RADIANS holds the main page's guns at that turn, so captures of one angle can be compared, or of angles a frame apart (about 0.0017 at 60 frames a second) to find flicker.
  • OPENBLOOD_LAUNCHER_FRAMES=N closes the launcher after N frames without saving the settings, and quits. With OPENBLOOD_PERF_LOG=N it logs launcher perf: every N frames: the time a frame, the worst frame, the wait for the swapchain (the GPU's share when the frame rate is not held) and the CPU's. OPENBLOOD_LAUNCHER_UNCAPPED=1 presents without vsync, where the GPU allows it.
  • OPENBLOOD_LAUNCHER_SCREEN=quick_start captures the mission page (OPENBLOOD_LAUNCHER_MISSION=N picks the mission); bindings opens the Buttons tab.
  • OPENBLOOD_LAUNCHER_SCREEN=settings with OPENBLOOD_LAUNCHER_TAB=display, graphics, gameplay, reprisal, controls, buttons or files chooses the tab (enhancements picks Graphics).
  • OPENBLOOD_LAUNCHER_PLAY=1 presses Play at once when the saved disc is valid; OPENBLOOD_LAUNCHER_PLAY=quick starts the mission OPENBLOOD_LAUNCHER_MISSION picks (custom levels follow the 13 stock missions) as Quick Play does. A scripted Play does not save the settings. A comma list (1,quick,1) gives each opening of the launcher the next entry, and the last from then on.
  • OPENBLOOD_RETURN_TO_LAUNCHER=N makes the first N sessions that --frames ends go back to the launcher, as Quit to launcher does, each session counting its frames again. With OPENBLOOD_LAUNCHER_PLAY=1,quick,1,quick and --frames 700 it plays Play, Quit to launcher and Quick Play over and over: on 3 December 2026 that crashed every time in the third session (the lit meshes' cache kept buffers of the device the last session destroyed, and released them on the new one; RenderShutdownSDL now clears it).