Merge pull request #7214 from Jupeyy/pr_fix_vk_leak

Decrease descriptor pool's current size when descriptor is freed
This commit is contained in:
Robert Müller 2023-09-19 17:04:07 +00:00 committed by GitHub
commit 6a4318bf1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5853,6 +5853,15 @@ public:
return true;
}
void FreeDescriptorSetFromPool(SDeviceDescriptorSet &DescrSet)
{
if(DescrSet.m_PoolIndex != std::numeric_limits<size_t>::max())
{
vkFreeDescriptorSets(m_VKDevice, DescrSet.m_pPools->m_vPools[DescrSet.m_PoolIndex].m_Pool, 1, &DescrSet.m_Descriptor);
DescrSet.m_pPools->m_vPools[DescrSet.m_PoolIndex].m_CurSize -= 1;
}
}
[[nodiscard]] bool CreateNewTexturedStandardDescriptorSets(size_t TextureSlot, size_t DescrIndex)
{
auto &Texture = m_vTextures[TextureSlot];
@ -5894,8 +5903,7 @@ public:
void DestroyTexturedStandardDescriptorSets(CTexture &Texture, size_t DescrIndex)
{
auto &DescrSet = Texture.m_aVKStandardTexturedDescrSets[DescrIndex];
if(DescrSet.m_PoolIndex != std::numeric_limits<size_t>::max())
vkFreeDescriptorSets(m_VKDevice, DescrSet.m_pPools->m_vPools[DescrSet.m_PoolIndex].m_Pool, 1, &DescrSet.m_Descriptor);
FreeDescriptorSetFromPool(DescrSet);
DescrSet = {};
}
@ -5940,8 +5948,7 @@ public:
void DestroyTextured3DStandardDescriptorSets(CTexture &Texture)
{
auto &DescrSet = Texture.m_VKStandard3DTexturedDescrSet;
if(DescrSet.m_PoolIndex != std::numeric_limits<size_t>::max())
vkFreeDescriptorSets(m_VKDevice, DescrSet.m_pPools->m_vPools[DescrSet.m_PoolIndex].m_Pool, 1, &DescrSet.m_Descriptor);
FreeDescriptorSetFromPool(DescrSet);
}
[[nodiscard]] bool CreateNewTextDescriptorSets(size_t Texture, size_t TextureOutline)
@ -5991,8 +5998,7 @@ public:
void DestroyTextDescriptorSets(CTexture &Texture, CTexture &TextureOutline)
{
auto &DescrSet = Texture.m_VKTextDescrSet;
if(DescrSet.m_PoolIndex != std::numeric_limits<size_t>::max())
vkFreeDescriptorSets(m_VKDevice, DescrSet.m_pPools->m_vPools[DescrSet.m_PoolIndex].m_Pool, 1, &DescrSet.m_Descriptor);
FreeDescriptorSetFromPool(DescrSet);
}
[[nodiscard]] bool HasMultiSampling()