mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Rewrite CPU zones folding.
This commit is contained in:
parent
527b5f3311
commit
fb032b4f9b
@ -23,7 +23,7 @@ struct TimelineDraw
|
|||||||
uint16_t depth;
|
uint16_t depth;
|
||||||
short_ptr<void*> ev;
|
short_ptr<void*> ev;
|
||||||
Int48 rend;
|
Int48 rend;
|
||||||
int num;
|
uint32_t num;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,10 +394,11 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V
|
|||||||
const auto vStart = ctx.vStart;
|
const auto vStart = ctx.vStart;
|
||||||
const auto vEnd = ctx.vEnd;
|
const auto vEnd = ctx.vEnd;
|
||||||
const auto nspx = ctx.nspx;
|
const auto nspx = ctx.nspx;
|
||||||
const auto pxns = ctx.pxns;
|
|
||||||
|
const auto MinVisNs = int64_t( round( MinVisSize * nspx ) );
|
||||||
|
|
||||||
// cast to uint64_t, so that unended zones (end = -1) are still drawn
|
// cast to uint64_t, so that unended zones (end = -1) are still drawn
|
||||||
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, vStart - std::max<int64_t>( delay, 2 * MinVisSize * nspx ) ), [] ( const auto& l, const auto& r ) { Adapter a; return (uint64_t)a(l).End() < (uint64_t)r; } );
|
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, vStart - std::max<int64_t>( delay, 2 * MinVisNs ) ), [] ( const auto& l, const auto& r ) { Adapter a; return (uint64_t)a(l).End() < (uint64_t)r; } );
|
||||||
if( it == vec.end() ) return depth;
|
if( it == vec.end() ) return depth;
|
||||||
|
|
||||||
const auto zitend = std::lower_bound( it, vec.end(), vEnd + resolution, [] ( const auto& l, const auto& r ) { Adapter a; return a(l).Start() < r; } );
|
const auto zitend = std::lower_bound( it, vec.end(), vEnd + resolution, [] ( const auto& l, const auto& r ) { Adapter a; return a(l).Start() < r; } );
|
||||||
@ -406,35 +407,27 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V
|
|||||||
if( !a(*it).IsEndValid() && m_worker.GetZoneEnd( a(*it) ) < vStart ) return depth;
|
if( !a(*it).IsEndValid() && m_worker.GetZoneEnd( a(*it) ) < vStart ) return depth;
|
||||||
if( m_worker.GetZoneEnd( a(*(zitend-1)) ) < vStart ) return depth;
|
if( m_worker.GetZoneEnd( a(*(zitend-1)) ) < vStart ) return depth;
|
||||||
|
|
||||||
const auto MinVisNs = MinVisSize * nspx;
|
|
||||||
int maxdepth = depth + 1;
|
int maxdepth = depth + 1;
|
||||||
|
|
||||||
while( it < zitend )
|
while( it < zitend )
|
||||||
{
|
{
|
||||||
auto& ev = a(*it);
|
auto& ev = a(*it);
|
||||||
const auto end = m_worker.GetZoneEnd( ev );
|
const auto end = m_worker.GetZoneEnd( ev );
|
||||||
const auto zsz = std::max( ( end - ev.Start() ) * pxns, pxns * 0.5 );
|
const auto zsz = end - ev.Start();
|
||||||
if( zsz < MinVisSize )
|
if( zsz < MinVisNs )
|
||||||
{
|
{
|
||||||
int num = 0;
|
|
||||||
auto px1ns = end - vStart;
|
|
||||||
auto rend = end;
|
|
||||||
auto nextTime = end + MinVisNs;
|
auto nextTime = end + MinVisNs;
|
||||||
|
auto next = it + 1;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const auto prevIt = it;
|
next = std::lower_bound( next, zitend, nextTime, [] ( const auto& l, const auto& r ) { Adapter a; return (uint64_t)a(l).End() < (uint64_t)r; } );
|
||||||
it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { Adapter a; return (uint64_t)a(l).End() < (uint64_t)r; } );
|
if( next == zitend ) break;
|
||||||
if( it == prevIt ) ++it;
|
const auto nt = m_worker.GetZoneEnd( a(*next) );
|
||||||
num += std::distance( prevIt, it );
|
if( nt - nextTime >= MinVisNs ) break;
|
||||||
if( it == zitend ) break;
|
nextTime = nt + MinVisNs;
|
||||||
const auto nend = m_worker.GetZoneEnd( a(*it) );
|
|
||||||
const auto nsnext = nend - vStart;
|
|
||||||
if( nsnext - px1ns >= MinVisNs * 2 ) break;
|
|
||||||
px1ns = nsnext;
|
|
||||||
rend = nend;
|
|
||||||
nextTime = nend + nspx;
|
|
||||||
}
|
}
|
||||||
m_draw.emplace_back( TimelineDraw { TimelineDrawType::Folded, uint16_t( depth ), (void**)&ev, rend, num } );
|
m_draw.emplace_back( TimelineDraw { TimelineDrawType::Folded, uint16_t( depth ), (void**)&ev, m_worker.GetZoneEnd( a(*(next-1)) ), uint32_t( next - it ) } );
|
||||||
|
it = next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user