1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Zone text (custom string) transfer.

This commit is contained in:
Bartosz Taudul
2017-09-27 02:18:17 +02:00
parent 3c0ce01954
commit d1bbb731fc
9 changed files with 93 additions and 6 deletions
+2
View File
@@ -16,6 +16,8 @@
#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 }; 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 FrameMark tracy::Profiler::FrameMark();
#endif
+14 -1
View File
@@ -103,6 +103,15 @@ void Profiler::ZoneEnd( uint64_t id, QueueZoneEnd&& data )
ZoneEndImpl( s_token, id, std::move( data ) );
}
void Profiler::ZoneText( uint64_t id, QueueZoneText&& data )
{
QueueItem item;
item.hdr.type = QueueType::ZoneText;
item.hdr.id = id;
item.zoneText = std::move( data );
s_queue.enqueue( s_token, std::move( item ) );
}
void Profiler::FrameMark()
{
QueueItem item;
@@ -199,7 +208,7 @@ bool Profiler::SendData( const char* data, size_t len )
bool Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
{
assert( type == QueueType::StringData || type == QueueType::ThreadName );
assert( type == QueueType::StringData || type == QueueType::ThreadName || type == QueueType::CustomStringData );
QueueHeader hdr;
hdr.type = type;
@@ -261,6 +270,10 @@ bool Profiler::HandleServerQuery()
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
}
break;
case ServerQueryCustomString:
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
delete[] (const char*)ptr;
break;
case ServerQuerySourceLocation:
SendSourceLocation( ptr );
break;
+1
View File
@@ -44,6 +44,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 FrameMark();
static bool ShouldExit();
+8
View File
@@ -22,6 +22,14 @@ public:
Profiler::ZoneEnd( m_id, QueueZoneEnd { Profiler::GetTime() } );
}
void Text( const char* txt, size_t size )
{
auto ptr = new char[size+1];
memcpy( ptr, txt, size );
ptr[size] = '\0';
Profiler::ZoneText( m_id, QueueZoneText { (uint64_t)ptr } );
}
private:
uint64_t m_id;
};