mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 20:33:52 +00:00
Preprocess samples.
This commit is contained in:
parent
2456ae36bf
commit
da6ea47541
@ -59,6 +59,13 @@ struct ContextSwitchDraw
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SamplesDraw
|
||||||
|
{
|
||||||
|
bool folded;
|
||||||
|
uint32_t idx;
|
||||||
|
uint32_t num;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,12 +275,14 @@ void TimelineItemThread::DrawOverlay( const ImVec2& ul, const ImVec2& dr )
|
|||||||
|
|
||||||
void TimelineItemThread::DrawFinished()
|
void TimelineItemThread::DrawFinished()
|
||||||
{
|
{
|
||||||
|
m_samplesDraw.clear();
|
||||||
m_ctxDraw.clear();
|
m_ctxDraw.clear();
|
||||||
m_draw.clear();
|
m_draw.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td )
|
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td )
|
||||||
{
|
{
|
||||||
|
assert( m_samplesDraw.empty() );
|
||||||
assert( m_ctxDraw.empty() );
|
assert( m_ctxDraw.empty() );
|
||||||
assert( m_draw.empty() );
|
assert( m_draw.empty() );
|
||||||
|
|
||||||
@ -297,7 +299,9 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if( m_view.GetViewData().drawContextSwitches )
|
const auto& vd = m_view.GetViewData();
|
||||||
|
|
||||||
|
if( vd.drawContextSwitches )
|
||||||
{
|
{
|
||||||
auto ctxSwitch = m_worker.GetContextSwitchData( m_thread->id );
|
auto ctxSwitch = m_worker.GetContextSwitchData( m_thread->id );
|
||||||
if( ctxSwitch )
|
if( ctxSwitch )
|
||||||
@ -307,6 +311,13 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( vd.drawSamples && !m_thread->samples.empty() )
|
||||||
|
{
|
||||||
|
td.Queue( [this, &ctx] {
|
||||||
|
PreprocessSamples( ctx, m_thread->samples );
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
@ -538,4 +549,53 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Vector<SampleData>& vec )
|
||||||
|
{
|
||||||
|
const auto vStart = ctx.vStart;
|
||||||
|
const auto vEnd = ctx.vEnd;
|
||||||
|
const auto nspx = ctx.nspx;
|
||||||
|
const auto pxns = ctx.pxns;
|
||||||
|
|
||||||
|
const auto MinVis = 6 * GetScale();
|
||||||
|
auto it = std::lower_bound( vec.begin(), vec.end(), vStart - 2 * MinVis * nspx, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
|
if( it == vec.end() ) return;
|
||||||
|
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;
|
||||||
|
|
||||||
|
while( it < itend )
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
const auto px0 = ( it->time.Val() - vStart ) * pxns;
|
||||||
|
double px1;
|
||||||
|
auto next = it+1;
|
||||||
|
uint32_t num = 0;
|
||||||
|
if( next != itend )
|
||||||
|
{
|
||||||
|
auto px1ns = next->time.Val() - vStart;
|
||||||
|
px1 = px1ns * pxns;
|
||||||
|
if( px1 - px0 < MinVis )
|
||||||
|
{
|
||||||
|
const auto MinVisNs = MinVis * nspx;
|
||||||
|
visible = false;
|
||||||
|
auto nextTime = px0 + MinVisNs;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
const auto prev = next;
|
||||||
|
next = std::lower_bound( next, itend, nextTime, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
|
if( prev == next ) ++next;
|
||||||
|
if( next == itend ) break;
|
||||||
|
const auto nsnext = next->time.Val() - vStart;
|
||||||
|
if( nsnext - px1ns >= MinVisNs ) break;
|
||||||
|
px1ns = nsnext;
|
||||||
|
nextTime = next->time.Val() + nspx;
|
||||||
|
}
|
||||||
|
num = next - it;
|
||||||
|
px1 = px1ns * pxns;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_samplesDraw.emplace_back( SamplesDraw { !visible, uint32_t( it - vec.begin() ), num } );
|
||||||
|
it = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,12 @@ private:
|
|||||||
int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth );
|
int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth );
|
||||||
|
|
||||||
void PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch );
|
void PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch );
|
||||||
|
void PreprocessSamples( const TimelineContext& ctx, const Vector<SampleData>& vec );
|
||||||
|
|
||||||
const ThreadData* m_thread;
|
const ThreadData* m_thread;
|
||||||
bool m_ghost;
|
bool m_ghost;
|
||||||
|
|
||||||
|
std::vector<SamplesDraw> m_samplesDraw;
|
||||||
std::vector<ContextSwitchDraw> m_ctxDraw;
|
std::vector<ContextSwitchDraw> m_ctxDraw;
|
||||||
std::vector<TimelineDraw> m_draw;
|
std::vector<TimelineDraw> m_draw;
|
||||||
int m_depth;
|
int m_depth;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user