mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 20:43:15 +00:00
Manage postprocess texture lifetimes in the same way as for hw textures
This commit is contained in:
parent
b3316fbe21
commit
ef802b85e7
4 changed files with 39 additions and 5 deletions
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "vk_pptexture.h"
|
||||
#include "vk_texture.h"
|
||||
#include "vulkan/system/vk_framebuffer.h"
|
||||
#include "vulkan/system/vk_commandbuffer.h"
|
||||
|
||||
|
@ -91,13 +92,22 @@ VkPPTexture::VkPPTexture(VulkanFrameBuffer* fb, PPTexture *texture)
|
|||
barrier.addImage(&TexImage, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true);
|
||||
barrier.execute(fb->GetCommands()->GetTransferCommands());
|
||||
}
|
||||
|
||||
fb->GetTextureManager()->AddPPTexture(this);
|
||||
}
|
||||
|
||||
VkPPTexture::~VkPPTexture()
|
||||
{
|
||||
if (TexImage.Image) fb->GetCommands()->FrameDeleteList.Images.push_back(std::move(TexImage.Image));
|
||||
if (TexImage.View) fb->GetCommands()->FrameDeleteList.ImageViews.push_back(std::move(TexImage.View));
|
||||
if (TexImage.DepthOnlyView) fb->GetCommands()->FrameDeleteList.ImageViews.push_back(std::move(TexImage.DepthOnlyView));
|
||||
if (TexImage.PPFramebuffer) fb->GetCommands()->FrameDeleteList.Framebuffers.push_back(std::move(TexImage.PPFramebuffer));
|
||||
if (Staging) fb->GetCommands()->FrameDeleteList.Buffers.push_back(std::move(Staging));
|
||||
if (fb)
|
||||
fb->GetTextureManager()->RemovePPTexture(this);
|
||||
}
|
||||
|
||||
void VkPPTexture::Reset()
|
||||
{
|
||||
if (fb)
|
||||
{
|
||||
TexImage.Reset(fb);
|
||||
if (Staging)
|
||||
fb->GetCommands()->FrameDeleteList.Buffers.push_back(std::move(Staging));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "hwrenderer/postprocessing/hw_postprocess.h"
|
||||
#include "vulkan/system/vk_objects.h"
|
||||
#include "vulkan/textures/vk_imagetransition.h"
|
||||
#include <list>
|
||||
|
||||
class VulkanFrameBuffer;
|
||||
|
||||
|
@ -13,7 +14,10 @@ public:
|
|||
VkPPTexture(VulkanFrameBuffer* fb, PPTexture *texture);
|
||||
~VkPPTexture();
|
||||
|
||||
void Reset();
|
||||
|
||||
VulkanFrameBuffer* fb = nullptr;
|
||||
std::list<VkPPTexture*>::iterator it;
|
||||
|
||||
VkTextureImage TexImage;
|
||||
std::unique_ptr<VulkanBuffer> Staging;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "vk_texture.h"
|
||||
#include "vk_hwtexture.h"
|
||||
#include "vk_pptexture.h"
|
||||
|
||||
VkTextureManager::VkTextureManager(VulkanFrameBuffer* fb) : fb(fb)
|
||||
{
|
||||
|
@ -31,6 +32,8 @@ VkTextureManager::~VkTextureManager()
|
|||
{
|
||||
while (!Textures.empty())
|
||||
RemoveTexture(Textures.back());
|
||||
while (!PPTextures.empty())
|
||||
RemovePPTexture(PPTextures.back());
|
||||
}
|
||||
|
||||
void VkTextureManager::AddTexture(VkHardwareTexture* texture)
|
||||
|
@ -44,3 +47,15 @@ void VkTextureManager::RemoveTexture(VkHardwareTexture* texture)
|
|||
texture->fb = nullptr;
|
||||
Textures.erase(texture->it);
|
||||
}
|
||||
|
||||
void VkTextureManager::AddPPTexture(VkPPTexture* texture)
|
||||
{
|
||||
texture->it = PPTextures.insert(PPTextures.end(), texture);
|
||||
}
|
||||
|
||||
void VkTextureManager::RemovePPTexture(VkPPTexture* texture)
|
||||
{
|
||||
texture->Reset();
|
||||
texture->fb = nullptr;
|
||||
PPTextures.erase(texture->it);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
class VulkanFrameBuffer;
|
||||
class VkHardwareTexture;
|
||||
class VkMaterial;
|
||||
class VkPPTexture;
|
||||
|
||||
class VkTextureManager
|
||||
{
|
||||
|
@ -17,8 +18,12 @@ public:
|
|||
void AddTexture(VkHardwareTexture* texture);
|
||||
void RemoveTexture(VkHardwareTexture* texture);
|
||||
|
||||
void AddPPTexture(VkPPTexture* texture);
|
||||
void RemovePPTexture(VkPPTexture* texture);
|
||||
|
||||
private:
|
||||
VulkanFrameBuffer* fb = nullptr;
|
||||
|
||||
std::list<VkHardwareTexture*> Textures;
|
||||
std::list<VkPPTexture*> PPTextures;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue