Allow calculating zone depth.

This commit is contained in:
Bartosz Taudul 2019-09-08 14:16:12 +02:00
parent cdc4575dba
commit 2714152f84
2 changed files with 19 additions and 0 deletions

View File

@ -12222,6 +12222,24 @@ void View::CrashTooltip()
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
int View::GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const
{
auto td = m_worker.GetThreadData( tid );
assert( td );
auto timeline = &td->timeline;
int depth = 0;
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;
assert( !( zone.end >= 0 && (*it)->Start() > zone.end ) );
if( *it == &zone ) return depth;
assert( (*it)->child >= 0 );
timeline = &m_worker.GetZoneChildren( (*it)->child );
depth++;
}
}
const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
{ {
for( const auto& thread : m_worker.GetThreadData() ) for( const auto& thread : m_worker.GetThreadData() )

View File

@ -178,6 +178,7 @@ private:
void CallstackTooltip( uint32_t idx ); void CallstackTooltip( uint32_t idx );
void CrashTooltip(); void CrashTooltip();
int GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const;
const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const; const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const; const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
const ThreadData* GetZoneThreadData( const ZoneEvent& zone ) const; const ThreadData* GetZoneThreadData( const ZoneEvent& zone ) const;