From d3dacfc2cb2f2de97ce14c187e33fb3d71e1cdd2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 9 Apr 2019 12:28:25 +0200 Subject: [PATCH] - improve error handling during vulkan initialization --- src/rendering/vulkan/system/vk_device.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rendering/vulkan/system/vk_device.cpp b/src/rendering/vulkan/system/vk_device.cpp index a30292247..0dd90f75d 100644 --- a/src/rendering/vulkan/system/vk_device.cpp +++ b/src/rendering/vulkan/system/vk_device.cpp @@ -112,6 +112,8 @@ bool VulkanDevice::CheckRequiredFeatures(const VkPhysicalDeviceFeatures &f) void VulkanDevice::SelectPhysicalDevice() { AvailableDevices = GetPhysicalDevices(instance); + if (AvailableDevices.empty()) + I_Error("No Vulkan devices found. Either the graphics card has no vulkan support or the driver is too old."); for (size_t idx = 0; idx < AvailableDevices.size(); idx++) { @@ -426,6 +428,8 @@ std::vector VulkanDevice::GetPhysicalDevices(VkInstance in { uint32_t deviceCount = 0; VkResult result = vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr); + if (result != VK_ERROR_INITIALIZATION_FAILED) // Some drivers return this when a card does not support vulkan + return {}; if (result != VK_SUCCESS) I_Error("vkEnumeratePhysicalDevices failed"); if (deviceCount == 0)