- make the VkHardwareTexture and VKBuffer linked lists private

This commit is contained in:
Magnus Norddahl 2019-04-30 19:49:29 +02:00
parent d985d98122
commit ab8378152f
5 changed files with 25 additions and 13 deletions

View file

@ -29,6 +29,12 @@ VKBuffer::~VKBuffer()
fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer)); 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() void VKBuffer::Reset()
{ {
if (mBuffer && map) if (mBuffer && map)

View file

@ -16,6 +16,7 @@ public:
VKBuffer(); VKBuffer();
~VKBuffer(); ~VKBuffer();
static void ResetAll();
void Reset(); void Reset();
void SetData(size_t size, const void *data, bool staticdata) override; void SetData(size_t size, const void *data, bool staticdata) override;
@ -28,15 +29,16 @@ public:
void *Lock(unsigned int size) override; void *Lock(unsigned int size) override;
void Unlock() override; void Unlock() override;
static VKBuffer *First;
VKBuffer *Prev = nullptr;
VKBuffer *Next = nullptr;
VkBufferUsageFlags mBufferType = 0; VkBufferUsageFlags mBufferType = 0;
std::unique_ptr<VulkanBuffer> mBuffer; std::unique_ptr<VulkanBuffer> mBuffer;
std::unique_ptr<VulkanBuffer> mStaging; std::unique_ptr<VulkanBuffer> mStaging;
bool mPersistent = false; bool mPersistent = false;
TArray<uint8_t> mStaticUpload; TArray<uint8_t> mStaticUpload;
private:
static VKBuffer *First;
VKBuffer *Prev = nullptr;
VKBuffer *Next = nullptr;
}; };
class VKVertexBuffer : public IVertexBuffer, public VKBuffer class VKVertexBuffer : public IVertexBuffer, public VKBuffer

View file

@ -94,12 +94,9 @@ VulkanFrameBuffer::VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevi
VulkanFrameBuffer::~VulkanFrameBuffer() VulkanFrameBuffer::~VulkanFrameBuffer()
{ {
// All descriptors must be destroyed before the descriptor pool in renderpass manager is destroyed // All descriptors must be destroyed before the descriptor pool in renderpass manager is destroyed
for (VkHardwareTexture *cur = VkHardwareTexture::First; cur; cur = cur->Next) VkHardwareTexture::ResetAll();
cur->Reset();
for (VKBuffer *cur = VKBuffer::First; cur; cur = cur->Next)
cur->Reset();
VKBuffer::ResetAll();
PPResource::ResetAll(); PPResource::ResetAll();
delete MatricesUBO; delete MatricesUBO;

View file

@ -56,6 +56,12 @@ VkHardwareTexture::~VkHardwareTexture()
Reset(); Reset();
} }
void VkHardwareTexture::ResetAll()
{
for (VkHardwareTexture *cur = VkHardwareTexture::First; cur; cur = cur->Next)
cur->Reset();
}
void VkHardwareTexture::Reset() void VkHardwareTexture::Reset()
{ {
if (auto fb = GetVulkanFrameBuffer()) if (auto fb = GetVulkanFrameBuffer())

View file

@ -23,6 +23,7 @@ public:
VkHardwareTexture(); VkHardwareTexture();
~VkHardwareTexture(); ~VkHardwareTexture();
static void ResetAll();
void Reset(); void Reset();
void Precache(FMaterial *mat, int translation, int flags); void Precache(FMaterial *mat, int translation, int flags);
@ -37,10 +38,6 @@ public:
// Wipe screen // Wipe screen
void CreateWipeTexture(int w, int h, const char *name); 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); VulkanImage *GetImage(FTexture *tex, int translation, int flags);
VulkanImageView *GetImageView(FTexture *tex, int translation, int flags); VulkanImageView *GetImageView(FTexture *tex, int translation, int flags);
@ -55,6 +52,10 @@ private:
void ResetDescriptors(); void ResetDescriptors();
static VkHardwareTexture *First;
VkHardwareTexture *Prev = nullptr;
VkHardwareTexture *Next = nullptr;
struct DescriptorEntry struct DescriptorEntry
{ {
int clampmode; int clampmode;