RobertBeckebans / RBDOOM-3-BFG

Doom 3 BFG Edition source port with updated DX12 / Vulkan renderer and modern game engine features
https://www.moddb.com/mods/rbdoom-3-bfg
GNU General Public License v3.0
1.37k stars 244 forks source link

Fix clang compile failure and memory issues in debug tools #843

Closed SRSaunders closed 4 months ago

SRSaunders commented 4 months ago

Fixes #842

This also fixes a few memory issues found by valgrind in debug tools/Optick:

  1. Fix memory leak in Optick thread storage on exit while thread is still in scope (e.g. MainThread)
  2. Fix uninitialized variables in ImmediateMode (for debug tools) and Optick

This PR also simplifies / generalizes OPTICK_THREAD() instrumentation for RBDoom3BFG and fixes an Optick thread scope problem in idGameThread::Run(). I previously tested com_smp to enable/disable the thread instrumentation based on smp mode, but stupidly put this inside a conditional scope - something you shouldn't do with Optick. This change eliminates the need for this check and allows Optick to see the full scope for idGameThread::Run() when operating in smp mode, as well as all other <xxx>::Run() threads. Note that In non-smp mode, idGameThread::Run() executes on the main thread and calling OPTICK_THREAD() is not required or desired (e.g. prevents labeling of frame number in main thread).