Search for zone present in given thread at given time.

This commit is contained in:
Bartosz Taudul 2018-04-01 21:47:08 +02:00
parent 20824a200c
commit 912cfdbc5e
2 changed files with 29 additions and 0 deletions

View File

@ -4048,6 +4048,34 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
return 0;
}
const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
{
// TODO add thread rev-map
ThreadData* td = nullptr;
for( const auto& t : m_worker.GetThreadData() )
{
if( t->id == thread )
{
td = t;
break;
}
}
if( !td ) return nullptr;
const Vector<ZoneEvent*>* timeline = &td->timeline;
if( timeline->empty() ) return nullptr;
ZoneEvent* ret = nullptr;
for(;;)
{
auto it = std::upper_bound( timeline->begin(), timeline->end(), time, [] ( const auto& l, const auto& r ) { return l < r->start; } );
if( it != timeline->begin() ) --it;
if( (*it)->start > time || ( (*it)->end >= 0 && (*it)->end < time ) ) return ret;
ret = *it;
if( (*it)->child.empty() ) return ret;
timeline = &(*it)->child;
}
}
#ifndef TRACY_NO_STATISTICS
void View::FindZones()
{

View File

@ -99,6 +99,7 @@ private:
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
uint64_t GetZoneThread( const ZoneEvent& zone ) const;
uint64_t GetZoneThread( const GpuEvent& zone ) const;
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
#ifndef TRACY_NO_STATISTICS
void FindZones();