device_select_layer: apply DRI_PRIME even if default device is > 1 to match opengl behavior

This fixes DRI_PRIME=1 doing nothing if the GPU order is [dGPU, dGPU,
iGPU, cpu] (or more GPUs than that) and the iGPU is the default GPU.

Fixes: afa1fba1 ("vulkan/device_select: don't pick a cpu driver as the default")

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19101>
This commit is contained in:
Luna Nova 2023-01-15 16:09:04 -08:00 committed by Mike Blumenkrantz
parent 7fcda2b4e3
commit f958a45a71

View file

@ -457,8 +457,7 @@ static uint32_t get_default_device(const struct instance_info *info,
default_idx = device_select_find_non_cpu(pci_infos, physical_device_count);
/* DRI_PRIME=1 handling - pick any other device than default. */
if (default_idx != -1 && dri_prime_is_one && physical_device_count > (cpu_count + 1)) {
if (default_idx == 0 || default_idx == 1)
default_idx = find_non_cpu_skip(pci_infos, physical_device_count, default_idx);
default_idx = find_non_cpu_skip(pci_infos, physical_device_count, default_idx);
}
free(pci_infos);
return default_idx == -1 ? 0 : default_idx;