Skip to content

Commit

Permalink
Decrease descriptor pool's current size when descriptor is freed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupeyy committed Sep 19, 2023
1 parent c47a045 commit fcbe429
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/engine/client/backend/vulkan/backend_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5853,6 +5853,15 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
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];
Expand Down Expand Up @@ -5894,8 +5903,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
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 = {};
}

Expand Down Expand Up @@ -5940,8 +5948,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
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)
Expand Down Expand Up @@ -5991,8 +5998,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
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()
Expand Down

0 comments on commit fcbe429

Please sign in to comment.