Commit 215f5237 authored by Peng Huang's avatar Peng Huang Committed by Chromium LUCI CQ

Fix crash for calling vkGetPhysicalDeviceProperties2()

The crash in vkGetPhysicalDeviceProperties2() which is supported
by Vulkan 1.1.0. The Vulkan loader may support 1.1.0, but the
device may not support 1.1.0, so we need check device API version
before calling it.

Bug: 1158768
Change-Id: Ib306feda2c4b790ef06e5802e4777744bf1c4892
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593548
Commit-Queue: Peng Huang <penghuang@chromium.org>
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837122}
parent 4522fbe2
......@@ -265,17 +265,7 @@ bool VulkanInstance::CollectInfo() {
auto& info = vulkan_info_.physical_devices.back();
info.device = device;
info.driver_properties = VkPhysicalDeviceDriverProperties{
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES,
};
VkPhysicalDeviceProperties2 properties2 = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
.pNext = &info.driver_properties,
};
vkGetPhysicalDeviceProperties2(device, &properties2);
info.properties = properties2.properties;
vkGetPhysicalDeviceProperties(device, &info.properties);
count = 0;
result = vkEnumerateDeviceExtensionProperties(
......@@ -292,9 +282,20 @@ bool VulkanInstance::CollectInfo() {
// The API version of the VkInstance might be different than the supported
// API version of the VkPhysicalDevice, so we need to check the GPU's
// API version instead of just testing to see if
// vkGetPhysicalDeviceFeatures2 is non-null.
// vkGetPhysicalDeviceProperties2 and vkGetPhysicalDeviceFeatures2 are
// non-null.
static_assert(kVulkanRequiredApiVersion >= VK_API_VERSION_1_1, "");
if (info.properties.apiVersion >= kVulkanRequiredApiVersion) {
info.driver_properties = VkPhysicalDeviceDriverProperties{
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES,
};
VkPhysicalDeviceProperties2 properties2 = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
.pNext = &info.driver_properties,
};
vkGetPhysicalDeviceProperties2(device, &properties2);
VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr_conversion_features =
{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES};
VkPhysicalDeviceProtectedMemoryFeatures protected_memory_feature = {
......
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