mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- postponed destruction of Vulkan resources
Provided uniform way to handle lifetime of some of Vulkan resources This helps to avoid issues like descriptor set that outlives its pool https://forum.zdoom.org/viewtopic.php?t=64341
This commit is contained in:
parent
8d36f0a0cf
commit
dffe45835d
4 changed files with 29 additions and 16 deletions
|
@ -33,6 +33,15 @@ void VkRenderPassManager::RenderBuffersReset()
|
|||
|
||||
void VkRenderPassManager::TextureSetPoolReset()
|
||||
{
|
||||
if (auto fb = GetVulkanFrameBuffer())
|
||||
{
|
||||
auto &deleteList = fb->FrameDeleteList;
|
||||
|
||||
for (auto &desc : TextureDescriptorPools)
|
||||
{
|
||||
deleteList.DescriptorPools.push_back(std::move(desc));
|
||||
}
|
||||
}
|
||||
TextureDescriptorPools.clear();
|
||||
TextureDescriptorSetsLeft = 0;
|
||||
TextureDescriptorsLeft = 0;
|
||||
|
|
|
@ -188,6 +188,7 @@ void VulkanFrameBuffer::DeleteFrameObjects()
|
|||
FrameDeleteList.ImageViews.clear();
|
||||
FrameDeleteList.Buffers.clear();
|
||||
FrameDeleteList.Descriptors.clear();
|
||||
FrameDeleteList.DescriptorPools.clear();
|
||||
FrameDeleteList.CommandBuffers.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
std::vector<std::unique_ptr<VulkanImageView>> ImageViews;
|
||||
std::vector<std::unique_ptr<VulkanBuffer>> Buffers;
|
||||
std::vector<std::unique_ptr<VulkanDescriptorSet>> Descriptors;
|
||||
std::vector<std::unique_ptr<VulkanDescriptorPool>> DescriptorPools;
|
||||
std::vector<std::unique_ptr<VulkanCommandBuffer>> CommandBuffers;
|
||||
} FrameDeleteList;
|
||||
|
||||
|
|
|
@ -53,32 +53,34 @@ VkHardwareTexture::~VkHardwareTexture()
|
|||
if (Prev) Prev->Next = Next;
|
||||
else First = Next;
|
||||
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
if (fb)
|
||||
{
|
||||
auto &deleteList = fb->FrameDeleteList;
|
||||
for (auto &it : mDescriptorSets)
|
||||
{
|
||||
deleteList.Descriptors.push_back(std::move(it.descriptor));
|
||||
it.descriptor = nullptr;
|
||||
Reset();
|
||||
}
|
||||
mDescriptorSets.clear();
|
||||
|
||||
void VkHardwareTexture::Reset()
|
||||
{
|
||||
if (auto fb = GetVulkanFrameBuffer())
|
||||
{
|
||||
ResetDescriptors();
|
||||
|
||||
auto &deleteList = fb->FrameDeleteList;
|
||||
if (mImage) deleteList.Images.push_back(std::move(mImage));
|
||||
if (mImageView) deleteList.ImageViews.push_back(std::move(mImageView));
|
||||
if (mStagingBuffer) deleteList.Buffers.push_back(std::move(mStagingBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
void VkHardwareTexture::Reset()
|
||||
{
|
||||
mDescriptorSets.clear();
|
||||
mImage.reset();
|
||||
mImageView.reset();
|
||||
mStagingBuffer.reset();
|
||||
}
|
||||
|
||||
void VkHardwareTexture::ResetDescriptors()
|
||||
{
|
||||
if (auto fb = GetVulkanFrameBuffer())
|
||||
{
|
||||
auto &deleteList = fb->FrameDeleteList;
|
||||
|
||||
for (auto &it : mDescriptorSets)
|
||||
{
|
||||
deleteList.Descriptors.push_back(std::move(it.descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
mDescriptorSets.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue