mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Transfer of colored messages.
This commit is contained in:
parent
6a09229ae7
commit
efc54babe3
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#define TracyMessage(x,y)
|
#define TracyMessage(x,y)
|
||||||
#define TracyMessageL(x)
|
#define TracyMessageL(x)
|
||||||
|
#define TracyMessageC(x,y,z)
|
||||||
|
#define TracyMessageLC(x,y)
|
||||||
|
|
||||||
#define TracyAlloc(x,y)
|
#define TracyAlloc(x,y)
|
||||||
#define TracyFree(x)
|
#define TracyFree(x)
|
||||||
@ -96,6 +98,8 @@
|
|||||||
|
|
||||||
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
|
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
|
||||||
#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 TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color );
|
||||||
|
|
||||||
#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 );
|
||||||
|
@ -1339,6 +1339,7 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
|||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
|
case QueueType::MessageColor:
|
||||||
ptr = MemRead<uint64_t>( &item.message.text );
|
ptr = MemRead<uint64_t>( &item.message.text );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
@ -1420,6 +1421,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
|
case QueueType::MessageColor:
|
||||||
ptr = MemRead<uint64_t>( &item->message.text );
|
ptr = MemRead<uint64_t>( &item->message.text );
|
||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
|
@ -256,6 +256,47 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color )
|
||||||
|
{
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
|
#endif
|
||||||
|
Magic magic;
|
||||||
|
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::MessageColor );
|
||||||
|
MemWrite( &item->messageColor.time, GetTime() );
|
||||||
|
MemWrite( &item->messageColor.thread, GetThreadHandle() );
|
||||||
|
MemWrite( &item->messageColor.text, (uint64_t)ptr );
|
||||||
|
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||||
|
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||||
|
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||||
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
}
|
||||||
|
|
||||||
|
static tracy_force_inline void MessageColor( const char* txt, uint32_t color )
|
||||||
|
{
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
|
#endif
|
||||||
|
Magic magic;
|
||||||
|
auto token = GetToken();
|
||||||
|
auto& tail = token->get_tail_index();
|
||||||
|
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||||
|
MemWrite( &item->hdr.type, QueueType::MessageLiteralColor );
|
||||||
|
MemWrite( &item->messageColor.time, GetTime() );
|
||||||
|
MemWrite( &item->messageColor.thread, GetThreadHandle() );
|
||||||
|
MemWrite( &item->messageColor.text, (uint64_t)txt );
|
||||||
|
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||||
|
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||||
|
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||||
|
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 = 5 };
|
enum : uint32_t { ProtocolVersion = 6 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ enum class QueueType : uint8_t
|
|||||||
ZoneText,
|
ZoneText,
|
||||||
ZoneName,
|
ZoneName,
|
||||||
Message,
|
Message,
|
||||||
|
MessageColor,
|
||||||
ZoneBeginAllocSrcLoc,
|
ZoneBeginAllocSrcLoc,
|
||||||
ZoneBeginAllocSrcLocCallstack,
|
ZoneBeginAllocSrcLocCallstack,
|
||||||
CallstackMemory,
|
CallstackMemory,
|
||||||
@ -39,6 +40,7 @@ enum class QueueType : uint8_t
|
|||||||
LockMark,
|
LockMark,
|
||||||
PlotData,
|
PlotData,
|
||||||
MessageLiteral,
|
MessageLiteral,
|
||||||
|
MessageLiteralColor,
|
||||||
GpuNewContext,
|
GpuNewContext,
|
||||||
GpuZoneBegin,
|
GpuZoneBegin,
|
||||||
GpuZoneBeginCallstack,
|
GpuZoneBeginCallstack,
|
||||||
@ -190,6 +192,13 @@ struct QueueMessage
|
|||||||
uint64_t text; // ptr
|
uint64_t text; // ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueMessageColor : public QueueMessage
|
||||||
|
{
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
};
|
||||||
|
|
||||||
struct QueueGpuNewContext
|
struct QueueGpuNewContext
|
||||||
{
|
{
|
||||||
int64_t cpuTime;
|
int64_t cpuTime;
|
||||||
@ -311,6 +320,7 @@ struct QueueItem
|
|||||||
QueueLockMark lockMark;
|
QueueLockMark lockMark;
|
||||||
QueuePlotData plotData;
|
QueuePlotData plotData;
|
||||||
QueueMessage message;
|
QueueMessage message;
|
||||||
|
QueueMessageColor messageColor;
|
||||||
QueueGpuNewContext gpuNewContext;
|
QueueGpuNewContext gpuNewContext;
|
||||||
QueueGpuZoneBegin gpuZoneBegin;
|
QueueGpuZoneBegin gpuZoneBegin;
|
||||||
QueueGpuZoneEnd gpuZoneEnd;
|
QueueGpuZoneEnd gpuZoneEnd;
|
||||||
@ -335,6 +345,7 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
||||||
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( 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 ),
|
||||||
@ -364,6 +375,7 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
|
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ), // callstack
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ), // callstack
|
||||||
|
@ -2500,6 +2500,12 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::MessageLiteral:
|
case QueueType::MessageLiteral:
|
||||||
ProcessMessageLiteral( ev.message );
|
ProcessMessageLiteral( ev.message );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::MessageColor:
|
||||||
|
ProcessMessageColor( ev.messageColor );
|
||||||
|
break;
|
||||||
|
case QueueType::MessageLiteralColor:
|
||||||
|
ProcessMessageLiteralColor( ev.messageColor );
|
||||||
|
break;
|
||||||
case QueueType::GpuNewContext:
|
case QueueType::GpuNewContext:
|
||||||
ProcessGpuNewContext( ev.gpuNewContext );
|
ProcessGpuNewContext( ev.gpuNewContext );
|
||||||
break;
|
break;
|
||||||
@ -3073,6 +3079,30 @@ void Worker::ProcessMessageLiteral( const QueueMessage& ev )
|
|||||||
InsertMessageData( msg, ev.thread );
|
InsertMessageData( msg, ev.thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessMessageColor( const QueueMessageColor& ev )
|
||||||
|
{
|
||||||
|
auto it = m_pendingCustomStrings.find( ev.text );
|
||||||
|
assert( it != m_pendingCustomStrings.end() );
|
||||||
|
auto msg = m_slab.Alloc<MessageData>();
|
||||||
|
msg->time = TscTime( ev.time );
|
||||||
|
msg->ref = StringRef( StringRef::Type::Idx, it->second.idx );
|
||||||
|
msg->thread = ev.thread;
|
||||||
|
m_data.lastTime = std::max( m_data.lastTime, msg->time );
|
||||||
|
InsertMessageData( msg, ev.thread );
|
||||||
|
m_pendingCustomStrings.erase( it );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessMessageLiteralColor( const QueueMessageColor& ev )
|
||||||
|
{
|
||||||
|
CheckString( ev.text );
|
||||||
|
auto msg = m_slab.Alloc<MessageData>();
|
||||||
|
msg->time = TscTime( ev.time );
|
||||||
|
msg->ref = StringRef( StringRef::Type::Ptr, ev.text );
|
||||||
|
msg->thread = ev.thread;
|
||||||
|
m_data.lastTime = std::max( m_data.lastTime, msg->time );
|
||||||
|
InsertMessageData( msg, ev.thread );
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev )
|
void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev )
|
||||||
{
|
{
|
||||||
assert( !m_gpuCtxMap[ev.context] );
|
assert( !m_gpuCtxMap[ev.context] );
|
||||||
|
@ -367,6 +367,8 @@ private:
|
|||||||
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
|
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
|
||||||
tracy_force_inline void ProcessMessage( const QueueMessage& ev );
|
tracy_force_inline void ProcessMessage( const QueueMessage& ev );
|
||||||
tracy_force_inline void ProcessMessageLiteral( const QueueMessage& ev );
|
tracy_force_inline void ProcessMessageLiteral( const QueueMessage& ev );
|
||||||
|
tracy_force_inline void ProcessMessageColor( const QueueMessageColor& ev );
|
||||||
|
tracy_force_inline void ProcessMessageLiteralColor( const QueueMessageColor& ev );
|
||||||
tracy_force_inline void ProcessGpuNewContext( const QueueGpuNewContext& ev );
|
tracy_force_inline void ProcessGpuNewContext( const QueueGpuNewContext& ev );
|
||||||
tracy_force_inline void ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev );
|
tracy_force_inline void ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev );
|
||||||
tracy_force_inline void ProcessGpuZoneBeginCallstack( const QueueGpuZoneBegin& ev );
|
tracy_force_inline void ProcessGpuZoneBeginCallstack( const QueueGpuZoneBegin& ev );
|
||||||
|
Loading…
Reference in New Issue
Block a user