Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-08-13 02:31:04 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-08-13 14:10:37 +0300
commit7f856a1b169853032aa45e481810275b22fb0498 (patch)
tree3c9bbd55a0d638b69d21f708a1e6b8b7a6598730 /server/TracyView.cpp
parent9417ad994de87e134ab5a558997e23d67cb73d0f (diff)
Very bad context switch visualization.
Diffstat (limited to 'server/TracyView.cpp')
-rw-r--r--server/TracyView.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index 3b083583..0a9ccbb8 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -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();