device_select_layer: pick a default device before applying DRI_PRIME

This ensures DRI_PRIME works if there are multiple CPU devices available

Suggested by @pepp

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>
(cherry picked from commit 571ce2e481)
This commit is contained in:
Luna Nova 2023-01-15 16:12:59 -08:00 committed by Dylan Baker
parent f220932fd6
commit a2e6a1f0db
2 changed files with 11 additions and 2 deletions

View File

@ -6464,7 +6464,7 @@
"description": "device_select_layer: pick a default device before applying DRI_PRIME",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "afa1fba198f44b904efe6dddb323679c105dcfdf",
"notes": null

View File

@ -452,8 +452,17 @@ static uint32_t get_default_device(const struct instance_info *info,
else
default_idx = device_select_find_boot_vga_vid_did(pci_infos, physical_device_count);
}
if (default_idx == -1 && cpu_count)
/* If no GPU has been selected so far, select the first non-CPU device. If none are available,
* pick the first CPU device.
*/
if (default_idx == -1) {
default_idx = device_select_find_non_cpu(pci_infos, physical_device_count);
if (default_idx != -1) {
/* device_select_find_non_cpu picked a default, do nothing */
} else if (cpu_count) {
default_idx = 0;
}
}
/* DRI_PRIME=1 handling - pick any other device than default. */
if (default_idx != -1 && dri_prime_is_one && physical_device_count > (cpu_count + 1)) {
default_idx = find_non_cpu_skip(pci_infos, physical_device_count, default_idx);