Allow sending text messages.

This commit is contained in:
Bartosz Taudul 2017-10-14 13:23:13 +02:00
parent e0300c3524
commit 8c7b60fbe6
3 changed files with 31 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#define TracyPlot(x,y) #define TracyPlot(x,y)
#define TracyMesage(x,y)
#else #else
#include "TracyLock.hpp" #include "TracyLock.hpp"
@ -39,6 +41,8 @@
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val ); #define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
#endif #endif
#endif #endif

View File

@ -127,6 +127,23 @@ public:
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
static tracy_force_inline void Message( const char* txt, size_t size )
{
uint32_t cpu;
Magic magic;
auto ptr = new char[size+1];
memcpy( ptr, txt, size );
ptr[size] = '\0';
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::Message;
item->message.time = GetTime( cpu );
item->message.thread = GetThreadHandle();
item->message.text = (uint64_t)ptr;
tail.store( magic + 1, std::memory_order_release );
}
static bool ShouldExit(); static bool ShouldExit();
private: private:

View File

@ -23,6 +23,7 @@ enum class QueueType : uint8_t
LockMark, LockMark,
PlotData, PlotData,
PlotName, PlotName,
Message,
NUM_TYPES NUM_TYPES
}; };
@ -125,6 +126,13 @@ struct QueuePlotData
} data; } data;
}; };
struct QueueMessage
{
int64_t time;
uint64_t thread;
uint64_t text; // ptr
};
struct QueueHeader struct QueueHeader
{ {
union union
@ -151,6 +159,7 @@ struct QueueItem
QueueLockRelease lockRelease; QueueLockRelease lockRelease;
QueueLockMark lockMark; QueueLockMark lockMark;
QueuePlotData plotData; QueuePlotData plotData;
QueueMessage message;
}; };
}; };
@ -174,6 +183,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( QueueStringTransfer ), // plot name sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name
sizeof( QueueHeader ) + sizeof( QueueMessage ),
}; };
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" ); static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );