Display context switch wait call stack.

This commit is contained in:
Bartosz Taudul 2021-11-13 01:21:47 +01:00
parent ce8e42f00b
commit 1200409a44
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 19 additions and 4 deletions

View File

@ -3287,7 +3287,7 @@ void View::DrawZones()
auto ctxSwitch = m_worker.GetContextSwitchData( v->id );
if( ctxSwitch )
{
DrawContextSwitches( ctxSwitch, hover, pxns, int64_t( nspx ), wpos, ctxOffset, offset, v->isFiber );
DrawContextSwitches( ctxSwitch, v->samples, hover, pxns, int64_t( nspx ), wpos, ctxOffset, offset, v->isFiber );
}
}
@ -3875,7 +3875,7 @@ static const char* DecodeContextSwitchState( uint8_t state )
}
}
void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber )
void View::DrawContextSwitches( const ContextSwitch* ctx, const Vector<SampleData>& sampleData, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber )
{
auto& vec = ctx->v;
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, m_vd.zvStart ), [] ( const auto& l, const auto& r ) { return (uint64_t)l.End() < (uint64_t)r; } );
@ -3917,6 +3917,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
if( hover )
{
bool tooltip = false;
if( ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( pxw, offset + ty ) ) )
{
ImGui::BeginTooltip();
@ -3949,7 +3950,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
ImGui::SameLine();
TextDisabledUnformatted( DecodeContextSwitchState( pit->State() ) );
}
ImGui::EndTooltip();
tooltip = true;
if( IsMouseClicked( 2 ) )
{
@ -3967,6 +3968,20 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
{
ZoomToRange( pit->End(), ev.WakeupVal() );
}
tooltip = true;
}
if( tooltip )
{
if( !sampleData.empty() )
{
auto sdit = std::lower_bound( sampleData.begin(), sampleData.end(), ev.Start(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
if( sdit != sampleData.end() && sdit->time.Val() == ev.Start() )
{
ImGui::Separator();
TextDisabledUnformatted( "Wait stack:" );
CallstackTooltipContents( sdit->callstack.Val() );
}
}
ImGui::EndTooltip();
}
}

View File

@ -174,7 +174,7 @@ private:
void DrawZoneFramesHeader();
void DrawZoneFrames( const FrameData& frames );
void DrawZones();
void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber );
void DrawContextSwitches( const ContextSwitch* ctx, const Vector<SampleData>& sampleData, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber );
void DrawSamples( const Vector<SampleData>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset );
#ifndef TRACY_NO_STATISTICS
int DispatchGhostLevel( const Vector<GhostZone>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );