1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-06 07:03:52 +00:00

Use short ptr for GPU zone data.

This commit is contained in:
Bartosz Taudul 2019-11-02 15:52:34 +01:00
parent c7664b0a98
commit cb20bf01f9
5 changed files with 25 additions and 23 deletions

View File

@ -405,8 +405,8 @@ struct ThreadData
struct GpuCtxThreadData struct GpuCtxThreadData
{ {
Vector<GpuEvent*> timeline; Vector<short_ptr<GpuEvent>> timeline;
Vector<GpuEvent*> stack; Vector<short_ptr<GpuEvent>> stack;
}; };
struct GpuCtxData struct GpuCtxData

View File

@ -3289,7 +3289,7 @@ int View::SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
return maxdepth; return maxdepth;
} }
int View::DispatchGpuZoneLevel( const Vector<GpuEvent*>& 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 View::DispatchGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& 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 )
{ {
const auto ty = ImGui::GetFontSize(); const auto ty = ImGui::GetFontSize();
const auto ostep = ty + 1; const auto ostep = ty + 1;
@ -3313,7 +3313,7 @@ static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift )
return time + t / 1000000000 * drift; return time + t / 1000000000 * drift;
} }
int View::DrawGpuZoneLevel( const Vector<GpuEvent*>& 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 View::DrawGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& 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 )
{ {
const auto delay = m_worker.GetDelay(); const auto delay = m_worker.GetDelay();
const auto resolution = m_worker.GetResolution(); const auto resolution = m_worker.GetResolution();
@ -3473,7 +3473,7 @@ int View::DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxn
return maxdepth; return maxdepth;
} }
int View::SkipGpuZoneLevel( const Vector<GpuEvent*>& 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 View::SkipGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& 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 )
{ {
const auto delay = m_worker.GetDelay(); const auto delay = m_worker.GetDelay();
const auto resolution = m_worker.GetResolution(); const auto resolution = m_worker.GetResolution();
@ -13372,7 +13372,7 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
for( const auto& td : ctx->threadData ) for( const auto& td : ctx->threadData )
{ {
const GpuEvent* parent = nullptr; const GpuEvent* parent = nullptr;
const Vector<GpuEvent*>* timeline = &td.second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{ {
@ -13421,7 +13421,7 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
for( const auto& ctx : m_worker.GetGpuData() ) for( const auto& ctx : m_worker.GetGpuData() )
{ {
assert( ctx->threadData.size() == 1 ); assert( ctx->threadData.size() == 1 );
const Vector<GpuEvent*>* timeline = &ctx->threadData.begin()->second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &ctx->threadData.begin()->second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{ {
@ -13447,7 +13447,7 @@ const GpuCtxData* View::GetZoneCtx( const GpuEvent& zone ) const
{ {
for( const auto& td : ctx->threadData ) for( const auto& td : ctx->threadData )
{ {
const Vector<GpuEvent*>* timeline = &td.second.timeline; const Vector<short_ptr<GpuEvent>>* timeline = &td.second.timeline;
if( timeline->empty() ) continue; if( timeline->empty() ) continue;
for(;;) for(;;)
{ {

View File

@ -11,6 +11,7 @@
#include "TracyBuzzAnim.hpp" #include "TracyBuzzAnim.hpp"
#include "TracyDecayValue.hpp" #include "TracyDecayValue.hpp"
#include "TracyShortPtr.hpp"
#include "TracyTexture.hpp" #include "TracyTexture.hpp"
#include "TracyUserData.hpp" #include "TracyUserData.hpp"
#include "TracyVector.hpp" #include "TracyVector.hpp"
@ -121,9 +122,9 @@ private:
int DispatchZoneLevel( const Vector<ZoneEvent*>& 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<ZoneEvent*>& 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<ZoneEvent*>& 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<ZoneEvent*>& 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<ZoneEvent*>& 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<ZoneEvent*>& 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<GpuEvent*>& 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 DispatchGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& 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<GpuEvent*>& 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<short_ptr<GpuEvent>>& 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<GpuEvent*>& 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<short_ptr<GpuEvent>>& 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 );
void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint8_t tid ); void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint8_t tid );
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax ); int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax ); int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );

View File

@ -966,7 +966,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
{ {
f.Read( sz ); f.Read( sz );
m_data.gpuChildren.reserve_exact( sz, m_slab ); m_data.gpuChildren.reserve_exact( sz, m_slab );
memset( m_data.zoneChildren.data(), 0, sizeof( Vector<GpuEvent*> ) * sz ); memset( m_data.zoneChildren.data(), 0, sizeof( Vector<short_ptr<GpuEvent>> ) * sz );
} }
childIdx = 0; childIdx = 0;
f.Read( sz ); f.Read( sz );
@ -4247,7 +4247,7 @@ void Worker::ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& e
if( back->Child() < 0 ) if( back->Child() < 0 )
{ {
back->SetChild( int32_t( m_data.gpuChildren.size() ) ); back->SetChild( int32_t( m_data.gpuChildren.size() ) );
m_data.gpuChildren.push_back( Vector<GpuEvent*>() ); m_data.gpuChildren.push_back( Vector<short_ptr<GpuEvent>>() );
} }
timeline = &m_data.gpuChildren[back->Child()]; timeline = &m_data.gpuChildren[back->Child()];
} }
@ -4943,8 +4943,8 @@ void Worker::ReadTimelinePre0510( FileRead& f, GpuEvent* zone, int64_t& refTime,
{ {
const auto child = m_data.gpuChildren.size(); const auto child = m_data.gpuChildren.size();
zone->SetChild( child ); zone->SetChild( child );
m_data.gpuChildren.push_back( Vector<GpuEvent*>() ); m_data.gpuChildren.push_back( Vector<short_ptr<GpuEvent>>() );
Vector<GpuEvent*> tmp; Vector<short_ptr<GpuEvent>> tmp;
ReadTimelinePre0510( f, tmp, sz, refTime, refGpuTime, fileVer ); ReadTimelinePre0510( f, tmp, sz, refTime, refGpuTime, fileVer );
m_data.gpuChildren[child] = std::move( tmp ); m_data.gpuChildren[child] = std::move( tmp );
} }
@ -5158,7 +5158,7 @@ void Worker::ReadTimelinePre0510( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t
while( ++zone != zptr ); while( ++zone != zptr );
} }
void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx ) void Worker::ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx )
{ {
assert( size != 0 ); assert( size != 0 );
vec.reserve_exact( size, m_slab ); vec.reserve_exact( size, m_slab );
@ -5199,7 +5199,7 @@ void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size, i
while( ++zone != zptr ); while( ++zone != zptr );
} }
void Worker::ReadTimelinePre0510( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer ) void Worker::ReadTimelinePre0510( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer )
{ {
assert( size != 0 ); assert( size != 0 );
vec.reserve_exact( size, m_slab ); vec.reserve_exact( size, m_slab );
@ -5742,7 +5742,7 @@ void Worker::WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t
} }
} }
void Worker::WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec, int64_t& refTime, int64_t& refGpuTime ) void Worker::WriteTimeline( FileWrite& f, const Vector<short_ptr<GpuEvent>>& vec, int64_t& refTime, int64_t& refGpuTime )
{ {
uint64_t sz = vec.size(); uint64_t sz = vec.size();
f.Write( &sz, sizeof( sz ) ); f.Write( &sz, sizeof( sz ) );

View File

@ -19,6 +19,7 @@
#include "../common/TracySocket.hpp" #include "../common/TracySocket.hpp"
#include "tracy_flat_hash_map.hpp" #include "tracy_flat_hash_map.hpp"
#include "TracyEvent.hpp" #include "TracyEvent.hpp"
#include "TracyShortPtr.hpp"
#include "TracySlab.hpp" #include "TracySlab.hpp"
#include "TracyStringDiscovery.hpp" #include "TracyStringDiscovery.hpp"
#include "TracyThreadCompress.hpp" #include "TracyThreadCompress.hpp"
@ -198,7 +199,7 @@ private:
ThreadCompress externalThreadCompress; ThreadCompress externalThreadCompress;
Vector<Vector<ZoneEvent*>> zoneChildren; Vector<Vector<ZoneEvent*>> zoneChildren;
Vector<Vector<GpuEvent*>> gpuChildren; Vector<Vector<short_ptr<GpuEvent>>> gpuChildren;
Vector<Vector<ZoneEvent*>> zoneVectorCache; Vector<Vector<ZoneEvent*>> zoneVectorCache;
@ -364,7 +365,7 @@ public:
const char* GetZoneName( const GpuEvent& ev, const SourceLocation& srcloc ) const; const char* GetZoneName( const GpuEvent& ev, const SourceLocation& srcloc ) const;
tracy_force_inline const Vector<ZoneEvent*>& GetZoneChildren( int32_t idx ) const { return m_data.zoneChildren[idx]; } tracy_force_inline const Vector<ZoneEvent*>& GetZoneChildren( int32_t idx ) const { return m_data.zoneChildren[idx]; }
tracy_force_inline const Vector<GpuEvent*>& GetGpuChildren( int32_t idx ) const { return m_data.gpuChildren[idx]; } tracy_force_inline const Vector<short_ptr<GpuEvent>>& GetGpuChildren( int32_t idx ) const { return m_data.gpuChildren[idx]; }
std::vector<int16_t> GetMatchingSourceLocation( const char* query, bool ignoreCase ) const; std::vector<int16_t> GetMatchingSourceLocation( const char* query, bool ignoreCase ) const;
@ -563,11 +564,11 @@ private:
void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx ); void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int32_t& childIdx );
void ReadTimelinePre042( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int fileVer ); void ReadTimelinePre042( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int fileVer );
void ReadTimelinePre0510( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer ); void ReadTimelinePre0510( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size, int64_t& refTime, int fileVer );
void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx ); void ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx );
void ReadTimelinePre0510( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer ); void ReadTimelinePre0510( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer );
void WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime ); void WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime );
void WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec, int64_t& refTime, int64_t& refGpuTime ); void WriteTimeline( FileWrite& f, const Vector<short_ptr<GpuEvent>>& vec, int64_t& refTime, int64_t& refGpuTime );
int64_t TscTime( int64_t tsc ) { return int64_t( tsc * m_timerMul ); } int64_t TscTime( int64_t tsc ) { return int64_t( tsc * m_timerMul ); }
int64_t TscTime( uint64_t tsc ) { return int64_t( tsc * m_timerMul ); } int64_t TscTime( uint64_t tsc ) { return int64_t( tsc * m_timerMul ); }