diff --git a/client/Tracy.hpp b/client/Tracy.hpp index 7b6eacc3..b7a4dc55 100755 --- a/client/Tracy.hpp +++ b/client/Tracy.hpp @@ -13,8 +13,8 @@ #include "TracyProfiler.hpp" #include "TracyScoped.hpp" -#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 ); -#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, color ); +#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); +#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); #define FrameMark tracy::Profiler::FrameMark(); diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index b222743c..f467df5a 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -225,6 +225,7 @@ bool Profiler::SendSourceLocation( uint64_t ptr ) item.srcloc.file = (uint64_t)srcloc->file; item.srcloc.function = (uint64_t)srcloc->function; item.srcloc.line = srcloc->line; + item.srcloc.color = srcloc->color; const auto sz = QueueDataSize[item.hdr.idx]; @@ -301,7 +302,7 @@ void Profiler::CalibrateTimer() class FakeZone { public: - FakeZone( const SourceLocation* srcloc, uint32_t color ) {} + FakeZone( const SourceLocation* srcloc ) {} ~FakeZone() {} private: @@ -315,20 +316,20 @@ void Profiler::CalibrateDelay() static_assert( Events * 2 < QueuePrealloc, "Delay calibration loop will allocate memory in queue" ); for( int i=0; i child; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index de922bf0..1b3ae2cf 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -238,7 +238,6 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ) zone->start = ev.time * m_timerMul; zone->srcloc = ev.srcloc; - zone->color = ev.color; std::unique_lock lock( m_lock ); @@ -606,6 +605,14 @@ const char* View::GetThreadString( uint64_t id ) const } } +const QueueSourceLocation& View::GetSourceLocation( uint64_t srcloc ) const +{ + static const QueueSourceLocation empty = {}; + const auto it = m_sourceLocation.find( srcloc ); + if( it == m_sourceLocation.end() ) return empty; + return it->second; +} + void View::Draw() { s_instance->DrawImpl(); @@ -1024,7 +1031,8 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, con while( it < zitend ) { auto& ev = **it; - const auto color = ev.color != 0 ? ( ev.color | 0xFF000000 ) : 0xDDDD6666; + auto& srcloc = GetSourceLocation( ev.srcloc ); + const auto color = srcloc.color != 0 ? ( srcloc.color | 0xFF000000 ) : 0xDDDD6666; const auto end = GetZoneEnd( ev ); const auto zsz = ( ev.end - ev.start ) * pxns; if( zsz < MinVisSize ) @@ -1037,7 +1045,8 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, con { ++it; if( it == zitend ) break; - if( (*it)->color != ev.color ) break; + auto& srcloc2 = GetSourceLocation( (*it)->srcloc ); + if( srcloc.color != srcloc2.color ) break; const auto nend = GetZoneEnd( **it ); const auto pxnext = ( nend - m_zvStart ) * pxns; if( pxnext - px1 >= MinVisSize * 2 ) break; @@ -1056,16 +1065,9 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, con } else { - const char* func = "???"; - const char* filename = "???"; - uint32_t line = 0; - auto srcit = m_sourceLocation.find( ev.srcloc ); - if( srcit != m_sourceLocation.end() ) - { - func = GetString( srcit->second.function ); - filename = GetString( srcit->second.file ); - line = srcit->second.line; - } + const auto func = GetString( srcloc.function ); + const auto filename = GetString( srcloc.file ); + const auto line = srcloc.line; const auto tsz = ImGui::CalcTextSize( func ); const auto pr0 = ( ev.start - m_zvStart ) * pxns; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 21c31717..975566f2 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -72,6 +72,7 @@ private: const char* TimeToString( int64_t ns ) const; const char* GetString( uint64_t ptr ) const; const char* GetThreadString( uint64_t id ) const; + const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const; void DrawImpl(); void DrawFrames();