Added support for TRACY_NO_FRAME_IMAGE define.

This commit is contained in:
Bartosz Taudul 2021-04-29 20:55:16 +02:00
parent de5f258b03
commit eb7d220eea
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 19 additions and 2 deletions

View File

@ -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 )
{

View File

@ -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<uint32_t>::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<QueueItem> m_serialQueue, m_serialDequeue;
TracyMutex m_serialLock;
#ifndef TRACY_NO_FRAME_IMAGE
FastVector<FrameImageQueueItem> m_fiQueue, m_fiDequeue;
TracyMutex m_fiLock;
#endif
std::atomic<uint64_t> m_frameCount;
std::atomic<bool> m_isConnected;