diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-10-01 15:30:02 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-10-01 15:30:02 +0000 |
| commit | cf9c56aae857803ad4d3f1d624941317ccb9f96e (patch) | |
| tree | a41f91620e0c9eda140db502a85bd05cc05172e8 /Graphics/GraphicsEngineVulkan | |
| parent | Multiple minor updates to resource lifetime management system in Vk backend (diff) | |
| download | DiligentCore-cf9c56aae857803ad4d3f1d624941317ccb9f96e.tar.gz DiligentCore-cf9c56aae857803ad4d3f1d624941317ccb9f96e.zip | |
Added few extra debug checks to Vk backend
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
3 files changed, 34 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h index 3ff54944..a0200ee6 100644 --- a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h +++ b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h @@ -149,6 +149,10 @@ public: RenderDeviceVkImpl& GetDeviceVkImpl() {return m_DeviceVkImpl;} +#ifdef DEVELOPMENT + int32_t GetAllocatedPoolCounter()const{return m_AllocatedPoolCounter;} +#endif + protected: VulkanUtilities::DescriptorPoolWrapper CreateDescriptorPool(const char* DebugName)const; @@ -186,10 +190,20 @@ public: { } + ~DescriptorSetAllocator(); + DescriptorSetAllocation Allocate(Uint64 CommandQueueMask, VkDescriptorSetLayout SetLayout); +#ifdef DEVELOPMENT + int32_t GetAllocatedDescriptorSetCounter()const{return m_AllocatedSetCounter;} +#endif + private: void FreeDescriptorSet(VkDescriptorSet Set, VkDescriptorPool Pool, Uint64 QueueMask); + +#ifdef DEVELOPMENT + std::atomic_int32_t m_AllocatedSetCounter = 0; +#endif }; diff --git a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp index 20d9fac6..cd2cb7a1 100644 --- a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp @@ -144,6 +144,11 @@ static VkDescriptorSet AllocateDescriptorSet(const VulkanUtilities::VulkanLogica } +DescriptorSetAllocator::~DescriptorSetAllocator() +{ + DEV_CHECK_ERR(m_AllocatedSetCounter == 0, m_AllocatedSetCounter, " descriptor set(s) have not been returned to the allocator. If there are outstanding references to the sets in release queues, the app will crash when DescriptorSetAllocator::FreeDescriptorSet() is called"); +} + DescriptorSetAllocation DescriptorSetAllocator::Allocate(Uint64 CommandQueueMask, VkDescriptorSetLayout SetLayout) { // Descriptor pools are externally synchronized, meaning that the application must not allocate @@ -163,6 +168,10 @@ DescriptorSetAllocation DescriptorSetAllocator::Allocate(Uint64 CommandQueueMask { std::swap(*it, m_Pools.front()); } + +#ifdef DEVELOPMENT + ++m_AllocatedSetCounter; +#endif return {Set, Pool, CommandQueueMask, *this}; } } @@ -175,6 +184,10 @@ DescriptorSetAllocation DescriptorSetAllocator::Allocate(Uint64 CommandQueueMask auto Set = AllocateDescriptorSet(LogicalDevice, NewPool, SetLayout, ""); DEV_CHECK_ERR(Set != VK_NULL_HANDLE, "Failed to allocate descriptor set"); +#ifdef DEVELOPMENT + ++m_AllocatedSetCounter; +#endif + return {Set, NewPool, CommandQueueMask, *this }; } @@ -211,6 +224,9 @@ void DescriptorSetAllocator::FreeDescriptorSet(VkDescriptorSet Set, VkDescriptor { std::lock_guard<std::mutex> Lock(Allocator->m_Mutex); Allocator->m_DeviceVkImpl.GetLogicalDevice().FreeDescriptorSet(Pool, Set); +#ifdef DEVELOPMENT + --Allocator->m_AllocatedSetCounter; +#endif } } diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index f29dfa3c..62772d92 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -139,7 +139,10 @@ RenderDeviceVkImpl::~RenderDeviceVkImpl() ReleaseStaleResources(true); - VERIFY(m_TransientCmdPoolMgr.GetAllocatedPoolCount() == 0, "All allocated transient command pools must have been released now. If there are outstanding references to the pools in release queues, the app will crash when CommandPoolManager::FreeCommandPool() is called."); + DEV_CHECK_ERR(m_DescriptorSetAllocator.GetAllocatedDescriptorSetCounter() == 0, "All allocated descriptor sets must have been released now."); + DEV_CHECK_ERR(m_TransientCmdPoolMgr.GetAllocatedPoolCount() == 0, "All allocated transient command pools must have been released now. If there are outstanding references to the pools in release queues, the app will crash when CommandPoolManager::FreeCommandPool() is called."); + DEV_CHECK_ERR(m_DynamicDescriptorPool.GetAllocatedPoolCounter() == 0, "All allocated dynamic descriptor pools must have been released now."); + DEV_CHECK_ERR(m_DynamicMemoryManager.GetMasterBlockCounter() == 0, "All allocated dynamic master blocks must have been returned to the pool."); // Immediately destroys all command pools m_TransientCmdPoolMgr.DestroyPools(); |
