From 0b9559c05ba2bbff6ad73499853ac21f1dc52f3e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 28 Jun 2018 01:07:21 +0200 Subject: [PATCH] Retrieval of GPU context from GPU zone. --- server/TracyView.cpp | 19 +++++++++++++++++++ server/TracyView.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index d35b6783..1f37c40f 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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* 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 diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 5e0de331..94654988 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -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