From eb7d220eeaacdab81a87001313a06c098885d45e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 29 Apr 2021 20:55:16 +0200 Subject: [PATCH] Added support for TRACY_NO_FRAME_IMAGE define. --- client/TracyProfiler.cpp | 11 +++++++++++ client/TracyProfiler.hpp | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index e8e98c14..9024c2d7 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -940,7 +940,9 @@ enum { QueuePrealloc = 256 * 1024 }; static Profiler* s_instance = nullptr; static Thread* s_thread; +#ifndef TRACY_NO_FRAME_IMAGE static Thread* s_compressThread; +#endif #ifdef TRACY_HAS_SYSTEM_TRACING static Thread* s_sysTraceThread = nullptr; @@ -1203,8 +1205,10 @@ Profiler::Profiler() , m_lz4Buf( (char*)tracy_malloc( LZ4Size + sizeof( lz4sz_t ) ) ) , m_serialQueue( 1024*1024 ) , m_serialDequeue( 1024*1024 ) +#ifndef TRACY_NO_FRAME_IMAGE , m_fiQueue( 16 ) , m_fiDequeue( 16 ) +#endif , m_frameCount( 0 ) , m_isConnected( false ) #ifdef TRACY_ON_DEMAND @@ -1254,8 +1258,10 @@ void Profiler::SpawnWorkerThreads() s_thread = (Thread*)tracy_malloc( sizeof( Thread ) ); new(s_thread) Thread( LaunchWorker, this ); +#ifndef TRACY_NO_FRAME_IMAGE s_compressThread = (Thread*)tracy_malloc( sizeof( Thread ) ); new(s_compressThread) Thread( LaunchCompressWorker, this ); +#endif #ifdef TRACY_HAS_SYSTEM_TRACING if( SysTraceStart( m_samplingPeriod ) ) @@ -1307,8 +1313,11 @@ Profiler::~Profiler() } #endif +#ifndef TRACY_NO_FRAME_IMAGE s_compressThread->~Thread(); tracy_free( s_compressThread ); +#endif + s_thread->~Thread(); tracy_free( s_thread ); @@ -1808,6 +1817,7 @@ void Profiler::Worker() } } +#ifndef TRACY_NO_FRAME_IMAGE void Profiler::CompressWorker() { ThreadExitHandler threadExitHandler; @@ -1874,6 +1884,7 @@ void Profiler::CompressWorker() } } } +#endif static void FreeAssociatedMemory( const QueueItem& item ) { diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index c821da7d..230835ca 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -213,11 +213,12 @@ public: static tracy_force_inline void SendFrameImage( const void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip ) { +#ifndef TRACY_NO_FRAME_IMAGE auto& profiler = GetProfiler(); assert( profiler.m_frameCount.load( std::memory_order_relaxed ) < std::numeric_limits::max() ); -#ifdef TRACY_ON_DEMAND +# ifdef TRACY_ON_DEMAND if( !profiler.IsConnected() ) return; -#endif +# endif const auto sz = size_t( w ) * size_t( h ) * 4; auto ptr = (char*)tracy_malloc( sz ); memcpy( ptr, image, sz ); @@ -231,6 +232,7 @@ public: fi->flip = flip; profiler.m_fiQueue.commit_next(); profiler.m_fiLock.unlock(); +#endif } static tracy_force_inline void PlotData( const char* name, int64_t val ) @@ -642,8 +644,10 @@ private: static void LaunchWorker( void* ptr ) { ((Profiler*)ptr)->Worker(); } void Worker(); +#ifndef TRACY_NO_FRAME_IMAGE static void LaunchCompressWorker( void* ptr ) { ((Profiler*)ptr)->CompressWorker(); } void CompressWorker(); +#endif void ClearQueues( tracy::moodycamel::ConsumerToken& token ); void ClearSerial(); @@ -790,8 +794,10 @@ private: FastVector m_serialQueue, m_serialDequeue; TracyMutex m_serialLock; +#ifndef TRACY_NO_FRAME_IMAGE FastVector m_fiQueue, m_fiDequeue; TracyMutex m_fiLock; +#endif std::atomic m_frameCount; std::atomic m_isConnected;