mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Allow sending text messages.
This commit is contained in:
parent
e0300c3524
commit
8c7b60fbe6
@ -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
|
||||||
|
@ -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:
|
||||||
|
@ -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" );
|
||||||
|
Loading…
Reference in New Issue
Block a user