Better error handling when GEVulkanDriver construction fails

This commit is contained in:
Benau 2022-07-01 12:52:07 +08:00
parent 34ae56d33a
commit dc168e1b13
2 changed files with 7 additions and 2 deletions

View File

@ -72,6 +72,8 @@ void GEVulkan2dRenderer::destroy()
delete g_tris_index_buffer; delete g_tris_index_buffer;
g_tris_index_buffer = NULL; g_tris_index_buffer = NULL;
if (!g_vk)
return;
vkDestroyDescriptorSetLayout(g_vk->getDevice(), g_descriptor_set_layout, vkDestroyDescriptorSetLayout(g_vk->getDevice(), g_descriptor_set_layout,
NULL); NULL);
vkDestroyDescriptorPool(g_vk->getDevice(), g_descriptor_pool, NULL); vkDestroyDescriptorPool(g_vk->getDevice(), g_descriptor_pool, NULL);

View File

@ -561,7 +561,8 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
catch (std::exception& e) catch (std::exception& e)
{ {
destroyVulkan(); destroyVulkan();
throw std::runtime_error("GEVulkanDriver constructor failed"); throw std::runtime_error(std::string(
"GEVulkanDriver constructor failed: ") + e.what());
} }
} // GEVulkanDriver } // GEVulkanDriver
@ -585,7 +586,9 @@ void GEVulkanDriver::destroyVulkan()
m_transparent_texture = NULL; m_transparent_texture = NULL;
} }
getVulkanMeshCache()->destroy(); if (m_irrlicht_device->getSceneManager() &&
m_irrlicht_device->getSceneManager()->getMeshCache())
getVulkanMeshCache()->destroy();
GEVulkan2dRenderer::destroy(); GEVulkan2dRenderer::destroy();
GEVulkanShaderManager::destroy(); GEVulkanShaderManager::destroy();