Add error messages if Vulkan init failed, prevent Vulkan context freeing uninitialized device and instance.
This commit is contained in:
@@ -344,6 +344,8 @@ Error VulkanContext::_create_physical_device() {
|
||||
"Please look at the Getting Started guide for additional information.\n"
|
||||
"vkCreateInstance Failure");
|
||||
|
||||
inst_initialized = true;
|
||||
|
||||
/* Make initial call to query gpu_count, then second call for gpu info*/
|
||||
err = vkEnumeratePhysicalDevices(inst, &gpu_count, nullptr);
|
||||
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
|
||||
@@ -1133,6 +1135,7 @@ Error VulkanContext::initialize() {
|
||||
return err;
|
||||
}
|
||||
|
||||
device_initialized = true;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1584,15 +1587,21 @@ VulkanContext::~VulkanContext() {
|
||||
if (queue_props) {
|
||||
free(queue_props);
|
||||
}
|
||||
for (uint32_t i = 0; i < FRAME_LAG; i++) {
|
||||
vkDestroyFence(device, fences[i], nullptr);
|
||||
vkDestroySemaphore(device, image_acquired_semaphores[i], nullptr);
|
||||
vkDestroySemaphore(device, draw_complete_semaphores[i], nullptr);
|
||||
if (separate_present_queue) {
|
||||
vkDestroySemaphore(device, image_ownership_semaphores[i], nullptr);
|
||||
if (device_initialized) {
|
||||
for (uint32_t i = 0; i < FRAME_LAG; i++) {
|
||||
vkDestroyFence(device, fences[i], nullptr);
|
||||
vkDestroySemaphore(device, image_acquired_semaphores[i], nullptr);
|
||||
vkDestroySemaphore(device, draw_complete_semaphores[i], nullptr);
|
||||
if (separate_present_queue) {
|
||||
vkDestroySemaphore(device, image_ownership_semaphores[i], nullptr);
|
||||
}
|
||||
}
|
||||
if (inst_initialized) {
|
||||
DestroyDebugUtilsMessengerEXT(inst, dbg_messenger, nullptr);
|
||||
}
|
||||
vkDestroyDevice(device, nullptr);
|
||||
}
|
||||
if (inst_initialized) {
|
||||
vkDestroyInstance(inst, nullptr);
|
||||
}
|
||||
DestroyDebugUtilsMessengerEXT(inst, dbg_messenger, nullptr);
|
||||
vkDestroyDevice(device, nullptr);
|
||||
vkDestroyInstance(inst, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user