Commit cf6b0582 authored by Brian Ho's avatar Brian Ho Committed by Commit Bot

gpu: Check Vulkan API version before calling 1.1 functions

To load the Vulkan instance function pointers, we currently use the
Vulkan API version of the VkInstance (returned via
vkEnumerateInstanceVersion) which refers to the maximum supported
version of the Vulkan implementation on the system. The actual hardware,
however, may only support up to an earlier API version. When the API
versions differ between the VkInstance and the VkPhysicalDevices, the
spec mandates that you must use the lowest API version [1].

More concretely, this bug manifests in Chrome when the VkInstance
supports 1.1, but the GPU only supports 1.0. In this case, we load
1.1-specific functions like vkGetPhysicalDeviceFeatures2, but when we
actually try to run them on our 1.0 VkPhysicalDevice, the GPU process
crashes [2].

This CL fixes this bug by explicitly checking the VkPhysicalDevice's
API version instead of just seeing if vkGetPhysicalDeviceFeatures2 is
non-null.

[1] https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPhysicalDeviceProperties.html
[2] https://cs.chromium.org/chromium/src/gpu/vulkan/vulkan_instance.cc?l=282&rcl=cf2dfbbe19a94a77242a325388eeaeb62f530483

Bug: 1012880
Change-Id: I5e60bae02cf47e3c94f0ac9ba1ed60c0712e8d8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1853871Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704822}
parent a8b4350b
...@@ -269,7 +269,11 @@ void VulkanInstance::CollectInfo() { ...@@ -269,7 +269,11 @@ void VulkanInstance::CollectInfo() {
DLOG_IF(ERROR, result != VK_SUCCESS) DLOG_IF(ERROR, result != VK_SUCCESS)
<< "vkEnumerateDeviceLayerProperties failed: " << result; << "vkEnumerateDeviceLayerProperties failed: " << result;
if (vkGetPhysicalDeviceFeatures2) { // 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.
if (info.properties.apiVersion >= VK_MAKE_VERSION(1, 1, 0)) {
VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr_converson_features = VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr_converson_features =
{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES}; {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES};
VkPhysicalDeviceProtectedMemoryFeatures protected_memory_feature = { 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