Implement getting zone parent when thread id is known.

This commit is contained in:
Bartosz Taudul 2019-10-31 14:59:52 +01:00
parent 456deefdbc
commit c0df3dd965
2 changed files with 20 additions and 0 deletions

View File

@ -13237,6 +13237,25 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
return nullptr;
}
const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) const
{
const auto thread = m_worker.GetThreadData( tid );
const ZoneEvent* parent = nullptr;
const Vector<ZoneEvent*>* timeline = &thread->timeline;
if( timeline->empty() ) return nullptr;
for(;;)
{
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
if( it != timeline->begin() ) --it;
if( zone.End() >= 0 && (*it)->Start() > zone.End() ) break;
if( *it == &zone ) return parent;
if( (*it)->Child() < 0 ) break;
parent = *it;
timeline = &m_worker.GetZoneChildren( parent->Child() );
}
return nullptr;
}
const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
{
for( const auto& ctx : m_worker.GetGpuData() )

View File

@ -191,6 +191,7 @@ private:
int GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const;
const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;
const ZoneEvent* GetZoneParent( const ZoneEvent& zone, uint64_t tid ) const;
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
const ThreadData* GetZoneThreadData( const ZoneEvent& zone ) const;
uint64_t GetZoneThread( const ZoneEvent& zone ) const;