Retrieval of GPU context from GPU zone.

This commit is contained in:
Bartosz Taudul 2018-06-28 01:07:21 +02:00
parent 4a467b6d03
commit 0b9559c05b
2 changed files with 20 additions and 0 deletions

View File

@ -5941,6 +5941,25 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
}
}
const GpuCtxData* View::GetZoneCtx( const GpuEvent& zone ) const
{
for( const auto& ctx : m_worker.GetGpuData() )
{
const Vector<GpuEvent*>* timeline = &ctx->timeline;
if( timeline->empty() ) continue;
for(;;)
{
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } );
if( it != timeline->begin() ) --it;
if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break;
if( *it == &zone ) return ctx;
if( (*it)->child.empty() ) break;
timeline = &(*it)->child;
}
}
return nullptr;
}
const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
{
// TODO add thread rev-map

View File

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