From 1ca52f424e4aac8a31a36b72910efec014cd9c4c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 24 Jul 2018 09:46:45 -0700 Subject: Added extra debug checks to ~DeviceContextVkImpl() --- Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h | 6 ++++++ .../include/VulkanUtilities/VulkanDescriptorPool.h | 5 +++++ Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp | 10 ++++++++++ Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 2 ++ 4 files changed, 23 insertions(+) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h index af4f8dd7..2777a78e 100644 --- a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h +++ b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h @@ -128,6 +128,12 @@ public: DescriptorPoolAllocation Allocate(VkDescriptorSetLayout SetLayout); void DisposeAllocations(uint64_t FenceValue); void ReleaseStaleAllocations(uint64_t LastCompletedFence); + + size_t GetStaleAllocationCount()const + { + return m_ReleasedAllocations.size(); + } + size_t GetPendingReleaseAllocationCount(); private: friend class DescriptorPoolAllocation; diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h index 34bbb99d..7a429147 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h +++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h @@ -48,6 +48,11 @@ namespace VulkanUtilities void ReleaseDiscardedSets(uint64_t LastCompletedFence); DescriptorPoolWrapper&& Release(); + + size_t GetDiscardedSetCount()const + { + return m_DiscardedSets.size(); + } private: // Shared point to logical device must be defined before the command pool diff --git a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp index d6c22d8a..45cba04d 100644 --- a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp @@ -112,4 +112,14 @@ void DescriptorPoolManager::ReleaseStaleAllocations(uint64_t LastCompletedFence) Pool->ReleaseDiscardedSets(LastCompletedFence); } +size_t DescriptorPoolManager::GetPendingReleaseAllocationCount() +{ + size_t count = 0; + std::lock_guard Lock(m_Mutex); + for(auto &Pool : m_DescriptorPools) + count += Pool->GetDiscardedSetCount(); + return count; +} + + } diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 1d9c4e05..39e7d744 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -142,9 +142,11 @@ namespace Diligent // moved to the release queue by Flush(). For deferred contexts, this should have happened in the last FinishCommandList() // call. VERIFY(m_ReleaseQueue.GetStaleResourceCount() == 0, "All stale resources must have been discarded at this point"); + VERIFY(m_DynamicDescriptorPool.GetStaleAllocationCount() == 0, "All stale dynamic descriptor set allocations must have been discarded at this point"); ReleaseStaleContextResources(m_NextCmdBuffNumber, pDeviceVkImpl->GetNextFenceValue(), pDeviceVkImpl->GetCompletedFenceValue()); // Since we idled the GPU, all stale resources must have been destroyed now VERIFY(m_ReleaseQueue.GetPendingReleaseResourceCount() == 0, "All stale resources must have been destroyed at this point"); + VERIFY(m_DynamicDescriptorPool.GetPendingReleaseAllocationCount() == 0, "All stale descriptor set allocations must have been destroyed at this point"); auto VkCmdPool = m_CmdPool.Release(); pDeviceVkImpl->SafeReleaseVkObject(std::move(VkCmdPool)); -- cgit v1.2.3