mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- delay destruction of VkHardwareTexture resources until current frame has finished rendering
This commit is contained in:
parent
c00a46043d
commit
29a30037cb
4 changed files with 34 additions and 4 deletions
|
@ -13,7 +13,7 @@ VKBuffer::~VKBuffer()
|
|||
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
if (fb && mBuffer)
|
||||
fb->mFrameDeleteList.push_back(std::move(mBuffer));
|
||||
fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer));
|
||||
}
|
||||
|
||||
void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
||||
|
|
|
@ -99,6 +99,8 @@ VulkanFrameBuffer::~VulkanFrameBuffer()
|
|||
delete mViewpoints;
|
||||
delete mLights;
|
||||
mShadowMap.Reset();
|
||||
|
||||
DeleteFrameObjects();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::InitializeState()
|
||||
|
@ -205,13 +207,21 @@ void VulkanFrameBuffer::Update()
|
|||
|
||||
mDrawCommands.reset();
|
||||
mUploadCommands.reset();
|
||||
mFrameDeleteList.clear();
|
||||
DeleteFrameObjects();
|
||||
|
||||
Finish.Unclock();
|
||||
|
||||
Super::Update();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::DeleteFrameObjects()
|
||||
{
|
||||
FrameDeleteList.Images.clear();
|
||||
FrameDeleteList.ImageViews.clear();
|
||||
FrameDeleteList.Buffers.clear();
|
||||
FrameDeleteList.Descriptors.clear();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::SubmitCommands(bool finish)
|
||||
{
|
||||
mDrawCommands->end();
|
||||
|
@ -270,7 +280,7 @@ void VulkanFrameBuffer::SubmitCommands(bool finish)
|
|||
vkResetFences(device->device, 1, &mRenderFinishedFence->fence);
|
||||
mDrawCommands.reset();
|
||||
mUploadCommands.reset();
|
||||
mFrameDeleteList.clear();
|
||||
DeleteFrameObjects();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,14 @@ public:
|
|||
|
||||
std::unique_ptr<IIndexBuffer> FanToTrisIndexBuffer;
|
||||
|
||||
std::vector<std::unique_ptr<VulkanBuffer>> mFrameDeleteList;
|
||||
class DeleteList
|
||||
{
|
||||
public:
|
||||
std::vector<std::unique_ptr<VulkanImage>> Images;
|
||||
std::vector<std::unique_ptr<VulkanImageView>> ImageViews;
|
||||
std::vector<std::unique_ptr<VulkanBuffer>> Buffers;
|
||||
std::vector<std::unique_ptr<VulkanDescriptorSet>> Descriptors;
|
||||
} FrameDeleteList;
|
||||
|
||||
std::unique_ptr<SWSceneDrawer> swdrawer;
|
||||
|
||||
|
@ -95,6 +102,7 @@ private:
|
|||
void SubmitCommands(bool finish);
|
||||
void CopyScreenToBuffer(int w, int h, void *data);
|
||||
void UpdateShadowMap();
|
||||
void DeleteFrameObjects();
|
||||
|
||||
std::unique_ptr<VkShaderManager> mShaderManager;
|
||||
std::unique_ptr<VkSamplerManager> mSamplerManager;
|
||||
|
|
|
@ -52,6 +52,18 @@ VkHardwareTexture::~VkHardwareTexture()
|
|||
if (Next) Next->Prev = Prev;
|
||||
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.second));
|
||||
mDescriptorSets.clear();
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue