1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Adapt GPU zone utility functions to magic vectors.

This commit is contained in:
Bartosz Taudul 2019-11-10 01:56:28 +01:00
parent 9b52152e77
commit d32e3cb867

View File

@ -13378,7 +13378,15 @@ void View::ZoneTooltip( const GpuEvent& ev )
{ {
const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) ); const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
assert( td != ctx->threadData.end() ); assert( td != ctx->threadData.end() );
const auto begin = td->second.timeline.front()->GpuStart(); int64_t begin;
if( td->second.timeline.is_magic() )
{
begin = ((Vector<GpuEvent>*)&td->second.timeline)->front().GpuStart();
}
else
{
begin = td->second.timeline.front()->GpuStart();
}
const auto drift = GpuDrift( ctx ); const auto drift = GpuDrift( ctx );
TextFocused( "Delay to execution:", TimeToString( AdjustGpuTime( ev.GpuStart(), begin, drift ) - ev.CpuStart() ) ); TextFocused( "Delay to execution:", TimeToString( AdjustGpuTime( ev.GpuStart(), begin, drift ) - ev.CpuStart() ) );
} }
@ -13559,6 +13567,19 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{
if( timeline->is_magic() )
{
auto vec = (Vector<GpuEvent>*)timeline;
auto it = std::upper_bound( vec->begin(), vec->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r.GpuStart(); } );
if( it != vec->begin() ) --it;
if( zone.GpuEnd() >= 0 && it->GpuStart() > zone.GpuEnd() ) break;
if( it == &zone ) return parent;
if( it->Child() < 0 ) break;
parent = it;
timeline = &m_worker.GetGpuChildren( parent->Child() );
}
else
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
@ -13570,6 +13591,7 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
} }
} }
} }
}
return nullptr; return nullptr;
} }
@ -13621,6 +13643,18 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
const Vector<short_ptr<GpuEvent>>* timeline = &ctx->threadData.begin()->second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &ctx->threadData.begin()->second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{
if( timeline->is_magic() )
{
auto vec = (Vector<GpuEvent>*)timeline;
auto it = std::upper_bound( vec->begin(), vec->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r.GpuStart(); } );
if( it != vec->begin() ) --it;
if( zone.GpuEnd() >= 0 && it->GpuStart() > zone.GpuEnd() ) break;
if( it == &zone ) return ctx->thread;
if( it->Child() < 0 ) break;
timeline = &m_worker.GetGpuChildren( it->Child() );
}
else
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
@ -13630,6 +13664,7 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
timeline = &m_worker.GetGpuChildren( (*it)->Child() ); timeline = &m_worker.GetGpuChildren( (*it)->Child() );
} }
} }
}
return 0; return 0;
} }
else else
@ -13647,6 +13682,18 @@ const GpuCtxData* View::GetZoneCtx( const GpuEvent& zone ) const
const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{
if( timeline->is_magic() )
{
auto vec = (Vector<GpuEvent>*)timeline;
auto it = std::upper_bound( vec->begin(), vec->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r.GpuStart(); } );
if( it != vec->begin() ) --it;
if( zone.GpuEnd() >= 0 && it->GpuStart() > zone.GpuEnd() ) break;
if( it == &zone ) return ctx;
if( it->Child() < 0 ) break;
timeline = &m_worker.GetGpuChildren( it->Child() );
}
else
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.GpuStart(), [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->GpuStart(); } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
@ -13657,6 +13704,7 @@ const GpuCtxData* View::GetZoneCtx( const GpuEvent& zone ) const
} }
} }
} }
}
return nullptr; return nullptr;
} }
@ -13829,12 +13877,25 @@ int64_t View::GetZoneChildTime( const GpuEvent& zone )
int64_t time = 0; int64_t time = 0;
if( zone.Child() >= 0 ) if( zone.Child() >= 0 )
{ {
for( auto& v : m_worker.GetGpuChildren( zone.Child() ) ) auto& children = m_worker.GetGpuChildren( zone.Child() );
if( children.is_magic() )
{
auto& vec = *(Vector<GpuEvent>*)&children;
for( auto& v : vec )
{
const auto childSpan = std::max( int64_t( 0 ), v.GpuEnd() - v.GpuStart() );
time += childSpan;
}
}
else
{
for( auto& v : children )
{ {
const auto childSpan = std::max( int64_t( 0 ), v->GpuEnd() - v->GpuStart() ); const auto childSpan = std::max( int64_t( 0 ), v->GpuEnd() - v->GpuStart() );
time += childSpan; time += childSpan;
} }
} }
}
return time; return time;
} }