diff --git a/Libraries/LibGfx/VulkanContext.cpp b/Libraries/LibGfx/VulkanContext.cpp index c7f0bb0b6a0..c5e884003b6 100644 --- a/Libraries/LibGfx/VulkanContext.cpp +++ b/Libraries/LibGfx/VulkanContext.cpp @@ -75,14 +75,19 @@ static ErrorOr create_logical_device(VkPhysicalDevice physical_device) queue_families.resize(queue_family_count); vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, queue_families.data()); - int graphics_queue_family_index = -1; - for (int i = 0; i < static_cast(queue_families.size()); i++) { - if (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { - graphics_queue_family_index = i; + bool graphics_queue_family_found = false; + uint32_t graphics_queue_family_index = 0; + for (; graphics_queue_family_index < queue_families.size(); ++graphics_queue_family_index) { + if (queue_families[graphics_queue_family_index].queueFlags & VK_QUEUE_GRAPHICS_BIT) { + graphics_queue_family_found = true; break; } } + if (!graphics_queue_family_found) { + return Error::from_string_literal("Graphics queue family not found"); + } + VkDeviceQueueCreateInfo queue_create_info {}; queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queue_create_info.queueFamilyIndex = graphics_queue_family_index;