mirror of
https://github.com/wolfpld/tracy.git
synced 2026-01-18 17:11:26 +01:00
Store tail atomic variable in register.
Also: use macros for lock free queue prepare and commit.
This commit is contained in:
45
TracyLua.hpp
45
TracyLua.hpp
@@ -179,11 +179,10 @@ static tracy_force_inline void SendLuaCallstack( lua_State* L, uint32_t depth )
|
||||
}
|
||||
assert( dst - ptr == spaceNeeded + 4 );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::CallstackAlloc );
|
||||
TracyLfqPrepare( QueueType::CallstackAlloc );
|
||||
MemWrite( &item->callstackAlloc.ptr, (uint64_t)ptr );
|
||||
MemWrite( &item->callstackAlloc.nativePtr, (uint64_t)Callstack( depth ) );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static inline int LuaZoneBeginS( lua_State* L )
|
||||
@@ -200,11 +199,10 @@ static inline int LuaZoneBeginS( lua_State* L )
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
#ifdef TRACY_CALLSTACK
|
||||
const uint32_t depth = TRACY_CALLSTACK;
|
||||
@@ -232,11 +230,10 @@ static inline int LuaZoneBeginNS( lua_State* L )
|
||||
const auto name = lua_tolstring( L, 1, &nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
#ifdef TRACY_CALLSTACK
|
||||
const uint32_t depth = TRACY_CALLSTACK;
|
||||
@@ -266,11 +263,10 @@ static inline int LuaZoneBegin( lua_State* L )
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBeginAllocSrcLoc );
|
||||
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -294,11 +290,10 @@ static inline int LuaZoneBeginN( lua_State* L )
|
||||
const auto name = lua_tolstring( L, 1, &nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBeginAllocSrcLoc );
|
||||
TracyLfqPrepare( QueueType::ZoneBeginAllocSrcLoc );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -316,10 +311,9 @@ static inline int LuaZoneEnd( lua_State* L )
|
||||
}
|
||||
#endif
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneEnd );
|
||||
TracyLfqPrepare( QueueType::ZoneEnd );
|
||||
MemWrite( &item->zoneEnd.time, Profiler::GetTime() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -340,10 +334,9 @@ static inline int LuaZoneText( lua_State* L )
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneText );
|
||||
TracyLfqPrepare( QueueType::ZoneText );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -364,10 +357,9 @@ static inline int LuaZoneName( lua_State* L )
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneName );
|
||||
TracyLfqPrepare( QueueType::ZoneName );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -383,11 +375,10 @@ static inline int LuaMessage( lua_State* L )
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::Message );
|
||||
TracyLfqPrepare( QueueType::Message );
|
||||
MemWrite( &item->message.time, Profiler::GetTime() );
|
||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,8 +102,7 @@ public:
|
||||
|
||||
const float period = 1.f;
|
||||
const auto thread = GetThreadHandle();
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::GpuNewContext );
|
||||
TracyLfqPrepare( QueueType::GpuNewContext );
|
||||
MemWrite( &item->gpuNewContext.cpuTime, tcpu );
|
||||
MemWrite( &item->gpuNewContext.gpuTime, tgpu );
|
||||
MemWrite( &item->gpuNewContext.thread, thread );
|
||||
@@ -115,7 +114,7 @@ public:
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
void Collect()
|
||||
@@ -141,12 +140,11 @@ public:
|
||||
uint64_t time;
|
||||
glGetQueryObjectui64v( m_query[m_tail], GL_QUERY_RESULT, &time );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::GpuTime );
|
||||
TracyLfqPrepare( QueueType::GpuTime );
|
||||
MemWrite( &item->gpuTime.gpuTime, (int64_t)time );
|
||||
MemWrite( &item->gpuTime.queryId, (uint16_t)m_tail );
|
||||
MemWrite( &item->gpuTime.context, m_context );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
m_tail = ( m_tail + 1 ) % QueryCount;
|
||||
}
|
||||
@@ -192,14 +190,13 @@ public:
|
||||
const auto queryId = GetGpuCtx().ptr->NextQueryId();
|
||||
glQueryCounter( GetGpuCtx().ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::GpuZoneBegin );
|
||||
TracyLfqPrepare( QueueType::GpuZoneBegin );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
memset( &item->gpuZoneBegin.thread, 0, sizeof( item->gpuZoneBegin.thread ) );
|
||||
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneBegin.context, GetGpuCtx().ptr->GetId() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline GpuCtxScope( const SourceLocationData* srcloc, int depth )
|
||||
@@ -214,14 +211,13 @@ public:
|
||||
glQueryCounter( GetGpuCtx().ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
const auto thread = GetThreadHandle();
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::GpuZoneBeginCallstack );
|
||||
TracyLfqPrepare( QueueType::GpuZoneBeginCallstack );
|
||||
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
|
||||
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
|
||||
MemWrite( &item->gpuZoneBegin.thread, thread );
|
||||
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneBegin.context, GetGpuCtx().ptr->GetId() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
GetProfiler().SendCallstack( depth );
|
||||
}
|
||||
@@ -234,13 +230,12 @@ public:
|
||||
const auto queryId = GetGpuCtx().ptr->NextQueryId();
|
||||
glQueryCounter( GetGpuCtx().ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::GpuZoneEnd );
|
||||
TracyLfqPrepare( QueueType::GpuZoneEnd );
|
||||
MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
|
||||
memset( &item->gpuZoneEnd.thread, 0, sizeof( item->gpuZoneEnd.thread ) );
|
||||
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
|
||||
MemWrite( &item->gpuZoneEnd.context, GetGpuCtx().ptr->GetId() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,6 +13,23 @@
|
||||
#include "../common/TracyQueue.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
|
||||
|
||||
#define TracyLfqPrepare( type ) \
|
||||
char* __nextPtr; \
|
||||
QueueItem* item; \
|
||||
auto& __tail = LfqProducer::PrepareNext( item, __nextPtr, type );
|
||||
|
||||
#define TracyLfqCommit \
|
||||
LfqProducer::CommitNext( __tail, __nextPtr );
|
||||
|
||||
#define TracyLfqPrepareC( type ) \
|
||||
char* nextPtr; \
|
||||
tracy::QueueItem* item; \
|
||||
auto& tail = tracy::LfqProducer::PrepareNext( item, nextPtr, type );
|
||||
|
||||
#define TracyLfqCommitC \
|
||||
tracy::LfqProducer::CommitNext( tail, nextPtr );
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@@ -84,11 +101,12 @@ public:
|
||||
tracy_force_inline void PrepareThread();
|
||||
tracy_force_inline void CleanupThread();
|
||||
|
||||
tracy_force_inline char* PrepareNext( char*& nextPtr, size_t sz )
|
||||
tracy_force_inline std::atomic<char*>& PrepareNext( char*& ptr, char*& nextPtr, size_t sz )
|
||||
{
|
||||
auto tailBlk = NextBlock( m_tail.load() );
|
||||
auto tail = tailBlk->tail.load();
|
||||
nextPtr = tail + sz;
|
||||
auto& tail = tailBlk->tail;
|
||||
ptr = tail.load();
|
||||
nextPtr = ptr + sz;
|
||||
return tail;
|
||||
}
|
||||
|
||||
@@ -121,17 +139,20 @@ public:
|
||||
|
||||
inline LfqProducer& operator=( LfqProducer&& ) noexcept;
|
||||
|
||||
static tracy_force_inline QueueItem* PrepareNext( char*& nextPtr, QueueType type )
|
||||
static tracy_force_inline std::atomic<char*>& PrepareNext( QueueItem*& item, char*& nextPtr, QueueType type )
|
||||
{
|
||||
auto item = (QueueItem*)PrepareNext( nextPtr, QueueDataSize[(uint8_t)type] );
|
||||
char* ptr;
|
||||
auto& ret = PrepareNext( ptr, nextPtr, QueueDataSize[(uint8_t)type] );
|
||||
item = (QueueItem*)ptr;
|
||||
MemWrite( &item->hdr.type, type );
|
||||
return item;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static tracy_force_inline char* PrepareNext( char*& nextPtr, size_t sz )
|
||||
static tracy_force_inline std::atomic<char*>& PrepareNext( char*& ptr, char*& nextPtr, size_t sz )
|
||||
{
|
||||
auto tail = lfq.tail->load();
|
||||
auto np = tail + sz;
|
||||
auto& tail = *lfq.tail;
|
||||
ptr = tail.load();
|
||||
auto np = ptr + sz;
|
||||
if( np <= lfq.dataEnd )
|
||||
{
|
||||
nextPtr = np;
|
||||
@@ -139,13 +160,13 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetProducer().m_prod->PrepareNext( nextPtr, sz );
|
||||
return GetProducer().m_prod->PrepareNext( ptr, nextPtr, sz );
|
||||
}
|
||||
}
|
||||
|
||||
static tracy_force_inline void CommitNext( char* nextPtr )
|
||||
static tracy_force_inline void CommitNext( std::atomic<char*>& tail, char* nextPtr )
|
||||
{
|
||||
lfq.tail->store( nextPtr, std::memory_order_release );
|
||||
tail.store( nextPtr, std::memory_order_release );
|
||||
}
|
||||
|
||||
static tracy_force_inline void FlushData()
|
||||
|
||||
@@ -23,8 +23,7 @@ public:
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::LockAnnounce );
|
||||
TracyLfqPrepare( QueueType::LockAnnounce );
|
||||
MemWrite( &item->lockAnnounce.id, m_id );
|
||||
MemWrite( &item->lockAnnounce.time, Profiler::GetTime() );
|
||||
MemWrite( &item->lockAnnounce.lckloc, (uint64_t)srcloc );
|
||||
@@ -32,7 +31,7 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
LockableCtx( const LockableCtx& ) = delete;
|
||||
@@ -40,15 +39,14 @@ public:
|
||||
|
||||
tracy_force_inline ~LockableCtx()
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::LockTerminate );
|
||||
TracyLfqPrepare( QueueType::LockTerminate );
|
||||
MemWrite( &item->lockTerminate.id, m_id );
|
||||
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
|
||||
MemWrite( &item->lockTerminate.type, LockType::Lockable );
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline bool BeforeLock()
|
||||
@@ -219,8 +217,7 @@ public:
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::LockAnnounce );
|
||||
TracyLfqPrepare( QueueType::LockAnnounce );
|
||||
MemWrite( &item->lockAnnounce.id, m_id );
|
||||
MemWrite( &item->lockAnnounce.time, Profiler::GetTime() );
|
||||
MemWrite( &item->lockAnnounce.lckloc, (uint64_t)srcloc );
|
||||
@@ -230,7 +227,7 @@ public:
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
SharedLockableCtx( const SharedLockableCtx& ) = delete;
|
||||
@@ -238,8 +235,7 @@ public:
|
||||
|
||||
tracy_force_inline ~SharedLockableCtx()
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::LockTerminate );
|
||||
TracyLfqPrepare( QueueType::LockTerminate );
|
||||
MemWrite( &item->lockTerminate.id, m_id );
|
||||
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
|
||||
MemWrite( &item->lockTerminate.type, LockType::SharedLockable );
|
||||
@@ -248,7 +244,7 @@ public:
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline bool BeforeLock()
|
||||
|
||||
@@ -582,11 +582,10 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
|
||||
}
|
||||
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::CrashReport );
|
||||
TracyLfqPrepare( QueueType::CrashReport );
|
||||
item->crashReport.time = Profiler::GetTime();
|
||||
item->crashReport.text = (uint64_t)s_crashText;
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
GetProfiler().SendCallstack( 60, "KiUserExceptionDispatcher" );
|
||||
}
|
||||
@@ -620,9 +619,8 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
|
||||
CloseHandle( h );
|
||||
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::Crash );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqPrepare( QueueType::Crash );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 500 ) );
|
||||
@@ -812,11 +810,10 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
|
||||
}
|
||||
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::CrashReport );
|
||||
TracyLfqPrepare( QueueType::CrashReport );
|
||||
item->crashReport.time = Profiler::GetTime();
|
||||
item->crashReport.text = (uint64_t)s_crashText;
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
GetProfiler().SendCallstack( 60, "__kernel_rt_sigreturn" );
|
||||
}
|
||||
@@ -839,9 +836,8 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
|
||||
closedir( dp );
|
||||
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::Crash );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqPrepare( QueueType::Crash );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 500 ) );
|
||||
@@ -1544,15 +1540,14 @@ void Profiler::CompressWorker()
|
||||
CompressImageDxt1( (const char*)fi->image, etc1buf, w, h );
|
||||
tracy_free( fi->image );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::FrameImage );
|
||||
TracyLfqPrepare( QueueType::FrameImage );
|
||||
MemWrite( &item->frameImage.image, (uint64_t)etc1buf );
|
||||
MemWrite( &item->frameImage.frame, fi->frame );
|
||||
MemWrite( &item->frameImage.w, w );
|
||||
MemWrite( &item->frameImage.h, h );
|
||||
uint8_t flip = fi->flip;
|
||||
MemWrite( &item->frameImage.flip, flip );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
fi++;
|
||||
}
|
||||
@@ -2398,19 +2393,17 @@ void Profiler::CalibrateDelay()
|
||||
for( int i=0; i<Iterations; i++ )
|
||||
{
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBegin );
|
||||
TracyLfqPrepare( QueueType::ZoneBegin );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneBegin );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)&__tracy_source_location );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneEnd );
|
||||
TracyLfqPrepare( QueueType::ZoneEnd );
|
||||
MemWrite( &item->hdr.type, QueueType::ZoneEnd );
|
||||
MemWrite( &item->zoneEnd.time, GetTime() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
}
|
||||
const auto t1 = GetTime();
|
||||
@@ -2499,8 +2492,7 @@ void Profiler::ReportTopology()
|
||||
{
|
||||
auto& data = cpuData[i];
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::CpuTopology );
|
||||
TracyLfqPrepare( QueueType::CpuTopology );
|
||||
MemWrite( &item->cpuTopology.package, data.package );
|
||||
MemWrite( &item->cpuTopology.core, data.core );
|
||||
MemWrite( &item->cpuTopology.thread, data.thread );
|
||||
@@ -2509,7 +2501,7 @@ void Profiler::ReportTopology()
|
||||
DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_free( cpuData );
|
||||
@@ -2545,8 +2537,7 @@ void Profiler::ReportTopology()
|
||||
{
|
||||
auto& data = cpuData[i];
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::CpuTopology );
|
||||
TracyLfqPrepare( QueueType::CpuTopology );
|
||||
MemWrite( &item->cpuTopology.package, data.package );
|
||||
MemWrite( &item->cpuTopology.core, data.core );
|
||||
MemWrite( &item->cpuTopology.thread, data.thread );
|
||||
@@ -2555,7 +2546,7 @@ void Profiler::ReportTopology()
|
||||
DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_free( cpuData );
|
||||
@@ -2569,10 +2560,9 @@ void Profiler::SendCallstack( int depth, const char* skipBefore )
|
||||
auto ptr = Callstack( depth );
|
||||
CutCallstack( ptr, skipBefore );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::Callstack );
|
||||
TracyLfqPrepare( QueueType::Callstack );
|
||||
MemWrite( &item->callstack.ptr, ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2613,11 +2603,10 @@ void Profiler::ProcessSysTime()
|
||||
{
|
||||
m_sysTimeLast = t;
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::SysTimeReport );
|
||||
TracyLfqPrepare( QueueType::SysTimeReport );
|
||||
MemWrite( &item->sysTime.time, GetTime() );
|
||||
MemWrite( &item->sysTime.sysTime, sysTime );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2625,8 +2614,7 @@ void Profiler::ProcessSysTime()
|
||||
|
||||
void Profiler::ParameterSetup( uint32_t idx, const char* name, bool isBool, int32_t val )
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ParamSetup );
|
||||
TracyLfqPrepare( QueueType::ParamSetup );
|
||||
tracy::MemWrite( &item->paramSetup.idx, idx );
|
||||
tracy::MemWrite( &item->paramSetup.name, (uint64_t)name );
|
||||
tracy::MemWrite( &item->paramSetup.isBool, (uint8_t)isBool );
|
||||
@@ -2636,7 +2624,7 @@ void Profiler::ParameterSetup( uint32_t idx, const char* name, bool isBool, int3
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
void Profiler::HandleParameter( uint64_t payload )
|
||||
@@ -2667,18 +2655,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_l
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneBegin );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneBegin );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
@@ -2697,18 +2683,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___trac
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneBeginCallstack );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneBeginCallstack );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
|
||||
tracy::GetProfiler().SendCallstack( depth );
|
||||
@@ -2733,18 +2717,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc( uint64_t srcloc, int act
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneBeginAllocSrcLoc );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneBeginAllocSrcLoc );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
@@ -2767,18 +2749,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srclo
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
|
||||
tracy::GetProfiler().SendCallstack( depth );
|
||||
@@ -2790,17 +2770,15 @@ TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
if( !ctx.active ) return;
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneEnd );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneEnd );
|
||||
tracy::MemWrite( &item->zoneEnd.time, tracy::Profiler::GetTime() );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2812,17 +2790,15 @@ TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size
|
||||
ptr[size] = '\0';
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneText );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneText );
|
||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2834,17 +2810,15 @@ TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size
|
||||
ptr[size] = '\0';
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneValidation );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = tracy::LfqProducer::PrepareNext( nextPtr, tracy::QueueType::ZoneName );
|
||||
TracyLfqPrepareC( tracy::QueueType::ZoneName );
|
||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
tracy::LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommitC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,11 +150,10 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::FrameMarkMsg );
|
||||
TracyLfqPrepare( QueueType::FrameMarkMsg );
|
||||
MemWrite( &item->frameMark.time, GetTime() );
|
||||
MemWrite( &item->frameMark.name, uint64_t( name ) );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void SendFrameMark( const char* name, QueueType type )
|
||||
@@ -196,13 +195,12 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::PlotData );
|
||||
TracyLfqPrepare( QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
MemWrite( &item->plotData.type, PlotDataType::Int );
|
||||
MemWrite( &item->plotData.data.i, val );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void PlotData( const char* name, float val )
|
||||
@@ -210,13 +208,12 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::PlotData );
|
||||
TracyLfqPrepare( QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
MemWrite( &item->plotData.type, PlotDataType::Float );
|
||||
MemWrite( &item->plotData.data.f, val );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void PlotData( const char* name, double val )
|
||||
@@ -224,19 +221,17 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::PlotData );
|
||||
TracyLfqPrepare( QueueType::PlotData );
|
||||
MemWrite( &item->plotData.name, (uint64_t)name );
|
||||
MemWrite( &item->plotData.time, GetTime() );
|
||||
MemWrite( &item->plotData.type, PlotDataType::Double );
|
||||
MemWrite( &item->plotData.data.d, val );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void ConfigurePlot( const char* name, PlotFormatType type )
|
||||
{
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::PlotConfig );
|
||||
TracyLfqPrepare( QueueType::PlotConfig );
|
||||
MemWrite( &item->plotConfig.name, (uint64_t)name );
|
||||
MemWrite( &item->plotConfig.type, (uint8_t)type );
|
||||
|
||||
@@ -244,7 +239,7 @@ public:
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
||||
@@ -255,11 +250,10 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, callstack == 0 ? QueueType::Message : QueueType::MessageCallstack );
|
||||
TracyLfqPrepare( callstack == 0 ? QueueType::Message : QueueType::MessageCallstack );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||
}
|
||||
@@ -269,11 +263,10 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, callstack == 0 ? QueueType::MessageLiteral : QueueType::MessageLiteralCallstack );
|
||||
TracyLfqPrepare( callstack == 0 ? QueueType::MessageLiteral : QueueType::MessageLiteralCallstack );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.text, (uint64_t)txt );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||
}
|
||||
@@ -286,14 +279,13 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, callstack == 0 ? QueueType::MessageColor : QueueType::MessageColorCallstack );
|
||||
TracyLfqPrepare( callstack == 0 ? QueueType::MessageColor : QueueType::MessageColorCallstack );
|
||||
MemWrite( &item->messageColor.time, GetTime() );
|
||||
MemWrite( &item->messageColor.text, (uint64_t)ptr );
|
||||
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||
}
|
||||
@@ -303,14 +295,13 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( !GetProfiler().IsConnected() ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, callstack == 0 ? QueueType::MessageLiteralColor : QueueType::MessageLiteralColorCallstack );
|
||||
TracyLfqPrepare( callstack == 0 ? QueueType::MessageLiteralColor : QueueType::MessageLiteralColorCallstack );
|
||||
MemWrite( &item->messageColor.time, GetTime() );
|
||||
MemWrite( &item->messageColor.text, (uint64_t)txt );
|
||||
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||
}
|
||||
@@ -320,8 +311,7 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::MessageAppInfo );
|
||||
TracyLfqPrepare( QueueType::MessageAppInfo );
|
||||
MemWrite( &item->message.time, GetTime() );
|
||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||
|
||||
@@ -329,7 +319,7 @@ public:
|
||||
GetProfiler().DeferItem( *item );
|
||||
#endif
|
||||
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
static tracy_force_inline void MemAlloc( const void* ptr, size_t size )
|
||||
@@ -402,10 +392,9 @@ public:
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
auto ptr = Callstack( depth );
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::Callstack );
|
||||
TracyLfqPrepare( QueueType::Callstack );
|
||||
MemWrite( &item->callstack.ptr, ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,10 @@ public:
|
||||
#endif
|
||||
{
|
||||
if( !m_active ) return;
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBegin );
|
||||
TracyLfqPrepare( QueueType::ZoneBegin );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline ScopedZone( const SourceLocationData* srcloc, int depth, bool is_active = true )
|
||||
@@ -40,11 +39,10 @@ public:
|
||||
#endif
|
||||
{
|
||||
if( !m_active ) return;
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneBeginCallstack );
|
||||
TracyLfqPrepare( QueueType::ZoneBeginCallstack );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
|
||||
GetProfiler().SendCallstack( depth );
|
||||
}
|
||||
@@ -55,10 +53,9 @@ public:
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||
#endif
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneEnd );
|
||||
TracyLfqPrepare( QueueType::ZoneEnd );
|
||||
MemWrite( &item->zoneEnd.time, Profiler::GetTime() );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline void Text( const char* txt, size_t size )
|
||||
@@ -70,10 +67,9 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneText );
|
||||
TracyLfqPrepare( QueueType::ZoneText );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
tracy_force_inline void Name( const char* txt, size_t size )
|
||||
@@ -85,10 +81,9 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ZoneName );
|
||||
TracyLfqPrepare( QueueType::ZoneName );
|
||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -66,8 +66,7 @@ void WINAPI EventRecordCallback( PEVENT_RECORD record )
|
||||
{
|
||||
const auto cswitch = (const CSwitch*)record->UserData;
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ContextSwitch );
|
||||
TracyLfqPrepare( QueueType::ContextSwitch );
|
||||
MemWrite( &item->contextSwitch.time, hdr.TimeStamp.QuadPart );
|
||||
memcpy( &item->contextSwitch.oldThread, &cswitch->oldThreadId, sizeof( cswitch->oldThreadId ) );
|
||||
memcpy( &item->contextSwitch.newThread, &cswitch->newThreadId, sizeof( cswitch->newThreadId ) );
|
||||
@@ -76,18 +75,17 @@ void WINAPI EventRecordCallback( PEVENT_RECORD record )
|
||||
MemWrite( &item->contextSwitch.cpu, record->BufferContext.ProcessorNumber );
|
||||
MemWrite( &item->contextSwitch.reason, cswitch->oldThreadWaitReason );
|
||||
MemWrite( &item->contextSwitch.state, cswitch->oldThreadState );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
else if( hdr.EventDescriptor.Opcode == 50 )
|
||||
{
|
||||
const auto rt = (const ReadyThread*)record->UserData;
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ThreadWakeup );
|
||||
TracyLfqPrepare( QueueType::ThreadWakeup );
|
||||
MemWrite( &item->threadWakeup.time, hdr.TimeStamp.QuadPart );
|
||||
memcpy( &item->threadWakeup.thread, &rt->threadId, sizeof( rt->threadId ) );
|
||||
memset( ((char*)&item->threadWakeup.thread)+4, 0, 4 );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,11 +272,10 @@ void SysTraceSendExternalName( uint64_t thread )
|
||||
{
|
||||
{
|
||||
uint64_t _pid = pid;
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::TidToPid );
|
||||
TracyLfqPrepare( QueueType::TidToPid );
|
||||
MemWrite( &item->tidToPid.tid, thread );
|
||||
MemWrite( &item->tidToPid.pid, _pid );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
if( pid == 4 )
|
||||
{
|
||||
@@ -599,15 +596,14 @@ static void HandleTraceLine( const char* line )
|
||||
|
||||
uint8_t reason = 100;
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ContextSwitch );
|
||||
TracyLfqPrepare( QueueType::ContextSwitch );
|
||||
MemWrite( &item->contextSwitch.time, time );
|
||||
MemWrite( &item->contextSwitch.oldThread, oldPid );
|
||||
MemWrite( &item->contextSwitch.newThread, newPid );
|
||||
MemWrite( &item->contextSwitch.cpu, cpu );
|
||||
MemWrite( &item->contextSwitch.reason, reason );
|
||||
MemWrite( &item->contextSwitch.state, oldState );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
else if( memcmp( line, "sched_wakeup", 12 ) == 0 )
|
||||
{
|
||||
@@ -618,11 +614,10 @@ static void HandleTraceLine( const char* line )
|
||||
|
||||
const auto pid = ReadNumber( line );
|
||||
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::ThreadWakeup );
|
||||
TracyLfqPrepare( QueueType::ThreadWakeup );
|
||||
MemWrite( &item->threadWakeup.time, time );
|
||||
MemWrite( &item->threadWakeup.thread, pid );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,11 +811,10 @@ void SysTraceSendExternalName( uint64_t thread )
|
||||
{
|
||||
{
|
||||
uint64_t _pid = pid;
|
||||
char* nextPtr;
|
||||
auto item = LfqProducer::PrepareNext( nextPtr, QueueType::TidToPid );
|
||||
TracyLfqPrepare( QueueType::TidToPid );
|
||||
MemWrite( &item->tidToPid.tid, thread );
|
||||
MemWrite( &item->tidToPid.pid, _pid );
|
||||
LfqProducer::CommitNext( nextPtr );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
sprintf( fn, "/proc/%i/comm", pid );
|
||||
f = fopen( fn, "rb" );
|
||||
|
||||
Reference in New Issue
Block a user