Properly handle resource clean up

This commit is contained in:
Exzap 2024-12-05 12:33:21 +01:00
parent e97493b2a1
commit d59e17b105
2 changed files with 8 additions and 6 deletions

View File

@ -336,7 +336,9 @@ VKRBuffer::~VKRBuffer()
{
if (m_mappedMemory)
vkUnmapMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_bufferMemory);
if (m_bufferMemory != VK_NULL_HANDLE)
vkFreeMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_bufferMemory, nullptr);
if (m_buffer != VK_NULL_HANDLE)
vkDestroyBuffer(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_buffer, nullptr);
}

View File

@ -679,6 +679,9 @@ VulkanRenderer::~VulkanRenderer()
vkDestroyDebugUtilsMessengerEXT(m_instance, m_debugCallback, nullptr);
}
// destroy memory manager
delete memoryManager;
// destroy instance, devices
if (m_instance != VK_NULL_HANDLE)
{
@ -690,9 +693,6 @@ VulkanRenderer::~VulkanRenderer()
vkDestroyInstance(m_instance, nullptr);
}
// destroy memory manager
delete memoryManager;
// crashes?
//glslang::FinalizeProcess();
}