From 13cab1c0b61176059a568724721e4043fd1e4234 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 10 Jun 2019 09:13:56 +0200 Subject: [PATCH] - delay postprocess texture destruction until the end of the frame --- src/rendering/vulkan/renderer/vk_postprocess.cpp | 11 +++++++++++ src/rendering/vulkan/renderer/vk_postprocess.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/rendering/vulkan/renderer/vk_postprocess.cpp b/src/rendering/vulkan/renderer/vk_postprocess.cpp index ab37dd9f1..3f0cc6ea3 100644 --- a/src/rendering/vulkan/renderer/vk_postprocess.cpp +++ b/src/rendering/vulkan/renderer/vk_postprocess.cpp @@ -402,6 +402,17 @@ VkPPTexture::VkPPTexture(PPTexture *texture) } } +VkPPTexture::~VkPPTexture() +{ + if (auto fb = GetVulkanFrameBuffer()) + { + if (TexImage.Image) fb->FrameDeleteList.Images.push_back(std::move(TexImage.Image)); + if (TexImage.View) fb->FrameDeleteList.ImageViews.push_back(std::move(TexImage.View)); + if (TexImage.DepthOnlyView) fb->FrameDeleteList.ImageViews.push_back(std::move(TexImage.DepthOnlyView)); + if (Staging) fb->FrameDeleteList.Buffers.push_back(std::move(Staging)); + } +} + ///////////////////////////////////////////////////////////////////////////// VkPPShader::VkPPShader(PPShader *shader) diff --git a/src/rendering/vulkan/renderer/vk_postprocess.h b/src/rendering/vulkan/renderer/vk_postprocess.h index fa50bebca..07f524f86 100644 --- a/src/rendering/vulkan/renderer/vk_postprocess.h +++ b/src/rendering/vulkan/renderer/vk_postprocess.h @@ -88,6 +88,7 @@ class VkPPTexture : public PPTextureBackend { public: VkPPTexture(PPTexture *texture); + ~VkPPTexture(); VkTextureImage TexImage; std::unique_ptr Staging;