diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 799e8876..d438b844 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -1142,12 +1142,14 @@ thread_local bool RpThreadShutdown = false; # ifdef TRACY_MANUAL_LIFETIME ProfilerData* s_profilerData = nullptr; static ProfilerThreadData& GetProfilerThreadData(); +static std::atomic s_isProfilerStarted { false }; TRACY_API void StartupProfiler() { s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) ); new (s_profilerData) ProfilerData(); s_profilerData->profiler.SpawnWorkerThreads(); GetProfilerThreadData().token = ProducerWrapper( *s_profilerData ); + s_isProfilerStarted.store( true, std::memory_order_seq_cst ); } static ProfilerData& GetProfilerData() { @@ -1156,6 +1158,7 @@ static ProfilerData& GetProfilerData() } TRACY_API void ShutdownProfiler() { + s_isProfilerStarted.store( false, std::memory_order_seq_cst ); s_profilerData->~ProfilerData(); tracy_free( s_profilerData ); s_profilerData = nullptr; @@ -1163,6 +1166,10 @@ TRACY_API void ShutdownProfiler() RpThreadInitDone = false; RpInitDone.store( 0, std::memory_order_release ); } +TRACY_API bool IsProfilerStarted() +{ + return s_isProfilerStarted.load( std::memory_order_seq_cst ); +} # else static std::atomic profilerDataLock { 0 }; static std::atomic profilerData { nullptr }; @@ -4439,6 +4446,11 @@ TRACY_API void ___tracy_shutdown_profiler( void ) { tracy::ShutdownProfiler(); } + +TRACY_API int ___tracy_profiler_started( void ) +{ + return tracy::s_isProfilerStarted.load( std::memory_order_seq_cst ); +} # endif #ifdef __cplusplus diff --git a/public/client/TracyProfiler.hpp b/public/client/TracyProfiler.hpp index e3b256df..c2bf5b11 100644 --- a/public/client/TracyProfiler.hpp +++ b/public/client/TracyProfiler.hpp @@ -51,6 +51,10 @@ namespace tracy #if defined(TRACY_DELAYED_INIT) && defined(TRACY_MANUAL_LIFETIME) TRACY_API void StartupProfiler(); TRACY_API void ShutdownProfiler(); +TRACY_API bool IsProfilerStarted(); +# define TracyIsStarted tracy::IsProfilerStarted() +#else +# define TracyIsStarted true #endif class GpuCtx; diff --git a/public/tracy/Tracy.hpp b/public/tracy/Tracy.hpp index 978eb5ef..c557a2c8 100644 --- a/public/tracy/Tracy.hpp +++ b/public/tracy/Tracy.hpp @@ -109,6 +109,7 @@ #define TracyParameterRegister(x,y) #define TracyParameterSetup(x,y,z,w) #define TracyIsConnected false +#define TracyIsStarted false #define TracySetProgramName(x) #define TracyFiberEnter(x) diff --git a/public/tracy/TracyC.h b/public/tracy/TracyC.h index cf23203d..6e62d56a 100644 --- a/public/tracy/TracyC.h +++ b/public/tracy/TracyC.h @@ -97,6 +97,7 @@ typedef const void* TracyCZoneCtx; #define TracyCMessageLCS(x,y,z) #define TracyCIsConnected 0 +#define TracyCIsStarted 0 #ifdef TRACY_FIBERS # define TracyCFiberEnter(fiber) @@ -185,6 +186,11 @@ typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx; #ifdef TRACY_MANUAL_LIFETIME TRACY_API void ___tracy_startup_profiler(void); TRACY_API void ___tracy_shutdown_profiler(void); +TRACY_API int ___tracy_profiler_started(void); + +# define TracyCIsStarted ___tracy_profiler_started() +#else +# define TracyCIsStarted 1 #endif TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz );