From 53e3eee9eeac184125cb9003ed00ba58a12748d9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 17 Jun 2018 20:56:46 +0200 Subject: [PATCH] Delay query until results are available. This will query for the new values with a bit of lag, but it ignores issues with broken drivers... --- TracyVulkan.hpp | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/TracyVulkan.hpp b/TracyVulkan.hpp index 1e4fdace..1dcb9b83 100644 --- a/TracyVulkan.hpp +++ b/TracyVulkan.hpp @@ -40,6 +40,7 @@ public: , m_context( s_vkCtxCounter.fetch_add( 1, std::memory_order_relaxed ) ) , m_head( 0 ) , m_tail( 0 ) + , m_oldCnt( 0 ) { VkPhysicalDeviceProperties prop; vkGetPhysicalDeviceProperties( physdev, &prop ); @@ -107,31 +108,22 @@ public: if( m_tail == m_head ) return; - auto cnt = m_head < m_tail ? QueryCount - m_tail : m_head - m_tail; - int64_t res[QueryCount]; - - // 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 cnt; + if( m_oldCnt != 0 ) { - unsigned int idx; - for( idx=0; idx