From c93c265681ab2d505b893ef224dc3752ba86ce54 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 1 Nov 2023 15:18:41 +0000 Subject: [PATCH] Wait for GPU before destroying counter query pools The get query results uses VK_QUERY_RESULT_WAIT_BIT option which makes destroying the query pool safe (the validation layers must not handle this case or it isn't specified behaviour). This change adds a GPU sync which removes the following validation error. The GPU has already been waited on by the queries using VK_QUERY_RESULT_WAIT_BIT options. Validation Error: [ VUID-vkDestroyQueryPool-queryPool-00793 ] | MessageID = 0x5ef3bf2b | Cannot call vkDestroyQueryPool on VkQueryPool 0xf49d4000000029b[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to queryPool must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.261.1/windows/1.3-extensions/vkspec.html#VUID-vkDestroyQueryPool-queryPool-00793) --- renderdoc/driver/vulkan/vk_counters.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_counters.cpp b/renderdoc/driver/vulkan/vk_counters.cpp index 9282bfaf9..3bdb1d76e 100644 --- a/renderdoc/driver/vulkan/vk_counters.cpp +++ b/renderdoc/driver/vulkan/vk_counters.cpp @@ -690,6 +690,8 @@ rdcarray VulkanReplay::FetchCountersKHR(const rdcarraySubmitCmds(); + m_pDriver->FlushQ(); ObjDisp(dev)->DestroyQueryPool(Unwrap(dev), queryPool, NULL); @@ -1021,6 +1023,8 @@ rdcarray VulkanReplay::FetchCounters(const rdcarray & sizeof(uint64_t) * timeStampData.size(), &timeStampData[0], sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT); CheckVkResult(vkr); + m_pDriver->SubmitCmds(); + m_pDriver->FlushQ(); ObjDisp(dev)->DestroyQueryPool(Unwrap(dev), timeStampPool, NULL);