1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 04:43:53 +00:00

Replace #ifdef TRACT_HAS_CALLSTACK with constexpr call

This commit is contained in:
Igor S. Gerasimov 2024-12-27 10:12:55 +01:00
parent cf912bbb19
commit e9eecbb2c6

View File

@ -513,7 +513,7 @@ public:
static tracy_force_inline void MemAllocCallstack( const void* ptr, size_t size, int depth, bool secure )
{
if( secure && !ProfilerAvailable() ) return;
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
auto& profiler = GetProfiler();
# ifdef TRACY_ON_DEMAND
if( !profiler.IsConnected() ) return;
@ -526,10 +526,9 @@ public:
SendCallstackSerial( callstack );
SendMemAlloc( QueueType::MemAllocCallstack, thread, ptr, size );
profiler.m_serialLock.unlock();
#else
static_cast<void>(depth); // unused
} else {
MemAlloc( ptr, size, secure );
#endif
}
}
static tracy_force_inline void MemFreeCallstack( const void* ptr, int depth, bool secure )
@ -540,7 +539,7 @@ public:
MemFree( ptr, secure );
return;
}
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
auto& profiler = GetProfiler();
# ifdef TRACY_ON_DEMAND
if( !profiler.IsConnected() ) return;
@ -553,10 +552,9 @@ public:
SendCallstackSerial( callstack );
SendMemFree( QueueType::MemFreeCallstack, thread, ptr );
profiler.m_serialLock.unlock();
#else
static_cast<void>(depth); // unused
} else {
MemFree( ptr, secure );
#endif
}
}
static tracy_force_inline void MemAllocNamed( const void* ptr, size_t size, bool secure, const char* name )
@ -590,7 +588,7 @@ public:
static tracy_force_inline void MemAllocCallstackNamed( const void* ptr, size_t size, int depth, bool secure, const char* name )
{
if( secure && !ProfilerAvailable() ) return;
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
auto& profiler = GetProfiler();
# ifdef TRACY_ON_DEMAND
if( !profiler.IsConnected() ) return;
@ -604,16 +602,15 @@ public:
SendMemName( name );
SendMemAlloc( QueueType::MemAllocCallstackNamed, thread, ptr, size );
profiler.m_serialLock.unlock();
#else
static_cast<void>(depth); // unused
} else {
MemAllocNamed( ptr, size, secure, name );
#endif
}
}
static tracy_force_inline void MemFreeCallstackNamed( const void* ptr, int depth, bool secure, const char* name )
{
if( secure && !ProfilerAvailable() ) return;
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
auto& profiler = GetProfiler();
# ifdef TRACY_ON_DEMAND
if( !profiler.IsConnected() ) return;
@ -627,10 +624,9 @@ public:
SendMemName( name );
SendMemFree( QueueType::MemFreeCallstackNamed, thread, ptr );
profiler.m_serialLock.unlock();
#else
static_cast<void>(depth); // unused
} else {
MemFreeNamed( ptr, secure, name );
#endif
}
}
static tracy_force_inline void MemDiscard( const char* name, bool secure )
@ -649,7 +645,7 @@ public:
static tracy_force_inline void MemDiscardCallstack( const char* name, bool secure, int depth )
{
if( secure && !ProfilerAvailable() ) return;
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
# ifdef TRACY_ON_DEMAND
if( !GetProfiler().IsConnected() ) return;
# endif
@ -661,22 +657,19 @@ public:
SendCallstackSerial( callstack );
SendMemDiscard( QueueType::MemDiscard, thread, name );
GetProfiler().m_serialLock.unlock();
#else
static_cast<void>(depth); // unused
} else {
MemDiscard( name, secure );
#endif
}
}
static tracy_force_inline void SendCallstack( int depth )
{
#ifdef TRACY_HAS_CALLSTACK
if (depth > 0 && has_stacktrace()) {
auto ptr = Callstack( depth );
TracyQueuePrepare( QueueType::Callstack );
MemWrite( &item->callstackFat.ptr, (uint64_t)ptr );
TracyQueueCommit( callstackFatThread );
#else
static_cast<void>(depth); // unused
#endif
}
}
static tracy_force_inline void ParameterRegister( ParameterCallback cb, void* data )
@ -911,14 +904,12 @@ private:
static tracy_force_inline void SendCallstackSerial( void* ptr )
{
#ifdef TRACY_HAS_CALLSTACK
if (has_stacktrace()) {
auto item = GetProfiler().m_serialQueue.prepare_next();
MemWrite( &item->hdr.type, QueueType::CallstackSerial );
MemWrite( &item->callstackFat.ptr, (uint64_t)ptr );
GetProfiler().m_serialQueue.commit_next();
#else
static_cast<void>(ptr); // unused
#endif
}
}
static tracy_force_inline void SendMemAlloc( QueueType type, const uint32_t thread, const void* ptr, size_t size )