Allow sending custom zone names.

This commit is contained in:
Bartosz Taudul 2017-09-28 19:28:24 +02:00
parent 362a37a705
commit 8c1c395cec
8 changed files with 38 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#define ZoneScopedC(x)
#define ZoneText(x,y)
#define ZoneName(x)
#define FrameMark
@ -19,6 +20,7 @@
#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
#define ZoneName( name ) ___tracy_scoped_zone.Name( name );
#define FrameMark tracy::Profiler::FrameMark();

View File

@ -112,6 +112,15 @@ void Profiler::ZoneText( uint64_t id, QueueZoneText&& data )
s_queue.enqueue( s_token, std::move( item ) );
}
void Profiler::ZoneName( uint64_t id, QueueZoneName&& data )
{
QueueItem item;
item.hdr.type = QueueType::ZoneName;
item.hdr.id = id;
item.zoneName = std::move( data );
s_queue.enqueue( s_token, std::move( item ) );
}
void Profiler::FrameMark()
{
QueueItem item;

View File

@ -45,6 +45,7 @@ public:
static uint64_t ZoneBegin( QueueZoneBegin&& data );
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
static void ZoneText( uint64_t id, QueueZoneText&& data );
static void ZoneName( uint64_t id, QueueZoneName&& data );
static void FrameMark();
static bool ShouldExit();

View File

@ -30,6 +30,11 @@ public:
Profiler::ZoneText( m_id, QueueZoneText { (uint64_t)ptr } );
}
void Name( const char* name )
{
Profiler::ZoneName( m_id, QueueZoneName { (uint64_t)name } );
}
private:
uint64_t m_id;
};

View File

@ -16,6 +16,7 @@ enum class QueueType : uint8_t
FrameMark,
SourceLocation,
ZoneText,
ZoneName,
NUM_TYPES
};
@ -46,6 +47,11 @@ struct QueueZoneText
uint64_t text; // ptr
};
struct QueueZoneName
{
uint64_t name; // ptr
};
struct QueueHeader
{
union
@ -65,6 +71,7 @@ struct QueueItem
QueueZoneEnd zoneEnd;
QueueSourceLocation srcloc;
QueueZoneText zoneText;
QueueZoneName zoneName;
};
};
@ -81,6 +88,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ), // frame mark
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
sizeof( QueueHeader ) + sizeof( QueueZoneName ),
};
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );

View File

@ -9,6 +9,7 @@ namespace tracy
struct TextData
{
const char* userText;
uint64_t zoneName; // ptr
};
struct Event

View File

@ -248,6 +248,9 @@ void View::Process( const QueueItem& ev )
case QueueType::ZoneText:
ProcessZoneText( ev.hdr.id, ev.zoneText );
break;
case QueueType::ZoneName:
ProcessZoneName( ev.hdr.id, ev.zoneName );
break;
default:
assert( false );
break;
@ -330,6 +333,14 @@ void View::ProcessZoneText( uint64_t id, const QueueZoneText& ev )
CheckCustomString( ev.text, it->second );
}
void View::ProcessZoneName( uint64_t id, const QueueZoneName& ev )
{
auto it = m_openZones.find( id );
assert( it != m_openZones.end() );
CheckString( ev.name );
GetTextData( *it->second )->zoneName = ev.name;
}
void View::CheckString( uint64_t ptr )
{
if( m_strings.find( ptr ) != m_strings.end() ) return;

View File

@ -53,6 +53,7 @@ private:
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
void ProcessFrameMark( uint64_t id );
void ProcessZoneText( uint64_t id, const QueueZoneText& ev );
void ProcessZoneName( uint64_t id, const QueueZoneName& ev );
void CheckString( uint64_t ptr );
void CheckThreadString( uint64_t id );