Add workaround for qualcomm vulkan AHDARDWAREBUFFER_USAGE_VENDER_0
Test: manual building and testing on device. Bugs related to lack of
flag go away.
Bug: 128923272
Change-Id: I2457988c097d73020162947c346a8716d373185e
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index ac62ff4..4011329 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -172,6 +172,8 @@
LOG_ALWAYS_FATAL_IF(physDeviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0));
mDriverVersion = physDeviceProperties.driverVersion;
+ mIsQualcomm = physDeviceProperties.vendorID == 20803;
+
// query to get the initial queue props size
uint32_t queueCount;
mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, nullptr);
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index 54333f3..a7a43cc 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -181,6 +181,13 @@
SwapBehavior mSwapBehavior = SwapBehavior::Discard;
GrVkExtensions mExtensions;
uint32_t mDriverVersion = 0;
+
+ // TODO: Remove once fix has landed. Temporaryly needed for workaround for setting up AHB
+ // surfaces on Qualcomm. Currently if you don't use VkSwapchain Qualcomm is not setting
+ // reporting that we need to use one of their private vendor usage bits which greatly effects
+ // performance if it is not used.
+ bool mIsQualcomm = false;
+ bool isQualcomm() const { return mIsQualcomm; }
};
} /* namespace renderthread */
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp
index 3fed6b0..36f540c 100644
--- a/libs/hwui/renderthread/VulkanSurface.cpp
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -299,6 +299,10 @@
}
windowInfo.windowUsageFlags = hwbUsage.androidHardwareBufferUsage;
+ if (vkManager.isQualcomm()) {
+ windowInfo.windowUsageFlags =
+ windowInfo.windowUsageFlags | AHARDWAREBUFFER_USAGE_VENDOR_0;
+ }
} else {
ALOGE("VulkanSurface::Create() vkmGetPhysicalDeviceImageFormatProperties2 is missing");