Add functionality for getting zone thread.

This commit is contained in:
Bartosz Taudul 2018-03-18 16:38:42 +01:00
parent 616269e849
commit d08c10c5b6
2 changed files with 20 additions and 0 deletions

View File

@ -3464,6 +3464,25 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
return nullptr;
}
uint64_t View::GetZoneThread( const ZoneEvent& zone ) const
{
for( const auto& thread : m_worker.GetThreadData() )
{
const Vector<ZoneEvent*>* timeline = &thread->timeline;
if( timeline->empty() ) continue;
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 != -1 && (*it)->start > zone.end ) break;
if( *it == &zone ) return thread->id;
if( (*it)->child.empty() ) break;
timeline = &(*it)->child;
}
}
return 0;
}
#ifndef TRACY_NO_STATISTICS
void View::FindZones()
{

View File

@ -96,6 +96,7 @@ private:
void ZoneTooltip( const GpuEvent& ev );
const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
uint64_t GetZoneThread( const ZoneEvent& zone ) const;
#ifndef TRACY_NO_STATISTICS
void FindZones();