mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 06:34:36 +00:00
Zones can inherit custom colors from parents.
Co-authored-by: Martijn Courteaux <courteauxmartijn@gmail.com>
This commit is contained in:
parent
8724400884
commit
b359936c04
@ -3412,6 +3412,7 @@ In this window, you can set various trace-related options. For example, the time
|
||||
\item \emph{Source location dynamic} -- Zone color is determined by source location (function name) and depth level.
|
||||
\end{itemize}
|
||||
Enabling the \emph{Ignore custom} option will force usage of the selected zone coloring scheme, disregarding any colors set by the user in profiled code.
|
||||
Enabling the \emph{Inherit parent colors} option will cause zones that have a color set by the user in the profiled code to be propagated down to the child zones, although slightly darker.
|
||||
\item \emph{\faRulerHorizontal{} Zone name shortening} -- controls display behavior of long zone names, which don't fit inside a zone box:
|
||||
\begin{itemize}
|
||||
\item \emph{Disabled} -- Shortening of zone names is not performed and names are always displayed in full (e.g.\ \texttt{bool ns::container<float>::add(const float\&)}).
|
||||
|
@ -20,6 +20,14 @@ static tracy_force_inline uint32_t HighlightColor( uint32_t color )
|
||||
( std::min<int>( 0xFF, ( ( ( color & 0x000000FF ) ) + V ) ) );
|
||||
}
|
||||
|
||||
static tracy_force_inline uint32_t DarkenColorSlightly( uint32_t color )
|
||||
{
|
||||
return 0xFF000000 |
|
||||
( ( ( ( color & 0x00FF0000 ) >> 16 ) * 4 / 5 ) << 16 ) |
|
||||
( ( ( ( color & 0x0000FF00 ) >> 8 ) * 4 / 5 ) << 8 ) |
|
||||
( ( ( ( color & 0x000000FF ) ) * 4 / 5 ) );
|
||||
}
|
||||
|
||||
static tracy_force_inline uint32_t DarkenColor( uint32_t color )
|
||||
{
|
||||
return 0xFF000000 |
|
||||
|
@ -24,6 +24,7 @@ struct TimelineDraw
|
||||
short_ptr<void*> ev;
|
||||
Int48 rend;
|
||||
uint32_t num;
|
||||
uint32_t inheritedColor;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "TracyColor.hpp"
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyLockHelpers.hpp"
|
||||
#include "TracyMouse.hpp"
|
||||
@ -300,7 +301,7 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
|
||||
else
|
||||
#endif
|
||||
{
|
||||
m_depth = PreprocessZoneLevel( ctx, m_thread->timeline, 0, visible );
|
||||
m_depth = PreprocessZoneLevel( ctx, m_thread->timeline, 0, visible, 0 );
|
||||
}
|
||||
} );
|
||||
|
||||
@ -399,20 +400,20 @@ int TimelineItemThread::PreprocessGhostLevel( const TimelineContext& ctx, const
|
||||
}
|
||||
#endif
|
||||
|
||||
int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible )
|
||||
int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, uint32_t inheritedColor )
|
||||
{
|
||||
if( vec.is_magic() )
|
||||
{
|
||||
return PreprocessZoneLevel<VectorAdapterDirect<ZoneEvent>>( ctx, *(Vector<ZoneEvent>*)( &vec ), depth, visible );
|
||||
return PreprocessZoneLevel<VectorAdapterDirect<ZoneEvent>>( ctx, *(Vector<ZoneEvent>*)( &vec ), depth, visible, inheritedColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
return PreprocessZoneLevel<VectorAdapterPointer<ZoneEvent>>( ctx, vec, depth, visible );
|
||||
return PreprocessZoneLevel<VectorAdapterPointer<ZoneEvent>>( ctx, vec, depth, visible, inheritedColor );
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Adapter, typename V>
|
||||
int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible )
|
||||
int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, uint32_t inheritedColor )
|
||||
{
|
||||
const auto vStart = ctx.vStart;
|
||||
const auto vEnd = ctx.vEnd;
|
||||
@ -450,17 +451,38 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V
|
||||
if( nt - pt >= MinVisNs ) break;
|
||||
nextTime = nt + MinVisNs;
|
||||
}
|
||||
if( visible ) m_draw.emplace_back( TimelineDraw { TimelineDrawType::Folded, uint16_t( depth ), (void**)&ev, m_worker.GetZoneEnd( a(*(next-1)) ), uint32_t( next - it ) } );
|
||||
if( visible ) m_draw.emplace_back( TimelineDraw { TimelineDrawType::Folded, uint16_t( depth ), (void**)&ev, m_worker.GetZoneEnd( a(*(next-1)) ), uint32_t( next - it ), inheritedColor } );
|
||||
it = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ev.HasChildren() )
|
||||
const auto hasChildren = ev.HasChildren();
|
||||
auto currentInherited = inheritedColor;
|
||||
if( m_view.GetViewData().inheritParentColors )
|
||||
{
|
||||
const auto d = PreprocessZoneLevel( ctx, m_worker.GetZoneChildren( ev.Child() ), depth + 1, visible );
|
||||
uint32_t color = 0;
|
||||
if( m_worker.HasZoneExtra( ev ) )
|
||||
{
|
||||
const auto& extra = m_worker.GetZoneExtra( ev );
|
||||
color = extra.color.Val();
|
||||
}
|
||||
if( color == 0 )
|
||||
{
|
||||
auto& srcloc = m_worker.GetSourceLocation( ev.SrcLoc() );
|
||||
color = srcloc.color;
|
||||
}
|
||||
if( color != 0 )
|
||||
{
|
||||
currentInherited = color | 0xFF000000;
|
||||
if( hasChildren ) inheritedColor = DarkenColorSlightly( color );
|
||||
}
|
||||
}
|
||||
if( hasChildren )
|
||||
{
|
||||
const auto d = PreprocessZoneLevel( ctx, m_worker.GetZoneChildren( ev.Child() ), depth + 1, visible, inheritedColor );
|
||||
if( d > maxdepth ) maxdepth = d;
|
||||
}
|
||||
if( visible ) m_draw.emplace_back( TimelineDraw { TimelineDrawType::Zone, uint16_t( depth ), (void**)&ev } );
|
||||
if( visible ) m_draw.emplace_back( TimelineDraw { TimelineDrawType::Zone, uint16_t( depth ), (void**)&ev, 0, 0, currentInherited } );
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ private:
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
int PreprocessGhostLevel( const TimelineContext& ctx, const Vector<GhostZone>& vec, int depth, bool visible );
|
||||
#endif
|
||||
int PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible );
|
||||
int PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, uint32_t inheritedColor );
|
||||
|
||||
template<typename Adapter, typename V>
|
||||
int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible );
|
||||
int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, uint32_t inheritedColor );
|
||||
|
||||
void PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch, bool visible );
|
||||
void PreprocessSamples( const TimelineContext& ctx, const Vector<SampleData>& vec, bool visible, int yPos );
|
||||
|
@ -145,6 +145,7 @@ void UserData::LoadState( ViewData& data )
|
||||
if( ini_sget( ini, "options", "drawCpuUsageGraph", "%d", &v ) ) data.drawCpuUsageGraph = v;
|
||||
if( ini_sget( ini, "options", "drawSamples", "%d", &v ) ) data.drawSamples = v;
|
||||
if( ini_sget( ini, "options", "dynamicColors", "%d", &v ) ) data.dynamicColors = v;
|
||||
if( ini_sget( ini, "options", "inheritParentColors", "%d", &v ) ) data.inheritParentColors = v;
|
||||
if( ini_sget( ini, "options", "forceColors", "%d", &v ) ) data.forceColors = v;
|
||||
if( ini_sget( ini, "options", "ghostZones", "%d", &v ) ) data.ghostZones = v;
|
||||
if( ini_sget( ini, "options", "frameTarget", "%d", &v ) ) data.frameTarget = v;
|
||||
@ -194,6 +195,7 @@ void UserData::SaveState( const ViewData& data )
|
||||
fprintf( f, "drawCpuUsageGraph = %d\n", data.drawCpuUsageGraph );
|
||||
fprintf( f, "drawSamples = %d\n", data.drawSamples );
|
||||
fprintf( f, "dynamicColors = %d\n", data.dynamicColors );
|
||||
fprintf( f, "inheritParentColors = %d\n", data.inheritParentColors );
|
||||
fprintf( f, "forceColors = %d\n", data.forceColors );
|
||||
fprintf( f, "ghostZones = %d\n", data.ghostZones );
|
||||
fprintf( f, "frameTarget = %d\n", data.frameTarget );
|
||||
|
@ -313,7 +313,7 @@ private:
|
||||
uint32_t GetRawSrcLocColor( const SourceLocation& srcloc, int depth );
|
||||
uint32_t GetZoneColor( const ZoneEvent& ev, uint64_t thread, int depth );
|
||||
uint32_t GetZoneColor( const GpuEvent& ev );
|
||||
ZoneColorData GetZoneColorData( const ZoneEvent& ev, uint64_t thread, int depth );
|
||||
ZoneColorData GetZoneColorData( const ZoneEvent& ev, uint64_t thread, int depth, uint32_t inheritedColor );
|
||||
ZoneColorData GetZoneColorData( const GpuEvent& ev );
|
||||
|
||||
void ZoomToZone( const ZoneEvent& ev );
|
||||
|
@ -53,6 +53,7 @@ struct ViewData
|
||||
uint8_t drawCpuUsageGraph = true;
|
||||
uint8_t drawSamples = true;
|
||||
uint8_t dynamicColors = 1;
|
||||
uint8_t inheritParentColors = true;
|
||||
uint8_t forceColors = false;
|
||||
uint8_t ghostZones = true;
|
||||
ShortenName shortenName = ShortenName::NoSpaceAndNormalize;
|
||||
|
@ -225,6 +225,9 @@ void View::DrawOptions()
|
||||
ImGui::SameLine();
|
||||
bool forceColors = m_vd.forceColors;
|
||||
if( SmallCheckbox( "Ignore custom", &forceColors ) ) m_vd.forceColors = forceColors;
|
||||
ImGui::SameLine();
|
||||
bool inheritColors = m_vd.inheritParentColors;
|
||||
if( SmallCheckbox( "Inherit parent colors", &inheritColors ) ) m_vd.inheritParentColors = inheritColors;
|
||||
ImGui::Indent();
|
||||
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
|
||||
ImGui::RadioButton( "Static", &ival, 0 );
|
||||
|
@ -76,27 +76,27 @@ uint32_t View::GetZoneColor( const GpuEvent& ev )
|
||||
return color != 0 ? ( color | 0xFF000000 ) : 0xFF222288;
|
||||
}
|
||||
|
||||
View::ZoneColorData View::GetZoneColorData( const ZoneEvent& ev, uint64_t thread, int depth )
|
||||
View::ZoneColorData View::GetZoneColorData( const ZoneEvent& ev, uint64_t thread, int depth, uint32_t inheritedColor )
|
||||
{
|
||||
ZoneColorData ret;
|
||||
const auto& srcloc = ev.SrcLoc();
|
||||
if( m_zoneInfoWindow == &ev )
|
||||
{
|
||||
ret.color = GetZoneColor( ev, thread, depth );
|
||||
ret.color = inheritedColor ? inheritedColor : GetZoneColor( ev, thread, depth );
|
||||
ret.accentColor = 0xFF44DD44;
|
||||
ret.thickness = 3.f;
|
||||
ret.highlight = true;
|
||||
}
|
||||
else if( m_zoneHighlight == &ev )
|
||||
{
|
||||
ret.color = GetZoneColor( ev, thread, depth );
|
||||
ret.color = inheritedColor ? inheritedColor : GetZoneColor( ev, thread, depth );
|
||||
ret.accentColor = 0xFF4444FF;
|
||||
ret.thickness = 3.f;
|
||||
ret.highlight = true;
|
||||
}
|
||||
else if( m_zoneSrcLocHighlight == srcloc )
|
||||
{
|
||||
ret.color = GetZoneColor( ev, thread, depth );
|
||||
ret.color = inheritedColor ? inheritedColor : GetZoneColor( ev, thread, depth );
|
||||
ret.accentColor = 0xFFEEEEEE;
|
||||
ret.thickness = 1.f;
|
||||
ret.highlight = true;
|
||||
@ -119,7 +119,7 @@ View::ZoneColorData View::GetZoneColorData( const ZoneEvent& ev, uint64_t thread
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto color = GetZoneColor( ev, thread, depth );
|
||||
const auto color = inheritedColor ? inheritedColor : GetZoneColor( ev, thread, depth );
|
||||
ret.color = color;
|
||||
ret.accentColor = HighlightColor( color );
|
||||
ret.thickness = 1.f;
|
||||
|
@ -223,7 +223,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineD
|
||||
case TimelineDrawType::Folded:
|
||||
{
|
||||
auto& ev = *(const ZoneEvent*)v.ev.get();
|
||||
const auto color = m_vd.dynamicColors == 2 ? 0xFF666666 : GetThreadColor( tid, v.depth );
|
||||
const auto color = v.inheritedColor ? v.inheritedColor : ( m_vd.dynamicColors == 2 ? 0xFF666666 : GetThreadColor( tid, v.depth ) );
|
||||
const auto rend = v.rend.Val();
|
||||
const auto px0 = ( ev.Start() - vStart ) * pxns;
|
||||
const auto px1 = ( rend - vStart ) * pxns;
|
||||
@ -284,7 +284,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineD
|
||||
auto& ev = *(const ZoneEvent*)v.ev.get();
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
const auto zsz = std::max( ( end - ev.Start() ) * pxns, pxns * 0.5 );
|
||||
const auto zoneColor = GetZoneColorData( ev, tid, v.depth );
|
||||
const auto zoneColor = GetZoneColorData( ev, tid, v.depth, v.inheritedColor );
|
||||
const char* zoneName = m_worker.GetZoneName( ev );
|
||||
|
||||
auto tsz = ImGui::CalcTextSize( zoneName );
|
||||
|
Loading…
Reference in New Issue
Block a user