From f1095bba125f61a01372a45d90486573a1d24fbd Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 23 Jan 2022 15:46:30 +0100 Subject: [PATCH] GPU statistics data accessors. --- server/TracyWorker.cpp | 19 +++++++++++++++++++ server/TracyWorker.hpp | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 55243cec..ab2b6f12 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -289,6 +289,7 @@ Worker::Worker( const char* addr, uint16_t port ) #ifndef TRACY_NO_STATISTICS m_data.sourceLocationZonesReady = true; + m_data.gpuSourceLocationZonesReady = true; m_data.callstackSamplesReady = true; m_data.ghostZonesReady = true; m_data.ctxUsageReady = true; @@ -3723,6 +3724,15 @@ Worker::SourceLocationZones* Worker::GetSourceLocationZonesReal( uint16_t srcloc m_data.srclocZonesLast.second = &it->second; return &it->second; } + +Worker::GpuSourceLocationZones* Worker::GetGpuSourceLocationZonesReal( uint16_t srcloc ) +{ + auto it = m_data.gpuSourceLocationZones.find( srcloc ); + assert( it != m_data.gpuSourceLocationZones.end() ); + m_data.gpuZonesLast.first = srcloc; + m_data.gpuZonesLast.second = &it->second; + return &it->second; +} #else uint64_t* Worker::GetSourceLocationZonesCntReal( uint16_t srcloc ) { @@ -3732,6 +3742,15 @@ uint64_t* Worker::GetSourceLocationZonesCntReal( uint16_t srcloc ) m_data.srclocCntLast.second = &it->second; return &it->second; } + +uint64_t* Worker::GetGpuSourceLocationZonesCntReal( uint16_t srcloc ) +{ + auto it = m_data.gpuSourceLocationZonesCnt.find( srcloc ); + assert( it != m_data.gpuSourceLocationZonesCnt.end() ); + m_data.gpuCntLast.first = srcloc; + m_data.gpuCntLast.second = &it->second; + return &it->second; +} #endif const ThreadData* Worker::GetThreadData( uint64_t tid ) const diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 149341c0..aa975a5e 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -297,8 +297,11 @@ private: #ifndef TRACY_NO_STATISTICS unordered_flat_map sourceLocationZones; bool sourceLocationZonesReady = false; + unordered_flat_map gpuSourceLocationZones; + bool gpuSourceLocationZonesReady = false; #else unordered_flat_map sourceLocationZonesCnt; + unordered_flat_map gpuSourceLocationZonesCnt; #endif unordered_flat_map*, uint32_t, VarArrayHasher, VarArrayComparator> callstackMap; @@ -365,8 +368,10 @@ private: std::pair shrinkSrclocLast = std::make_pair( std::numeric_limits::max(), 0 ); #ifndef TRACY_NO_STATISTICS std::pair srclocZonesLast = std::make_pair( 0, nullptr ); + std::pair gpuZonesLast = std::make_pair( 0, nullptr ); #else std::pair srclocCntLast = std::make_pair( 0, nullptr ); + std::pair gpuCntLast = std::make_pair( 0, nullptr ); #endif #ifndef TRACY_NO_STATISTICS @@ -805,6 +810,13 @@ private: return GetSourceLocationZonesReal( srcloc ); } SourceLocationZones* GetSourceLocationZonesReal( uint16_t srcloc ); + + GpuSourceLocationZones* GetGpuSourceLocationZones( uint16_t srcloc ) + { + if( m_data.gpuZonesLast.first == srcloc ) return m_data.gpuZonesLast.second; + return GetGpuSourceLocationZonesReal( srcloc ); + } + GpuSourceLocationZones* GetGpuSourceLocationZonesReal( uint16_t srcloc ); #else uint64_t* GetSourceLocationZonesCnt( uint16_t srcloc ) { @@ -812,6 +824,13 @@ private: return GetSourceLocationZonesCntReal( srcloc ); } uint64_t* GetSourceLocationZonesCntReal( uint16_t srcloc ); + + uint64_t* GetGpuSourceLocationZonesCnt( uint16_t srcloc ) + { + if( m_data.gpuCntLast.first == srcloc ) return m_data.gpuCntLast.second; + return GetGpuSourceLocationZonesCntReal( srcloc ); + } + uint64_t* GetGpuSourceLocationZonesCntReal( uint16_t srcloc ); #endif tracy_force_inline void NewZone( ZoneEvent* zone );