diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-11 13:34:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-11 13:34:38 +0200 |
commit | ba82626c2c050bf73e2ef6c78181fddfed42cfe5 (patch) | |
tree | 7c109c5c8f543e860d5753dacf0865d700e8e633 | |
parent | 9aedc020c37ed383c1829222d4b83a9a2cb66b59 (diff) | |
parent | 36130e5a051ea9b0875a6bed07b0ddaa47443585 (diff) |
Merge pull request #49506 from akien-mga/vulkan_prefer_discrete_gpu
Prefer discrete GPU over integrated one
-rw-r--r-- | drivers/vulkan/vulkan_context.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 38455bdbed..23c0a64568 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -694,8 +694,25 @@ Error VulkanContext::_create_physical_device() { free(physical_devices); ERR_FAIL_V(ERR_CANT_CREATE); } - /* for now, just grab the first physical device */ + + // TODO: At least on Linux Laptops integrated GPUs fail with Vulkan in many instances. + // The device should really be a preference, but for now choosing a discrete GPU over the + // integrated one is better than the default. + + // Default to first device uint32_t device_index = 0; + + for (uint32_t i = 0; i < gpu_count; ++i) { + VkPhysicalDeviceProperties props; + vkGetPhysicalDeviceProperties(physical_devices[i], &props); + + if (props.deviceType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { + // Prefer discrete GPU. + device_index = i; + break; + } + } + gpu = physical_devices[device_index]; free(physical_devices); |