From e020eee6860cbf8397bc58fb09e67f5a1e86d34a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 11 Oct 2026 16:18:49 +0100 Subject: [PATCH] Added local ref_ptr<> reference to the DescriptorPool to prevent it's deletion when detacting DescriptorSet::Implementation --- src/vsg/vk/DescriptorPool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vsg/vk/DescriptorPool.cpp b/src/vsg/vk/DescriptorPool.cpp index f3062dc8a..c756d84a1 100644 --- a/src/vsg/vk/DescriptorPool.cpp +++ b/src/vsg/vk/DescriptorPool.cpp @@ -138,15 +138,15 @@ ref_ptr DescriptorPool::allocateDescriptorSet(Des void DescriptorPool::freeDescriptorSet(ref_ptr dsi) { + // keep this DescritporPool alive while we detach it from the DescriptorSet::Implementation + ref_ptr keepAlive(this); { - // swap ownership so that DescriptorSet::Implementation' reference is reset to null and while this DescriptorPool takes a reference to it. - // acquire lock within local scope so that subsequent dsi->_descriptorPool = {} call doesn't unref and (possibly) delete this DescriptorPool while lock still held. std::scoped_lock lock(mutex); _recyclingList.push_back(dsi); ++_availableDescriptorSet; accumulateBindings(_recycledDescriptorPoolSizes, dsi->_descriptorSetLayout, +1); + dsi->_descriptorPool = {}; } - dsi->_descriptorPool = {}; } bool DescriptorPool::available(uint32_t& numSets, DescriptorPoolSizes& availableDescriptorPoolSizes) const