diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 84547ce2..1f349a06 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -587,12 +587,57 @@ enum { GhostZoneSize = sizeof( GhostZone ) }; #pragma pack() +using SrcLocCountMap = unordered_flat_map; + +tracy_force_inline void IncSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc) +{ + const auto it = countMap.find( srcloc ); + if( it == countMap.end() ) + { + countMap.emplace( srcloc, 1 ); + return; + } + + assert( it->second != 0 ); + it->second++; +} + +tracy_force_inline bool DecSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc) +{ + const auto it = countMap.find( srcloc ); + assert( it != countMap.end() ); + assert( it->second != 0 ); + + if( it->second == 1 ) + { + countMap.erase( it ); + return false; + } + + it->second--; + return true; +} + +tracy_force_inline bool HasSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc) +{ + const auto it = countMap.find( srcloc ); + + if( it != countMap.end() ) + { + assert( it->second != 0 ); + return true; + } + + return false; +} + struct ThreadData { uint64_t id; uint64_t count; Vector> timeline; Vector> stack; + SrcLocCountMap stackCount; Vector> messages; uint32_t nextZoneId; Vector zoneIdStack; @@ -604,6 +649,10 @@ struct ThreadData Vector samples; SampleData pendingSample; uint64_t kernelSampleCnt; + + tracy_force_inline void IncStackCount(int16_t srcloc) { IncSrcLocCount( stackCount, srcloc ); } + + tracy_force_inline bool DecStackCount(int16_t srcloc) { return DecSrcLocCount( stackCount, srcloc ); } }; struct GpuCtxThreadData diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index a55aae86..1b860248 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2006,6 +2006,7 @@ Worker::~Worker() { v->timeline.~Vector(); v->stack.~Vector(); + v->stackCount.~Table(); v->messages.~Vector(); v->zoneIdStack.~Vector(); v->samples.~Vector();