Add Tracy frame time instrumentation

This commit is contained in:
Eidolon 2023-09-18 16:16:08 -05:00
parent e9d789abc9
commit 42e5646c15
3 changed files with 17 additions and 0 deletions

View file

@ -14,6 +14,7 @@
#include <vector>
#include <imgui.h>
#include <tracy/tracy/Tracy.hpp>
#include "cxxutil.hpp"
#include "f_finale.h"
@ -292,6 +293,7 @@ void I_FinishUpdate(void)
{
if (rendermode == render_none)
{
FrameMark;
return;
}
@ -299,6 +301,7 @@ void I_FinishUpdate(void)
if (rendermode == render_opengl)
{
finish_legacy_ogl_update();
FrameMark;
return;
}
#endif
@ -310,6 +313,7 @@ void I_FinishUpdate(void)
if (rhi == nullptr)
{
// ???
FrameMark;
return;
}
@ -338,6 +342,8 @@ void I_FinishUpdate(void)
rhi->present();
rhi->finish();
FrameMark;
// Immediately prepare to begin drawing the next frame
I_StartDisplayUpdate();
}

View file

@ -27,6 +27,8 @@
#include <stdexcept>
#include <string>
#include <tracy/tracy/Tracy.hpp>
#if defined (__GNUC__) || defined (__unix__)
#include <unistd.h>
#endif
@ -278,6 +280,8 @@ int main(int argc, char **argv)
myargc = argc;
myargv = argv; /// \todo pull out path to exe from this string
tracy::SetThreadName("Main");
#ifdef HAVE_TTF
#ifdef _WIN32
I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE);

View file

@ -12,6 +12,7 @@
#include <memory>
#include <SDL.h>
#include <tracy/tracy/Tracy.hpp>
#include "../audio/chunk_load.hpp"
#include "../audio/gain.hpp"
@ -121,8 +122,12 @@ public:
~SdlAudioLockHandle() { SDL_UnlockAudio(); }
};
static const char* kAudio = "Audio";
void audio_callback(void* userdata, Uint8* buffer, int len)
{
tracy::SetThreadName("SDL Audio Thread");
FrameMarkStart(kAudio);
// The SDL Audio lock is implied to be held during callback.
try
@ -156,6 +161,8 @@ void audio_callback(void* userdata, Uint8* buffer, int len)
{
}
FrameMarkEnd(kAudio);
return;
}