mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Disable all tracing if TRACY_ON_DEMAND is defined.
This commit is contained in:
parent
a5381337f6
commit
e5b133073c
12
TracyLua.hpp
12
TracyLua.hpp
@ -121,6 +121,7 @@ namespace detail
|
||||
|
||||
static inline int LuaZoneBegin( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const uint32_t color = Color::DeepSkyBlue3;
|
||||
|
||||
lua_Debug dbg;
|
||||
@ -163,11 +164,13 @@ static inline int LuaZoneBegin( lua_State* L )
|
||||
MemWrite( &item->zoneBegin.thread, GetThreadHandle() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int LuaZoneBeginN( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const uint32_t color = Color::DeepSkyBlue3;
|
||||
|
||||
lua_Debug dbg;
|
||||
@ -214,11 +217,13 @@ static inline int LuaZoneBeginN( lua_State* L )
|
||||
MemWrite( &item->zoneBegin.thread, GetThreadHandle() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int LuaZoneEnd( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -233,11 +238,13 @@ static inline int LuaZoneEnd( lua_State* L )
|
||||
#endif
|
||||
MemWrite( &item->zoneEnd.thread, GetThreadHandle() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int LuaZoneText( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
auto txt = lua_tostring( L, 1 );
|
||||
const auto size = strlen( txt );
|
||||
|
||||
@ -252,11 +259,13 @@ static inline int LuaZoneText( lua_State* L )
|
||||
MemWrite( &item->zoneText.thread, GetThreadHandle() );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int LuaZoneName( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
auto txt = lua_tostring( L, 1 );
|
||||
const auto size = strlen( txt );
|
||||
|
||||
@ -271,11 +280,13 @@ static inline int LuaZoneName( lua_State* L )
|
||||
MemWrite( &item->zoneText.thread, GetThreadHandle() );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int LuaMessage( lua_State* L )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
auto txt = lua_tostring( L, 1 );
|
||||
const auto size = strlen( txt );
|
||||
|
||||
@ -291,6 +302,7 @@ static inline int LuaMessage( lua_State* L )
|
||||
MemWrite( &item->message.thread, GetThreadHandle() );
|
||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
GLint bits;
|
||||
glGetQueryiv( GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &bits );
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const float period = 1.f;
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
@ -78,10 +79,12 @@ public:
|
||||
MemWrite( &item->gpuNewContext.context, m_context );
|
||||
MemWrite( &item->gpuNewContext.accuracyBits, (uint8_t)bits );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Collect()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
ZoneScopedC( Color::Red4 );
|
||||
|
||||
auto start = m_tail;
|
||||
@ -122,6 +125,7 @@ public:
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
m_tail = ( m_tail + 1 ) % QueryCount;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
@ -157,6 +161,7 @@ class GpuCtxScope
|
||||
public:
|
||||
tracy_force_inline GpuCtxScope( const SourceLocation* srcloc )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto queryId = s_gpuCtx.ptr->NextQueryId();
|
||||
glQueryCounter( s_gpuCtx.ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
@ -171,10 +176,12 @@ public:
|
||||
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline GpuCtxScope( const SourceLocation* srcloc, int depth )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto queryId = s_gpuCtx.ptr->NextQueryId();
|
||||
glQueryCounter( s_gpuCtx.ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
@ -193,10 +200,12 @@ public:
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
|
||||
s_profiler.SendCallstack( depth, thread );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline ~GpuCtxScope()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto queryId = s_gpuCtx.ptr->NextQueryId();
|
||||
glQueryCounter( s_gpuCtx.ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
@ -209,6 +218,7 @@ public:
|
||||
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneEnd.context, s_gpuCtx.ptr->GetId() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE );
|
||||
vkQueueWaitIdle( queue );
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -109,6 +110,7 @@ public:
|
||||
MemWrite( &item->gpuNewContext.context, m_context );
|
||||
MemWrite( &item->gpuNewContext.accuracyBits, uint8_t( 0 ) );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
~VkCtx()
|
||||
@ -118,6 +120,7 @@ public:
|
||||
|
||||
void Collect( VkCommandBuffer cmdbuf )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
ZoneScopedC( Color::Red4 );
|
||||
|
||||
if( m_tail == m_head ) return;
|
||||
@ -158,6 +161,7 @@ public:
|
||||
|
||||
m_tail += cnt;
|
||||
if( m_tail == QueryCount ) m_tail = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
@ -192,6 +196,7 @@ public:
|
||||
tracy_force_inline VkCtxScope( const SourceLocation* srcloc, VkCommandBuffer cmdbuf )
|
||||
: m_cmdbuf( cmdbuf )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
auto ctx = s_vkCtx.ptr;
|
||||
const auto queryId = ctx->NextQueryId();
|
||||
vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId );
|
||||
@ -207,11 +212,13 @@ public:
|
||||
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline VkCtxScope( const SourceLocation* srcloc, VkCommandBuffer cmdbuf, int depth )
|
||||
: m_cmdbuf( cmdbuf )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
|
||||
auto ctx = s_vkCtx.ptr;
|
||||
@ -231,10 +238,12 @@ public:
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
|
||||
s_profiler.SendCallstack( depth, thread );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline ~VkCtxScope()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
auto ctx = s_vkCtx.ptr;
|
||||
const auto queryId = ctx->NextQueryId();
|
||||
vkCmdWriteTimestamp( m_cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId );
|
||||
@ -248,6 +257,7 @@ public:
|
||||
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneEnd.context, ctx->GetId() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -31,6 +32,7 @@ public:
|
||||
MemWrite( &item->lockAnnounce.lckloc, (uint64_t)srcloc );
|
||||
MemWrite( &item->lockAnnounce.type, LockType::Lockable );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
Lockable( const Lockable& ) = delete;
|
||||
@ -38,6 +40,7 @@ public:
|
||||
|
||||
tracy_force_inline void lock()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
{
|
||||
Magic magic;
|
||||
@ -51,9 +54,11 @@ public:
|
||||
MemWrite( &item->lockWait.type, LockType::Lockable );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
|
||||
m_lockable.lock();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
{
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
@ -65,12 +70,14 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline void unlock()
|
||||
{
|
||||
m_lockable.unlock();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -80,11 +87,13 @@ public:
|
||||
MemWrite( &item->lockRelease.thread, GetThreadHandle() );
|
||||
MemWrite( &item->lockRelease.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline bool try_lock()
|
||||
{
|
||||
const auto ret = m_lockable.try_lock();
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
if( ret )
|
||||
{
|
||||
Magic magic;
|
||||
@ -97,11 +106,13 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
tracy_force_inline void Mark( const SourceLocation* srcloc ) const
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -111,6 +122,7 @@ public:
|
||||
MemWrite( &item->lockMark.thread, GetThreadHandle() );
|
||||
MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
@ -128,6 +140,7 @@ public:
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -137,6 +150,7 @@ public:
|
||||
MemWrite( &item->lockAnnounce.lckloc, (uint64_t)srcloc );
|
||||
MemWrite( &item->lockAnnounce.type, LockType::SharedLockable );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
SharedLockable( const SharedLockable& ) = delete;
|
||||
@ -144,6 +158,7 @@ public:
|
||||
|
||||
tracy_force_inline void lock()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
{
|
||||
Magic magic;
|
||||
@ -157,9 +172,11 @@ public:
|
||||
MemWrite( &item->lockWait.type, LockType::SharedLockable );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
|
||||
m_lockable.lock();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
{
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
@ -171,12 +188,14 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline void unlock()
|
||||
{
|
||||
m_lockable.unlock();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -186,11 +205,13 @@ public:
|
||||
MemWrite( &item->lockRelease.thread, GetThreadHandle() );
|
||||
MemWrite( &item->lockRelease.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline bool try_lock()
|
||||
{
|
||||
const auto ret = m_lockable.try_lock();
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
if( ret )
|
||||
{
|
||||
Magic magic;
|
||||
@ -203,11 +224,13 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
tracy_force_inline void lock_shared()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
{
|
||||
Magic magic;
|
||||
@ -221,9 +244,11 @@ public:
|
||||
MemWrite( &item->lockWait.type, LockType::SharedLockable );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
|
||||
m_lockable.lock_shared();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
{
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
@ -235,12 +260,14 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline void unlock_shared()
|
||||
{
|
||||
m_lockable.unlock_shared();
|
||||
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -250,11 +277,13 @@ public:
|
||||
MemWrite( &item->lockRelease.thread, GetThreadHandle() );
|
||||
MemWrite( &item->lockRelease.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline bool try_lock_shared()
|
||||
{
|
||||
const auto ret = m_lockable.try_lock_shared();
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
if( ret )
|
||||
{
|
||||
Magic magic;
|
||||
@ -267,11 +296,13 @@ public:
|
||||
MemWrite( &item->lockObtain.time, Profiler::GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
tracy_force_inline void Mark( const SourceLocation* srcloc ) const
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -281,6 +312,7 @@ public:
|
||||
MemWrite( &item->lockMark.thread, GetThreadHandle() );
|
||||
MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -118,6 +118,7 @@ public:
|
||||
|
||||
static tracy_force_inline void FrameMark()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -125,10 +126,12 @@ public:
|
||||
MemWrite( &item->hdr.type, QueueType::FrameMarkMsg );
|
||||
MemWrite( &item->frameMark.time, GetTime() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void PlotData( const char* name, int64_t val )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -139,10 +142,12 @@ public:
|
||||
MemWrite( &item->plotData.type, PlotDataType::Int );
|
||||
MemWrite( &item->plotData.data.i, val );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void PlotData( const char* name, float val )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -153,10 +158,12 @@ public:
|
||||
MemWrite( &item->plotData.type, PlotDataType::Float );
|
||||
MemWrite( &item->plotData.data.f, val );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void PlotData( const char* name, double val )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -167,10 +174,12 @@ public:
|
||||
MemWrite( &item->plotData.type, PlotDataType::Double );
|
||||
MemWrite( &item->plotData.data.d, val );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void Message( const char* txt, size_t size )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
@ -183,10 +192,12 @@ public:
|
||||
MemWrite( &item->message.thread, GetThreadHandle() );
|
||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void Message( const char* txt )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -196,29 +207,35 @@ public:
|
||||
MemWrite( &item->message.thread, GetThreadHandle() );
|
||||
MemWrite( &item->message.text, (uint64_t)txt );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void MemAlloc( const void* ptr, size_t size )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
|
||||
s_profiler.m_serialLock.lock();
|
||||
SendMemAlloc( QueueType::MemAlloc, thread, ptr, size );
|
||||
s_profiler.m_serialLock.unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void MemFree( const void* ptr )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
|
||||
s_profiler.m_serialLock.lock();
|
||||
SendMemFree( QueueType::MemFree, thread, ptr );
|
||||
s_profiler.m_serialLock.unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
static tracy_force_inline void MemAllocCallstack( const void* ptr, size_t size, int depth )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
# ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
|
||||
rpmalloc_thread_initialize();
|
||||
@ -228,6 +245,7 @@ public:
|
||||
SendMemAlloc( QueueType::MemAllocCallstack, thread, ptr, size );
|
||||
SendCallstackMemory( callstack );
|
||||
s_profiler.m_serialLock.unlock();
|
||||
# endif
|
||||
#else
|
||||
MemAlloc( ptr, size );
|
||||
#endif
|
||||
@ -236,6 +254,7 @@ public:
|
||||
static tracy_force_inline void MemFreeCallstack( const void* ptr, int depth )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
# ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
|
||||
rpmalloc_thread_initialize();
|
||||
@ -245,6 +264,7 @@ public:
|
||||
SendMemFree( QueueType::MemFreeCallstack, thread, ptr );
|
||||
SendCallstackMemory( callstack );
|
||||
s_profiler.m_serialLock.unlock();
|
||||
# endif
|
||||
#else
|
||||
MemFree( ptr );
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@ class ScopedZone
|
||||
public:
|
||||
tracy_force_inline ScopedZone( const SourceLocation* srcloc )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
m_thread = thread;
|
||||
Magic magic;
|
||||
@ -34,10 +35,12 @@ public:
|
||||
MemWrite( &item->zoneBegin.thread, thread );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline ScopedZone( const SourceLocation* srcloc, int depth )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
const auto thread = GetThreadHandle();
|
||||
m_thread = thread;
|
||||
Magic magic;
|
||||
@ -57,10 +60,12 @@ public:
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
|
||||
s_profiler.SendCallstack( depth, thread );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline ~ScopedZone()
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
@ -75,10 +80,12 @@ public:
|
||||
#endif
|
||||
MemWrite( &item->zoneEnd.thread, m_thread );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline void Text( const char* txt, size_t size )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
@ -90,10 +97,12 @@ public:
|
||||
MemWrite( &item->zoneText.thread, m_thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
tracy_force_inline void Name( const char* txt, size_t size )
|
||||
{
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
@ -105,6 +114,7 @@ public:
|
||||
MemWrite( &item->zoneText.thread, m_thread );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user