Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Vanik <ben.vanik@gmail.com>2020-11-27 14:37:35 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2020-11-27 22:12:24 +0300
commit7dfdad2e02f41343c3ecf61faa6af00f8d616edf (patch)
tree69c89ad09899bd6abed96f128ca4ba7f4168eaf2
parentdfdf70aea35efb5b8aafc47025d1b1bce04ea9f4 (diff)
Adding ZoneColor to set a dynamic color override to an existing zone.
-rw-r--r--Tracy.hpp4
-rw-r--r--TracyC.h3
-rw-r--r--client/TracyProfiler.cpp18
-rw-r--r--client/TracyScoped.hpp13
-rw-r--r--common/TracyProtocol.hpp2
-rw-r--r--common/TracyQueue.hpp10
-rw-r--r--manual/tracy.tex4
-rw-r--r--server/TracyEvent.hpp1
-rw-r--r--server/TracyVersion.hpp2
-rw-r--r--server/TracyView.cpp12
-rw-r--r--server/TracyWorker.cpp41
-rw-r--r--server/TracyWorker.hpp3
12 files changed, 106 insertions, 7 deletions
diff --git a/Tracy.hpp b/Tracy.hpp
index 34e8736a..0421d6eb 100644
--- a/Tracy.hpp
+++ b/Tracy.hpp
@@ -23,6 +23,8 @@
#define ZoneTextV(x,y,z)
#define ZoneName(x,y)
#define ZoneNameV(x,y,z)
+#define ZoneColor(x)
+#define ZoneColorV(x,y)
#define ZoneValue(x)
#define ZoneValueV(x,y)
@@ -128,6 +130,8 @@
#define ZoneTextV( varname, txt, size ) varname.Text( txt, size );
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
#define ZoneNameV( varname, txt, size ) varname.Name( txt, size );
+#define ZoneColor( color ) __trace_scoped_zone.Color( color );
+#define ZoneColorV( varname, color ) varname.Color( color );
#define ZoneValue( value ) ___tracy_scoped_zone.Value( value );
#define ZoneValueV( varname, value ) varname.Value( value );
diff --git a/TracyC.h b/TracyC.h
index b900fd3f..a7740605 100644
--- a/TracyC.h
+++ b/TracyC.h
@@ -27,6 +27,7 @@ typedef const void* TracyCZoneCtx;
#define TracyCZoneEnd(c)
#define TracyCZoneText(c,x,y)
#define TracyCZoneName(c,x,y)
+#define TracyCZoneColor(c,x)
#define TracyCZoneValue(c,x)
#define TracyCAlloc(x,y)
@@ -111,6 +112,7 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srclo
TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx );
TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size );
TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size );
+TRACY_API void ___tracy_emit_zone_color( TracyCZoneCtx ctx, uint32_t color );
TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value );
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
@@ -129,6 +131,7 @@ TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value );
#define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size );
#define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size );
+#define TracyCZoneColor( ctx, color ) ___tracy_emit_zone_color( ctx, color );
#define TracyCZoneValue( ctx, value ) ___tracy_emit_zone_value( ctx, value );
diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp
index 778a5b1c..2d6e65fb 100644
--- a/client/TracyProfiler.cpp
+++ b/client/TracyProfiler.cpp
@@ -3290,6 +3290,24 @@ TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size
}
}
+TRACY_API void ___tracy_emit_zone_color( TracyCZoneCtx ctx, uint32_t color ) {
+ if( !ctx.active ) return;
+#ifndef TRACY_NO_VERIFY
+ {
+ TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
+ tracy::MemWrite( &item->zoneValidation.id, ctx.id );
+ TracyLfqCommitC;
+ }
+#endif
+ {
+ TracyLfqPrepareC( tracy::QueueType::ZoneColor );
+ tracy::MemWrite( &item->zoneColor.r, uint8_t( ( color ) & 0xFF ) );
+ tracy::MemWrite( &item->zoneColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
+ tracy::MemWrite( &item->zoneColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
+ TracyLfqCommitC;
+ }
+}
+
TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value )
{
if( !ctx.active ) return;
diff --git a/client/TracyScoped.hpp b/client/TracyScoped.hpp
index 78005e62..d6ad56b3 100644
--- a/client/TracyScoped.hpp
+++ b/client/TracyScoped.hpp
@@ -136,6 +136,19 @@ public:
TracyLfqCommit;
}
+ tracy_force_inline void Color( uint32_t color )
+ {
+ if( !m_active ) return;
+#ifdef TRACY_ON_DEMAND
+ if( GetProfiler().ConnectionId() != m_connectionId ) return;
+#endif
+ TracyLfqPrepare( QueueType::ZoneColor );
+ MemWrite( &item->zoneColor.r, uint8_t( ( color ) & 0xFF ) );
+ MemWrite( &item->zoneColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
+ MemWrite( &item->zoneColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
+ TracyLfqCommit;
+ }
+
tracy_force_inline void Value( uint64_t value )
{
if( !m_active ) return;
diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp
index a24d05da..9deb3539 100644
--- a/common/TracyProtocol.hpp
+++ b/common/TracyProtocol.hpp
@@ -9,7 +9,7 @@ namespace tracy
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
-enum : uint32_t { ProtocolVersion = 42 };
+enum : uint32_t { ProtocolVersion = 43 };
enum : uint16_t { BroadcastVersion = 2 };
using lz4sz_t = uint32_t;
diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp
index 5063cf59..0d4f6352 100644
--- a/common/TracyQueue.hpp
+++ b/common/TracyQueue.hpp
@@ -57,6 +57,7 @@ enum class QueueType : uint8_t
Crash,
CrashReport,
ZoneValidation,
+ ZoneColor,
ZoneValue,
FrameMarkMsg,
FrameMarkMsgStart,
@@ -124,6 +125,13 @@ struct QueueZoneValidation
uint32_t id;
};
+struct QueueZoneColor
+{
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+};
+
struct QueueZoneValue
{
uint64_t value;
@@ -489,6 +497,7 @@ struct QueueItem
QueueZoneBeginLean zoneBeginLean;
QueueZoneEnd zoneEnd;
QueueZoneValidation zoneValidation;
+ QueueZoneColor zoneColor;
QueueZoneValue zoneValue;
QueueStringTransfer stringTransfer;
QueueFrameMark frameMark;
@@ -593,6 +602,7 @@ static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ), // crash
sizeof( QueueHeader ) + sizeof( QueueCrashReport ),
sizeof( QueueHeader ) + sizeof( QueueZoneValidation ),
+ sizeof( QueueHeader ) + sizeof( QueueZoneColor ),
sizeof( QueueHeader ) + sizeof( QueueZoneValue ),
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // continuous frames
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // start
diff --git a/manual/tracy.tex b/manual/tracy.tex
index a68ae1e3..6aec9b54 100644
--- a/manual/tracy.tex
+++ b/manual/tracy.tex
@@ -1027,7 +1027,7 @@ $2560\times1440$ & 23~FPS & 3300~FPS & 1600~FPS
To record a zone's\footnote{A \texttt{zone} represents the lifetime of a special on-stack profiler variable. Typically it would exist for the duration of a whole scope of the profiled function, but you also can measure time spent in scopes of a for-loop, or an if-branch.} execution time add the \texttt{ZoneScoped} macro at the beginning of the scope you want to measure. This will automatically record function name, source file name and location. Optionally you may use the \texttt{ZoneScopedC(color)} macro to set a custom color for the zone. Note that the color value will be constant in the recording (don't try to parametrize it). You may also set a custom name for the zone, using the \texttt{ZoneScopedN(name)} macro. Color and name may be combined by using the \texttt{ZoneScopedNC(name, color)} macro.
-Use the \texttt{ZoneText(text, size)} macro to add a custom text string that will be displayed along the zone information (for example, name of the file you are opening). Multiple text strings can be attached to any single zone. If you want to send a numeric value and don't want to pay the cost of converting it to a string, you may use the \texttt{ZoneValue(uint64\_t)} macro.
+Use the \texttt{ZoneText(text, size)} macro to add a custom text string that will be displayed along the zone information (for example, name of the file you are opening). Multiple text strings can be attached to any single zone. The dynamic color of a zone can be specified with the \texttt{ZoneColor(uint32\_t)} macro to override the source location color. If you want to send a numeric value and don't want to pay the cost of converting it to a string, you may use the \texttt{ZoneValue(uint64\_t)} macro.
If you want to set zone name on a per-call basis, you may do so using the \texttt{ZoneName(text, size)} macro. This name won't be used in the process of grouping the zones for statistical purposes (sections~\ref{statistics} and~\ref{findzone}).
@@ -1050,7 +1050,7 @@ The zone markup macros automatically report when they end, through the RAII mech
Using the \texttt{ZoneScoped} family of macros creates a stack variable named \texttt{\_\_\_tracy\_scoped\_zone}. If you want to measure more than one zone in the same scope, you will need to use the \texttt{ZoneNamed} macros, which require that you provide a name for the created variable. For example, instead of \texttt{ZoneScopedN("Zone name")}, you would use \texttt{ZoneNamedN(variableName, "Zone name", true)}\footnote{The last parameter is explained in section~\ref{filteringzones}.}.
-The \texttt{ZoneText}, \texttt{ZoneValue} and \texttt{ZoneName} macros apply to the zones created using the \texttt{ZoneScoped} macros. For zones created using the \texttt{ZoneNamed} macros, you can use the \texttt{ZoneTextV(variableName, text, size)}, \texttt{ZoneValueV(variableName, uint64\_t)}, or \texttt{ZoneNameV(variableName, text, size)} macros, or invoke the methods \texttt{Text}, \texttt{Value} or \texttt{Name} directly on the variable you have created.
+The \texttt{ZoneText}, \texttt{ZoneColor}, \texttt{ZoneValue}, and \texttt{ZoneName} macros apply to the zones created using the \texttt{ZoneScoped} macros. For zones created using the \texttt{ZoneNamed} macros, you can use the \texttt{ZoneTextV(variableName, text, size)}, \texttt{ZoneColorV(variableName, uint32\_t)}, \texttt{ZoneValueV(variableName, uint64\_t)}, or \texttt{ZoneNameV(variableName, text, size)} macros, or invoke the methods \texttt{Text}, \texttt{Color}, \texttt{Value}, or \texttt{Name} directly on the variable you have created.
Zone objects can't be moved or copied.
diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp
index baacb409..047ccf8b 100644
--- a/server/TracyEvent.hpp
+++ b/server/TracyEvent.hpp
@@ -207,6 +207,7 @@ struct ZoneExtra
Int24 callstack;
StringIdx text;
StringIdx name;
+ Int24 color;
};
enum { ZoneExtraSize = sizeof( ZoneExtra ) };
diff --git a/server/TracyVersion.hpp b/server/TracyVersion.hpp
index 739a2dfb..4b81c7c8 100644
--- a/server/TracyVersion.hpp
+++ b/server/TracyVersion.hpp
@@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 7 };
-enum { Patch = 4 };
+enum { Patch = 5 };
}
}
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index bce1a8ed..b3a9b5a1 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -16561,8 +16561,16 @@ uint32_t View::GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth
{
const auto sl = ev.SrcLoc();
const auto& srcloc = m_worker.GetSourceLocation( sl );
- const auto color = srcloc.color;
- if( color != 0 && !m_vd.forceColors ) return color | 0xFF000000;
+ if( !m_vd.forceColors )
+ {
+ if( m_worker.HasZoneExtra( ev ) )
+ {
+ const auto custom_color = m_worker.GetZoneExtra( ev ).color.Val();
+ if( custom_color != 0 ) return custom_color | 0xFF000000;
+ }
+ const auto color = srcloc.color;
+ if( color != 0 ) return color | 0xFF000000;
+ }
switch( m_vd.dynamicColors )
{
case 0:
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index 5061f3ac..80692de8 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -822,13 +822,25 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
f.Skip( sz * ( sizeof( uint64_t ) + sizeof( MessageData::time ) + sizeof( MessageData::ref ) + sizeof( MessageData::color ) + sizeof( MessageData::callstack ) ) );
}
- if( fileVer >= FileVersion( 0, 6, 3 ) )
+ if( fileVer >= FileVersion( 0, 7, 5 ) )
{
f.Read( sz );
assert( sz != 0 );
m_data.zoneExtra.reserve_exact( sz, m_slab );
f.Read( m_data.zoneExtra.data(), sz * sizeof( ZoneExtra ) );
}
+ else if( fileVer >= FileVersion( 0, 6, 3 ) )
+ {
+ f.Read( sz );
+ assert( sz != 0 );
+ m_data.zoneExtra.reserve_exact( sz, m_slab );
+ for( uint64_t i=0; i<sz; i++ )
+ {
+ auto* zoneExtra = &m_data.zoneExtra[i];
+ f.Read3( zoneExtra->callstack, zoneExtra->text, zoneExtra->name );
+ zoneExtra->color = 0;
+ }
+ }
else
{
m_data.zoneExtra.push_back( ZoneExtra {} );
@@ -4116,6 +4128,9 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::ZoneName:
ProcessZoneName();
break;
+ case QueueType::ZoneColor:
+ ProcessZoneColor( ev.zoneColor );
+ break;
case QueueType::ZoneValue:
ProcessZoneValue( ev.zoneValue );
break;
@@ -4506,6 +4521,12 @@ void Worker::ZoneTextFailure( uint64_t thread )
m_failureData.thread = thread;
}
+void Worker::ZoneColorFailure( uint64_t thread )
+{
+ m_failure = Failure::ZoneColor;
+ m_failureData.thread = thread;
+}
+
void Worker::ZoneNameFailure( uint64_t thread )
{
m_failure = Failure::ZoneName;
@@ -4738,6 +4759,23 @@ void Worker::ProcessZoneName()
extra.name = StringIdx( GetSingleStringIdx() );
}
+void Worker::ProcessZoneColor( const QueueZoneColor& ev )
+{
+ auto td = RetrieveThread( m_threadCtx );
+ if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() )
+ {
+ ZoneColorFailure( m_threadCtx );
+ return;
+ }
+
+ td->nextZoneId = 0;
+ auto& stack = td->stack;
+ auto zone = stack.back();
+ auto& extra = RequestZoneExtra( *zone );
+ const uint32_t color = ( ev.b << 16 ) | ( ev.g << 8 ) | ev.r;
+ extra.color = color;
+}
+
void Worker::ProcessZoneValue( const QueueZoneValue& ev )
{
char tmp[32];
@@ -7221,6 +7259,7 @@ static const char* s_failureReasons[] = {
"Invalid order of zone begin and end events.",
"Zone is ended twice.",
"Zone text transfer destination doesn't match active zone.",
+ "Zone color transfer destination doesn't match active zone.",
"Zone name transfer destination doesn't match active zone.",
"Memory free event without a matching allocation.",
"Discontinuous frame begin/end mismatch.",
diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp
index 5b9409b8..2fe6ba00 100644
--- a/server/TracyWorker.hpp
+++ b/server/TracyWorker.hpp
@@ -383,6 +383,7 @@ public:
ZoneStack,
ZoneDoubleEnd,
ZoneText,
+ ZoneColor,
ZoneName,
MemFree,
FrameEnd,
@@ -608,6 +609,7 @@ private:
tracy_force_inline void ProcessFrameImage( const QueueFrameImage& ev );
tracy_force_inline void ProcessZoneText();
tracy_force_inline void ProcessZoneName();
+ tracy_force_inline void ProcessZoneColor( const QueueZoneColor& ev );
tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev );
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );
@@ -670,6 +672,7 @@ private:
void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );
void ZoneDoubleEndFailure( uint64_t thread, const ZoneEvent* ev );
void ZoneTextFailure( uint64_t thread );
+ void ZoneColorFailure( uint64_t thread );
void ZoneNameFailure( uint64_t thread );
void MemFreeFailure( uint64_t thread );
void FrameEndFailure();