Revert "Turn on vk unit tests"
This reverts commit aa3e498bbc9825b8c07a2094dc83e15b6bb47ffc.
Reason for revert: Synchronization with WebView is hard.
Also:
* All currently shipping devices that turn Vulkan on for HWUI support at
least two graphics queues, with the exception of emulators using
swiftshader.
* Using two graphics queues doesn't significantly regress RAM on those
devices
Bug: 280564832
Test: DailyMail app
Change-Id: Ica0c461af9df771292967ed10df63b2aa6902ae3
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 763bc63..8e0eb08 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -22,15 +22,13 @@
#include <GrBackendSurface.h>
#include <GrDirectContext.h>
#include <GrTypes.h>
-#include <include/gpu/ganesh/SkSurfaceGanesh.h>
#include <android/sync.h>
+#include <gui/TraceUtils.h>
+#include <include/gpu/ganesh/SkSurfaceGanesh.h>
#include <ui/FatVector.h>
#include <vk/GrVkExtensions.h>
#include <vk/GrVkTypes.h>
-#include <cstring>
-
-#include <gui/TraceUtils.h>
#include "Properties.h"
#include "RenderThread.h"
#include "pipeline/skia/ShaderCache.h"
@@ -91,19 +89,6 @@
}
}
-GrVkGetProc VulkanManager::sSkiaGetProp = [](const char* proc_name, VkInstance instance,
- VkDevice device) {
- if (device != VK_NULL_HANDLE) {
- if (strcmp("vkQueueSubmit", proc_name) == 0) {
- return (PFN_vkVoidFunction)VulkanManager::interceptedVkQueueSubmit;
- } else if (strcmp("vkQueueWaitIdle", proc_name) == 0) {
- return (PFN_vkVoidFunction)VulkanManager::interceptedVkQueueWaitIdle;
- }
- return vkGetDeviceProcAddr(device, proc_name);
- }
- return vkGetInstanceProcAddr(instance, proc_name);
-};
-
#define GET_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(VK_NULL_HANDLE, "vk" #F)
#define GET_INST_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(mInstance, "vk" #F)
#define GET_DEV_PROC(F) m##F = (PFN_vk##F)vkGetDeviceProcAddr(mDevice, "vk" #F)
@@ -139,6 +124,7 @@
}
mGraphicsQueue = VK_NULL_HANDLE;
+ mAHBUploadQueue = VK_NULL_HANDLE;
mDevice = VK_NULL_HANDLE;
mPhysicalDevice = VK_NULL_HANDLE;
mInstance = VK_NULL_HANDLE;
@@ -232,7 +218,7 @@
mDriverVersion = physDeviceProperties.driverVersion;
// query to get the initial queue props size
- uint32_t queueCount;
+ uint32_t queueCount = 0;
mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, nullptr);
LOG_ALWAYS_FATAL_IF(!queueCount);
@@ -240,11 +226,14 @@
std::unique_ptr<VkQueueFamilyProperties[]> queueProps(new VkQueueFamilyProperties[queueCount]);
mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, queueProps.get());
+ constexpr auto kRequestedQueueCount = 2;
+
// iterate to find the graphics queue
mGraphicsQueueIndex = queueCount;
for (uint32_t i = 0; i < queueCount; i++) {
if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
mGraphicsQueueIndex = i;
+ LOG_ALWAYS_FATAL_IF(queueProps[i].queueCount < kRequestedQueueCount);
break;
}
}
@@ -274,7 +263,14 @@
LOG_ALWAYS_FATAL_IF(!hasKHRSwapchainExtension);
}
- grExtensions.init(sSkiaGetProp, mInstance, mPhysicalDevice, mInstanceExtensions.size(),
+ auto getProc = [](const char* proc_name, VkInstance instance, VkDevice device) {
+ if (device != VK_NULL_HANDLE) {
+ return vkGetDeviceProcAddr(device, proc_name);
+ }
+ return vkGetInstanceProcAddr(instance, proc_name);
+ };
+
+ grExtensions.init(getProc, mInstance, mPhysicalDevice, mInstanceExtensions.size(),
mInstanceExtensions.data(), mDeviceExtensions.size(),
mDeviceExtensions.data());
@@ -313,7 +309,7 @@
// and we can't depend on it on all platforms
features.features.robustBufferAccess = VK_FALSE;
- float queuePriorities[1] = {0.0};
+ float queuePriorities[kRequestedQueueCount] = {0.0};
void* queueNextPtr = nullptr;
@@ -346,7 +342,7 @@
queueNextPtr, // pNext
0, // VkDeviceQueueCreateFlags
mGraphicsQueueIndex, // queueFamilyIndex
- 1, // queueCount
+ kRequestedQueueCount, // queueCount
queuePriorities, // pQueuePriorities
};
@@ -404,6 +400,7 @@
this->setupDevice(mExtensions, mPhysicalDeviceFeatures2);
mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue);
+ mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 1, &mAHBUploadQueue);
if (Properties::enablePartialUpdates && Properties::useBufferAge) {
mSwapBehavior = SwapBehavior::BufferAge;
@@ -417,16 +414,24 @@
sk_sp<GrDirectContext> VulkanManager::createContext(GrContextOptions& options,
ContextType contextType) {
+ auto getProc = [](const char* proc_name, VkInstance instance, VkDevice device) {
+ if (device != VK_NULL_HANDLE) {
+ return vkGetDeviceProcAddr(device, proc_name);
+ }
+ return vkGetInstanceProcAddr(instance, proc_name);
+ };
+
GrVkBackendContext backendContext;
backendContext.fInstance = mInstance;
backendContext.fPhysicalDevice = mPhysicalDevice;
backendContext.fDevice = mDevice;
- backendContext.fQueue = mGraphicsQueue;
+ backendContext.fQueue =
+ (contextType == ContextType::kRenderThread) ? mGraphicsQueue : mAHBUploadQueue;
backendContext.fGraphicsQueueIndex = mGraphicsQueueIndex;
backendContext.fMaxAPIVersion = mAPIVersion;
backendContext.fVkExtensions = &mExtensions;
backendContext.fDeviceFeatures2 = &mPhysicalDeviceFeatures2;
- backendContext.fGetProc = sSkiaGetProp;
+ backendContext.fGetProc = std::move(getProc);
LOG_ALWAYS_FATAL_IF(options.fContextDeleteProc != nullptr, "Conflicting fContextDeleteProcs!");
this->incStrong((void*)onGrContextReleased);
@@ -638,8 +643,6 @@
ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to get semaphore Fd");
} else {
ALOGE("VulkanManager::swapBuffers(): Semaphore submission failed");
-
- std::lock_guard<std::mutex> lock(mGraphicsQueueMutex);
mQueueWaitIdle(mGraphicsQueue);
}
if (mDestroySemaphoreContext) {
@@ -654,7 +657,6 @@
void VulkanManager::destroySurface(VulkanSurface* surface) {
// Make sure all submit commands have finished before starting to destroy objects.
if (VK_NULL_HANDLE != mGraphicsQueue) {
- std::lock_guard<std::mutex> lock(mGraphicsQueueMutex);
mQueueWaitIdle(mGraphicsQueue);
}
mDeviceWaitIdle(mDevice);
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index 00a40c0..2be1ffd 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -17,10 +17,6 @@
#ifndef VULKANMANAGER_H
#define VULKANMANAGER_H
-#include <functional>
-#include <mutex>
-
-#include "vulkan/vulkan_core.h"
#if !defined(VK_USE_PLATFORM_ANDROID_KHR)
#define VK_USE_PLATFORM_ANDROID_KHR
#endif
@@ -186,25 +182,8 @@
VkDevice mDevice = VK_NULL_HANDLE;
uint32_t mGraphicsQueueIndex;
-
- std::mutex mGraphicsQueueMutex;
VkQueue mGraphicsQueue = VK_NULL_HANDLE;
-
- static VKAPI_ATTR VkResult interceptedVkQueueSubmit(VkQueue queue, uint32_t submitCount,
- const VkSubmitInfo* pSubmits,
- VkFence fence) {
- sp<VulkanManager> manager = VulkanManager::getInstance();
- std::lock_guard<std::mutex> lock(manager->mGraphicsQueueMutex);
- return manager->mQueueSubmit(queue, submitCount, pSubmits, fence);
- }
-
- static VKAPI_ATTR VkResult interceptedVkQueueWaitIdle(VkQueue queue) {
- sp<VulkanManager> manager = VulkanManager::getInstance();
- std::lock_guard<std::mutex> lock(manager->mGraphicsQueueMutex);
- return manager->mQueueWaitIdle(queue);
- }
-
- static GrVkGetProc sSkiaGetProp;
+ VkQueue mAHBUploadQueue = VK_NULL_HANDLE;
// Variables saved to populate VkFunctorInitParams.
static const uint32_t mAPIVersion = VK_MAKE_VERSION(1, 1, 0);