mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Allow sending custom zone names.
This commit is contained in:
parent
362a37a705
commit
8c1c395cec
@ -7,6 +7,7 @@
|
|||||||
#define ZoneScopedC(x)
|
#define ZoneScopedC(x)
|
||||||
|
|
||||||
#define ZoneText(x,y)
|
#define ZoneText(x,y)
|
||||||
|
#define ZoneName(x)
|
||||||
|
|
||||||
#define FrameMark
|
#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 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 ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
|
||||||
|
#define ZoneName( name ) ___tracy_scoped_zone.Name( name );
|
||||||
|
|
||||||
#define FrameMark tracy::Profiler::FrameMark();
|
#define FrameMark tracy::Profiler::FrameMark();
|
||||||
|
|
||||||
|
@ -112,6 +112,15 @@ void Profiler::ZoneText( uint64_t id, QueueZoneText&& data )
|
|||||||
s_queue.enqueue( s_token, std::move( item ) );
|
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()
|
void Profiler::FrameMark()
|
||||||
{
|
{
|
||||||
QueueItem item;
|
QueueItem item;
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
static uint64_t ZoneBegin( QueueZoneBegin&& data );
|
static uint64_t ZoneBegin( QueueZoneBegin&& data );
|
||||||
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
|
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
|
||||||
static void ZoneText( uint64_t id, QueueZoneText&& data );
|
static void ZoneText( uint64_t id, QueueZoneText&& data );
|
||||||
|
static void ZoneName( uint64_t id, QueueZoneName&& data );
|
||||||
static void FrameMark();
|
static void FrameMark();
|
||||||
|
|
||||||
static bool ShouldExit();
|
static bool ShouldExit();
|
||||||
|
@ -30,6 +30,11 @@ public:
|
|||||||
Profiler::ZoneText( m_id, QueueZoneText { (uint64_t)ptr } );
|
Profiler::ZoneText( m_id, QueueZoneText { (uint64_t)ptr } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Name( const char* name )
|
||||||
|
{
|
||||||
|
Profiler::ZoneName( m_id, QueueZoneName { (uint64_t)name } );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t m_id;
|
uint64_t m_id;
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,7 @@ enum class QueueType : uint8_t
|
|||||||
FrameMark,
|
FrameMark,
|
||||||
SourceLocation,
|
SourceLocation,
|
||||||
ZoneText,
|
ZoneText,
|
||||||
|
ZoneName,
|
||||||
NUM_TYPES
|
NUM_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +47,11 @@ struct QueueZoneText
|
|||||||
uint64_t text; // ptr
|
uint64_t text; // ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueZoneName
|
||||||
|
{
|
||||||
|
uint64_t name; // ptr
|
||||||
|
};
|
||||||
|
|
||||||
struct QueueHeader
|
struct QueueHeader
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
@ -65,6 +71,7 @@ struct QueueItem
|
|||||||
QueueZoneEnd zoneEnd;
|
QueueZoneEnd zoneEnd;
|
||||||
QueueSourceLocation srcloc;
|
QueueSourceLocation srcloc;
|
||||||
QueueZoneText zoneText;
|
QueueZoneText zoneText;
|
||||||
|
QueueZoneName zoneName;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,6 +88,7 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ), // frame mark
|
sizeof( QueueHeader ), // frame mark
|
||||||
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueZoneName ),
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
|
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
|
||||||
|
@ -9,6 +9,7 @@ namespace tracy
|
|||||||
struct TextData
|
struct TextData
|
||||||
{
|
{
|
||||||
const char* userText;
|
const char* userText;
|
||||||
|
uint64_t zoneName; // ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Event
|
struct Event
|
||||||
|
@ -248,6 +248,9 @@ void View::Process( const QueueItem& ev )
|
|||||||
case QueueType::ZoneText:
|
case QueueType::ZoneText:
|
||||||
ProcessZoneText( ev.hdr.id, ev.zoneText );
|
ProcessZoneText( ev.hdr.id, ev.zoneText );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::ZoneName:
|
||||||
|
ProcessZoneName( ev.hdr.id, ev.zoneName );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
@ -330,6 +333,14 @@ void View::ProcessZoneText( uint64_t id, const QueueZoneText& ev )
|
|||||||
CheckCustomString( ev.text, it->second );
|
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 )
|
void View::CheckString( uint64_t ptr )
|
||||||
{
|
{
|
||||||
if( m_strings.find( ptr ) != m_strings.end() ) return;
|
if( m_strings.find( ptr ) != m_strings.end() ) return;
|
||||||
|
@ -53,6 +53,7 @@ private:
|
|||||||
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
|
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
|
||||||
void ProcessFrameMark( uint64_t id );
|
void ProcessFrameMark( uint64_t id );
|
||||||
void ProcessZoneText( uint64_t id, const QueueZoneText& ev );
|
void ProcessZoneText( uint64_t id, const QueueZoneText& ev );
|
||||||
|
void ProcessZoneName( uint64_t id, const QueueZoneName& ev );
|
||||||
|
|
||||||
void CheckString( uint64_t ptr );
|
void CheckString( uint64_t ptr );
|
||||||
void CheckThreadString( uint64_t id );
|
void CheckThreadString( uint64_t id );
|
||||||
|
Loading…
Reference in New Issue
Block a user