From 3dddd004d3622b7e0d7bad5dea52d622657585e5 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 10 Jan 2020 20:48:02 -0800 Subject: Fixed few issues with queries --- .../include/VulkanUtilities/VulkanCommandBuffer.h | 4 ++-- Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 2 ++ Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp | 5 +++-- Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp | 10 +++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h index ef454910..786a2059 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h +++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h @@ -201,8 +201,8 @@ public: m_State.FramebufferHeight = 0; if (m_State.InsidePassQueries != 0) { - LOG_ERROR_MESSAGE("There are outstanding queries that have been started inside the render pass, but have " - "not been ended. Vulkan requires that a query must either begin and end inside the same " + LOG_ERROR_MESSAGE("Ending render pass while there are outstanding queries that have been started inside the pass, " + "but have not been ended. Vulkan requires that a query must either begin and end inside the same " "subpass of a render pass instance, or must both begin and end outside of a render pass " "instance (i.e. contain entire render pass instances). (17.2)"); } diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 5af8012f..e8b254a8 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1186,6 +1186,8 @@ void DeviceContextVkImpl::ResetRenderTargets() TDeviceContextBase::ResetRenderTargets(); m_RenderPass = VK_NULL_HANDLE; m_Framebuffer = VK_NULL_HANDLE; + if (m_CommandBuffer.GetVkCmdBuffer() != VK_NULL_HANDLE && m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE) + m_CommandBuffer.EndRenderPass(); } void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl* pBuffVk, diff --git a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp index 44b84e78..548c497b 100644 --- a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp @@ -136,9 +136,10 @@ QueryManagerVk::~QueryManagerVk() for (Uint32 QueryType = QUERY_TYPE_UNDEFINED + 1; QueryType < QUERY_TYPE_NUM_TYPES; ++QueryType) { auto& HeapInfo = m_Heaps[QueryType]; - if (HeapInfo.AvailableQueries.size() != HeapInfo.PoolSize) + + auto OutstandingQueries = HeapInfo.PoolSize - (HeapInfo.AvailableQueries.size() + HeapInfo.StaleQueries.size()); + if (OutstandingQueries != 0) { - auto OutstandingQueries = HeapInfo.PoolSize - HeapInfo.AvailableQueries.size(); if (OutstandingQueries == 1) { LOG_ERROR_MESSAGE("One query of type ", GetQueryTypeString(static_cast(QueryType)), diff --git a/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp index 3eb95eba..abd1567e 100644 --- a/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp @@ -53,9 +53,13 @@ QueryVkImpl::QueryVkImpl(IReferenceCounters* pRefCounters, QueryVkImpl::~QueryVkImpl() { - auto* pQueryMgr = m_pContext.RawPtr()->GetQueryManager(); - VERIFY_EXPR(pQueryMgr != nullptr); - pQueryMgr->DiscardQuery(m_Desc.Type, m_QueryPoolIndex); + if (m_QueryPoolIndex != QueryManagerVk::InvalidIndex) + { + VERIFY(m_pContext != nullptr, "Device context is not initialized"); + auto* pQueryMgr = m_pContext.RawPtr()->GetQueryManager(); + VERIFY_EXPR(pQueryMgr != nullptr); + pQueryMgr->DiscardQuery(m_Desc.Type, m_QueryPoolIndex); + } } bool QueryVkImpl::AllocateQuery() -- cgit v1.2.3