Prevent crash when trying to release buffer from already destroyed memory pool

This commit is contained in:
Georg Hagen
2024-08-21 15:45:46 +02:00
parent 6f19758beb
commit 35515c7902
5 changed files with 7 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ namespace OpenVulkano::Vulkan
~ManagedBuffer()
{
allocation->device.destroy(buffer);
if (allocation) [[likely]] allocation->device.destroy(buffer);
}
[[nodiscard]] bool IsLast() const

View File

@@ -23,6 +23,8 @@ namespace OpenVulkano::Vulkan
{
if (memPool->FreeBuffer(buffer)) return;
}
Logger::RENDER->error("Attempted to released buffer to pool, but owning pool no longer exists!");
buffer->allocation = nullptr; // Allocation is no longer valid since owning pool is gone already
delete buffer;
}

View File

@@ -98,6 +98,7 @@ namespace OpenVulkano::Vulkan
{
transferQueue.waitIdle();
transferQueue = nullptr;
OnShutdown(this); // Notify all custom resources that it's time to die
geometries.clear();
nodes.clear();
textures.clear();

View File

@@ -14,6 +14,7 @@
#include "IShaderOwner.hpp"
#include "MemoryPool.hpp"
#include "Base/Wrapper.hpp"
#include "Base/Event.hpp"
#include "Base/Render/IResourceManager.hpp"
#include "Vulkan/Image.hpp"
#include "Scene/Shader/DescriptorInputDescription.hpp"
@@ -134,6 +135,8 @@ namespace OpenVulkano
vk::DescriptorSetLayout* GetDescriptorLayoutSet(const DescriptorSetLayoutBinding& descriptorSetLayoutBinding);
VulkanShader* CreateShader(Scene::Shader* shader);
Event<ResourceManager*> OnShutdown;
};
}
}