From 2f669aea4102d343fa3ef1dd277cf8935ff4a121 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 14 Nov 2017 23:29:48 +0100 Subject: [PATCH] Workaround gcc issues. --- TracyOpenGL.hpp | 14 +++++++------- client/TracyProfiler.cpp | 3 +-- client/TracyProfiler.hpp | 6 ++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/TracyOpenGL.hpp b/TracyOpenGL.hpp index 529d89a6..69237fd0 100644 --- a/TracyOpenGL.hpp +++ b/TracyOpenGL.hpp @@ -30,10 +30,10 @@ public: #include "client/TracyProfiler.hpp" #include "common/TracyAlloc.hpp" -#define TracyGpuContext tracy::s_gpuCtx = (tracy::GpuCtx*)tracy::tracy_malloc( sizeof( tracy::GpuCtx ) ); new(tracy::s_gpuCtx) tracy::GpuCtx; +#define TracyGpuContext tracy::s_gpuCtx.ptr = (tracy::GpuCtx*)tracy::tracy_malloc( sizeof( tracy::GpuCtx ) ); new(tracy::s_gpuCtx.ptr) tracy::GpuCtx; #define TracyGpuZone( name ) static const tracy::SourceLocation __tracy_gpu_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::GpuCtxScope ___tracy_gpu_zone( &__tracy_gpu_source_location ); #define TracyGpuZoneC( name, color ) static const tracy::SourceLocation __tracy_gpu_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::GpuCtxScope ___tracy_gpu_zone( &__tracy_gpu_source_location ); -#define TracyGpuCollect tracy::s_gpuCtx->Collect(); +#define TracyGpuCollect tracy::s_gpuCtx.ptr->Collect(); namespace tracy { @@ -133,14 +133,14 @@ private: unsigned int m_tail; }; -extern thread_local GpuCtx* s_gpuCtx; +extern thread_local GpuCtxWrapper s_gpuCtx; class GpuCtxScope { public: tracy_force_inline GpuCtxScope( const SourceLocation* srcloc ) { - glQueryCounter( s_gpuCtx->NextQueryId(), GL_TIMESTAMP ); + glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); Magic magic; auto& token = s_token.ptr; @@ -149,13 +149,13 @@ public: item->hdr.type = QueueType::GpuZoneBegin; item->gpuZoneBegin.cpuTime = Profiler::GetTime(); item->gpuZoneBegin.srcloc = (uint64_t)srcloc; - item->gpuZoneBegin.context = s_gpuCtx->GetId(); + item->gpuZoneBegin.context = s_gpuCtx.ptr->GetId(); tail.store( magic + 1, std::memory_order_release ); } tracy_force_inline ~GpuCtxScope() { - glQueryCounter( s_gpuCtx->NextQueryId(), GL_TIMESTAMP ); + glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); Magic magic; auto& token = s_token.ptr; @@ -163,7 +163,7 @@ public: auto item = token->enqueue_begin( magic ); item->hdr.type = QueueType::GpuZoneEnd; item->gpuZoneEnd.cpuTime = Profiler::GetTime(); - item->gpuZoneEnd.context = s_gpuCtx->GetId(); + item->gpuZoneEnd.context = s_gpuCtx.ptr->GetId(); tail.store( magic + 1, std::memory_order_release ); } }; diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 6363a724..fdb0beec 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -100,8 +100,7 @@ moodycamel::ConcurrentQueue init_order(103) s_queue( QueuePrealloc ); std::atomic init_order(104) s_lockCounter( 0 ); std::atomic init_order(104) s_gpuCtxCounter( 0 ); -class GpuCtx; -thread_local GpuCtx* init_order(104) s_gpuCtx = nullptr; +thread_local GpuCtxWrapper init_order(104) s_gpuCtx { nullptr }; #ifdef TRACY_COLLECT_THREAD_NAMES struct ThreadNameData; diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index c592b2af..238f6f0e 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -41,6 +41,12 @@ struct ProducerWrapper extern thread_local ProducerWrapper s_token; +class GpuCtx; +struct GpuCtxWrapper +{ + GpuCtx* ptr; +}; + using Magic = moodycamel::ConcurrentQueueDefaultTraits::index_t; class Profiler