Commit 5ba08e9d authored by Peng Huang's avatar Peng Huang Committed by Chromium LUCI CQ

Fix crash in vkGetPhysicalDeviceXcbPresentationSupportKHR()

I found the crash happens with NVidia driver, if an Intel GPU is being
used, but vkGetPhysicalDeviceXcbPresentationSupportKHR() is called
for NVidia device. Fix the problem by checking device id first,
and don't call vkGetPhysicalDeviceXcbPresentationSupportKHR(), if device
id doesn't match.

Bug: 1153027
Change-Id: Ib5b3b5f168ebd7665c31c8996148301c34ce34a2
Cq-Include-Trybots: luci.chromium.try:gpu-fyi-try-android-p-pixel-2-skv-32,gpu-fyi-try-linux-intel-skv,gpu-fyi-try-linux-nvidia-skv
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601065
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839014}
parent 8729ad68
...@@ -80,11 +80,26 @@ bool VulkanDeviceQueue::Initialize( ...@@ -80,11 +80,26 @@ bool VulkanDeviceQueue::Initialize(
if (device_properties.apiVersion < info.used_api_version) if (device_properties.apiVersion < info.used_api_version)
continue; continue;
// If gpu_info is provided, the device should match it.
if (gpu_info && (device_properties.vendorID != gpu_info->gpu.vendor_id ||
device_properties.deviceID != gpu_info->gpu.device_id)) {
continue;
}
if (device_properties.deviceType < 0 ||
device_properties.deviceType > VK_PHYSICAL_DEVICE_TYPE_CPU) {
DLOG(ERROR) << "Unsupported device type: "
<< device_properties.deviceType;
continue;
}
const VkPhysicalDevice& device = device_info.device; const VkPhysicalDevice& device = device_info.device;
bool found = false;
for (size_t n = 0; n < device_info.queue_families.size(); ++n) { for (size_t n = 0; n < device_info.queue_families.size(); ++n) {
if ((device_info.queue_families[n].queueFlags & queue_flags) != if ((device_info.queue_families[n].queueFlags & queue_flags) !=
queue_flags) queue_flags) {
continue; continue;
}
if (options & DeviceQueueOption::PRESENTATION_SUPPORT_QUEUE_FLAG && if (options & DeviceQueueOption::PRESENTATION_SUPPORT_QUEUE_FLAG &&
!get_presentation_support.Run(device, device_info.queue_families, !get_presentation_support.Run(device, device_info.queue_families,
...@@ -92,34 +107,26 @@ bool VulkanDeviceQueue::Initialize( ...@@ -92,34 +107,26 @@ bool VulkanDeviceQueue::Initialize(
continue; continue;
} }
// If gpu_info is provided, the device should match it.
if (gpu_info && (device_properties.vendorID != gpu_info->gpu.vendor_id ||
device_properties.deviceID != gpu_info->gpu.device_id)) {
continue;
}
if (device_properties.deviceType < 0 ||
device_properties.deviceType > VK_PHYSICAL_DEVICE_TYPE_CPU) {
DLOG(ERROR) << "Unsupported device type: "
<< device_properties.deviceType;
continue;
}
if (kDeviceTypeScores[device_properties.deviceType] > device_score) { if (kDeviceTypeScores[device_properties.deviceType] > device_score) {
device_index = i; device_index = i;
queue_index = static_cast<int>(n); queue_index = static_cast<int>(n);
device_score = kDeviceTypeScores[device_properties.deviceType]; device_score = kDeviceTypeScores[device_properties.deviceType];
found = true;
break;
} }
}
if (!found)
continue;
// Use the device, if it matches gpu_info. // Use the device, if it matches gpu_info.
if (gpu_info) if (gpu_info)
break; break;
// If the device is a discrete GPU, we will use it. Otherwise go through // If the device is a discrete GPU, we will use it. Otherwise go through
// all the devices and find the device with the highest score. // all the devices and find the device with the highest score.
if (device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) if (device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
break; break;
}
} }
if (device_index == -1) { if (device_index == -1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment