From 1d815e6ced74ed41ffa0a5405f9897fc2e475704 Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Thu, 27 Aug 2020 22:32:49 +0200 Subject: [PATCH] Better handling of device creation failure --- base/VulkanDevice.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/base/VulkanDevice.cpp b/base/VulkanDevice.cpp index b063334d..d19a1e9b 100644 --- a/base/VulkanDevice.cpp +++ b/base/VulkanDevice.cpp @@ -284,15 +284,16 @@ namespace vks deviceCreateInfo.ppEnabledExtensionNames = deviceExtensions.data(); } - VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &logicalDevice); + this->enabledFeatures = enabledFeatures; - if (result == VK_SUCCESS) + VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &logicalDevice); + if (result != VK_SUCCESS) { - // Create a default command pool for graphics command buffers - commandPool = createCommandPool(queueFamilyIndices.graphics); + return result; } - this->enabledFeatures = enabledFeatures; + // Create a default command pool for graphics command buffers + commandPool = createCommandPool(queueFamilyIndices.graphics); return result; }