diff --git a/server/TracyTimelineItemThread.cpp b/server/TracyTimelineItemThread.cpp index 1dfbab09..d2b213c9 100644 --- a/server/TracyTimelineItemThread.cpp +++ b/server/TracyTimelineItemThread.cpp @@ -259,8 +259,8 @@ void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int of bool TimelineItemThread::DrawContents( const TimelineContext& ctx, int& offset ) { - m_view.DrawThread( ctx, *m_thread, m_draw, m_ctxDraw, m_samplesDraw, offset, m_depth ); - if( m_depth == 0 && m_msgDraw.empty() ) + m_view.DrawThread( ctx, *m_thread, m_draw, m_ctxDraw, m_samplesDraw, offset, m_depth, m_hasCtxSwitch, m_hasSamples ); + if( m_depth == 0 && !m_hasMessages ) { auto& crash = m_worker.GetCrashEvent(); return crash.thread == m_thread->id; @@ -303,6 +303,7 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t const auto& vd = m_view.GetViewData(); + m_hasCtxSwitch = false; if( vd.drawContextSwitches ) { auto ctxSwitch = m_worker.GetContextSwitchData( m_thread->id ); @@ -314,6 +315,7 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t } } + m_hasSamples = false; if( vd.drawSamples && !m_thread->samples.empty() ) { td.Queue( [this, &ctx] { @@ -321,6 +323,7 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t } ); } + m_hasMessages = false; td.Queue( [this, &ctx] { PreprocessMessages( ctx, m_thread->messages, m_thread->id ); } ); @@ -469,6 +472,8 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx, if( it == citend ) return; if( citend != vec.end() ) ++citend; + m_hasCtxSwitch = true; + const auto MinCtxNs = int64_t( round( GetScale() * MinCtxSize * nspx ) ); const auto& sampleData = m_thread->samples; @@ -540,6 +545,8 @@ void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Ve const auto itend = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } ); if( it == itend ) return; + m_hasSamples = true; + while( it < itend ) { auto next = it + 1; @@ -576,6 +583,8 @@ void TimelineItemThread::PreprocessMessages( const TimelineContext& ctx, const V auto end = std::lower_bound( it, vec.end(), vEnd+1, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); if( it == end ) return; + m_hasMessages = true; + const auto hMsg = m_view.GetMessageHighlight(); const auto hThread = hMsg ? m_worker.DecompressThread( hMsg->thread ) : 0; diff --git a/server/TracyTimelineItemThread.hpp b/server/TracyTimelineItemThread.hpp index 0f3391e0..1de231e3 100644 --- a/server/TracyTimelineItemThread.hpp +++ b/server/TracyTimelineItemThread.hpp @@ -54,6 +54,9 @@ private: std::vector m_draw; std::vector m_msgDraw; int m_depth; + bool m_hasCtxSwitch; + bool m_hasSamples; + bool m_hasMessages; }; } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6249763c..dd0e9480 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -127,7 +127,7 @@ public: void HighlightThread( uint64_t thread ); void ZoomToRange( int64_t start, int64_t end, bool pause = true ); bool DrawPlot( const TimelineContext& ctx, PlotData& plot, int& offset ); - void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector& draw, const std::vector& ctxDraw, const std::vector& samplesDraw, int& offset, int depth ); + void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector& draw, const std::vector& ctxDraw, const std::vector& samplesDraw, int& offset, int depth, bool hasCtxSwitches, bool hasSamples ); void DrawThreadMessagesList( const TimelineContext& ctx, const std::vector& drawList, int offset, uint64_t tid ); void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr ); bool DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset ); diff --git a/server/TracyView_ZoneTimeline.cpp b/server/TracyView_ZoneTimeline.cpp index ccf209f3..e898d073 100644 --- a/server/TracyView_ZoneTimeline.cpp +++ b/server/TracyView_ZoneTimeline.cpp @@ -23,7 +23,7 @@ static tracy_force_inline uint32_t MixGhostColor( uint32_t c0, uint32_t c1 ) ( ( ( ( ( c0 & 0x000000FF ) ) + 3 * ( ( c1 & 0x000000FF ) ) ) >> 2 ) ); } -void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector& draw, const std::vector& ctxDraw, const std::vector& samplesDraw, int& offset, int depth ) +void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector& draw, const std::vector& ctxDraw, const std::vector& samplesDraw, int& offset, int depth, bool _hasCtxSwitches, bool _hasSamples ) { const auto& wpos = ctx.wpos; const auto ty = ctx.ty; @@ -39,8 +39,8 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con ImGui::PopFont(); const auto sampleOffset = offset; - const auto hasSamples = m_vd.drawSamples && !samplesDraw.empty(); - const auto hasCtxSwitch = m_vd.drawContextSwitches && !ctxDraw.empty(); + const auto hasSamples = m_vd.drawSamples && _hasSamples; + const auto hasCtxSwitch = m_vd.drawContextSwitches && _hasCtxSwitches; if( hasSamples ) { @@ -67,13 +67,13 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con } offset += ostep * depth; - if( hasCtxSwitch ) + if( hasCtxSwitch && !ctxDraw.empty() ) { auto ctxSwitch = m_worker.GetContextSwitchData( thread.id ); assert( ctxSwitch ); DrawContextSwitchList( ctx, ctxDraw, ctxSwitch->v, ctxOffset, offset, thread.isFiber ); } - if( hasSamples ) + if( hasSamples && !samplesDraw.empty() ) { DrawSampleList( ctx, samplesDraw, thread.samples, sampleOffset ); }