mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 12:28:07 +02:00
vulkan/device_select: for vulkan 1.0 use vid/did for boot_vga
In device select layer EnumeratePhysicalDevices() function pci bus information is available only in case of vulkan >= 1.1. Hence use vid/did to match boot_vga device in case of vulkan 1.0. Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14535>
This commit is contained in:
parent
5b9bf3434f
commit
1cc549949d
1 changed files with 63 additions and 3 deletions
|
|
@ -308,6 +308,63 @@ static int device_select_find_dri_prime_tag_default(struct device_pci_info *pci_
|
|||
return default_idx;
|
||||
}
|
||||
|
||||
static int device_select_find_boot_vga_vid_did(struct device_pci_info *pci_infos,
|
||||
uint32_t device_count)
|
||||
{
|
||||
char path[1024];
|
||||
int fd;
|
||||
int default_idx = -1;
|
||||
uint8_t boot_vga = 0;
|
||||
ssize_t size_ret;
|
||||
#pragma pack(push, 1)
|
||||
struct id {
|
||||
uint16_t vid;
|
||||
uint16_t did;
|
||||
}id;
|
||||
#pragma pack(pop)
|
||||
|
||||
for (unsigned i = 0; i < 64; i++) {
|
||||
snprintf(path, 1023, "/sys/class/drm/card%d/device/boot_vga", i);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
uint8_t val;
|
||||
size_ret = read(fd, &val, 1);
|
||||
close(fd);
|
||||
if (size_ret == 1 && val == '1')
|
||||
boot_vga = 1;
|
||||
} else {
|
||||
return default_idx;
|
||||
}
|
||||
|
||||
if (boot_vga) {
|
||||
snprintf(path, 1023, "/sys/class/drm/card%d/device/config", i);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
size_ret = read(fd, &id, 4);
|
||||
close(fd);
|
||||
if (size_ret != 4)
|
||||
return default_idx;
|
||||
} else {
|
||||
return default_idx;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!boot_vga)
|
||||
return default_idx;
|
||||
|
||||
for (unsigned i = 0; i < device_count; ++i) {
|
||||
if (id.vid == pci_infos[i].dev_info.vendor_id &&
|
||||
id.did == pci_infos[i].dev_info.device_id) {
|
||||
default_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return default_idx;
|
||||
}
|
||||
|
||||
static int device_select_find_boot_vga_default(struct device_pci_info *pci_infos,
|
||||
uint32_t device_count)
|
||||
{
|
||||
|
|
@ -393,11 +450,14 @@ static uint32_t get_default_device(const struct instance_info *info,
|
|||
default_idx = device_select_find_wayland_pci_default(pci_infos, physical_device_count);
|
||||
if (default_idx == -1 && info->has_xcb)
|
||||
default_idx = device_select_find_xcb_pci_default(pci_infos, physical_device_count);
|
||||
if (default_idx == -1 && info->has_pci_bus)
|
||||
default_idx = device_select_find_boot_vga_default(pci_infos, physical_device_count);
|
||||
if (default_idx == -1) {
|
||||
if (info->has_vulkan11 && info->has_pci_bus)
|
||||
default_idx = device_select_find_boot_vga_default(pci_infos, physical_device_count);
|
||||
else
|
||||
default_idx = device_select_find_boot_vga_vid_did(pci_infos, physical_device_count);
|
||||
}
|
||||
if (default_idx == -1 && cpu_count)
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue