Me again, still trying to figure out some bugs that came up after I have updated my local code base to day 242.

For some reason, introduction of the DEBUG_IF(Renderer_UseSoftware) macro call to the platform layer makes the debug system go bananas. During the cutscene mode the GroundChunks submenu (with the RecomputeOnEXEChange variable) never gets drawn on screen. However, all is well when I remove the macro call at platform level.

It doesn't happen at Day 239 and earlier. After 240-241 the renderer was moved into the third tier and the actual DisplayBufferInWindow call (where Renderer_UseSoftware is used to determine which render path to take) happens after calling DEBUGGameFrameEnd and collating the debug records. So my reasoning is something weird happens to the debug event table during this.

From what I understand, the DEBUGGameFrameEnd function swaps current event array index on the debug event table:

Why does the EventArrayIndex_EventIndex gets reset when CurrentEventArrayIndex doesn't? GlobalDebugTable_.EventArrayIndex_EventIndex >> 32 would return zero but CurrentEventArrayIndex might be set to one. What am I missing?

The only other reference to EventArrayIndex_EventIndex that I've found in the code base is the AtomicAddU64 in the RecordDebugEvent macro. Code listed below:

I feel like calling RecordDebugEvent on the platform layer messes something up. Why do we even bother with the GlobalDebugTable->CurrentEventArrayIndex if it never gets encoded into EventArrayIndex_EventIndex?

During my debugging I've made a completely identical copy of DEBUGInitializeValue function with a different name and used it in the platform layer where I've written out the complete function call instead of DEBUG_IF macro. Everything works now as intended.

I've compiled the code under -O2 instead of -O0 and everything works perfectly. Then I've had a terrible sense of deja vu, added static to DEBUGInitializeValue function's definition and lo and behold: all is right in the world again.