diff --git a/TracyOpenGL.hpp b/TracyOpenGL.hpp index 58b17ba0..7690cd48 100644 --- a/TracyOpenGL.hpp +++ b/TracyOpenGL.hpp @@ -164,7 +164,8 @@ class GpuCtxScope public: tracy_force_inline GpuCtxScope( const SourceLocation* srcloc ) { - glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); + const auto queryId = s_gpuCtx.ptr->NextQueryId(); + glQueryCounter( queryId, GL_TIMESTAMP ); Magic magic; auto& token = s_token.ptr; @@ -174,13 +175,15 @@ public: MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); memset( &item->gpuZoneBegin.thread, 0, sizeof( item->gpuZoneBegin.thread ) ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() ); tail.store( magic + 1, std::memory_order_release ); } tracy_force_inline GpuCtxScope( const SourceLocation* srcloc, int depth ) { - glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); + const auto queryId = s_gpuCtx.ptr->NextQueryId(); + glQueryCounter( queryId, GL_TIMESTAMP ); const auto thread = GetThreadHandle(); @@ -192,6 +195,7 @@ public: MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.thread, thread ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() ); tail.store( magic + 1, std::memory_order_release ); @@ -200,7 +204,8 @@ public: tracy_force_inline ~GpuCtxScope() { - glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); + const auto queryId = s_gpuCtx.ptr->NextQueryId(); + glQueryCounter( queryId, GL_TIMESTAMP ); Magic magic; auto& token = s_token.ptr; @@ -208,6 +213,7 @@ public: auto item = token->enqueue_begin( magic ); MemWrite( &item->hdr.type, QueueType::GpuZoneEnd ); MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() ); + MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneEnd.context, s_gpuCtx.ptr->GetId() ); tail.store( magic + 1, std::memory_order_release ); } diff --git a/TracyVulkan.hpp b/TracyVulkan.hpp index 8ea81237..d0c45abe 100644 --- a/TracyVulkan.hpp +++ b/TracyVulkan.hpp @@ -195,7 +195,8 @@ public: : m_cmdbuf( cmdbuf ) { auto ctx = s_vkCtx.ptr; - vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, ctx->NextQueryId() ); + const auto queryId = ctx->NextQueryId(); + vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId ); Magic magic; auto& token = s_token.ptr; @@ -205,6 +206,7 @@ public: MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneBegin.context, ctx->GetId() ); tail.store( magic + 1, std::memory_order_release ); } @@ -215,7 +217,8 @@ public: const auto thread = GetThreadHandle(); auto ctx = s_vkCtx.ptr; - vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, ctx->NextQueryId() ); + const auto queryId = ctx->NextQueryId(); + vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId ); Magic magic; auto& token = s_token.ptr; @@ -225,6 +228,7 @@ public: MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.thread, thread ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneBegin.context, ctx->GetId() ); tail.store( magic + 1, std::memory_order_release ); @@ -234,7 +238,8 @@ public: tracy_force_inline ~VkCtxScope() { auto ctx = s_vkCtx.ptr; - vkCmdWriteTimestamp( m_cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, ctx->NextQueryId() ); + const auto queryId = ctx->NextQueryId(); + vkCmdWriteTimestamp( m_cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId ); Magic magic; auto& token = s_token.ptr; @@ -242,6 +247,7 @@ public: auto item = token->enqueue_begin( magic ); MemWrite( &item->hdr.type, QueueType::GpuZoneEnd ); MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() ); + MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneEnd.context, ctx->GetId() ); tail.store( magic + 1, std::memory_order_release ); } diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 52b7f2b9..504e0870 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -177,12 +177,14 @@ struct QueueGpuZoneBegin int64_t cpuTime; uint64_t srcloc; uint64_t thread; + uint16_t queryId; uint8_t context; }; struct QueueGpuZoneEnd { int64_t cpuTime; + uint16_t queryId; uint8_t context; };