Transfer query ids of GPU events.

This commit is contained in:
Bartosz Taudul 2018-06-22 15:57:54 +02:00
parent cd5ca3e754
commit 51c5f47ae2
3 changed files with 20 additions and 6 deletions

View File

@ -164,7 +164,8 @@ class GpuCtxScope
public: public:
tracy_force_inline GpuCtxScope( const SourceLocation* srcloc ) 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; Magic magic;
auto& token = s_token.ptr; auto& token = s_token.ptr;
@ -174,13 +175,15 @@ public:
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
memset( &item->gpuZoneBegin.thread, 0, sizeof( item->gpuZoneBegin.thread ) ); memset( &item->gpuZoneBegin.thread, 0, sizeof( item->gpuZoneBegin.thread ) );
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() ); MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
tracy_force_inline GpuCtxScope( const SourceLocation* srcloc, int depth ) 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(); const auto thread = GetThreadHandle();
@ -192,6 +195,7 @@ public:
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
MemWrite( &item->gpuZoneBegin.thread, thread ); MemWrite( &item->gpuZoneBegin.thread, thread );
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() ); MemWrite( &item->gpuZoneBegin.context, s_gpuCtx.ptr->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
@ -200,7 +204,8 @@ public:
tracy_force_inline ~GpuCtxScope() tracy_force_inline ~GpuCtxScope()
{ {
glQueryCounter( s_gpuCtx.ptr->NextQueryId(), GL_TIMESTAMP ); const auto queryId = s_gpuCtx.ptr->NextQueryId();
glQueryCounter( queryId, GL_TIMESTAMP );
Magic magic; Magic magic;
auto& token = s_token.ptr; auto& token = s_token.ptr;
@ -208,6 +213,7 @@ public:
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::GpuZoneEnd ); MemWrite( &item->hdr.type, QueueType::GpuZoneEnd );
MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneEnd.context, s_gpuCtx.ptr->GetId() ); MemWrite( &item->gpuZoneEnd.context, s_gpuCtx.ptr->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }

View File

@ -195,7 +195,8 @@ public:
: m_cmdbuf( cmdbuf ) : m_cmdbuf( cmdbuf )
{ {
auto ctx = s_vkCtx.ptr; 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; Magic magic;
auto& token = s_token.ptr; auto& token = s_token.ptr;
@ -205,6 +206,7 @@ public:
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() ); MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() );
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneBegin.context, ctx->GetId() ); MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -215,7 +217,8 @@ public:
const auto thread = GetThreadHandle(); const auto thread = GetThreadHandle();
auto ctx = s_vkCtx.ptr; 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; Magic magic;
auto& token = s_token.ptr; auto& token = s_token.ptr;
@ -225,6 +228,7 @@ public:
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
MemWrite( &item->gpuZoneBegin.thread, thread ); MemWrite( &item->gpuZoneBegin.thread, thread );
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneBegin.context, ctx->GetId() ); MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
@ -234,7 +238,8 @@ public:
tracy_force_inline ~VkCtxScope() tracy_force_inline ~VkCtxScope()
{ {
auto ctx = s_vkCtx.ptr; 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; Magic magic;
auto& token = s_token.ptr; auto& token = s_token.ptr;
@ -242,6 +247,7 @@ public:
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::GpuZoneEnd ); MemWrite( &item->hdr.type, QueueType::GpuZoneEnd );
MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneEnd.context, ctx->GetId() ); MemWrite( &item->gpuZoneEnd.context, ctx->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }

View File

@ -177,12 +177,14 @@ struct QueueGpuZoneBegin
int64_t cpuTime; int64_t cpuTime;
uint64_t srcloc; uint64_t srcloc;
uint64_t thread; uint64_t thread;
uint16_t queryId;
uint8_t context; uint8_t context;
}; };
struct QueueGpuZoneEnd struct QueueGpuZoneEnd
{ {
int64_t cpuTime; int64_t cpuTime;
uint16_t queryId;
uint8_t context; uint8_t context;
}; };