Commit 3bf4b9c1 authored by Brian Ho's avatar Brian Ho Committed by Commit Bot

Reland "gpu: Load vk functions for querying image/buffer properties"

Original CL: https://chromium-review.googlesource.com/1794142

The original CL was reverted due to using VK_VERSION_1_1 instead of
VK_API_VERSION_1_1 which causes Vulkan on Chrome to break for users with
Vulkan 1.0 or lower.

This CL reapplies the changes in the original CL but updates both the
new code and existing code with the proper version number.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1796527

BUG=996470
TEST=run ozone_test on a machine using Vulkan 1.0

Change-Id: I4fb7de01c6e7c24f88c3736c129bc08f822ba9a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1797245
Commit-Queue: Brian Ho <hob@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695627}
parent cf3bcb68
...@@ -70,10 +70,16 @@ VULKAN_INSTANCE_FUNCTIONS = [ ...@@ -70,10 +70,16 @@ VULKAN_INSTANCE_FUNCTIONS = [
'vkCreateImagePipeSurfaceFUCHSIA', 'vkCreateImagePipeSurfaceFUCHSIA',
] ]
}, },
{
'min_api_version': 'VK_API_VERSION_1_1',
'functions': [
'vkGetPhysicalDeviceImageFormatProperties2',
]
},
{ {
# vkGetPhysicalDeviceFeatures2() is defined in Vulkan 1.1 or suffixed in the # vkGetPhysicalDeviceFeatures2() is defined in Vulkan 1.1 or suffixed in the
# VK_KHR_get_physical_device_properties2 extension. # VK_KHR_get_physical_device_properties2 extension.
'min_api_version': 'VK_VERSION_1_1', 'min_api_version': 'VK_API_VERSION_1_1',
'extension': 'VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME', 'extension': 'VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME',
'extension_suffix': 'KHR', 'extension_suffix': 'KHR',
'functions': [ 'functions': [
...@@ -141,6 +147,12 @@ VULKAN_DEVICE_FUNCTIONS = [ ...@@ -141,6 +147,12 @@ VULKAN_DEVICE_FUNCTIONS = [
'vkWaitForFences', 'vkWaitForFences',
] ]
}, },
{
'min_api_version': 'VK_API_VERSION_1_1',
'functions': [
'vkGetImageMemoryRequirements2',
]
},
{ {
'ifdef': 'defined(OS_ANDROID)', 'ifdef': 'defined(OS_ANDROID)',
'extension': 'extension':
...@@ -161,7 +173,8 @@ VULKAN_DEVICE_FUNCTIONS = [ ...@@ -161,7 +173,8 @@ VULKAN_DEVICE_FUNCTIONS = [
'ifdef': 'defined(OS_LINUX)', 'ifdef': 'defined(OS_LINUX)',
'extension': 'VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME', 'extension': 'VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME',
'functions': [ 'functions': [
'vkGetMemoryFdKHR' 'vkGetMemoryFdKHR',
'vkGetMemoryFdPropertiesKHR',
] ]
}, },
{ {
......
...@@ -246,7 +246,19 @@ bool VulkanFunctionPointers::BindInstanceFunctionPointers( ...@@ -246,7 +246,19 @@ bool VulkanFunctionPointers::BindInstanceFunctionPointers(
} }
#endif // defined(OS_FUCHSIA) #endif // defined(OS_FUCHSIA)
if (api_version >= VK_VERSION_1_1) { if (api_version >= VK_API_VERSION_1_1) {
vkGetPhysicalDeviceImageFormatProperties2Fn =
reinterpret_cast<PFN_vkGetPhysicalDeviceImageFormatProperties2>(
vkGetInstanceProcAddrFn(
vk_instance, "vkGetPhysicalDeviceImageFormatProperties2"));
if (!vkGetPhysicalDeviceImageFormatProperties2Fn) {
DLOG(WARNING) << "Failed to bind vulkan entrypoint: "
<< "vkGetPhysicalDeviceImageFormatProperties2";
return false;
}
}
if (api_version >= VK_API_VERSION_1_1) {
vkGetPhysicalDeviceFeatures2Fn = vkGetPhysicalDeviceFeatures2Fn =
reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2>( reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2>(
vkGetInstanceProcAddrFn(vk_instance, vkGetInstanceProcAddrFn(vk_instance,
...@@ -715,6 +727,17 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers( ...@@ -715,6 +727,17 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(
return false; return false;
} }
if (api_version >= VK_API_VERSION_1_1) {
vkGetImageMemoryRequirements2Fn =
reinterpret_cast<PFN_vkGetImageMemoryRequirements2>(
vkGetDeviceProcAddrFn(vk_device, "vkGetImageMemoryRequirements2"));
if (!vkGetImageMemoryRequirements2Fn) {
DLOG(WARNING) << "Failed to bind vulkan entrypoint: "
<< "vkGetImageMemoryRequirements2";
return false;
}
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (gfx::HasExtension( if (gfx::HasExtension(
enabled_extensions, enabled_extensions,
...@@ -762,6 +785,15 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers( ...@@ -762,6 +785,15 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(
<< "vkGetMemoryFdKHR"; << "vkGetMemoryFdKHR";
return false; return false;
} }
vkGetMemoryFdPropertiesKHRFn =
reinterpret_cast<PFN_vkGetMemoryFdPropertiesKHR>(
vkGetDeviceProcAddrFn(vk_device, "vkGetMemoryFdPropertiesKHR"));
if (!vkGetMemoryFdPropertiesKHRFn) {
DLOG(WARNING) << "Failed to bind vulkan entrypoint: "
<< "vkGetMemoryFdPropertiesKHR";
return false;
}
} }
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
......
...@@ -107,6 +107,9 @@ struct VulkanFunctionPointers { ...@@ -107,6 +107,9 @@ struct VulkanFunctionPointers {
nullptr; nullptr;
#endif // defined(OS_FUCHSIA) #endif // defined(OS_FUCHSIA)
PFN_vkGetPhysicalDeviceImageFormatProperties2
vkGetPhysicalDeviceImageFormatProperties2Fn = nullptr;
PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2Fn = nullptr; PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2Fn = nullptr;
// Device functions // Device functions
...@@ -165,6 +168,8 @@ struct VulkanFunctionPointers { ...@@ -165,6 +168,8 @@ struct VulkanFunctionPointers {
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr; PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr;
PFN_vkWaitForFences vkWaitForFencesFn = nullptr; PFN_vkWaitForFences vkWaitForFencesFn = nullptr;
PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2Fn = nullptr;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
PFN_vkGetAndroidHardwareBufferPropertiesANDROID PFN_vkGetAndroidHardwareBufferPropertiesANDROID
vkGetAndroidHardwareBufferPropertiesANDROIDFn = nullptr; vkGetAndroidHardwareBufferPropertiesANDROIDFn = nullptr;
...@@ -177,6 +182,7 @@ struct VulkanFunctionPointers { ...@@ -177,6 +182,7 @@ struct VulkanFunctionPointers {
#if defined(OS_LINUX) #if defined(OS_LINUX)
PFN_vkGetMemoryFdKHR vkGetMemoryFdKHRFn = nullptr; PFN_vkGetMemoryFdKHR vkGetMemoryFdKHRFn = nullptr;
PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHRFn = nullptr;
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_FUCHSIA) #if defined(OS_FUCHSIA)
...@@ -261,6 +267,9 @@ struct VulkanFunctionPointers { ...@@ -261,6 +267,9 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkCreateImagePipeSurfaceFUCHSIAFn gpu::GetVulkanFunctionPointers()->vkCreateImagePipeSurfaceFUCHSIAFn
#endif // defined(OS_FUCHSIA) #endif // defined(OS_FUCHSIA)
#define vkGetPhysicalDeviceImageFormatProperties2 \
gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceImageFormatProperties2Fn
#define vkGetPhysicalDeviceFeatures2 \ #define vkGetPhysicalDeviceFeatures2 \
gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceFeatures2Fn gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceFeatures2Fn
...@@ -350,6 +359,9 @@ struct VulkanFunctionPointers { ...@@ -350,6 +359,9 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn
#define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn #define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn
#define vkGetImageMemoryRequirements2 \
gpu::GetVulkanFunctionPointers()->vkGetImageMemoryRequirements2Fn
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#define vkGetAndroidHardwareBufferPropertiesANDROID \ #define vkGetAndroidHardwareBufferPropertiesANDROID \
gpu::GetVulkanFunctionPointers() \ gpu::GetVulkanFunctionPointers() \
...@@ -365,6 +377,8 @@ struct VulkanFunctionPointers { ...@@ -365,6 +377,8 @@ struct VulkanFunctionPointers {
#if defined(OS_LINUX) #if defined(OS_LINUX)
#define vkGetMemoryFdKHR gpu::GetVulkanFunctionPointers()->vkGetMemoryFdKHRFn #define vkGetMemoryFdKHR gpu::GetVulkanFunctionPointers()->vkGetMemoryFdKHRFn
#define vkGetMemoryFdPropertiesKHR \
gpu::GetVulkanFunctionPointers()->vkGetMemoryFdPropertiesKHRFn
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_FUCHSIA) #if defined(OS_FUCHSIA)
......
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