Skip to content

Commit

Permalink
Merge pull request #620 from gan74/master
Browse files Browse the repository at this point in the history
Fixed Vulkan context running out of queries after 64k
  • Loading branch information
wolfpld authored Sep 11, 2023
2 parents 1ed4b71 + b979a3d commit 0341819
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions public/tracy/TracyVulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ class VkCtx
return;
}
#endif
assert(head > m_tail);
assert( head > m_tail );

const unsigned int wrappedTail = (unsigned int)( m_tail % m_queryCount );

unsigned int cnt;
if( m_oldCnt != 0 )
Expand All @@ -269,13 +271,16 @@ class VkCtx
}
else
{
cnt = (unsigned int)(head - m_tail);
assert(cnt <= m_queryCount);
cnt = (unsigned int)( head - m_tail );
assert( cnt <= m_queryCount );
if( wrappedTail + cnt > m_queryCount )
{
cnt = m_queryCount - wrappedTail;
}
}


const unsigned int tail = (unsigned int)(m_tail % m_queryCount);
if( VK_FUNCTION_WRAPPER( vkGetQueryPoolResults( m_device, m_query, tail, cnt, sizeof( int64_t ) * m_queryCount, m_res, sizeof( int64_t ), VK_QUERY_RESULT_64_BIT ) == VK_NOT_READY ) )
if( VK_FUNCTION_WRAPPER( vkGetQueryPoolResults( m_device, m_query, wrappedTail, cnt, sizeof( int64_t ) * m_queryCount, m_res, sizeof( int64_t ), VK_QUERY_RESULT_64_BIT ) == VK_NOT_READY ) )
{
m_oldCnt = cnt;
return;
Expand All @@ -286,7 +291,7 @@ class VkCtx
auto item = Profiler::QueueSerial();
MemWrite( &item->hdr.type, QueueType::GpuTime );
MemWrite( &item->gpuTime.gpuTime, m_res[idx] );
MemWrite( &item->gpuTime.queryId, uint16_t( tail + idx ) );
MemWrite( &item->gpuTime.queryId, uint16_t( wrappedTail + idx ) );
MemWrite( &item->gpuTime.context, m_context );
Profiler::QueueSerialFinish();
}
Expand All @@ -310,7 +315,7 @@ class VkCtx
}
}

VK_FUNCTION_WRAPPER( vkCmdResetQueryPool( cmdbuf, m_query, tail, cnt ) );
VK_FUNCTION_WRAPPER( vkCmdResetQueryPool( cmdbuf, m_query, wrappedTail, cnt ) );

m_tail += cnt;
}
Expand Down

0 comments on commit 0341819

Please sign in to comment.