@@ -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
0 commit comments