mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Custom lock name transfer.
This commit is contained in:
parent
0fe606dd8b
commit
e7240cb77d
@ -33,6 +33,7 @@
|
|||||||
#define LockableBase( type ) type
|
#define LockableBase( type ) type
|
||||||
#define SharedLockableBase( type ) type
|
#define SharedLockableBase( type ) type
|
||||||
#define LockMark(x) (void)x;
|
#define LockMark(x) (void)x;
|
||||||
|
#define LockableName(x,y,z);
|
||||||
|
|
||||||
#define TracyPlot(x,y)
|
#define TracyPlot(x,y)
|
||||||
#define TracyPlotConfig(x,y)
|
#define TracyPlotConfig(x,y)
|
||||||
@ -107,6 +108,7 @@
|
|||||||
#define LockableBase( type ) tracy::Lockable<type>
|
#define LockableBase( type ) tracy::Lockable<type>
|
||||||
#define SharedLockableBase( type ) tracy::SharedLockable<type>
|
#define SharedLockableBase( type ) tracy::SharedLockable<type>
|
||||||
#define LockMark( varname ) static const tracy::SourceLocationData __tracy_lock_location_##varname { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname );
|
#define LockMark( varname ) static const tracy::SourceLocationData __tracy_lock_location_##varname { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname );
|
||||||
|
#define LockableName( varname, txt, size ) varname.CustomName( txt, size );
|
||||||
|
|
||||||
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
|
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
|
||||||
#define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type );
|
#define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type );
|
||||||
|
@ -153,6 +153,20 @@ public:
|
|||||||
Profiler::QueueSerialFinish();
|
Profiler::QueueSerialFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
|
{
|
||||||
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
|
memcpy( ptr, name, size );
|
||||||
|
ptr[size] = '\0';
|
||||||
|
TracyLfqPrepare( QueueType::LockName );
|
||||||
|
MemWrite( &item->lockName.id, m_id );
|
||||||
|
MemWrite( &item->lockName.name, (uint64_t)ptr );
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
GetProfiler().DeferItem( *item );
|
||||||
|
#endif
|
||||||
|
TracyLfqCommit;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
|
|
||||||
@ -199,6 +213,11 @@ public:
|
|||||||
m_ctx.Mark( srcloc );
|
m_ctx.Mark( srcloc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
|
{
|
||||||
|
m_ctx.CustomName( name, size );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_lockable;
|
T m_lockable;
|
||||||
LockableCtx m_ctx;
|
LockableCtx m_ctx;
|
||||||
@ -434,6 +453,20 @@ public:
|
|||||||
Profiler::QueueSerialFinish();
|
Profiler::QueueSerialFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
|
{
|
||||||
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
|
memcpy( ptr, name, size );
|
||||||
|
ptr[size] = '\0';
|
||||||
|
TracyLfqPrepare( QueueType::LockName );
|
||||||
|
MemWrite( &item->lockName.id, m_id );
|
||||||
|
MemWrite( &item->lockName.name, (uint64_t)ptr );
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
GetProfiler().DeferItem( *item );
|
||||||
|
#endif
|
||||||
|
TracyLfqCommit;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
|
|
||||||
@ -500,6 +533,11 @@ public:
|
|||||||
m_ctx.Mark( srcloc );
|
m_ctx.Mark( srcloc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
|
{
|
||||||
|
m_ctx.CustomName( txt, size );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_lockable;
|
T m_lockable;
|
||||||
SharedLockableCtx m_ctx;
|
SharedLockableCtx m_ctx;
|
||||||
|
@ -1624,6 +1624,12 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
|||||||
ptr = MemRead<uint64_t>( &item.frameImage.image );
|
ptr = MemRead<uint64_t>( &item.frameImage.image );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
|
#ifndef TRACY_ON_DEMAND
|
||||||
|
case QueueType::LockName:
|
||||||
|
ptr = MemRead<uint64_t>( &item.lockName.name );
|
||||||
|
tracy_free( (void*)ptr );
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
case QueueType::MessageAppInfo:
|
case QueueType::MessageAppInfo:
|
||||||
// Don't free memory associated with deferred messages.
|
// Don't free memory associated with deferred messages.
|
||||||
@ -1786,6 +1792,13 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
MemWrite( &item->zoneEnd.time, dt );
|
MemWrite( &item->zoneEnd.time, dt );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QueueType::LockName:
|
||||||
|
ptr = MemRead<uint64_t>( &item->lockName.name );
|
||||||
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
|
#ifndef TRACY_ON_DEMAND
|
||||||
|
tracy_free( (void*)ptr );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case QueueType::GpuZoneBegin:
|
case QueueType::GpuZoneBegin:
|
||||||
case QueueType::GpuZoneBeginCallstack:
|
case QueueType::GpuZoneBeginCallstack:
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ namespace tracy
|
|||||||
|
|
||||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 27 };
|
enum : uint32_t { ProtocolVersion = 28 };
|
||||||
enum : uint32_t { BroadcastVersion = 0 };
|
enum : uint32_t { BroadcastVersion = 0 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
@ -32,6 +32,7 @@ enum class QueueType : uint8_t
|
|||||||
LockSharedWait,
|
LockSharedWait,
|
||||||
LockSharedObtain,
|
LockSharedObtain,
|
||||||
LockSharedRelease,
|
LockSharedRelease,
|
||||||
|
LockName,
|
||||||
MemAlloc,
|
MemAlloc,
|
||||||
MemFree,
|
MemFree,
|
||||||
MemAllocCallstack,
|
MemAllocCallstack,
|
||||||
@ -194,6 +195,12 @@ struct QueueLockMark
|
|||||||
uint64_t srcloc; // ptr
|
uint64_t srcloc; // ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueLockName
|
||||||
|
{
|
||||||
|
uint32_t id;
|
||||||
|
uint64_t name; // ptr
|
||||||
|
};
|
||||||
|
|
||||||
enum class PlotDataType : uint8_t
|
enum class PlotDataType : uint8_t
|
||||||
{
|
{
|
||||||
Float,
|
Float,
|
||||||
@ -412,6 +419,7 @@ struct QueueItem
|
|||||||
QueueLockObtain lockObtain;
|
QueueLockObtain lockObtain;
|
||||||
QueueLockRelease lockRelease;
|
QueueLockRelease lockRelease;
|
||||||
QueueLockMark lockMark;
|
QueueLockMark lockMark;
|
||||||
|
QueueLockName lockName;
|
||||||
QueuePlotData plotData;
|
QueuePlotData plotData;
|
||||||
QueueMessage message;
|
QueueMessage message;
|
||||||
QueueMessageColor messageColor;
|
QueueMessageColor messageColor;
|
||||||
@ -468,6 +476,7 @@ static constexpr size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueLockWait ), // shared
|
sizeof( QueueHeader ) + sizeof( QueueLockWait ), // shared
|
||||||
sizeof( QueueHeader ) + sizeof( QueueLockObtain ), // shared
|
sizeof( QueueHeader ) + sizeof( QueueLockObtain ), // shared
|
||||||
sizeof( QueueHeader ) + sizeof( QueueLockRelease ), // shared
|
sizeof( QueueHeader ) + sizeof( QueueLockRelease ), // shared
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueLockName ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ),
|
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMemFree ),
|
sizeof( QueueHeader ) + sizeof( QueueMemFree ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), // callstack
|
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), // callstack
|
||||||
|
@ -533,6 +533,7 @@ struct LockMap
|
|||||||
int64_t end = std::numeric_limits<int64_t>::min();
|
int64_t end = std::numeric_limits<int64_t>::min();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringIdx customName;
|
||||||
int16_t srcloc;
|
int16_t srcloc;
|
||||||
Vector<LockEventPtr> timeline;
|
Vector<LockEventPtr> timeline;
|
||||||
unordered_flat_map<uint64_t, uint8_t> threadMap;
|
unordered_flat_map<uint64_t, uint8_t> threadMap;
|
||||||
|
@ -7,7 +7,7 @@ namespace Version
|
|||||||
{
|
{
|
||||||
enum { Major = 0 };
|
enum { Major = 0 };
|
||||||
enum { Minor = 6 };
|
enum { Minor = 6 };
|
||||||
enum { Patch = 5 };
|
enum { Patch = 6 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,6 +718,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint64_t tsz;
|
uint64_t tsz;
|
||||||
f.Read( id );
|
f.Read( id );
|
||||||
|
if( fileVer >= FileVersion( 0, 6, 6 ) )
|
||||||
|
{
|
||||||
|
f.Read( lockmap.customName );
|
||||||
|
}
|
||||||
if( fileVer >= FileVersion( 0, 5, 2 ) )
|
if( fileVer >= FileVersion( 0, 5, 2 ) )
|
||||||
{
|
{
|
||||||
f.Read( lockmap.srcloc );
|
f.Read( lockmap.srcloc );
|
||||||
@ -832,6 +836,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
|||||||
{
|
{
|
||||||
LockType type;
|
LockType type;
|
||||||
uint64_t tsz;
|
uint64_t tsz;
|
||||||
|
if( fileVer >= FileVersion( 0, 6, 6 ) )
|
||||||
|
{
|
||||||
|
f.Skip( sizeof( LockMap::customName ) );
|
||||||
|
}
|
||||||
if( fileVer >= FileVersion( 0, 5, 2 ) )
|
if( fileVer >= FileVersion( 0, 5, 2 ) )
|
||||||
{
|
{
|
||||||
f.Skip( sizeof( uint32_t ) + sizeof( LockMap::srcloc ) );
|
f.Skip( sizeof( uint32_t ) + sizeof( LockMap::srcloc ) );
|
||||||
@ -3476,6 +3484,9 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::LockMark:
|
case QueueType::LockMark:
|
||||||
ProcessLockMark( ev.lockMark );
|
ProcessLockMark( ev.lockMark );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::LockName:
|
||||||
|
ProcessLockName( ev.lockName );
|
||||||
|
break;
|
||||||
case QueueType::PlotData:
|
case QueueType::PlotData:
|
||||||
ProcessPlotData( ev.plotData );
|
ProcessPlotData( ev.plotData );
|
||||||
break;
|
break;
|
||||||
@ -4223,6 +4234,16 @@ void Worker::ProcessLockMark( const QueueLockMark& ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessLockName( const QueueLockName& ev )
|
||||||
|
{
|
||||||
|
auto lit = m_data.lockMap.find( ev.id );
|
||||||
|
assert( lit != m_data.lockMap.end() );
|
||||||
|
auto it = m_pendingCustomStrings.find( ev.name );
|
||||||
|
assert( it != m_pendingCustomStrings.end() );
|
||||||
|
lit->second->customName = StringIdx( it->second.idx );
|
||||||
|
m_pendingCustomStrings.erase( it );
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::ProcessPlotData( const QueuePlotData& ev )
|
void Worker::ProcessPlotData( const QueuePlotData& ev )
|
||||||
{
|
{
|
||||||
PlotData* plot = m_data.plots.Retrieve( ev.name, [this] ( uint64_t name ) {
|
PlotData* plot = m_data.plots.Retrieve( ev.name, [this] ( uint64_t name ) {
|
||||||
@ -6011,6 +6032,7 @@ void Worker::Write( FileWrite& f )
|
|||||||
for( auto& v : m_data.lockMap )
|
for( auto& v : m_data.lockMap )
|
||||||
{
|
{
|
||||||
f.Write( &v.first, sizeof( v.first ) );
|
f.Write( &v.first, sizeof( v.first ) );
|
||||||
|
f.Write( &v.second->customName, sizeof( v.second->customName ) );
|
||||||
f.Write( &v.second->srcloc, sizeof( v.second->srcloc ) );
|
f.Write( &v.second->srcloc, sizeof( v.second->srcloc ) );
|
||||||
f.Write( &v.second->type, sizeof( v.second->type ) );
|
f.Write( &v.second->type, sizeof( v.second->type ) );
|
||||||
f.Write( &v.second->valid, sizeof( v.second->valid ) );
|
f.Write( &v.second->valid, sizeof( v.second->valid ) );
|
||||||
|
@ -523,6 +523,7 @@ private:
|
|||||||
tracy_force_inline void ProcessLockSharedObtain( const QueueLockObtain& ev );
|
tracy_force_inline void ProcessLockSharedObtain( const QueueLockObtain& ev );
|
||||||
tracy_force_inline void ProcessLockSharedRelease( const QueueLockRelease& ev );
|
tracy_force_inline void ProcessLockSharedRelease( const QueueLockRelease& ev );
|
||||||
tracy_force_inline void ProcessLockMark( const QueueLockMark& ev );
|
tracy_force_inline void ProcessLockMark( const QueueLockMark& ev );
|
||||||
|
tracy_force_inline void ProcessLockName( const QueueLockName& ev );
|
||||||
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
|
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
|
||||||
tracy_force_inline void ProcessPlotConfig( const QueuePlotConfig& ev );
|
tracy_force_inline void ProcessPlotConfig( const QueuePlotConfig& ev );
|
||||||
tracy_force_inline void ProcessMessage( const QueueMessage& ev );
|
tracy_force_inline void ProcessMessage( const QueueMessage& ev );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user