From 907574e6375f9af9860f20f530c130149a656783 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 5 Nov 2019 16:47:41 +0100 Subject: [PATCH] Allow remote plot configuration. --- Tracy.hpp | 2 ++ client/TracyProfiler.hpp | 17 +++++++++++++++++ common/TracyProtocol.hpp | 2 +- common/TracyQueue.hpp | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Tracy.hpp b/Tracy.hpp index a3ec997a..ebeac22f 100644 --- a/Tracy.hpp +++ b/Tracy.hpp @@ -35,6 +35,7 @@ #define LockMark(x) (void)x; #define TracyPlot(x,y) +#define TracyPlotConfig(x,y) #define TracyMessage(x,y) #define TracyMessageL(x) @@ -100,6 +101,7 @@ #define LockMark( varname ) static const tracy::SourceLocationData __tracy_lock_location_##varname { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname ); #define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val ); +#define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type ); #define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size ); #define TracyMessageL( txt ) tracy::Profiler::Message( txt ); diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index c3ef4eb8..2b34cb51 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -244,6 +244,23 @@ public: tail.store( magic + 1, std::memory_order_release ); } + static tracy_force_inline void ConfigurePlot( const char* name, PlotFormatType type ) + { + Magic magic; + auto token = GetToken(); + auto& tail = token->get_tail_index(); + auto item = token->enqueue_begin( magic ); + MemWrite( &item->hdr.type, QueueType::PlotConfig ); + MemWrite( &item->plotConfig.name, (uint64_t)name ); + MemWrite( &item->plotConfig.type, (uint8_t)type ); + +#ifdef TRACY_ON_DEMAND + GetProfiler().DeferItem( *item ); +#endif + + tail.store( magic + 1, std::memory_order_release ); + } + static tracy_force_inline void Message( const char* txt, size_t size ) { #ifdef TRACY_ON_DEMAND diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index d2742df9..f41ecb2e 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -9,7 +9,7 @@ namespace tracy { -enum : uint32_t { ProtocolVersion = 21 }; +enum : uint32_t { ProtocolVersion = 22 }; enum : uint32_t { BroadcastVersion = 0 }; using lz4sz_t = uint32_t; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index c8ab0f99..fc08d1fa 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -62,6 +62,7 @@ enum class QueueType : uint8_t CallstackFrame, SysTimeReport, TidToPid, + PlotConfig, StringData, ThreadName, CustomStringData, @@ -330,6 +331,19 @@ struct QueueTidToPid uint64_t pid; }; +enum class PlotFormatType : uint8_t +{ + Number, + Memory, + Percentage +}; + +struct QueuePlotConfig +{ + uint64_t name; // ptr + uint8_t type; +}; + struct QueueHeader { union @@ -378,6 +392,7 @@ struct QueueItem QueueContextSwitch contextSwitch; QueueThreadWakeup threadWakeup; QueueTidToPid tidToPid; + QueuePlotConfig plotConfig; }; }; #pragma pack() @@ -441,6 +456,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ), sizeof( QueueHeader ) + sizeof( QueueSysTime ), sizeof( QueueHeader ) + sizeof( QueueTidToPid ), + sizeof( QueueHeader ) + sizeof( QueuePlotConfig ), // keep all QueueStringTransfer below sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name