diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp index 17e1a8800..a62c3f681 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp @@ -53,7 +53,7 @@ namespace Nz using BindingStorage = std::aligned_storage_t; Bitset freeBindings; - Vk::DescriptorPool descriptorPool; + std::unique_ptr descriptorPool; std::unique_ptr storage; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index d6712c1b4..a601a3b02 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -145,9 +145,8 @@ namespace Nz inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept { - m_pool = descriptorSet.m_pool; - std::swap(m_handle, descriptorSet.m_handle); + std::swap(m_pool, descriptorSet.m_pool); return *this; } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index a8882e78a..7d7a9c333 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -83,8 +83,10 @@ namespace Nz } DescriptorPool pool; - if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); + pool.descriptorPool = std::make_unique(); + + if (!pool.descriptorPool->Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode())); pool.freeBindings.Resize(MaxSet, true); pool.storage = std::make_unique(MaxSet); @@ -100,10 +102,10 @@ namespace Nz if (freeBindingId == pool.freeBindings.npos) return {}; //< No free binding in this pool - Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + Vk::DescriptorSet descriptorSet = pool.descriptorPool->AllocateDescriptorSet(m_descriptorSetLayout); if (!descriptorSet) { - NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); + NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode())); return {}; }