mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Guarding against 'TracyIsStarted' in many of Tracy's functions so that MANUAL_LIFETIME can be used correctly. Mutexes that have been allocated *before* Tracy is initialised will not be tracked.
This commit is contained in:
parent
cc3cbfe6f2
commit
615128151d
@ -14,13 +14,20 @@ namespace tracy
|
|||||||
class LockableCtx
|
class LockableCtx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tracy_force_inline LockableCtx( const SourceLocationData* srcloc )
|
tracy_force_inline LockableCtx( const SourceLocationData* srcloc ) :
|
||||||
: m_id( GetLockCounter().fetch_add( 1, std::memory_order_relaxed ) )
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
, m_lockCount( 0 )
|
, m_lockCount( 0 )
|
||||||
, m_active( false )
|
, m_active( false )
|
||||||
|
#else
|
||||||
|
m_active(TracyIsStarted)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_id = GetLockCounter().fetch_add(1, std::memory_order_relaxed);
|
||||||
|
|
||||||
assert( m_id != (std::numeric_limits<uint32_t>::max)() );
|
assert( m_id != (std::numeric_limits<uint32_t>::max)() );
|
||||||
|
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
@ -40,6 +47,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline ~LockableCtx()
|
tracy_force_inline ~LockableCtx()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
||||||
MemWrite( &item->lockTerminate.id, m_id );
|
MemWrite( &item->lockTerminate.id, m_id );
|
||||||
@ -52,6 +62,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline bool BeforeLock()
|
tracy_force_inline bool BeforeLock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return false;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
bool queue = false;
|
bool queue = false;
|
||||||
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
||||||
@ -76,6 +89,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterLock()
|
tracy_force_inline void AfterLock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||||
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
||||||
@ -86,6 +102,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterUnlock()
|
tracy_force_inline void AfterUnlock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
||||||
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
||||||
@ -105,6 +124,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterTryLock( bool acquired )
|
tracy_force_inline void AfterTryLock( bool acquired )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !acquired ) return;
|
if( !acquired ) return;
|
||||||
|
|
||||||
@ -133,6 +155,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Mark( const SourceLocationData* srcloc )
|
tracy_force_inline void Mark( const SourceLocationData* srcloc )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
const auto active = m_active.load( std::memory_order_relaxed );
|
const auto active = m_active.load( std::memory_order_relaxed );
|
||||||
if( !active ) return;
|
if( !active ) return;
|
||||||
@ -154,6 +179,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void CustomName( const char* name, size_t size )
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, name, size );
|
memcpy( ptr, name, size );
|
||||||
@ -173,8 +201,9 @@ private:
|
|||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
std::atomic<uint32_t> m_lockCount;
|
std::atomic<uint32_t> m_lockCount;
|
||||||
std::atomic<bool> m_active;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::atomic<bool> m_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -229,12 +258,18 @@ class SharedLockableCtx
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tracy_force_inline SharedLockableCtx( const SourceLocationData* srcloc )
|
tracy_force_inline SharedLockableCtx( const SourceLocationData* srcloc )
|
||||||
: m_id( GetLockCounter().fetch_add( 1, std::memory_order_relaxed ) )
|
:
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
, m_lockCount( 0 )
|
, m_lockCount( 0 )
|
||||||
, m_active( false )
|
, m_active( false )
|
||||||
|
#else
|
||||||
|
m_active(TracyIsStarted)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
|
m_id = GetLockCounter().fetch_add(1, std::memory_order_relaxed);
|
||||||
assert(m_id != (std::numeric_limits<uint32_t>::max)());
|
assert(m_id != (std::numeric_limits<uint32_t>::max)());
|
||||||
|
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
@ -254,6 +289,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline ~SharedLockableCtx()
|
tracy_force_inline ~SharedLockableCtx()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
MemWrite( &item->hdr.type, QueueType::LockTerminate );
|
||||||
MemWrite( &item->lockTerminate.id, m_id );
|
MemWrite( &item->lockTerminate.id, m_id );
|
||||||
@ -266,6 +304,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline bool BeforeLock()
|
tracy_force_inline bool BeforeLock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return false;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
bool queue = false;
|
bool queue = false;
|
||||||
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
||||||
@ -290,6 +331,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterLock()
|
tracy_force_inline void AfterLock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
MemWrite( &item->hdr.type, QueueType::LockObtain );
|
||||||
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
||||||
@ -300,6 +344,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterUnlock()
|
tracy_force_inline void AfterUnlock()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
||||||
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
||||||
@ -319,6 +366,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterTryLock( bool acquired )
|
tracy_force_inline void AfterTryLock( bool acquired )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !acquired ) return;
|
if( !acquired ) return;
|
||||||
|
|
||||||
@ -347,6 +397,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline bool BeforeLockShared()
|
tracy_force_inline bool BeforeLockShared()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return false;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
bool queue = false;
|
bool queue = false;
|
||||||
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
const auto locks = m_lockCount.fetch_add( 1, std::memory_order_relaxed );
|
||||||
@ -371,6 +424,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterLockShared()
|
tracy_force_inline void AfterLockShared()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockSharedObtain );
|
MemWrite( &item->hdr.type, QueueType::LockSharedObtain );
|
||||||
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
MemWrite( &item->lockObtain.thread, GetThreadHandle() );
|
||||||
@ -381,6 +437,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterUnlockShared()
|
tracy_force_inline void AfterUnlockShared()
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
m_lockCount.fetch_sub( 1, std::memory_order_relaxed );
|
||||||
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
if( !m_active.load( std::memory_order_relaxed ) ) return;
|
||||||
@ -401,6 +460,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void AfterTryLockShared( bool acquired )
|
tracy_force_inline void AfterTryLockShared( bool acquired )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !acquired ) return;
|
if( !acquired ) return;
|
||||||
|
|
||||||
@ -429,6 +491,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Mark( const SourceLocationData* srcloc )
|
tracy_force_inline void Mark( const SourceLocationData* srcloc )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
const auto active = m_active.load( std::memory_order_relaxed );
|
const auto active = m_active.load( std::memory_order_relaxed );
|
||||||
if( !active ) return;
|
if( !active ) return;
|
||||||
@ -450,6 +515,9 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void CustomName( const char* name, size_t size )
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
{
|
{
|
||||||
|
#if !TRACY_ON_DEMAND
|
||||||
|
if (!m_active) return;
|
||||||
|
#endif
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, name, size );
|
memcpy( ptr, name, size );
|
||||||
@ -469,8 +537,8 @@ private:
|
|||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
std::atomic<uint32_t> m_lockCount;
|
std::atomic<uint32_t> m_lockCount;
|
||||||
std::atomic<bool> m_active;
|
|
||||||
#endif
|
#endif
|
||||||
|
std::atomic<bool> m_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -273,6 +273,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void QueueSerialFinish()
|
static tracy_force_inline void QueueSerialFinish()
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
auto& p = GetProfiler();
|
auto& p = GetProfiler();
|
||||||
p.m_serialQueue.commit_next();
|
p.m_serialQueue.commit_next();
|
||||||
p.m_serialLock.unlock();
|
p.m_serialLock.unlock();
|
||||||
@ -280,6 +281,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SendFrameMark( const char* name )
|
static tracy_force_inline void SendFrameMark( const char* name )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !name ) GetProfiler().m_frameCount.fetch_add( 1, std::memory_order_relaxed );
|
if( !name ) GetProfiler().m_frameCount.fetch_add( 1, std::memory_order_relaxed );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -293,6 +295,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SendFrameMark( const char* name, QueueType type )
|
static tracy_force_inline void SendFrameMark( const char* name, QueueType type )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
assert( type == QueueType::FrameMarkMsgStart || type == QueueType::FrameMarkMsgEnd );
|
assert( type == QueueType::FrameMarkMsgStart || type == QueueType::FrameMarkMsgEnd );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -306,6 +309,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SendFrameImage( const void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip )
|
static tracy_force_inline void SendFrameImage( const void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifndef TRACY_NO_FRAME_IMAGE
|
#ifndef TRACY_NO_FRAME_IMAGE
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
assert( profiler.m_frameCount.load( std::memory_order_relaxed ) < (std::numeric_limits<uint32_t>::max)() );
|
assert( profiler.m_frameCount.load( std::memory_order_relaxed ) < (std::numeric_limits<uint32_t>::max)() );
|
||||||
@ -336,6 +340,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void PlotData( const char* name, int64_t val )
|
static tracy_force_inline void PlotData( const char* name, int64_t val )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -348,6 +353,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void PlotData( const char* name, float val )
|
static tracy_force_inline void PlotData( const char* name, float val )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -360,6 +366,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void PlotData( const char* name, double val )
|
static tracy_force_inline void PlotData( const char* name, double val )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -372,6 +379,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void ConfigurePlot( const char* name, PlotFormatType type, bool step, bool fill, uint32_t color )
|
static tracy_force_inline void ConfigurePlot( const char* name, PlotFormatType type, bool step, bool fill, uint32_t color )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
TracyLfqPrepare( QueueType::PlotConfig );
|
TracyLfqPrepare( QueueType::PlotConfig );
|
||||||
MemWrite( &item->plotConfig.name, (uint64_t)name );
|
MemWrite( &item->plotConfig.name, (uint64_t)name );
|
||||||
MemWrite( &item->plotConfig.type, (uint8_t)type );
|
MemWrite( &item->plotConfig.type, (uint8_t)type );
|
||||||
@ -388,6 +396,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -409,6 +418,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void Message( const char* txt, int callstack )
|
static tracy_force_inline void Message( const char* txt, int callstack )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -425,6 +435,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color, int callstack )
|
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color, int callstack )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -449,6 +460,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MessageColor( const char* txt, uint32_t color, int callstack )
|
static tracy_force_inline void MessageColor( const char* txt, uint32_t color, int callstack )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -468,6 +480,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
@ -485,6 +498,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemAlloc( const void* ptr, size_t size, bool secure )
|
static tracy_force_inline void MemAlloc( const void* ptr, size_t size, bool secure )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -498,6 +512,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemFree( const void* ptr, bool secure )
|
static tracy_force_inline void MemFree( const void* ptr, bool secure )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -511,6 +526,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemAllocCallstack( const void* ptr, size_t size, int depth, bool secure )
|
static tracy_force_inline void MemAllocCallstack( const void* ptr, size_t size, int depth, bool secure )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
@ -533,6 +549,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemFreeCallstack( const void* ptr, int depth, bool secure )
|
static tracy_force_inline void MemFreeCallstack( const void* ptr, int depth, bool secure )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
if( !ProfilerAllocatorAvailable() )
|
if( !ProfilerAllocatorAvailable() )
|
||||||
{
|
{
|
||||||
@ -560,6 +577,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemAllocNamed( const void* ptr, size_t size, bool secure, const char* name )
|
static tracy_force_inline void MemAllocNamed( const void* ptr, size_t size, bool secure, const char* name )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -574,6 +592,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemFreeNamed( const void* ptr, bool secure, const char* name )
|
static tracy_force_inline void MemFreeNamed( const void* ptr, bool secure, const char* name )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -588,6 +607,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemAllocCallstackNamed( const void* ptr, size_t size, int depth, bool secure, const char* name )
|
static tracy_force_inline void MemAllocCallstackNamed( const void* ptr, size_t size, int depth, bool secure, const char* name )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
@ -612,6 +632,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MemFreeCallstackNamed( const void* ptr, int depth, bool secure, const char* name )
|
static tracy_force_inline void MemFreeCallstackNamed( const void* ptr, int depth, bool secure, const char* name )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( secure && !ProfilerAvailable() ) return;
|
if( secure && !ProfilerAvailable() ) return;
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
@ -636,6 +657,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SendCallstack( int depth )
|
static tracy_force_inline void SendCallstack( int depth )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
auto ptr = Callstack( depth );
|
auto ptr = Callstack( depth );
|
||||||
TracyQueuePrepare( QueueType::Callstack );
|
TracyQueuePrepare( QueueType::Callstack );
|
||||||
@ -648,6 +670,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void ParameterRegister( ParameterCallback cb, void* data )
|
static tracy_force_inline void ParameterRegister( ParameterCallback cb, void* data )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
profiler.m_paramCallback = cb;
|
profiler.m_paramCallback = cb;
|
||||||
profiler.m_paramCallbackData = data;
|
profiler.m_paramCallbackData = data;
|
||||||
@ -655,6 +678,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void ParameterSetup( uint32_t idx, const char* name, bool isBool, int32_t val )
|
static tracy_force_inline void ParameterSetup( uint32_t idx, const char* name, bool isBool, int32_t val )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
TracyLfqPrepare( QueueType::ParamSetup );
|
TracyLfqPrepare( QueueType::ParamSetup );
|
||||||
tracy::MemWrite( &item->paramSetup.idx, idx );
|
tracy::MemWrite( &item->paramSetup.idx, idx );
|
||||||
tracy::MemWrite( &item->paramSetup.name, (uint64_t)name );
|
tracy::MemWrite( &item->paramSetup.name, (uint64_t)name );
|
||||||
@ -670,6 +694,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SourceCallbackRegister( SourceContentsCallback cb, void* data )
|
static tracy_force_inline void SourceCallbackRegister( SourceContentsCallback cb, void* data )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
profiler.m_sourceCallback = cb;
|
profiler.m_sourceCallback = cb;
|
||||||
profiler.m_sourceCallbackData = data;
|
profiler.m_sourceCallbackData = data;
|
||||||
@ -678,6 +703,7 @@ public:
|
|||||||
#ifdef TRACY_FIBERS
|
#ifdef TRACY_FIBERS
|
||||||
static tracy_force_inline void EnterFiber( const char* fiber )
|
static tracy_force_inline void EnterFiber( const char* fiber )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
TracyQueuePrepare( QueueType::FiberEnter );
|
TracyQueuePrepare( QueueType::FiberEnter );
|
||||||
MemWrite( &item->fiberEnter.time, GetTime() );
|
MemWrite( &item->fiberEnter.time, GetTime() );
|
||||||
MemWrite( &item->fiberEnter.fiber, (uint64_t)fiber );
|
MemWrite( &item->fiberEnter.fiber, (uint64_t)fiber );
|
||||||
@ -686,6 +712,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void LeaveFiber()
|
static tracy_force_inline void LeaveFiber()
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
TracyQueuePrepare( QueueType::FiberLeave );
|
TracyQueuePrepare( QueueType::FiberLeave );
|
||||||
MemWrite( &item->fiberLeave.time, GetTime() );
|
MemWrite( &item->fiberLeave.time, GetTime() );
|
||||||
TracyQueueCommit( fiberLeave );
|
TracyQueueCommit( fiberLeave );
|
||||||
|
|||||||
@ -28,6 +28,7 @@ public:
|
|||||||
: m_active( is_active )
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_connectionId = GetProfiler().ConnectionId();
|
m_connectionId = GetProfiler().ConnectionId();
|
||||||
@ -45,6 +46,7 @@ public:
|
|||||||
: m_active( is_active )
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_connectionId = GetProfiler().ConnectionId();
|
m_connectionId = GetProfiler().ConnectionId();
|
||||||
@ -64,6 +66,7 @@ public:
|
|||||||
: m_active( is_active )
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_connectionId = GetProfiler().ConnectionId();
|
m_connectionId = GetProfiler().ConnectionId();
|
||||||
@ -82,6 +85,7 @@ public:
|
|||||||
: m_active( is_active )
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
m_connectionId = GetProfiler().ConnectionId();
|
m_connectionId = GetProfiler().ConnectionId();
|
||||||
@ -97,6 +101,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline ~ScopedZone()
|
tracy_force_inline ~ScopedZone()
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
@ -109,6 +114,7 @@ public:
|
|||||||
tracy_force_inline void Text( const char* txt, size_t size )
|
tracy_force_inline void Text( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
@ -124,6 +130,7 @@ public:
|
|||||||
tracy_force_inline void Name( const char* txt, size_t size )
|
tracy_force_inline void Name( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
@ -138,6 +145,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Color( uint32_t color )
|
tracy_force_inline void Color( uint32_t color )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
@ -151,6 +159,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Value( uint64_t value )
|
tracy_force_inline void Value( uint64_t value )
|
||||||
{
|
{
|
||||||
|
if (!TracyIsStarted) return;
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user