summaryrefslogtreecommitdiff
path: root/drivers/vulkan/vulkan_context.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-07-14 09:03:25 +0200
committerGitHub <noreply@github.com>2020-07-14 09:03:25 +0200
commit28e8347d6cb1e5e8945ba62b9678849046038bb6 (patch)
tree8e04d15eac7b6d4cba1b55e57452399a31a584de /drivers/vulkan/vulkan_context.cpp
parent41802d83975a52a4f6c23de0bceaa0e055031ee1 (diff)
parent996910b62706774792bde4934e23ef5bde37fc32 (diff)
Merge pull request #40354 from bruvzg/add_vulkan_init_message
Display error popup instead of crashing if Vulkan init failed.
Diffstat (limited to 'drivers/vulkan/vulkan_context.cpp')
-rw-r--r--drivers/vulkan/vulkan_context.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index a8a29aaeea..e064a4ad6a 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -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);
}