- use a linked list to keep track of all allocated VkHardwareTexture objects

This commit is contained in:
Magnus Norddahl 2019-03-01 18:31:33 +01:00
parent c691a8fe64
commit 308c884d02
4 changed files with 16 additions and 7 deletions

View file

@ -66,6 +66,10 @@ VulkanFrameBuffer::VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevi
VulkanFrameBuffer::~VulkanFrameBuffer()
{
// All descriptors must be destroyed before the descriptor pool in renderpass manager is destroyed
for (VkHardwareTexture *cur = VkHardwareTexture::First; cur; cur = cur->Next)
cur->Reset();
delete MatricesUBO;
delete ColorsUBO;
delete GlowingWallsUBO;
@ -73,8 +77,6 @@ VulkanFrameBuffer::~VulkanFrameBuffer()
delete mSkyData;
delete mViewpoints;
delete mLights;
for (auto tex : AllTextures)
tex->Reset();
}
void VulkanFrameBuffer::InitializeState()
@ -277,9 +279,7 @@ void VulkanFrameBuffer::CleanForRestart()
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture()
{
auto texture = new VkHardwareTexture();
AllTextures.Push(texture);
return texture;
return new VkHardwareTexture();
}
FModelRenderer *VulkanFrameBuffer::CreateModelRenderer(int mli)

View file

@ -86,8 +86,6 @@ private:
int lastSwapWidth = 0;
int lastSwapHeight = 0;
TArray<VkHardwareTexture*> AllTextures;
};
inline VulkanFrameBuffer *GetVulkanFrameBuffer() { return static_cast<VulkanFrameBuffer*>(screen); }

View file

@ -37,12 +37,19 @@
#include "vulkan/renderer/vk_renderpass.h"
#include "vk_hwtexture.h"
VkHardwareTexture *VkHardwareTexture::First = nullptr;
VkHardwareTexture::VkHardwareTexture()
{
Next = First;
First = this;
if (Next) Next->Prev = this;
}
VkHardwareTexture::~VkHardwareTexture()
{
if (Next) Next->Prev = Prev;
if (!Prev) First = Next;
}
void VkHardwareTexture::Reset()

View file

@ -32,6 +32,10 @@ public:
uint8_t *MapBuffer() override;
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name) override;
static VkHardwareTexture *First;
VkHardwareTexture *Prev = nullptr;
VkHardwareTexture *Next = nullptr;
private:
VulkanImageView *GetImageView(FTexture *tex, int clampmode, int translation, int flags);