Skip to content

Commit 8bfc6ad

Browse files
author
Eric Eaton
committed
Merge ZoneTooltip functions
1 parent ff4b18f commit 8bfc6ad

File tree

9 files changed

+104
-110
lines changed

9 files changed

+104
-110
lines changed

profiler/src/profiler/TracyView.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ class View
344344
void ShowZoneInfo( const ZoneEvent& ev );
345345
void ShowZoneInfo( const ZoneEventC ev, uint64_t thread );
346346

347-
void ZoneTooltip( const ZoneEvent& ev );
348-
void ZoneTooltipGPU( const ZoneEventC ev );
347+
void ZoneTooltip( const ZoneEventC ev );
349348
void CallstackTooltip( uint32_t idx );
350349
void CallstackTooltipContents( uint32_t idx );
351350
void CrashTooltip();
@@ -359,6 +358,7 @@ class View
359358
const ThreadData* GetZoneThreadData( const ZoneEvent& zone ) const;
360359
uint64_t GetZoneThread( const ZoneEvent& zone ) const;
361360
uint64_t GetZoneThreadGPU( const EventAdapter<true>& zone ) const;
361+
uint64_t GetZoneThread( const ZoneEventC evC ) const;
362362
bool FindMatchingZone( int prev0, int prev1, int flags );
363363
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
364364
uint64_t GetFrameNumber( const FrameData& fd, int i ) const;

profiler/src/profiler/TracyView_FindZone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void View::DrawZoneList( int id, const Vector<short_ptr<ZoneEvent>>& zones )
230230
{
231231
ZoomToZone( *ev );
232232
}
233-
ZoneTooltip( *ev );
233+
ZoneTooltip( { ev, nullptr } );
234234
m_zoneHover2 = ev;
235235
}
236236

profiler/src/profiler/TracyView_GpuTimeline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx,
203203
}
204204
else
205205
{
206-
ZoneTooltipGPU( { &ev.event, ctx } );
206+
ZoneTooltip( { &ev.event, ctx } );
207207

208208
if( IsMouseClicked( 2 ) && rend - start > 0 )
209209
{
@@ -288,7 +288,7 @@ int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx,
288288

289289
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y + 1 ) ) )
290290
{
291-
ZoneTooltipGPU( { &ev.event, ctx } );
291+
ZoneTooltip( { &ev.event, ctx } );
292292

293293
if( !m_zoomAnim.active && IsMouseClicked( 2 ) )
294294
{

profiler/src/profiler/TracyView_Memory.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ void View::DrawMemoryAllocWindow()
618618
{
619619
ZoomToZone( *zoneAlloc );
620620
}
621-
ZoneTooltip( *zoneAlloc );
621+
ZoneTooltip( { zoneAlloc, nullptr } );
622622
}
623623
}
624624

@@ -643,7 +643,7 @@ void View::DrawMemoryAllocWindow()
643643
{
644644
ZoomToZone( *zoneFree );
645645
}
646-
ZoneTooltip( *zoneFree );
646+
ZoneTooltip( { zoneFree, nullptr } );
647647
}
648648
if( zoneAlloc == zoneFree )
649649
{
@@ -833,7 +833,7 @@ void View::ListMemData( std::vector<const MemEvent*>& vec, const std::function<v
833833
{
834834
ZoomToZone( *zone );
835835
}
836-
ZoneTooltip( *zone );
836+
ZoneTooltip( { zone, nullptr } );
837837
}
838838
}
839839
ImGui::TableNextColumn();
@@ -877,7 +877,7 @@ void View::ListMemData( std::vector<const MemEvent*>& vec, const std::function<v
877877
{
878878
ZoomToZone( *zoneFree );
879879
}
880-
ZoneTooltip( *zoneFree );
880+
ZoneTooltip( { zoneFree, nullptr } );
881881
}
882882
}
883883
}

profiler/src/profiler/TracyView_Utility.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ uint64_t View::GetZoneThreadGPU( const EventAdapter<true>& zone ) const
491491
}
492492
}
493493

494+
uint64_t View::GetZoneThread( const ZoneEventC evC ) const
495+
{
496+
return evC.IsGpu() ? GetZoneThreadGPU( m_worker.GetGpuExtra( *evC.event ) ) : GetZoneThread( *evC.event );
497+
}
498+
494499
int64_t View::GetZoneChildTime( const ZoneEvent& zone, bool gpu )
495500
{
496501
int64_t time = 0;

profiler/src/profiler/TracyView_ZoneInfo.cpp

Lines changed: 79 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ void View::DrawZoneInfoWindow()
10491049
{
10501050
ZoomToZone( *v );
10511051
}
1052-
ZoneTooltip( *v );
1052+
ZoneTooltip( { v, nullptr } );
10531053
}
10541054
} );
10551055

@@ -1281,7 +1281,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime )
12811281
{
12821282
ZoomToZone( cev );
12831283
}
1284-
ZoneTooltip( cev );
1284+
ZoneTooltip( { &cev, nullptr } );
12851285
}
12861286
ImGui::PopID();
12871287
}
@@ -1350,7 +1350,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime )
13501350
{
13511351
ZoomToZone( cev );
13521352
}
1353-
ZoneTooltip( cev );
1353+
ZoneTooltip( { &cev, nullptr } );
13541354
}
13551355
ImGui::PopID();
13561356
ImGui::Unindent();
@@ -1416,7 +1416,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime )
14161416
{
14171417
ZoomToZone( cev );
14181418
}
1419-
ZoneTooltip( cev );
1419+
ZoneTooltip( { &cev, nullptr } );
14201420
}
14211421
ImGui::PopID();
14221422
ImGui::NextColumn();
@@ -1624,7 +1624,7 @@ void View::DrawGpuInfoWindow()
16241624
{
16251625
ZoomToZoneGPU( { v, ctx } );
16261626
}
1627-
ZoneTooltipGPU( { v, ctx } );
1627+
ZoneTooltip( { v, ctx } );
16281628
}
16291629
} );
16301630

@@ -1738,7 +1738,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime, const GpuCtxDa
17381738
{
17391739
ZoomToZoneGPU( { &cev, ctx } );
17401740
}
1741-
ZoneTooltipGPU( { &cev, ctx } );
1741+
ZoneTooltip( { &cev, ctx } );
17421742
}
17431743
ImGui::PopID();
17441744
}
@@ -1801,7 +1801,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime, const GpuCtxDa
18011801
{
18021802
ZoomToZoneGPU( { &cev, ctx } );
18031803
}
1804-
ZoneTooltipGPU( { &cev, ctx } );
1804+
ZoneTooltip( { &cev, ctx } );
18051805
}
18061806
ImGui::PopID();
18071807
ImGui::Unindent();
@@ -1857,7 +1857,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime, const GpuCtxDa
18571857
{
18581858
ZoomToZoneGPU( { &cev, ctx } );
18591859
}
1860-
ZoneTooltipGPU( { &cev, ctx } );
1860+
ZoneTooltip( { &cev, ctx } );
18611861
}
18621862
ImGui::PopID();
18631863
ImGui::NextColumn();
@@ -1902,16 +1902,16 @@ void View::ShowZoneInfo( const ZoneEventC ev, uint64_t thread )
19021902
}
19031903
}
19041904

1905-
void View::ZoneTooltip( const ZoneEvent& ev )
1905+
void View::ZoneTooltip( const ZoneEventC ev )
19061906
{
19071907
const auto tid = GetZoneThread( ev );
19081908
auto& srcloc = m_worker.GetSourceLocation( ev.SrcLoc() );
19091909
const auto end = m_worker.GetZoneEnd( ev );
19101910
const auto ztime = end - ev.Start();
1911-
const auto selftime = GetZoneSelfTime( ev );
1911+
const auto selftime = GetZoneSelfTime( *ev.event, ev.IsGpu() );
19121912

19131913
ImGui::BeginTooltip();
1914-
if( m_worker.HasZoneExtra( ev ) && m_worker.GetZoneExtra( ev ).name.Active() )
1914+
if( m_worker.HasZoneExtra( *ev.event ) && m_worker.GetZoneExtra( ev ).name.Active() )
19151915
{
19161916
ImGui::TextUnformatted( m_worker.GetString( m_worker.GetZoneExtra( ev ).name ) );
19171917
}
@@ -1937,124 +1937,104 @@ void View::ZoneTooltip( const ZoneEvent& ev )
19371937
ImGui::Separator();
19381938
TextFocused( "Execution time:", TimeToString( ztime ) );
19391939
#ifndef TRACY_NO_STATISTICS
1940-
if( m_worker.AreSourceLocationZonesReady() )
1941-
{
1942-
auto& zoneData = m_worker.GetZonesForSourceLocation( ev.SrcLoc() );
1943-
if( zoneData.total > 0 )
1940+
if( ev.IsGpu() ) {
1941+
if( m_worker.AreGpuSourceLocationZonesReady() )
19441942
{
1945-
ImGui::SameLine();
1946-
ImGui::TextDisabled( "(%.2f%% of mean time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 );
1943+
auto& zoneData = m_worker.GetGpuZonesForSourceLocation( ev.SrcLoc() );
1944+
if( zoneData.total > 0 )
1945+
{
1946+
ImGui::SameLine();
1947+
ImGui::TextDisabled( "(%.2f%% of mean time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 );
1948+
}
19471949
}
1948-
}
1949-
#endif
1950-
TextFocused( "Self time:", TimeToString( selftime ) );
1951-
if( ztime != 0 )
1952-
{
1953-
char buf[64];
1954-
PrintStringPercent( buf, 100.f * selftime / ztime );
1955-
ImGui::SameLine();
1956-
TextDisabledUnformatted( buf );
1957-
}
1958-
const auto ctx = m_worker.GetContextSwitchData( tid );
1959-
if( ctx )
1960-
{
1961-
int64_t time;
1962-
uint64_t cnt;
1963-
if( GetZoneRunningTime( ctx, ev, time, cnt ) )
1950+
} else {
1951+
if( m_worker.AreSourceLocationZonesReady() )
19641952
{
1965-
TextFocused( "Running state time:", TimeToString( time ) );
1966-
if( ztime != 0 )
1953+
auto& zoneData = m_worker.GetZonesForSourceLocation( ev.SrcLoc() );
1954+
if( zoneData.total > 0 )
19671955
{
1968-
char buf[64];
1969-
PrintStringPercent( buf, 100.f * time / ztime );
19701956
ImGui::SameLine();
1971-
TextDisabledUnformatted( buf );
1957+
ImGui::TextDisabled( "(%.2f%% of mean time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 );
19721958
}
1973-
TextFocused( "Running state regions:", RealToString( cnt ) );
19741959
}
19751960
}
1976-
if( m_worker.HasZoneExtra( ev ) && m_worker.GetZoneExtra( ev ).text.Active() )
1977-
{
1978-
ImGui::NewLine();
1979-
TextColoredUnformatted( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), m_worker.GetString( m_worker.GetZoneExtra( ev ).text ) );
1980-
}
1981-
ImGui::EndTooltip();
1982-
}
1983-
1984-
void View::ZoneTooltipGPU( const ZoneEventC evtC )
1985-
{
1986-
const auto& ev = m_worker.GetGpuExtra(*evtC.event);
1987-
auto ctx = evtC.ctx;
1988-
const auto tid = GetZoneThreadGPU( ev );
1989-
const auto& srcloc = m_worker.GetSourceLocation( ev.SrcLoc() );
1990-
const auto end = m_worker.GetZoneEndGPU( ev );
1991-
const auto ztime = end - ev.GpuStart();
1992-
const auto selftime = GetZoneSelfTime( ev, true );
1993-
1994-
ImGui::BeginTooltip();
1995-
ImGui::TextUnformatted( m_worker.GetString( srcloc.name ) );
1996-
ImGui::TextUnformatted( m_worker.GetString( srcloc.function ) );
1997-
ImGui::Separator();
1998-
SmallColorBox( GetSrcLocColor( srcloc, 0 ) );
1999-
ImGui::SameLine();
2000-
ImGui::TextUnformatted( LocationToString( m_worker.GetString( srcloc.file ), srcloc.line ) );
2001-
SmallColorBox( GetThreadColor( tid, 0 ) );
2002-
ImGui::SameLine();
2003-
TextFocused( "Thread:", m_worker.GetThreadName( tid ) );
2004-
ImGui::SameLine();
2005-
ImGui::TextDisabled( "(%s)", RealToString( tid ) );
2006-
if( m_worker.IsThreadFiber( tid ) )
2007-
{
2008-
ImGui::SameLine();
2009-
TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" );
2010-
}
2011-
ImGui::Separator();
2012-
TextFocused( "GPU execution time:", TimeToString( ztime ) );
2013-
TextFocused( "GPU self time:", TimeToString( selftime ) );
1961+
#endif
1962+
TextFocused( "Self time:", TimeToString( selftime ) );
20141963
if( ztime != 0 )
20151964
{
20161965
char buf[64];
20171966
PrintStringPercent( buf, 100.f * selftime / ztime );
20181967
ImGui::SameLine();
20191968
TextDisabledUnformatted( buf );
20201969
}
2021-
TextFocused( "CPU command setup time:", TimeToString( ev.CpuEnd() - ev.CpuStart() ) );
2022-
if( !ctx )
1970+
if( ev.IsGpu() )
20231971
{
2024-
TextFocused( "Delay to execution:", TimeToString( ev.GpuStart() - ev.CpuStart() ) );
2025-
}
2026-
else
2027-
{
2028-
const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
2029-
assert( td != ctx->threadData.end() );
2030-
int64_t begin;
2031-
if( td->second.timeline.is_magic() )
1972+
auto ctx = ev.ctx;
1973+
const auto& ex = m_worker.GetGpuExtra(*ev.event);
1974+
TextFocused( "CPU command setup time:", TimeToString( ex.CpuEnd() - ex.CpuStart() ) );
1975+
if( !ctx )
20321976
{
2033-
begin = ((Vector<ZoneEvent>*)&td->second.timeline)->front().Start();
1977+
TextFocused( "Delay to execution:", TimeToString( ex.GpuStart() - ex.CpuStart() ) );
20341978
}
20351979
else
20361980
{
2037-
begin = td->second.timeline.front()->Start();
1981+
const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ex.Thread() ) );
1982+
assert( td != ctx->threadData.end() );
1983+
int64_t begin;
1984+
if( td->second.timeline.is_magic() )
1985+
{
1986+
begin = ( (Vector<ZoneEvent>*)&td->second.timeline )->front().Start();
1987+
}
1988+
else
1989+
{
1990+
begin = td->second.timeline.front()->Start();
1991+
}
1992+
const auto drift = GpuDrift( ctx );
1993+
TextFocused( "Delay to execution:", TimeToString( AdjustGpuTime( ex.GpuStart(), begin, drift ) - ex.CpuStart() ) );
20381994
}
2039-
const auto drift = GpuDrift( ctx );
2040-
TextFocused( "Delay to execution:", TimeToString( AdjustGpuTime( ev.GpuStart(), begin, drift ) - ev.CpuStart() ) );
2041-
}
20421995

2043-
if( ctx->notes.contains( ev.query_id ) )
2044-
{
2045-
for( auto& p : ctx->notes.at( ev.query_id ) )
1996+
if( ctx->notes.contains( ex.query_id ) )
20461997
{
2047-
if( ctx->noteNames.count( p.first ) )
1998+
for( auto& p : ctx->notes.at( ex.query_id ) )
20481999
{
2049-
TextFocused( m_worker.GetString( ctx->noteNames.at( p.first ) ), RealToString( p.second ) );
2000+
if( ctx->noteNames.count( p.first ) )
2001+
{
2002+
TextFocused( m_worker.GetString( ctx->noteNames.at( p.first ) ), RealToString( p.second ) );
2003+
}
2004+
else
2005+
{
2006+
TextFocused( RealToString( p.first ), RealToString( p.second ) );
2007+
}
20502008
}
2051-
else
2009+
}
2010+
}
2011+
else
2012+
{
2013+
const auto ctx = m_worker.GetContextSwitchData( tid );
2014+
if( ctx )
2015+
{
2016+
int64_t time;
2017+
uint64_t cnt;
2018+
if( GetZoneRunningTime( ctx, *ev.event, time, cnt ) )
20522019
{
2053-
TextFocused( RealToString( p.first ), RealToString( p.second ) );
2020+
TextFocused( "Running state time:", TimeToString( time ) );
2021+
if( ztime != 0 )
2022+
{
2023+
char buf[64];
2024+
PrintStringPercent( buf, 100.f * time / ztime );
2025+
ImGui::SameLine();
2026+
TextDisabledUnformatted( buf );
2027+
}
2028+
TextFocused( "Running state regions:", RealToString( cnt ) );
20542029
}
20552030
}
20562031
}
20572032

2033+
if( m_worker.HasZoneExtra( *ev.event ) && m_worker.GetZoneExtra( ev ).text.Active() )
2034+
{
2035+
ImGui::NewLine();
2036+
TextColoredUnformatted( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), m_worker.GetString( m_worker.GetZoneExtra( ev ).text ) );
2037+
}
20582038
ImGui::EndTooltip();
20592039
}
20602040

profiler/src/profiler/TracyView_ZoneTimeline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineD
310310
}
311311
else
312312
{
313-
ZoneTooltip( ev );
313+
ZoneTooltip( { &ev, nullptr} );
314314

315315
if( IsMouseClicked( 2 ) && rend - ev.Start() > 0 )
316316
{
@@ -384,7 +384,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineD
384384

385385
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y + 1 ) ) )
386386
{
387-
ZoneTooltip( ev );
387+
ZoneTooltip( { &ev, nullptr} );
388388
if( IsMouseClickReleased( 1 ) ) m_setRangePopup = RangeSlim { ev.Start(), m_worker.GetZoneEnd( ev ), true };
389389

390390
if( !m_zoomAnim.active && IsMouseClicked( 2 ) )

0 commit comments

Comments
 (0)