mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Allow sending application information messages.
This commit is contained in:
parent
cd018e88a4
commit
60d2384a6a
@ -40,6 +40,7 @@
|
|||||||
#define TracyMessageL(x)
|
#define TracyMessageL(x)
|
||||||
#define TracyMessageC(x,y,z)
|
#define TracyMessageC(x,y,z)
|
||||||
#define TracyMessageLC(x,y)
|
#define TracyMessageLC(x,y)
|
||||||
|
#define TracyAppInfo(x,y)
|
||||||
|
|
||||||
#define TracyAlloc(x,y)
|
#define TracyAlloc(x,y)
|
||||||
#define TracyFree(x)
|
#define TracyFree(x)
|
||||||
@ -104,6 +105,7 @@
|
|||||||
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
|
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
|
||||||
#define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color );
|
#define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color );
|
||||||
#define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color );
|
#define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color );
|
||||||
|
#define TracyAppInfo( txt, size ) tracy::Profiler::MessageAppInfo( txt, size );
|
||||||
|
|
||||||
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
||||||
# define TracyAlloc( ptr, size ) tracy::Profiler::MemAllocCallstack( ptr, size, TRACY_CALLSTACK );
|
# define TracyAlloc( ptr, size ) tracy::Profiler::MemAllocCallstack( ptr, size, TRACY_CALLSTACK );
|
||||||
|
3
TracyC.h
3
TracyC.h
@ -36,6 +36,7 @@ typedef const void* TracyCZoneCtx;
|
|||||||
#define TracyCMessageL(x)
|
#define TracyCMessageL(x)
|
||||||
#define TracyCMessageC(x,y,z)
|
#define TracyCMessageC(x,y,z)
|
||||||
#define TracyCMessageLC(x,y)
|
#define TracyCMessageLC(x,y)
|
||||||
|
#define TracyCAppInfo(x,y)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -120,12 +121,14 @@ void ___tracy_emit_message( const char* txt, size_t size );
|
|||||||
void ___tracy_emit_messageL( const char* txt );
|
void ___tracy_emit_messageL( const char* txt );
|
||||||
void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color );
|
void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color );
|
||||||
void ___tracy_emit_messageLC( const char* txt, uint32_t color );
|
void ___tracy_emit_messageLC( const char* txt, uint32_t color );
|
||||||
|
void ___tracy_emit_message_appinfo( const char* txt, size_t size );
|
||||||
|
|
||||||
#define TracyCPlot( name, val ) ___tracy_emit_plot( name, val );
|
#define TracyCPlot( name, val ) ___tracy_emit_plot( name, val );
|
||||||
#define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size );
|
#define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size );
|
||||||
#define TracyCMessageL( txt ) ___tracy_emit_messageL( txt );
|
#define TracyCMessageL( txt ) ___tracy_emit_messageL( txt );
|
||||||
#define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color );
|
#define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color );
|
||||||
#define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color );
|
#define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color );
|
||||||
|
#define TracyCAppInfo( txt, color ) ___tracy_emit_message_appinfo( txt, color );
|
||||||
|
|
||||||
|
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
|
@ -1338,6 +1338,11 @@ void Profiler::Worker()
|
|||||||
for( auto& item : m_deferredQueue )
|
for( auto& item : m_deferredQueue )
|
||||||
{
|
{
|
||||||
const auto idx = MemRead<uint8_t>( &item.hdr.idx );
|
const auto idx = MemRead<uint8_t>( &item.hdr.idx );
|
||||||
|
if( (QueueType)idx == QueueType::MessageAppInfo )
|
||||||
|
{
|
||||||
|
uint64_t ptr = MemRead<uint64_t>( &item.message.text );
|
||||||
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
|
}
|
||||||
AppendData( &item, QueueDataSize[idx] );
|
AppendData( &item, QueueDataSize[idx] );
|
||||||
}
|
}
|
||||||
m_deferredLock.unlock();
|
m_deferredLock.unlock();
|
||||||
@ -1591,6 +1596,9 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
|||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
case QueueType::MessageColor:
|
case QueueType::MessageColor:
|
||||||
|
#ifndef TRACY_ON_DEMAND
|
||||||
|
case QueueType::MessageAppInfo:
|
||||||
|
#endif
|
||||||
ptr = MemRead<uint64_t>( &item.message.text );
|
ptr = MemRead<uint64_t>( &item.message.text );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
@ -1617,6 +1625,11 @@ 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;
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
case QueueType::MessageAppInfo:
|
||||||
|
// Don't free memory associated with deferred messages.
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
@ -1681,6 +1694,13 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::MessageAppInfo:
|
||||||
|
ptr = MemRead<uint64_t>( &item->message.text );
|
||||||
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
|
#ifndef TRACY_ON_DEMAND
|
||||||
|
tracy_free( (void*)ptr );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case QueueType::ZoneBeginAllocSrcLoc:
|
case QueueType::ZoneBeginAllocSrcLoc:
|
||||||
case QueueType::ZoneBeginAllocSrcLocCallstack:
|
case QueueType::ZoneBeginAllocSrcLocCallstack:
|
||||||
ptr = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
ptr = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||||
@ -2445,6 +2465,7 @@ void ___tracy_emit_message( const char* txt, size_t size ) { tracy::Profiler::Me
|
|||||||
void ___tracy_emit_messageL( const char* txt ) { tracy::Profiler::Message( txt ); }
|
void ___tracy_emit_messageL( const char* txt ) { tracy::Profiler::Message( txt ); }
|
||||||
void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color ) { tracy::Profiler::MessageColor( txt, size, color ); }
|
void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color ) { tracy::Profiler::MessageColor( txt, size, color ); }
|
||||||
void ___tracy_emit_messageLC( const char* txt, uint32_t color ) { tracy::Profiler::MessageColor( txt, color ); }
|
void ___tracy_emit_messageLC( const char* txt, uint32_t color ) { tracy::Profiler::MessageColor( txt, color ); }
|
||||||
|
void ___tracy_emit_message_appinfo( const char* txt, size_t size ) { tracy::Profiler::MessageAppInfo( txt, size ); }
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -335,6 +335,28 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
||||||
|
{
|
||||||
|
Magic magic;
|
||||||
|
const auto thread = GetThreadHandle();
|
||||||
|
auto token = GetToken();
|
||||||
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
|
memcpy( ptr, txt, size );
|
||||||
|
ptr[size] = '\0';
|
||||||
|
auto& tail = token->get_tail_index();
|
||||||
|
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||||
|
MemWrite( &item->hdr.type, QueueType::MessageAppInfo );
|
||||||
|
MemWrite( &item->message.time, GetTime() );
|
||||||
|
MemWrite( &item->message.thread, thread );
|
||||||
|
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||||
|
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
GetProfiler().DeferItem( *item );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
}
|
||||||
|
|
||||||
static tracy_force_inline void MemAlloc( const void* ptr, size_t size )
|
static tracy_force_inline void MemAlloc( const void* ptr, size_t size )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 10 };
|
enum : uint32_t { ProtocolVersion = 11 };
|
||||||
enum : uint32_t { BroadcastVersion = 0 };
|
enum : uint32_t { BroadcastVersion = 0 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
@ -12,6 +12,7 @@ enum class QueueType : uint8_t
|
|||||||
ZoneName,
|
ZoneName,
|
||||||
Message,
|
Message,
|
||||||
MessageColor,
|
MessageColor,
|
||||||
|
MessageAppInfo,
|
||||||
ZoneBeginAllocSrcLoc,
|
ZoneBeginAllocSrcLoc,
|
||||||
ZoneBeginAllocSrcLocCallstack,
|
ZoneBeginAllocSrcLocCallstack,
|
||||||
CallstackMemory,
|
CallstackMemory,
|
||||||
@ -348,9 +349,9 @@ struct QueueItem
|
|||||||
QueueSysTime sysTime;
|
QueueSysTime sysTime;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
enum { QueueItemSize = sizeof( QueueItem ) };
|
enum { QueueItemSize = sizeof( QueueItem ) };
|
||||||
|
|
||||||
static const size_t QueueDataSize[] = {
|
static const size_t QueueDataSize[] = {
|
||||||
@ -358,6 +359,7 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // app info
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
||||||
|
Loading…
Reference in New Issue
Block a user