mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
commit
8202502a2f
@ -1142,12 +1142,14 @@ thread_local bool RpThreadShutdown = false;
|
|||||||
# ifdef TRACY_MANUAL_LIFETIME
|
# ifdef TRACY_MANUAL_LIFETIME
|
||||||
ProfilerData* s_profilerData = nullptr;
|
ProfilerData* s_profilerData = nullptr;
|
||||||
static ProfilerThreadData& GetProfilerThreadData();
|
static ProfilerThreadData& GetProfilerThreadData();
|
||||||
|
static std::atomic<bool> s_isProfilerStarted { false };
|
||||||
TRACY_API void StartupProfiler()
|
TRACY_API void StartupProfiler()
|
||||||
{
|
{
|
||||||
s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) );
|
s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) );
|
||||||
new (s_profilerData) ProfilerData();
|
new (s_profilerData) ProfilerData();
|
||||||
s_profilerData->profiler.SpawnWorkerThreads();
|
s_profilerData->profiler.SpawnWorkerThreads();
|
||||||
GetProfilerThreadData().token = ProducerWrapper( *s_profilerData );
|
GetProfilerThreadData().token = ProducerWrapper( *s_profilerData );
|
||||||
|
s_isProfilerStarted.store( true, std::memory_order_seq_cst );
|
||||||
}
|
}
|
||||||
static ProfilerData& GetProfilerData()
|
static ProfilerData& GetProfilerData()
|
||||||
{
|
{
|
||||||
@ -1156,6 +1158,7 @@ static ProfilerData& GetProfilerData()
|
|||||||
}
|
}
|
||||||
TRACY_API void ShutdownProfiler()
|
TRACY_API void ShutdownProfiler()
|
||||||
{
|
{
|
||||||
|
s_isProfilerStarted.store( false, std::memory_order_seq_cst );
|
||||||
s_profilerData->~ProfilerData();
|
s_profilerData->~ProfilerData();
|
||||||
tracy_free( s_profilerData );
|
tracy_free( s_profilerData );
|
||||||
s_profilerData = nullptr;
|
s_profilerData = nullptr;
|
||||||
@ -1163,6 +1166,10 @@ TRACY_API void ShutdownProfiler()
|
|||||||
RpThreadInitDone = false;
|
RpThreadInitDone = false;
|
||||||
RpInitDone.store( 0, std::memory_order_release );
|
RpInitDone.store( 0, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
TRACY_API bool IsProfilerStarted()
|
||||||
|
{
|
||||||
|
return s_isProfilerStarted.load( std::memory_order_seq_cst );
|
||||||
|
}
|
||||||
# else
|
# else
|
||||||
static std::atomic<int> profilerDataLock { 0 };
|
static std::atomic<int> profilerDataLock { 0 };
|
||||||
static std::atomic<ProfilerData*> profilerData { nullptr };
|
static std::atomic<ProfilerData*> profilerData { nullptr };
|
||||||
@ -4439,6 +4446,11 @@ TRACY_API void ___tracy_shutdown_profiler( void )
|
|||||||
{
|
{
|
||||||
tracy::ShutdownProfiler();
|
tracy::ShutdownProfiler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACY_API int ___tracy_profiler_started( void )
|
||||||
|
{
|
||||||
|
return tracy::s_isProfilerStarted.load( std::memory_order_seq_cst );
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -51,6 +51,10 @@ namespace tracy
|
|||||||
#if defined(TRACY_DELAYED_INIT) && defined(TRACY_MANUAL_LIFETIME)
|
#if defined(TRACY_DELAYED_INIT) && defined(TRACY_MANUAL_LIFETIME)
|
||||||
TRACY_API void StartupProfiler();
|
TRACY_API void StartupProfiler();
|
||||||
TRACY_API void ShutdownProfiler();
|
TRACY_API void ShutdownProfiler();
|
||||||
|
TRACY_API bool IsProfilerStarted();
|
||||||
|
# define TracyIsStarted tracy::IsProfilerStarted()
|
||||||
|
#else
|
||||||
|
# define TracyIsStarted true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class GpuCtx;
|
class GpuCtx;
|
||||||
|
@ -109,6 +109,7 @@
|
|||||||
#define TracyParameterRegister(x,y)
|
#define TracyParameterRegister(x,y)
|
||||||
#define TracyParameterSetup(x,y,z,w)
|
#define TracyParameterSetup(x,y,z,w)
|
||||||
#define TracyIsConnected false
|
#define TracyIsConnected false
|
||||||
|
#define TracyIsStarted false
|
||||||
#define TracySetProgramName(x)
|
#define TracySetProgramName(x)
|
||||||
|
|
||||||
#define TracyFiberEnter(x)
|
#define TracyFiberEnter(x)
|
||||||
|
@ -97,6 +97,7 @@ typedef const void* TracyCZoneCtx;
|
|||||||
#define TracyCMessageLCS(x,y,z)
|
#define TracyCMessageLCS(x,y,z)
|
||||||
|
|
||||||
#define TracyCIsConnected 0
|
#define TracyCIsConnected 0
|
||||||
|
#define TracyCIsStarted 0
|
||||||
|
|
||||||
#ifdef TRACY_FIBERS
|
#ifdef TRACY_FIBERS
|
||||||
# define TracyCFiberEnter(fiber)
|
# define TracyCFiberEnter(fiber)
|
||||||
@ -185,6 +186,11 @@ typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx;
|
|||||||
#ifdef TRACY_MANUAL_LIFETIME
|
#ifdef TRACY_MANUAL_LIFETIME
|
||||||
TRACY_API void ___tracy_startup_profiler(void);
|
TRACY_API void ___tracy_startup_profiler(void);
|
||||||
TRACY_API void ___tracy_shutdown_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
|
#endif
|
||||||
|
|
||||||
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz );
|
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz );
|
||||||
|
Loading…
Reference in New Issue
Block a user