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 TracyMessageL(x)
|
||||
#define TracyMessageC(x,y,z)
|
||||
#define TracyMessageLC(x,y)
|
||||
|
||||
#define TracyAlloc(x,y)
|
||||
#define TracyFree(x)
|
||||
@ -96,6 +98,8 @@
|
||||
|
||||
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
|
||||
#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
|
||||
# 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 );
|
||||
break;
|
||||
case QueueType::Message:
|
||||
case QueueType::MessageColor:
|
||||
ptr = MemRead<uint64_t>( &item.message.text );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
@ -1420,6 +1421,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
case QueueType::Message:
|
||||
case QueueType::MessageColor:
|
||||
ptr = MemRead<uint64_t>( &item->message.text );
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
tracy_free( (void*)ptr );
|
||||
|
@ -256,6 +256,47 @@ public:
|
||||
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 )
|
||||
{
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
enum : uint32_t { ProtocolVersion = 5 };
|
||||
enum : uint32_t { ProtocolVersion = 6 };
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
|
||||
|
@ -11,6 +11,7 @@ enum class QueueType : uint8_t
|
||||
ZoneText,
|
||||
ZoneName,
|
||||
Message,
|
||||
MessageColor,
|
||||
ZoneBeginAllocSrcLoc,
|
||||
ZoneBeginAllocSrcLocCallstack,
|
||||
CallstackMemory,
|
||||
@ -39,6 +40,7 @@ enum class QueueType : uint8_t
|
||||
LockMark,
|
||||
PlotData,
|
||||
MessageLiteral,
|
||||
MessageLiteralColor,
|
||||
GpuNewContext,
|
||||
GpuZoneBegin,
|
||||
GpuZoneBeginCallstack,
|
||||
@ -190,6 +192,13 @@ struct QueueMessage
|
||||
uint64_t text; // ptr
|
||||
};
|
||||
|
||||
struct QueueMessageColor : public QueueMessage
|
||||
{
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
struct QueueGpuNewContext
|
||||
{
|
||||
int64_t cpuTime;
|
||||
@ -311,6 +320,7 @@ struct QueueItem
|
||||
QueueLockMark lockMark;
|
||||
QueuePlotData plotData;
|
||||
QueueMessage message;
|
||||
QueueMessageColor messageColor;
|
||||
QueueGpuNewContext gpuNewContext;
|
||||
QueueGpuZoneBegin gpuZoneBegin;
|
||||
QueueGpuZoneEnd gpuZoneEnd;
|
||||
@ -335,6 +345,7 @@ static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
||||
@ -364,6 +375,7 @@ static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ), // callstack
|
||||
|
@ -2500,6 +2500,12 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::MessageLiteral:
|
||||
ProcessMessageLiteral( ev.message );
|
||||
break;
|
||||
case QueueType::MessageColor:
|
||||
ProcessMessageColor( ev.messageColor );
|
||||
break;
|
||||
case QueueType::MessageLiteralColor:
|
||||
ProcessMessageLiteralColor( ev.messageColor );
|
||||
break;
|
||||
case QueueType::GpuNewContext:
|
||||
ProcessGpuNewContext( ev.gpuNewContext );
|
||||
break;
|
||||
@ -3073,6 +3079,30 @@ void Worker::ProcessMessageLiteral( const QueueMessage& ev )
|
||||
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 )
|
||||
{
|
||||
assert( !m_gpuCtxMap[ev.context] );
|
||||
|
@ -367,6 +367,8 @@ private:
|
||||
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
|
||||
tracy_force_inline void ProcessMessage( 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 ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev );
|
||||
tracy_force_inline void ProcessGpuZoneBeginCallstack( const QueueGpuZoneBegin& ev );
|
||||
|
Loading…
Reference in New Issue
Block a user