From d08c10c5b657158a950070cfcc0264ecd9e05833 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 18 Mar 2018 16:38:42 +0100 Subject: [PATCH] Add functionality for getting zone thread. --- server/TracyView.cpp | 19 +++++++++++++++++++ server/TracyView.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 82cdacdf..894ad5db 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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* 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() { diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 40d3ab12..b4e6450c 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -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();