diff --git a/TracyVulkan.hpp b/TracyVulkan.hpp index 632101df..1e4fdace 100644 --- a/TracyVulkan.hpp +++ b/TracyVulkan.hpp @@ -107,16 +107,38 @@ public: if( m_tail == m_head ) return; + auto cnt = m_head < m_tail ? QueryCount - m_tail : m_head - m_tail; int64_t res[QueryCount]; - const auto cnt = m_head < m_tail ? QueryCount - m_tail : m_head - m_tail; - vkGetQueryPoolResults( m_device, m_query, m_tail, cnt, sizeof( res ), res, sizeof( *res ), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT ); + + // This memset is required, because Nvidia drivers seem to break Vulkan spec: "If VK_QUERY_RESULT_WITH_AVAILABILITY_BIT + // is set, the final integer value written for each query is non-zero if the query's status was available or zero if the + // status was unavailable." + // Nvidia drivers in some cases do not write the non-zero value, even if the following zero values are written. + memset( res, 0xFF, sizeof( *res ) * cnt ); + + if( vkGetQueryPoolResults( m_device, m_query, m_tail, cnt, sizeof( res ), res, sizeof( *res ), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT ) == VK_NOT_READY ) + { + unsigned int idx; + for( idx=0; idxget_tail_index(); - unsigned int idx; - for( idx=0; idx