diff --git a/src/rendering/vulkan/system/vk_buffers.cpp b/src/rendering/vulkan/system/vk_buffers.cpp index f1e94ac63..d02899568 100644 --- a/src/rendering/vulkan/system/vk_buffers.cpp +++ b/src/rendering/vulkan/system/vk_buffers.cpp @@ -29,6 +29,12 @@ VKBuffer::~VKBuffer() fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer)); } +void VKBuffer::ResetAll() +{ + for (VKBuffer *cur = VKBuffer::First; cur; cur = cur->Next) + cur->Reset(); +} + void VKBuffer::Reset() { if (mBuffer && map) diff --git a/src/rendering/vulkan/system/vk_buffers.h b/src/rendering/vulkan/system/vk_buffers.h index 57ab7d923..b0bedfd42 100644 --- a/src/rendering/vulkan/system/vk_buffers.h +++ b/src/rendering/vulkan/system/vk_buffers.h @@ -16,6 +16,7 @@ public: VKBuffer(); ~VKBuffer(); + static void ResetAll(); void Reset(); void SetData(size_t size, const void *data, bool staticdata) override; @@ -28,15 +29,16 @@ public: void *Lock(unsigned int size) override; void Unlock() override; - static VKBuffer *First; - VKBuffer *Prev = nullptr; - VKBuffer *Next = nullptr; - VkBufferUsageFlags mBufferType = 0; std::unique_ptr mBuffer; std::unique_ptr mStaging; bool mPersistent = false; TArray mStaticUpload; + +private: + static VKBuffer *First; + VKBuffer *Prev = nullptr; + VKBuffer *Next = nullptr; }; class VKVertexBuffer : public IVertexBuffer, public VKBuffer diff --git a/src/rendering/vulkan/system/vk_framebuffer.cpp b/src/rendering/vulkan/system/vk_framebuffer.cpp index 2c765bc46..95f74b172 100644 --- a/src/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/rendering/vulkan/system/vk_framebuffer.cpp @@ -94,12 +94,9 @@ 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(); - - for (VKBuffer *cur = VKBuffer::First; cur; cur = cur->Next) - cur->Reset(); + VkHardwareTexture::ResetAll(); + VKBuffer::ResetAll(); PPResource::ResetAll(); delete MatricesUBO; diff --git a/src/rendering/vulkan/textures/vk_hwtexture.cpp b/src/rendering/vulkan/textures/vk_hwtexture.cpp index 3964235d2..6f077bdab 100644 --- a/src/rendering/vulkan/textures/vk_hwtexture.cpp +++ b/src/rendering/vulkan/textures/vk_hwtexture.cpp @@ -56,6 +56,12 @@ VkHardwareTexture::~VkHardwareTexture() Reset(); } +void VkHardwareTexture::ResetAll() +{ + for (VkHardwareTexture *cur = VkHardwareTexture::First; cur; cur = cur->Next) + cur->Reset(); +} + void VkHardwareTexture::Reset() { if (auto fb = GetVulkanFrameBuffer()) diff --git a/src/rendering/vulkan/textures/vk_hwtexture.h b/src/rendering/vulkan/textures/vk_hwtexture.h index 78524b103..f7f84277f 100644 --- a/src/rendering/vulkan/textures/vk_hwtexture.h +++ b/src/rendering/vulkan/textures/vk_hwtexture.h @@ -23,6 +23,7 @@ public: VkHardwareTexture(); ~VkHardwareTexture(); + static void ResetAll(); void Reset(); void Precache(FMaterial *mat, int translation, int flags); @@ -37,10 +38,6 @@ public: // Wipe screen void CreateWipeTexture(int w, int h, const char *name); - static VkHardwareTexture *First; - VkHardwareTexture *Prev = nullptr; - VkHardwareTexture *Next = nullptr; - VulkanImage *GetImage(FTexture *tex, int translation, int flags); VulkanImageView *GetImageView(FTexture *tex, int translation, int flags); @@ -55,6 +52,10 @@ private: void ResetDescriptors(); + static VkHardwareTexture *First; + VkHardwareTexture *Prev = nullptr; + VkHardwareTexture *Next = nullptr; + struct DescriptorEntry { int clampmode;