mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-13 05:48:12 +00:00
ZoneBegin / ZoneBeginCallstack with 32 and 16 bit time data.
This commit is contained in:
@@ -2599,6 +2599,32 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
int64_t t = MemRead<int64_t>( &item->zoneBegin.time );
|
||||
int64_t dt = t - refThread;
|
||||
refThread = t;
|
||||
if( dt >= 0 )
|
||||
{
|
||||
if( dt < ProtocolOffset16Bit )
|
||||
{
|
||||
const uint64_t srcloc = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
idx = QueueType( idx ) == QueueType::ZoneBegin ? (int)QueueType::ZoneBegin16 : (int)QueueType::ZoneBeginCallstack16;
|
||||
MemWrite( &item->hdr.idx, idx );
|
||||
MemWrite( &item->zoneBegin16.time, uint16_t( dt ) );
|
||||
MemWrite( &item->zoneBegin16.srcloc, srcloc );
|
||||
break;
|
||||
}
|
||||
else if( dt < ProtocolOffset32Bit )
|
||||
{
|
||||
dt -= ProtocolOffset16Bit;
|
||||
const uint64_t srcloc = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
idx = QueueType( idx ) == QueueType::ZoneBegin ? (int)QueueType::ZoneBegin32 : (int)QueueType::ZoneBeginCallstack32;
|
||||
MemWrite( &item->hdr.idx, idx );
|
||||
MemWrite( &item->zoneBegin32.time, uint32_t( dt ) );
|
||||
MemWrite( &item->zoneBegin32.srcloc, srcloc );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dt -= ProtocolOffset32Bit;
|
||||
}
|
||||
}
|
||||
MemWrite( &item->zoneBegin.time, dt );
|
||||
break;
|
||||
}
|
||||
@@ -3049,6 +3075,32 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
|
||||
int64_t t = MemRead<int64_t>( &item->zoneBegin.time );
|
||||
int64_t dt = t - refThread;
|
||||
refThread = t;
|
||||
if( dt >= 0 )
|
||||
{
|
||||
if( dt < ProtocolOffset16Bit )
|
||||
{
|
||||
const uint64_t srcloc = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
idx = QueueType( idx ) == QueueType::ZoneBegin ? (int)QueueType::ZoneBegin16 : (int)QueueType::ZoneBeginCallstack16;
|
||||
MemWrite( &item->hdr.idx, idx );
|
||||
MemWrite( &item->zoneBegin16.time, uint16_t( dt ) );
|
||||
MemWrite( &item->zoneBegin16.srcloc, srcloc );
|
||||
break;
|
||||
}
|
||||
else if( dt < ProtocolOffset32Bit )
|
||||
{
|
||||
dt -= ProtocolOffset16Bit;
|
||||
const uint64_t srcloc = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
idx = QueueType( idx ) == QueueType::ZoneBegin ? (int)QueueType::ZoneBegin32 : (int)QueueType::ZoneBeginCallstack32;
|
||||
MemWrite( &item->hdr.idx, idx );
|
||||
MemWrite( &item->zoneBegin32.time, uint32_t( dt ) );
|
||||
MemWrite( &item->zoneBegin32.srcloc, srcloc );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dt -= ProtocolOffset32Bit;
|
||||
}
|
||||
}
|
||||
MemWrite( &item->zoneBegin.time, dt );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,11 @@ enum class QueueType : uint8_t
|
||||
CallstackSampleContextSwitch,
|
||||
FrameImage,
|
||||
ZoneBegin,
|
||||
ZoneBegin32,
|
||||
ZoneBegin16,
|
||||
ZoneBeginCallstack,
|
||||
ZoneBeginCallstack32,
|
||||
ZoneBeginCallstack16,
|
||||
ZoneEnd,
|
||||
ZoneEnd32,
|
||||
ZoneEnd16,
|
||||
@@ -155,6 +159,18 @@ struct QueueZoneBeginThread : public QueueZoneBegin
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneBegin32
|
||||
{
|
||||
uint32_t time;
|
||||
uint64_t srcloc;
|
||||
};
|
||||
|
||||
struct QueueZoneBegin16
|
||||
{
|
||||
uint16_t time;
|
||||
uint64_t srcloc;
|
||||
};
|
||||
|
||||
struct QueueZoneEnd
|
||||
{
|
||||
int64_t time;
|
||||
@@ -796,6 +812,8 @@ struct QueueItem
|
||||
QueueZoneBegin zoneBegin;
|
||||
QueueZoneBeginLean zoneBeginLean;
|
||||
QueueZoneBeginThread zoneBeginThread;
|
||||
QueueZoneBegin32 zoneBegin32;
|
||||
QueueZoneBegin16 zoneBegin16;
|
||||
QueueZoneEnd zoneEnd;
|
||||
QueueZoneEnd32 zoneEnd32;
|
||||
QueueZoneEnd16 zoneEnd16;
|
||||
@@ -907,7 +925,11 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackSample ), // context switch
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameImage ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin32 ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin16 ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin32 ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin16 ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneEnd32 ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneEnd16 ),
|
||||
|
||||
@@ -4498,10 +4498,22 @@ bool Worker::Process( const QueueItem& ev )
|
||||
ProcessThreadContext( ev.threadCtx );
|
||||
break;
|
||||
case QueueType::ZoneBegin:
|
||||
ProcessZoneBegin( ev.zoneBegin );
|
||||
ProcessZoneBegin64( ev.zoneBegin );
|
||||
break;
|
||||
case QueueType::ZoneBegin32:
|
||||
ProcessZoneBegin32( ev.zoneBegin32 );
|
||||
break;
|
||||
case QueueType::ZoneBegin16:
|
||||
ProcessZoneBegin16( ev.zoneBegin16 );
|
||||
break;
|
||||
case QueueType::ZoneBeginCallstack:
|
||||
ProcessZoneBeginCallstack( ev.zoneBegin );
|
||||
ProcessZoneBeginCallstack64( ev.zoneBegin );
|
||||
break;
|
||||
case QueueType::ZoneBeginCallstack32:
|
||||
ProcessZoneBeginCallstack32( ev.zoneBegin32 );
|
||||
break;
|
||||
case QueueType::ZoneBeginCallstack16:
|
||||
ProcessZoneBeginCallstack16( ev.zoneBegin16 );
|
||||
break;
|
||||
case QueueType::ZoneBeginAllocSrcLoc:
|
||||
ProcessZoneBeginAllocSrcLoc( ev.zoneBeginLean );
|
||||
@@ -4879,6 +4891,31 @@ void Worker::ProcessZoneBegin( const QueueZoneBegin& ev )
|
||||
ProcessZoneBeginImpl( zone, ev );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBegin64( const QueueZoneBegin& ev )
|
||||
{
|
||||
QueueZoneBegin unpack = ev;
|
||||
if( ev.time >= 0 ) unpack.time += ProtocolOffset32Bit;
|
||||
ProcessZoneBegin( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBegin32( const QueueZoneBegin32& ev )
|
||||
{
|
||||
QueueZoneBegin unpack;
|
||||
unpack.time = int64_t( ev.time + ProtocolOffset16Bit );
|
||||
unpack.srcloc = ev.srcloc;
|
||||
|
||||
ProcessZoneBegin( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBegin16( const QueueZoneBegin16& ev )
|
||||
{
|
||||
QueueZoneBegin unpack;
|
||||
unpack.time = ev.time;
|
||||
unpack.srcloc = ev.srcloc;
|
||||
|
||||
ProcessZoneBegin( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginCallstack( const QueueZoneBegin& ev )
|
||||
{
|
||||
auto zone = AllocZoneEvent();
|
||||
@@ -4891,6 +4928,31 @@ void Worker::ProcessZoneBeginCallstack( const QueueZoneBegin& ev )
|
||||
it->second = 0;
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginCallstack64( const QueueZoneBegin& ev )
|
||||
{
|
||||
QueueZoneBegin unpack = ev;
|
||||
if( ev.time >= 0 ) unpack.time += ProtocolOffset32Bit;
|
||||
ProcessZoneBeginCallstack( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginCallstack32( const QueueZoneBegin32& ev )
|
||||
{
|
||||
QueueZoneBegin unpack;
|
||||
unpack.time = int64_t( ev.time + ProtocolOffset16Bit );
|
||||
unpack.srcloc = ev.srcloc;
|
||||
|
||||
ProcessZoneBeginCallstack( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginCallstack16( const QueueZoneBegin16& ev )
|
||||
{
|
||||
QueueZoneBegin unpack;
|
||||
unpack.time = ev.time;
|
||||
unpack.srcloc = ev.srcloc;
|
||||
|
||||
ProcessZoneBeginCallstack( unpack );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBeginLean& ev )
|
||||
{
|
||||
auto zone = AllocZoneEvent();
|
||||
|
||||
@@ -722,7 +722,13 @@ private:
|
||||
tracy_force_inline bool Process( const QueueItem& ev );
|
||||
tracy_force_inline void ProcessThreadContext( const QueueThreadContext& ev );
|
||||
tracy_force_inline void ProcessZoneBegin( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBegin64( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBegin32( const QueueZoneBegin32& ev );
|
||||
tracy_force_inline void ProcessZoneBegin16( const QueueZoneBegin16& ev );
|
||||
tracy_force_inline void ProcessZoneBeginCallstack( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginCallstack64( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginCallstack32( const QueueZoneBegin32& ev );
|
||||
tracy_force_inline void ProcessZoneBeginCallstack16( const QueueZoneBegin16& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLoc( const QueueZoneBeginLean& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBeginLean& ev );
|
||||
tracy_force_inline void ProcessZoneEnd( const QueueZoneEnd& ev );
|
||||
|
||||
Reference in New Issue
Block a user