From d2b676b55109eceb222be3301382dd5170dde24b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 20 Dec 2017 00:16:59 +0100 Subject: [PATCH] [dxvk] Fixed descriptor pool leak --- src/dxvk/dxvk_descriptor.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/dxvk/dxvk_descriptor.cpp b/src/dxvk/dxvk_descriptor.cpp index 8e14e3fa..ada34b8a 100644 --- a/src/dxvk/dxvk_descriptor.cpp +++ b/src/dxvk/dxvk_descriptor.cpp @@ -5,7 +5,10 @@ namespace dxvk { DxvkDescriptorAlloc::DxvkDescriptorAlloc( const Rc& vkd) : m_vkd(vkd) { - + // Allocate one pool right away so that there + // is always at least one pool available when + // allocating a descriptor set + m_pools.push_back(createDescriptorPool()); } @@ -18,22 +21,15 @@ namespace dxvk { VkDescriptorSet DxvkDescriptorAlloc::alloc(VkDescriptorSetLayout layout) { - VkDescriptorSet set = VK_NULL_HANDLE; - - if (m_poolId < m_pools.size()) - set = this->allocFrom(m_pools.at(m_poolId), layout); + VkDescriptorSet set = allocFrom(m_pools.at(m_poolId), layout); if (set == VK_NULL_HANDLE) { - VkDescriptorPool pool = this->createDescriptorPool(); - set = this->allocFrom(pool, layout); + if (++m_poolId >= m_pools.size()) + m_pools.push_back(createDescriptorPool()); - if (set == VK_NULL_HANDLE) - throw DxvkError("DxvkDescriptorAlloc::alloc: Failed to allocate descriptor set"); - - m_pools.push_back(pool); - m_poolId += 1; + set = allocFrom(m_pools.at(m_poolId), layout); } - + return set; } @@ -73,7 +69,7 @@ namespace dxvk { VkDescriptorPool pool = VK_NULL_HANDLE; if (m_vkd->vkCreateDescriptorPool(m_vkd->device(), &info, nullptr, &pool) != VK_SUCCESS) - throw DxvkError("DxvkDescriptorAlloc::createDescriptorPool: Failed to create descriptor pool"); + throw DxvkError("DxvkDescriptorAlloc: Failed to create descriptor pool"); return pool; }