summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/driver.cpp
diff options
context:
space:
mode:
author Chris Forbes <chrisforbes@google.com> 2021-07-22 13:54:04 -0700
committer Chris Forbes <chrisforbes@google.com> 2021-07-22 16:34:28 -0700
commite056c12782125c3ad5876f3ac7528d9889808675 (patch)
treedc26e936a537161c979c723489e749c57a2a0d0f /vulkan/libvulkan/driver.cpp
parent14e6c209231f199ccd4b4d5f0cd6e1f60bafda91 (diff)
Inline GetPhysicalDeviceProperties2 into QueryPresentationProperties
In general, we implement the 1.1 instance / physical device API as preferring to call the native 1.1 function if available; otherwise falling back to calling the equivalent GPDP2 function. If the underlying driver supports *neither* then any caller of that function has already invoked UB by calling it and so falling over is acceptable. Unfortunately, the loader itself does call vkGetPhysicalDeviceProperties2 in one case, regardless of what the driver may support, in order to determine whether the platform's swapchain implementation should expose some features. On a 1.0 driver without the GPDP2 extension, this caused trouble. As a slight further wrinkle, vkGetPhysicalDeviceProperties2 "cannot fail", making propagating a failure back up through the loader annoying. As a workaround, inline the calls to GetPhysicalDeviceProperties2 and GetPhysicalDeviceProperties2KHR into QueryPresentationProperties, where we can handle our one special case of both function pointers being missing but behavior being defined. Bug: b/192130684 Change-Id: Iff2bae98b7931bed80fafd895cf57061becabd8d
Diffstat (limited to 'vulkan/libvulkan/driver.cpp')
-rw-r--r--vulkan/libvulkan/driver.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index d7fdab5586..cf774fd9b8 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -979,6 +979,8 @@ VkResult EnumerateInstanceExtensionProperties(
void QueryPresentationProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties) {
+ ATRACE_CALL();
+
// Request the android-specific presentation properties via GPDP2
VkPhysicalDeviceProperties2 properties = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
@@ -994,7 +996,17 @@ void QueryPresentationProperties(
presentation_properties->pNext = nullptr;
presentation_properties->sharedImage = VK_FALSE;
- GetPhysicalDeviceProperties2(physicalDevice, &properties);
+ const auto& driver = GetData(physicalDevice).driver;
+
+ if (driver.GetPhysicalDeviceProperties2) {
+ // >= 1.1 driver, supports core GPDP2 entrypoint.
+ driver.GetPhysicalDeviceProperties2(physicalDevice, &properties);
+ } else if (driver.GetPhysicalDeviceProperties2KHR) {
+ // Old driver, but may support presentation properties
+ // if we have the GPDP2 extension. Otherwise, no presentation
+ // properties supported.
+ driver.GetPhysicalDeviceProperties2KHR(physicalDevice, &properties);
+ }
}
VkResult EnumerateDeviceExtensionProperties(