From c822e256c9a3110542cba8dfb07548de33446fa8 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 26 Dec 2025 20:26:45 -0500 Subject: [PATCH] Add more tracy zones --- src/p_saveg.c | 15 ++++++++++----- src/sdl/al_sound.c | 29 +++++++++++++++++++++++++++++ src/z_zone.cpp | 1 + 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 9213ccfdd..45bb7a5ae 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4427,6 +4427,7 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(savebuffer_t *save) { TracyCZone(__zone, true); + boolean ret = true; switch (READUINT8(save->p)) { case 0xb7: // luabanks marker @@ -4435,25 +4436,28 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(savebuffer_t *save) if (banksinuse > NUM_LUABANKS) { CONS_Alert(CONS_ERROR, M_GetText("Corrupt Luabanks! (Too many banks in use)\n")); - return false; + ret = false; + break; } for (i = 0; i < banksinuse; i++) luabanks[i] = READINT32(save->p); if (READUINT8(save->p) != 0x1d) // consistency marker { CONS_Alert(CONS_ERROR, M_GetText("Corrupt Luabanks! (Failed consistency check)\n")); - return false; + ret = false; + break; } } case 0x1d: // consistency marker break; default: // anything else is nonsense CONS_Alert(CONS_ERROR, M_GetText("Failed consistency check (???)\n")); - return false; + ret = false; + break; } TracyCZoneEnd(__zone); - return true; + return ret; } void P_SaveGame(savebuffer_t *save, INT16 mapnum) @@ -4571,9 +4575,10 @@ boolean P_LoadNetGame(savebuffer_t *save, boolean reloading) // so the thinkers would be deleted later. Therefore, P_SetupLevel will *not* spawn // precipitation when loading a netgame save. Instead, precip has to be spawned here. // This is done in P_NetUnArchiveSpecials now. + boolean ret = P_UnArchiveLuabanksAndConsistency(save); TracyCZoneEnd(__zone); - return P_UnArchiveLuabanksAndConsistency(save); + return ret; } boolean P_SaveBufferZAlloc(savebuffer_t *save, size_t alloc_size, INT32 tag, void *user) diff --git a/src/sdl/al_sound.c b/src/sdl/al_sound.c index 8c5b6f937..425302c0b 100644 --- a/src/sdl/al_sound.c +++ b/src/sdl/al_sound.c @@ -13,6 +13,8 @@ #ifdef HAVE_OPENAL +#include + #ifdef HAVE_GME #ifdef HAVE_ZLIB #ifndef _MSC_VER @@ -389,6 +391,7 @@ static sf_count_t SecondsToSamples(float seconds, int sampleRate) { static boolean I_QueueNextSample(boolean unqueue) { + TracyCZone(__zone, true); static INT16 *stream = NULL; ALenum format = AL_FORMAT_MONO16; @@ -462,17 +465,27 @@ static boolean I_QueueNextSample(boolean unqueue) else { CONS_Alert(CONS_ERROR, "Music is active, but no source is available\n"); + TracyCZoneEnd(__zone); return false; } if (unqueue && !TRY(alSourceUnqueueBuffers, audio.music, 1, &audio.musicbuffers[audio.bufferindex])) + { + TracyCZoneEnd(__zone); return false; + } if (!TRY(alBufferData, audio.musicbuffers[audio.bufferindex], format, stream, count, samplerate)) + { + TracyCZoneEnd(__zone); return false; + } if (!TRY(alSourceQueueBuffers, audio.music, 1, &audio.musicbuffers[audio.bufferindex])) + { + TracyCZoneEnd(__zone); return false; + } audio.bufferindex = (audio.bufferindex + 1) % BUFFERCOUNT; @@ -480,14 +493,17 @@ static boolean I_QueueNextSample(boolean unqueue) if (count == 0 && !audio.looping) { I_StopSong(); + TracyCZoneEnd(__zone); return false; } + TracyCZoneEnd(__zone); return true; } static void UpdateSound(audiostate_t *aud) { + TracyCZone(__zone, true); if (aud->music != INVALID_HANDLE) { ALint processed; @@ -501,6 +517,7 @@ static void UpdateSound(audiostate_t *aud) if (!I_QueueNextSample(false)) { I_UnloadSong(); + TracyCZoneEnd(__zone); return; } } @@ -508,14 +525,21 @@ static void UpdateSound(audiostate_t *aud) TRY(alSourcePlay, aud->music); aud->startplay = false; + TracyCZoneEnd(__zone); return; } if (!TRY(alGetSourcei, aud->music, AL_BUFFERS_PROCESSED, &processed)) + { + TracyCZoneEnd(__zone); return; + } if (!TRY(alGetSourcei, aud->music, AL_BUFFERS_QUEUED, &queued)) + { + TracyCZoneEnd(__zone); return; + } // semi-hack because this is sometimes not called for a longer period of time boolean need_restart = processed == BUFFERCOUNT; @@ -528,6 +552,7 @@ static void UpdateSound(audiostate_t *aud) if (need_restart) TRY(alSourcePlay, aud->music); } + TracyCZoneEnd(__zone); } void I_UpdateSound(void) @@ -547,8 +572,10 @@ void I_UpdateSound(void) static void AudioThread(void *userdata) { + TracyCZone(__zone, true); (void)userdata; + while (true) { // doesn't need to be that frequent, this thread just feeds buffers @@ -559,11 +586,13 @@ static void AudioThread(void *userdata) if (audio.shutdown) { audio.shutdown = false; + TracyCZoneEnd(__zone); return; } UpdateSound(&audio); } } + TracyCZoneEnd(__zone); } static char *ds2chunk(void *stream, size_t *len, size_t *samplerate) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index d06c1a8d4..e1c38896c 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -166,6 +166,7 @@ void Z_Free2(void *ptr, const char *file, INT32 line) #endif block->prev->next = block->next; block->next->prev = block->prev; + TracyCFree(block); free(block); }