From 9353ba11d33c945329dd546433037154ad834bbd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 22 May 2020 12:47:28 +0200 Subject: [PATCH] Add error handling when no physical device is found References: https://github.com/Plagman/gamescope/issues/49 --- src/rendervulkan.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp index 28c6da8..f09cc94 100644 --- a/src/rendervulkan.cpp +++ b/src/rendervulkan.cpp @@ -452,7 +452,7 @@ CVulkanTexture::~CVulkanTexture( void ) int init_device() { - uint32_t physicalDeviceCount; + uint32_t physicalDeviceCount = 0; VkPhysicalDevice deviceHandles[MAX_DEVICE_COUNT]; VkQueueFamilyProperties queueFamilyProperties[MAX_QUEUE_COUNT]; @@ -481,6 +481,12 @@ int init_device() break; } } + + if (!physicalDevice) + { + fprintf(stderr, "Failed to find physical device\n"); + return false; + } vkGetPhysicalDeviceMemoryProperties( physicalDevice, &memoryProperties );