mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 15:34:36 +00:00
Decouple check for existence from building draw lists.
We need to know if samples, context switches and messages are present to be able to correctly calculate thread height. However, if the thread is not visible, it is not necessary to provide a list of items to draw.
This commit is contained in:
parent
96d60ce626
commit
e3ec455aba
@ -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;
|
||||
|
||||
|
@ -54,6 +54,9 @@ private:
|
||||
std::vector<TimelineDraw> m_draw;
|
||||
std::vector<MessagesDraw> m_msgDraw;
|
||||
int m_depth;
|
||||
bool m_hasCtxSwitch;
|
||||
bool m_hasSamples;
|
||||
bool m_hasMessages;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& samplesDraw, int& offset, int depth );
|
||||
void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& samplesDraw, int& offset, int depth, bool hasCtxSwitches, bool hasSamples );
|
||||
void DrawThreadMessagesList( const TimelineContext& ctx, const std::vector<MessagesDraw>& 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 );
|
||||
|
@ -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<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& samplesDraw, int& offset, int depth )
|
||||
void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& 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 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user