Very bad context switch visualization.

This commit is contained in:
Bartosz Taudul 2019-08-13 01:31:04 +02:00
parent 9417ad994d
commit 7f856a1b16
2 changed files with 32 additions and 0 deletions

View File

@ -1882,6 +1882,13 @@ void View::DrawZones()
offset += ostep;
if( showFull )
{
auto ctxSwitch = m_worker.GetContextSwitchData( v->id );
if( ctxSwitch )
{
DrawContextSwitches( ctxSwitch, pxns, wpos, offset );
offset += ostep;
}
if( m_drawZones )
{
depth = DispatchZoneLevel( v->timeline, hover, pxns, int64_t( nspx ), wpos, offset, 0, yMin, yMax );
@ -2189,6 +2196,30 @@ void View::DrawZones()
}
}
void View::DrawContextSwitches( const ContextSwitch* ctx, double pxns, const ImVec2& wpos, int offset )
{
auto& vec = ctx->v;
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, m_zvStart ), [] ( const auto& l, const auto& r ) { return (uint64_t)l.end < (uint64_t)r; } );
if( it == vec.end() ) return;
const auto citend = std::lower_bound( it, vec.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l.start < r; } );
if( it == citend ) return;
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
const auto ty = ImGui::GetFontSize();
auto draw = ImGui::GetWindowDrawList();
while( it < citend )
{
auto& ev = *it;
const auto end = ev.end >= 0 ? ev.end : m_worker.GetLastTime();
const auto px0 = std::max( ( ev.start - m_zvStart ) * pxns, -10.0 );
const auto px1 = std::min( ( end - m_zvStart ) * pxns, w + 10.0 );
draw->AddLine( wpos + ImVec2( px0, round( offset + ty * 0.5 ) ), wpos + ImVec2( px1, round( offset + ty * 0.5 ) ), 0xFF00FF00 );
++it;
}
}
int View::DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax )
{
const auto ty = ImGui::GetFontSize();

View File

@ -108,6 +108,7 @@ private:
bool DrawZoneFramesHeader();
bool DrawZoneFrames( const FrameData& frames );
void DrawZones();
void DrawContextSwitches( const ContextSwitch* ctx, double pxns, const ImVec2& wpos, int offset );
int DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
int SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );