From 0bbdd86b866129769df31e8c769a8ef84cd6c5c6 Mon Sep 17 00:00:00 2001 From: Jaan Soulier Date: Tue, 26 Aug 2025 21:33:57 -0400 Subject: [PATCH] Fix device suitability checks in Vulkan GPU backend to always adhere to priority arrays --- src/gpu/vulkan/SDL_gpu_vulkan.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index e8b9b21406..bd2c7d41dd 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -11274,14 +11274,20 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable( renderer->vkGetPhysicalDeviceProperties( physicalDevice, &deviceProperties); - if (*deviceRank < devicePriority[deviceProperties.deviceType]) { + + /* Apply a large bias on the devicePriority so that we always respect the order in the priority arrays. + * We also rank by e.g. VRAM which should have less influence than the device type. + */ + Uint64 devicePriorityValue = devicePriority[deviceProperties.deviceType] * 1000000; + + if (*deviceRank < devicePriorityValue) { /* This device outranks the best device we've found so far! * This includes a dedicated GPU that has less features than an * integrated GPU, because this is a freak case that is almost * never intentionally desired by the end user */ - *deviceRank = devicePriority[deviceProperties.deviceType]; - } else if (*deviceRank > devicePriority[deviceProperties.deviceType]) { + *deviceRank = devicePriorityValue; + } else if (*deviceRank > devicePriorityValue) { /* Device is outranked by a previous device, don't even try to * run a query and reset the rank to avoid overwrites */