diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index bfc52043..5b28b0cf 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -393,9 +393,9 @@ struct ThreadData { uint64_t id; uint64_t count; - Vector timeline; - Vector stack; - Vector messages; + Vector> timeline; + Vector> stack; + Vector> messages; uint32_t nextZoneId; Vector zoneIdStack; #ifndef TRACY_NO_STATISTICS diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 73a8cd09..e3912783 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3004,7 +3004,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn } } -int View::DispatchZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) +int View::DispatchZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) { const auto ty = ImGui::GetFontSize(); const auto ostep = ty + 1; @@ -3021,7 +3021,7 @@ int View::DispatchZoneLevel( const Vector& vec, bool hover, double p } } -int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) +int View::DrawZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) { const auto delay = m_worker.GetDelay(); const auto resolution = m_worker.GetResolution(); @@ -3240,7 +3240,7 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, return maxdepth; } -int View::SkipZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) +int View::SkipZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) { const auto delay = m_worker.GetDelay(); const auto resolution = m_worker.GetResolution(); @@ -13330,7 +13330,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const for( const auto& thread : m_worker.GetThreadData() ) { const ZoneEvent* parent = nullptr; - const Vector* timeline = &thread->timeline; + const Vector>* timeline = &thread->timeline; if( timeline->empty() ) continue; for(;;) { @@ -13350,7 +13350,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) cons { const auto thread = m_worker.GetThreadData( tid ); const ZoneEvent* parent = nullptr; - const Vector* timeline = &thread->timeline; + const Vector>* timeline = &thread->timeline; if( timeline->empty() ) return nullptr; for(;;) { @@ -13393,7 +13393,7 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const { for( const auto& thread : m_worker.GetThreadData() ) { - const Vector* timeline = &thread->timeline; + const Vector>* timeline = &thread->timeline; if( timeline->empty() ) continue; for(;;) { @@ -13477,9 +13477,9 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const } if( !td ) return nullptr; - const Vector* timeline = &td->timeline; + const Vector>* timeline = &td->timeline; if( timeline->empty() ) return nullptr; - ZoneEvent* ret = nullptr; + const ZoneEvent* ret = nullptr; for(;;) { auto it = std::upper_bound( timeline->begin(), timeline->end(), time, [] ( const auto& l, const auto& r ) { return l < r->Start(); } ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 535eef1c..a3ab621a 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -119,9 +119,9 @@ private: bool DrawZoneFrames( const FrameData& frames ); void DrawZones(); void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset ); - int DispatchZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); - int DrawZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); - int SkipZoneLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); + int DispatchZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); + int DrawZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); + int SkipZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); int DispatchGpuZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); int DrawGpuZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); int SkipGpuZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); @@ -284,7 +284,7 @@ private: int m_memoryAllocHoverWait = 0; const FrameData* m_frames; uint32_t m_lockInfoWindow = InvalidId; - ZoneEvent* m_zoneHover = nullptr; + const ZoneEvent* m_zoneHover = nullptr; int m_frameHover = -1; bool m_messagesScrollBottom; ImGuiTextFilter m_messageFilter; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 4b1b5a9a..1b55d085 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -896,7 +896,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) { f.Read( sz ); m_data.zoneChildren.reserve_exact( sz, m_slab ); - memset( m_data.zoneChildren.data(), 0, sizeof( Vector ) * sz ); + memset( m_data.zoneChildren.data(), 0, sizeof( Vector> ) * sz ); } int32_t childIdx = 0; f.Read( sz ); @@ -1746,8 +1746,8 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) m_backgroundDone.store( false, std::memory_order_relaxed ); #ifndef TRACY_NO_STATISTICS m_threadBackground = std::thread( [this, reconstructMemAllocPlot] { - std::function&, uint16_t)> ProcessTimeline; - ProcessTimeline = [this, &ProcessTimeline] ( const Vector& vec, uint16_t thread ) + std::function>&, uint16_t)> ProcessTimeline; + ProcessTimeline = [this, &ProcessTimeline] ( Vector>& vec, uint16_t thread ) { if( m_shutdown.load( std::memory_order_relaxed ) ) return; for( auto& zone : vec ) @@ -1755,7 +1755,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) ReadTimelineUpdateStatistics( zone, thread ); if( zone->Child() >= 0 ) { - ProcessTimeline( GetZoneChildren( zone->Child() ), thread ); + ProcessTimeline( GetZoneChildrenMutable( zone->Child() ), thread ); } } }; @@ -2840,11 +2840,11 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread ) back->SetChild( int32_t( m_data.zoneChildren.size() ) ); if( m_data.zoneVectorCache.empty() ) { - m_data.zoneChildren.push_back( Vector( zone ) ); + m_data.zoneChildren.push_back( Vector>( zone ) ); } else { - Vector vze = std::move( m_data.zoneVectorCache.back_and_pop() ); + Vector> vze = std::move( m_data.zoneVectorCache.back_and_pop() ); assert( !vze.empty() ); vze.clear(); vze.push_back_non_empty( zone ); @@ -3603,9 +3603,9 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) const auto sz = childVec.size(); if( sz <= 8 * 1024 ) { - Vector fitVec; + Vector> fitVec; fitVec.reserve_exact( sz, m_slab ); - memcpy( fitVec.data(), childVec.data(), sz * sizeof( ZoneEvent* ) ); + memcpy( fitVec.data(), childVec.data(), sz * sizeof( short_ptr ) ); fitVec.swap( childVec ); m_data.zoneVectorCache.push_back( std::move( fitVec ) ); } @@ -4888,8 +4888,8 @@ void Worker::ReadTimelinePre042( FileRead& f, ZoneEvent* zone, uint16_t thread, { const auto child = m_data.zoneChildren.size(); zone->SetChild( child ); - m_data.zoneChildren.push_back( Vector() ); - Vector tmp; + m_data.zoneChildren.push_back( Vector>() ); + Vector> tmp; ReadTimelinePre042( f, tmp, thread, sz, fileVer ); m_data.zoneChildren[child] = std::move( tmp ); } @@ -4907,8 +4907,8 @@ void Worker::ReadTimelinePre0510( FileRead& f, ZoneEvent* zone, uint16_t thread, { const auto child = m_data.zoneChildren.size(); zone->SetChild( child ); - m_data.zoneChildren.push_back( Vector() ); - Vector tmp; + m_data.zoneChildren.push_back( Vector>() ); + Vector> tmp; ReadTimelinePre0510( f, tmp, thread, sz, refTime, fileVer ); m_data.zoneChildren[child] = std::move( tmp ); } @@ -4989,7 +4989,7 @@ void Worker::ReadTimelineUpdateStatistics( ZoneEvent* zone, uint16_t thread ) #endif } -void Worker::ReadTimeline( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx ) +void Worker::ReadTimeline( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx ) { assert( size != 0 ); vec.reserve_exact( size, m_slab ); @@ -5022,7 +5022,7 @@ void Worker::ReadTimeline( FileRead& f, Vector& vec, uint16_t thread while( ++zone != zptr ); } -void Worker::ReadTimelinePre042( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int fileVer ) +void Worker::ReadTimelinePre042( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int fileVer ) { assert( fileVer <= FileVersion( 0, 4, 1 ) ); assert( size != 0 ); @@ -5073,7 +5073,7 @@ void Worker::ReadTimelinePre042( FileRead& f, Vector& vec, uint16_t } } -void Worker::ReadTimelinePre0510( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer ) +void Worker::ReadTimelinePre0510( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer ) { assert( fileVer <= FileVersion( 0, 5, 9 ) ); assert( size != 0 ); @@ -5531,7 +5531,7 @@ void Worker::Write( FileWrite& f ) f.Write( &sz, sizeof( sz ) ); for( auto& v : thread->messages ) { - auto ptr = uint64_t( v ); + auto ptr = uint64_t( (MessageData*)v ); f.Write( &ptr, sizeof( ptr ) ); } } @@ -5713,7 +5713,7 @@ void Worker::Write( FileWrite& f ) } } -void Worker::WriteTimeline( FileWrite& f, const Vector& vec, int64_t& refTime ) +void Worker::WriteTimeline( FileWrite& f, const Vector>& vec, int64_t& refTime ) { uint64_t sz = vec.size(); f.Write( &sz, sizeof( sz ) ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index f09b168b..e254c63b 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -198,10 +198,10 @@ private: ThreadCompress localThreadCompress; ThreadCompress externalThreadCompress; - Vector> zoneChildren; + Vector>> zoneChildren; Vector>> gpuChildren; - Vector> zoneVectorCache; + Vector>> zoneVectorCache; Vector frameImage; Vector appInfo; @@ -364,7 +364,7 @@ public: const char* GetZoneName( const GpuEvent& ev ) const; const char* GetZoneName( const GpuEvent& ev, const SourceLocation& srcloc ) const; - tracy_force_inline const Vector& GetZoneChildren( int32_t idx ) const { return m_data.zoneChildren[idx]; } + tracy_force_inline const Vector>& GetZoneChildren( int32_t idx ) const { return m_data.zoneChildren[idx]; } tracy_force_inline const Vector>& GetGpuChildren( int32_t idx ) const { return m_data.gpuChildren[idx]; } std::vector GetMatchingSourceLocation( const char* query, bool ignoreCase ) const; @@ -553,6 +553,8 @@ private: StringLocation StoreString( char* str, size_t sz ); const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread ); + tracy_force_inline Vector>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; } + tracy_force_inline void ReadTimeline( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime, int32_t& childIdx ); tracy_force_inline void ReadTimelinePre042( FileRead& f, ZoneEvent* zone, uint16_t thread, int fileVer ); tracy_force_inline void ReadTimelinePre0510( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime, int fileVer ); @@ -561,13 +563,13 @@ private: tracy_force_inline void ReadTimelineUpdateStatistics( ZoneEvent* zone, uint16_t thread ); - void ReadTimeline( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx ); - void ReadTimelinePre042( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int fileVer ); - void ReadTimelinePre0510( FileRead& f, Vector& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer ); + void ReadTimeline( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx ); + void ReadTimelinePre042( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int fileVer ); + void ReadTimelinePre0510( FileRead& f, Vector>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer ); void ReadTimeline( FileRead& f, Vector>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx ); void ReadTimelinePre0510( FileRead& f, Vector>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer ); - void WriteTimeline( FileWrite& f, const Vector& vec, int64_t& refTime ); + void WriteTimeline( FileWrite& f, const Vector>& vec, int64_t& refTime ); void WriteTimeline( FileWrite& f, const Vector>& vec, int64_t& refTime, int64_t& refGpuTime ); int64_t TscTime( int64_t tsc ) { return int64_t( tsc * m_timerMul ); }