Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "VulkanManager.h" |
| 18 | |
Alec Mouri | 6db59a6 | 2019-08-02 17:05:26 -0700 | [diff] [blame] | 19 | #include <EGL/egl.h> |
| 20 | #include <EGL/eglext.h> |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 21 | #include <GrBackendSemaphore.h> |
| 22 | #include <GrBackendSurface.h> |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 23 | #include <GrDirectContext.h> |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 24 | #include <GrTypes.h> |
| 25 | #include <android/sync.h> |
Jagadeesh Pakaravoor | b624af3 | 2020-05-01 00:01:40 +0000 | [diff] [blame] | 26 | #include <ui/FatVector.h> |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 27 | #include <vk/GrVkExtensions.h> |
| 28 | #include <vk/GrVkTypes.h> |
Stan Iliev | 305e13a | 2018-11-13 11:14:48 -0500 | [diff] [blame] | 29 | |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 30 | #include <cstring> |
| 31 | |
rnlee | ce9762b | 2021-05-21 15:40:53 -0700 | [diff] [blame] | 32 | #include <gui/TraceUtils.h> |
Greg Daniel | cd55852 | 2016-11-17 13:31:40 -0500 | [diff] [blame] | 33 | #include "Properties.h" |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 34 | #include "RenderThread.h" |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 35 | #include "pipeline/skia/ShaderCache.h" |
Greg Daniel | 45ec62b | 2017-01-04 14:27:00 -0500 | [diff] [blame] | 36 | #include "renderstate/RenderState.h" |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 37 | |
Leon Scroggins III | 7ccb8a4 | 2021-11-30 14:17:28 -0500 | [diff] [blame] | 38 | #undef LOG_TAG |
| 39 | #define LOG_TAG "VulkanManager" |
| 40 | |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 41 | namespace android { |
| 42 | namespace uirenderer { |
| 43 | namespace renderthread { |
| 44 | |
John Reck | f6067df | 2023-04-11 16:27:51 -0400 | [diff] [blame] | 45 | static std::array<std::string_view, 18> sEnableExtensions{ |
| 46 | VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, |
| 47 | VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, |
| 48 | VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, |
| 49 | VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, |
| 50 | VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, |
| 51 | VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, |
| 52 | VK_KHR_MAINTENANCE1_EXTENSION_NAME, |
| 53 | VK_KHR_MAINTENANCE2_EXTENSION_NAME, |
| 54 | VK_KHR_MAINTENANCE3_EXTENSION_NAME, |
| 55 | VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, |
| 56 | VK_KHR_SURFACE_EXTENSION_NAME, |
| 57 | VK_KHR_SWAPCHAIN_EXTENSION_NAME, |
| 58 | VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, |
| 59 | VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, |
| 60 | VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, |
| 61 | VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME, |
| 62 | VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, |
| 63 | VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, |
| 64 | }; |
| 65 | |
| 66 | static bool shouldEnableExtension(const std::string_view& extension) { |
| 67 | for (const auto& it : sEnableExtensions) { |
| 68 | if (it == extension) { |
| 69 | return true; |
| 70 | } |
| 71 | } |
| 72 | return false; |
| 73 | } |
| 74 | |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 75 | static void free_features_extensions_structs(const VkPhysicalDeviceFeatures2& features) { |
| 76 | // All Vulkan structs that could be part of the features chain will start with the |
| 77 | // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader |
| 78 | // so we can get access to the pNext for the next struct. |
| 79 | struct CommonVulkanHeader { |
| 80 | VkStructureType sType; |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 81 | void* pNext; |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | void* pNext = features.pNext; |
| 85 | while (pNext) { |
| 86 | void* current = pNext; |
| 87 | pNext = static_cast<CommonVulkanHeader*>(current)->pNext; |
| 88 | free(current); |
| 89 | } |
| 90 | } |
| 91 | |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 92 | GrVkGetProc VulkanManager::sSkiaGetProp = [](const char* proc_name, VkInstance instance, |
| 93 | VkDevice device) { |
| 94 | if (device != VK_NULL_HANDLE) { |
| 95 | if (strcmp("vkQueueSubmit", proc_name) == 0) { |
| 96 | return (PFN_vkVoidFunction)VulkanManager::interceptedVkQueueSubmit; |
| 97 | } else if (strcmp("vkQueueWaitIdle", proc_name) == 0) { |
| 98 | return (PFN_vkVoidFunction)VulkanManager::interceptedVkQueueWaitIdle; |
| 99 | } |
| 100 | return vkGetDeviceProcAddr(device, proc_name); |
| 101 | } |
| 102 | return vkGetInstanceProcAddr(instance, proc_name); |
| 103 | }; |
| 104 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 105 | #define GET_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(VK_NULL_HANDLE, "vk" #F) |
| 106 | #define GET_INST_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(mInstance, "vk" #F) |
| 107 | #define GET_DEV_PROC(F) m##F = (PFN_vk##F)vkGetDeviceProcAddr(mDevice, "vk" #F) |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 108 | |
Derek Sollenberger | 802fefa | 2020-08-13 16:53:30 -0400 | [diff] [blame] | 109 | sp<VulkanManager> VulkanManager::getInstance() { |
| 110 | // cache a weakptr to the context to enable a second thread to share the same vulkan state |
| 111 | static wp<VulkanManager> sWeakInstance = nullptr; |
| 112 | static std::mutex sLock; |
| 113 | |
| 114 | std::lock_guard _lock{sLock}; |
| 115 | sp<VulkanManager> vulkanManager = sWeakInstance.promote(); |
| 116 | if (!vulkanManager.get()) { |
| 117 | vulkanManager = new VulkanManager(); |
| 118 | sWeakInstance = vulkanManager; |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 119 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 120 | |
Derek Sollenberger | 802fefa | 2020-08-13 16:53:30 -0400 | [diff] [blame] | 121 | return vulkanManager; |
| 122 | } |
| 123 | |
| 124 | VulkanManager::~VulkanManager() { |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 125 | if (mDevice != VK_NULL_HANDLE) { |
| 126 | mDeviceWaitIdle(mDevice); |
| 127 | mDestroyDevice(mDevice, nullptr); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 128 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 129 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 130 | if (mInstance != VK_NULL_HANDLE) { |
| 131 | mDestroyInstance(mInstance, nullptr); |
| 132 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 133 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 134 | mGraphicsQueue = VK_NULL_HANDLE; |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 135 | mDevice = VK_NULL_HANDLE; |
| 136 | mPhysicalDevice = VK_NULL_HANDLE; |
| 137 | mInstance = VK_NULL_HANDLE; |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 138 | mInstanceExtensionsOwner.clear(); |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 139 | mInstanceExtensions.clear(); |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 140 | mDeviceExtensionsOwner.clear(); |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 141 | mDeviceExtensions.clear(); |
| 142 | free_features_extensions_structs(mPhysicalDeviceFeatures2); |
| 143 | mPhysicalDeviceFeatures2 = {}; |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 144 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 145 | |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 146 | void VulkanManager::setupDevice(GrVkExtensions& grExtensions, VkPhysicalDeviceFeatures2& features) { |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 147 | VkResult err; |
| 148 | |
| 149 | constexpr VkApplicationInfo app_info = { |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 150 | VK_STRUCTURE_TYPE_APPLICATION_INFO, // sType |
| 151 | nullptr, // pNext |
| 152 | "android framework", // pApplicationName |
| 153 | 0, // applicationVersion |
| 154 | "android framework", // pEngineName |
| 155 | 0, // engineVerison |
| 156 | mAPIVersion, // apiVersion |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 157 | }; |
| 158 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 159 | { |
| 160 | GET_PROC(EnumerateInstanceExtensionProperties); |
| 161 | |
| 162 | uint32_t extensionCount = 0; |
| 163 | err = mEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 164 | LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err); |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 165 | mInstanceExtensionsOwner.resize(extensionCount); |
| 166 | err = mEnumerateInstanceExtensionProperties(nullptr, &extensionCount, |
| 167 | mInstanceExtensionsOwner.data()); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 168 | LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 169 | bool hasKHRSurfaceExtension = false; |
| 170 | bool hasKHRAndroidSurfaceExtension = false; |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 171 | for (const VkExtensionProperties& extension : mInstanceExtensionsOwner) { |
John Reck | f6067df | 2023-04-11 16:27:51 -0400 | [diff] [blame] | 172 | if (!shouldEnableExtension(extension.extensionName)) { |
| 173 | ALOGV("Not enabling instance extension %s", extension.extensionName); |
| 174 | continue; |
| 175 | } |
| 176 | ALOGV("Enabling instance extension %s", extension.extensionName); |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 177 | mInstanceExtensions.push_back(extension.extensionName); |
| 178 | if (!strcmp(extension.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) { |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 179 | hasKHRSurfaceExtension = true; |
| 180 | } |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 181 | if (!strcmp(extension.extensionName, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)) { |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 182 | hasKHRAndroidSurfaceExtension = true; |
| 183 | } |
| 184 | } |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 185 | LOG_ALWAYS_FATAL_IF(!hasKHRSurfaceExtension || !hasKHRAndroidSurfaceExtension); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | const VkInstanceCreateInfo instance_create = { |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 189 | VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType |
| 190 | nullptr, // pNext |
| 191 | 0, // flags |
| 192 | &app_info, // pApplicationInfo |
| 193 | 0, // enabledLayerNameCount |
| 194 | nullptr, // ppEnabledLayerNames |
| 195 | (uint32_t)mInstanceExtensions.size(), // enabledExtensionNameCount |
| 196 | mInstanceExtensions.data(), // ppEnabledExtensionNames |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | GET_PROC(CreateInstance); |
| 200 | err = mCreateInstance(&instance_create, nullptr, &mInstance); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 201 | LOG_ALWAYS_FATAL_IF(err < 0); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 202 | |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 203 | GET_INST_PROC(CreateDevice); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 204 | GET_INST_PROC(DestroyInstance); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 205 | GET_INST_PROC(EnumerateDeviceExtensionProperties); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 206 | GET_INST_PROC(EnumeratePhysicalDevices); |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 207 | GET_INST_PROC(GetPhysicalDeviceFeatures2); |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 208 | GET_INST_PROC(GetPhysicalDeviceImageFormatProperties2); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 209 | GET_INST_PROC(GetPhysicalDeviceProperties); |
| 210 | GET_INST_PROC(GetPhysicalDeviceQueueFamilyProperties); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 211 | |
| 212 | uint32_t gpuCount; |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 213 | LOG_ALWAYS_FATAL_IF(mEnumeratePhysicalDevices(mInstance, &gpuCount, nullptr)); |
| 214 | LOG_ALWAYS_FATAL_IF(!gpuCount); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 215 | // Just returning the first physical device instead of getting the whole array. Since there |
| 216 | // should only be one device on android. |
| 217 | gpuCount = 1; |
| 218 | err = mEnumeratePhysicalDevices(mInstance, &gpuCount, &mPhysicalDevice); |
| 219 | // VK_INCOMPLETE is returned when the count we provide is less than the total device count. |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 220 | LOG_ALWAYS_FATAL_IF(err && VK_INCOMPLETE != err); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 221 | |
Greg Daniel | 9625962 | 2018-10-01 14:42:56 -0400 | [diff] [blame] | 222 | VkPhysicalDeviceProperties physDeviceProperties; |
| 223 | mGetPhysicalDeviceProperties(mPhysicalDevice, &physDeviceProperties); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 224 | LOG_ALWAYS_FATAL_IF(physDeviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0)); |
Stan Iliev | bf99c44 | 2019-03-29 11:09:11 -0400 | [diff] [blame] | 225 | mDriverVersion = physDeviceProperties.driverVersion; |
Greg Daniel | 9625962 | 2018-10-01 14:42:56 -0400 | [diff] [blame] | 226 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 227 | // query to get the initial queue props size |
| 228 | uint32_t queueCount; |
| 229 | mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, nullptr); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 230 | LOG_ALWAYS_FATAL_IF(!queueCount); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 231 | |
| 232 | // now get the actual queue props |
| 233 | std::unique_ptr<VkQueueFamilyProperties[]> queueProps(new VkQueueFamilyProperties[queueCount]); |
| 234 | mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, queueProps.get()); |
| 235 | |
| 236 | // iterate to find the graphics queue |
| 237 | mGraphicsQueueIndex = queueCount; |
| 238 | for (uint32_t i = 0; i < queueCount; i++) { |
| 239 | if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
| 240 | mGraphicsQueueIndex = i; |
| 241 | break; |
| 242 | } |
| 243 | } |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 244 | LOG_ALWAYS_FATAL_IF(mGraphicsQueueIndex == queueCount); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 245 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 246 | { |
| 247 | uint32_t extensionCount = 0; |
| 248 | err = mEnumerateDeviceExtensionProperties(mPhysicalDevice, nullptr, &extensionCount, |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 249 | nullptr); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 250 | LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err); |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 251 | mDeviceExtensionsOwner.resize(extensionCount); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 252 | err = mEnumerateDeviceExtensionProperties(mPhysicalDevice, nullptr, &extensionCount, |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 253 | mDeviceExtensionsOwner.data()); |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 254 | LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 255 | bool hasKHRSwapchainExtension = false; |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 256 | for (const VkExtensionProperties& extension : mDeviceExtensionsOwner) { |
John Reck | f6067df | 2023-04-11 16:27:51 -0400 | [diff] [blame] | 257 | if (!shouldEnableExtension(extension.extensionName)) { |
| 258 | ALOGV("Not enabling device extension %s", extension.extensionName); |
| 259 | continue; |
| 260 | } |
| 261 | ALOGV("Enabling device extension %s", extension.extensionName); |
Roman Kiryanov | 74ace839e | 2019-03-07 18:22:19 -0800 | [diff] [blame] | 262 | mDeviceExtensions.push_back(extension.extensionName); |
| 263 | if (!strcmp(extension.extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) { |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 264 | hasKHRSwapchainExtension = true; |
| 265 | } |
| 266 | } |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 267 | LOG_ALWAYS_FATAL_IF(!hasKHRSwapchainExtension); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 268 | } |
| 269 | |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 270 | grExtensions.init(sSkiaGetProp, mInstance, mPhysicalDevice, mInstanceExtensions.size(), |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 271 | mInstanceExtensions.data(), mDeviceExtensions.size(), |
| 272 | mDeviceExtensions.data()); |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 273 | |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 274 | LOG_ALWAYS_FATAL_IF(!grExtensions.hasExtension(VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, 1)); |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 275 | |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 276 | memset(&features, 0, sizeof(VkPhysicalDeviceFeatures2)); |
| 277 | features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 278 | features.pNext = nullptr; |
| 279 | |
| 280 | // Setup all extension feature structs we may want to use. |
| 281 | void** tailPNext = &features.pNext; |
| 282 | |
| 283 | if (grExtensions.hasExtension(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, 2)) { |
| 284 | VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT* blend; |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 285 | blend = (VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT*)malloc( |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 286 | sizeof(VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT)); |
| 287 | LOG_ALWAYS_FATAL_IF(!blend); |
| 288 | blend->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT; |
| 289 | blend->pNext = nullptr; |
| 290 | *tailPNext = blend; |
| 291 | tailPNext = &blend->pNext; |
| 292 | } |
| 293 | |
Greg Daniel | 0503617 | 2018-11-28 17:08:04 -0500 | [diff] [blame] | 294 | VkPhysicalDeviceSamplerYcbcrConversionFeatures* ycbcrFeature; |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 295 | ycbcrFeature = (VkPhysicalDeviceSamplerYcbcrConversionFeatures*)malloc( |
Greg Daniel | 0503617 | 2018-11-28 17:08:04 -0500 | [diff] [blame] | 296 | sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures)); |
| 297 | LOG_ALWAYS_FATAL_IF(!ycbcrFeature); |
| 298 | ycbcrFeature->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES; |
| 299 | ycbcrFeature->pNext = nullptr; |
| 300 | *tailPNext = ycbcrFeature; |
| 301 | tailPNext = &ycbcrFeature->pNext; |
| 302 | |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 303 | // query to get the physical device features |
| 304 | mGetPhysicalDeviceFeatures2(mPhysicalDevice, &features); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 305 | // this looks like it would slow things down, |
| 306 | // and we can't depend on it on all platforms |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 307 | features.features.robustBufferAccess = VK_FALSE; |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 308 | |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 309 | float queuePriorities[1] = {0.0}; |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 310 | |
Stan Iliev | 7e73336 | 2019-02-28 13:16:36 -0500 | [diff] [blame] | 311 | void* queueNextPtr = nullptr; |
| 312 | |
| 313 | VkDeviceQueueGlobalPriorityCreateInfoEXT queuePriorityCreateInfo; |
| 314 | |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 315 | if (Properties::contextPriority != 0 && |
| 316 | grExtensions.hasExtension(VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, 2)) { |
Stan Iliev | 7e73336 | 2019-02-28 13:16:36 -0500 | [diff] [blame] | 317 | memset(&queuePriorityCreateInfo, 0, sizeof(VkDeviceQueueGlobalPriorityCreateInfoEXT)); |
| 318 | queuePriorityCreateInfo.sType = |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 319 | VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT; |
Stan Iliev | 7e73336 | 2019-02-28 13:16:36 -0500 | [diff] [blame] | 320 | queuePriorityCreateInfo.pNext = nullptr; |
| 321 | switch (Properties::contextPriority) { |
| 322 | case EGL_CONTEXT_PRIORITY_LOW_IMG: |
| 323 | queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT; |
| 324 | break; |
| 325 | case EGL_CONTEXT_PRIORITY_MEDIUM_IMG: |
| 326 | queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT; |
| 327 | break; |
| 328 | case EGL_CONTEXT_PRIORITY_HIGH_IMG: |
| 329 | queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT; |
| 330 | break; |
| 331 | default: |
| 332 | LOG_ALWAYS_FATAL("Unsupported context priority"); |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 333 | } |
| 334 | queueNextPtr = &queuePriorityCreateInfo; |
Stan Iliev | 7e73336 | 2019-02-28 13:16:36 -0500 | [diff] [blame] | 335 | } |
| 336 | |
Yiwei Zhang | 276d5fc | 2020-09-03 12:00:00 -0700 | [diff] [blame] | 337 | const VkDeviceQueueCreateInfo queueInfo = { |
| 338 | VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType |
| 339 | queueNextPtr, // pNext |
| 340 | 0, // VkDeviceQueueCreateFlags |
| 341 | mGraphicsQueueIndex, // queueFamilyIndex |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 342 | 1, // queueCount |
Yiwei Zhang | 276d5fc | 2020-09-03 12:00:00 -0700 | [diff] [blame] | 343 | queuePriorities, // pQueuePriorities |
| 344 | }; |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 345 | |
| 346 | const VkDeviceCreateInfo deviceInfo = { |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 347 | VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType |
| 348 | &features, // pNext |
| 349 | 0, // VkDeviceCreateFlags |
Yiwei Zhang | 276d5fc | 2020-09-03 12:00:00 -0700 | [diff] [blame] | 350 | 1, // queueCreateInfoCount |
| 351 | &queueInfo, // pQueueCreateInfos |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 352 | 0, // layerCount |
| 353 | nullptr, // ppEnabledLayerNames |
| 354 | (uint32_t)mDeviceExtensions.size(), // extensionCount |
| 355 | mDeviceExtensions.data(), // ppEnabledExtensionNames |
| 356 | nullptr, // ppEnabledFeatures |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 357 | }; |
| 358 | |
Stan Iliev | 90276c8 | 2019-02-03 18:01:02 -0500 | [diff] [blame] | 359 | LOG_ALWAYS_FATAL_IF(mCreateDevice(mPhysicalDevice, &deviceInfo, nullptr, &mDevice)); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 360 | |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 361 | GET_DEV_PROC(AllocateCommandBuffers); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 362 | GET_DEV_PROC(BeginCommandBuffer); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 363 | GET_DEV_PROC(CmdPipelineBarrier); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 364 | GET_DEV_PROC(CreateCommandPool); |
| 365 | GET_DEV_PROC(CreateFence); |
| 366 | GET_DEV_PROC(CreateSemaphore); |
| 367 | GET_DEV_PROC(DestroyCommandPool); |
| 368 | GET_DEV_PROC(DestroyDevice); |
| 369 | GET_DEV_PROC(DestroyFence); |
| 370 | GET_DEV_PROC(DestroySemaphore); |
| 371 | GET_DEV_PROC(DeviceWaitIdle); |
| 372 | GET_DEV_PROC(EndCommandBuffer); |
| 373 | GET_DEV_PROC(FreeCommandBuffers); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 374 | GET_DEV_PROC(GetDeviceQueue); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 375 | GET_DEV_PROC(GetSemaphoreFdKHR); |
| 376 | GET_DEV_PROC(ImportSemaphoreFdKHR); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 377 | GET_DEV_PROC(QueueSubmit); |
| 378 | GET_DEV_PROC(QueueWaitIdle); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 379 | GET_DEV_PROC(ResetCommandBuffer); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 380 | GET_DEV_PROC(ResetFences); |
Yiwei Zhang | 0b9f0b8 | 2019-08-15 11:33:59 -0700 | [diff] [blame] | 381 | GET_DEV_PROC(WaitForFences); |
Hugues Evrard | b9510a0 | 2021-03-01 14:35:22 +0000 | [diff] [blame] | 382 | GET_DEV_PROC(FrameBoundaryANDROID); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | void VulkanManager::initialize() { |
Greg Daniel | 1d9de71 | 2021-05-14 09:28:34 -0400 | [diff] [blame] | 386 | std::lock_guard _lock{mInitializeLock}; |
| 387 | |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 388 | if (mDevice != VK_NULL_HANDLE) { |
| 389 | return; |
| 390 | } |
| 391 | |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 392 | GET_PROC(EnumerateInstanceVersion); |
Greg Daniel | eaf310e | 2019-01-28 16:10:32 -0500 | [diff] [blame] | 393 | uint32_t instanceVersion; |
| 394 | LOG_ALWAYS_FATAL_IF(mEnumerateInstanceVersion(&instanceVersion)); |
| 395 | LOG_ALWAYS_FATAL_IF(instanceVersion < VK_MAKE_VERSION(1, 1, 0)); |
Greg Daniel | a227dbb | 2018-08-20 09:19:48 -0400 | [diff] [blame] | 396 | |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 397 | this->setupDevice(mExtensions, mPhysicalDeviceFeatures2); |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 398 | |
| 399 | mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue); |
| 400 | |
Greg Daniel | cd55852 | 2016-11-17 13:31:40 -0500 | [diff] [blame] | 401 | if (Properties::enablePartialUpdates && Properties::useBufferAge) { |
| 402 | mSwapBehavior = SwapBehavior::BufferAge; |
| 403 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 404 | } |
| 405 | |
Derek Sollenberger | 802fefa | 2020-08-13 16:53:30 -0400 | [diff] [blame] | 406 | sk_sp<GrDirectContext> VulkanManager::createContext(const GrContextOptions& options, |
| 407 | ContextType contextType) { |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 408 | |
| 409 | GrVkBackendContext backendContext; |
| 410 | backendContext.fInstance = mInstance; |
| 411 | backendContext.fPhysicalDevice = mPhysicalDevice; |
| 412 | backendContext.fDevice = mDevice; |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 413 | backendContext.fQueue = mGraphicsQueue; |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 414 | backendContext.fGraphicsQueueIndex = mGraphicsQueueIndex; |
| 415 | backendContext.fMaxAPIVersion = mAPIVersion; |
| 416 | backendContext.fVkExtensions = &mExtensions; |
| 417 | backendContext.fDeviceFeatures2 = &mPhysicalDeviceFeatures2; |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 418 | backendContext.fGetProc = sSkiaGetProp; |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 419 | |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 420 | return GrDirectContext::MakeVulkan(backendContext, options); |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 421 | } |
| 422 | |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 423 | VkFunctorInitParams VulkanManager::getVkFunctorInitParams() const { |
| 424 | return VkFunctorInitParams{ |
| 425 | .instance = mInstance, |
| 426 | .physical_device = mPhysicalDevice, |
| 427 | .device = mDevice, |
| 428 | .queue = mGraphicsQueue, |
| 429 | .graphics_queue_index = mGraphicsQueueIndex, |
Greg Daniel | eaf310e | 2019-01-28 16:10:32 -0500 | [diff] [blame] | 430 | .api_version = mAPIVersion, |
Bo Liu | 7b8c1eb | 2019-01-08 20:17:55 -0800 | [diff] [blame] | 431 | .enabled_instance_extension_names = mInstanceExtensions.data(), |
| 432 | .enabled_instance_extension_names_length = |
| 433 | static_cast<uint32_t>(mInstanceExtensions.size()), |
| 434 | .enabled_device_extension_names = mDeviceExtensions.data(), |
| 435 | .enabled_device_extension_names_length = |
| 436 | static_cast<uint32_t>(mDeviceExtensions.size()), |
| 437 | .device_features_2 = &mPhysicalDeviceFeatures2, |
| 438 | }; |
| 439 | } |
| 440 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 441 | Frame VulkanManager::dequeueNextBuffer(VulkanSurface* surface) { |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 442 | VulkanSurface::NativeBufferInfo* bufferInfo = surface->dequeueNativeBuffer(); |
| 443 | |
| 444 | if (bufferInfo == nullptr) { |
| 445 | ALOGE("VulkanSurface::dequeueNativeBuffer called with an invalid surface!"); |
| 446 | return Frame(-1, -1, 0); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 447 | } |
| 448 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 449 | LOG_ALWAYS_FATAL_IF(!bufferInfo->dequeued); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 450 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 451 | if (bufferInfo->dequeue_fence != -1) { |
Stan Iliev | 197843d | 2019-03-21 11:34:15 -0400 | [diff] [blame] | 452 | struct sync_file_info* finfo = sync_file_info(bufferInfo->dequeue_fence); |
| 453 | bool isSignalPending = false; |
| 454 | if (finfo != NULL) { |
| 455 | isSignalPending = finfo->status != 1; |
| 456 | sync_file_info_free(finfo); |
| 457 | } |
| 458 | if (isSignalPending) { |
| 459 | int fence_clone = dup(bufferInfo->dequeue_fence); |
| 460 | if (fence_clone == -1) { |
| 461 | ALOGE("dup(fence) failed, stalling until signalled: %s (%d)", strerror(errno), |
| 462 | errno); |
| 463 | sync_wait(bufferInfo->dequeue_fence, -1 /* forever */); |
| 464 | } else { |
| 465 | VkSemaphoreCreateInfo semaphoreInfo; |
| 466 | semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 467 | semaphoreInfo.pNext = nullptr; |
| 468 | semaphoreInfo.flags = 0; |
| 469 | VkSemaphore semaphore; |
| 470 | VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore); |
Greg Daniel | d667077 | 2021-06-09 12:01:12 -0400 | [diff] [blame] | 471 | if (err != VK_SUCCESS) { |
| 472 | ALOGE("Failed to create import semaphore, err: %d", err); |
| 473 | close(fence_clone); |
| 474 | sync_wait(bufferInfo->dequeue_fence, -1 /* forever */); |
| 475 | } else { |
| 476 | VkImportSemaphoreFdInfoKHR importInfo; |
| 477 | importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR; |
| 478 | importInfo.pNext = nullptr; |
| 479 | importInfo.semaphore = semaphore; |
| 480 | importInfo.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT; |
| 481 | importInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 482 | importInfo.fd = fence_clone; |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 483 | |
Greg Daniel | d667077 | 2021-06-09 12:01:12 -0400 | [diff] [blame] | 484 | err = mImportSemaphoreFdKHR(mDevice, &importInfo); |
| 485 | if (err != VK_SUCCESS) { |
| 486 | ALOGE("Failed to import semaphore, err: %d", err); |
| 487 | mDestroySemaphore(mDevice, semaphore, nullptr); |
| 488 | close(fence_clone); |
| 489 | sync_wait(bufferInfo->dequeue_fence, -1 /* forever */); |
| 490 | } else { |
| 491 | GrBackendSemaphore backendSemaphore; |
| 492 | backendSemaphore.initVulkan(semaphore); |
| 493 | // Skia will take ownership of the VkSemaphore and delete it once the wait |
| 494 | // has finished. The VkSemaphore also owns the imported fd, so it will |
| 495 | // close the fd when it is deleted. |
| 496 | bufferInfo->skSurface->wait(1, &backendSemaphore); |
| 497 | // The following flush blocks the GPU immediately instead of waiting for |
| 498 | // other drawing ops. It seems dequeue_fence is not respected otherwise. |
| 499 | // TODO: remove the flush after finding why backendSemaphore is not working. |
| 500 | bufferInfo->skSurface->flushAndSubmit(); |
| 501 | } |
| 502 | } |
Stan Iliev | 197843d | 2019-03-21 11:34:15 -0400 | [diff] [blame] | 503 | } |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 504 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 505 | } |
| 506 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 507 | int bufferAge = (mSwapBehavior == SwapBehavior::Discard) ? 0 : surface->getCurrentBuffersAge(); |
| 508 | return Frame(surface->logicalWidth(), surface->logicalHeight(), bufferAge); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 509 | } |
| 510 | |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 511 | struct DestroySemaphoreInfo { |
| 512 | PFN_vkDestroySemaphore mDestroyFunction; |
| 513 | VkDevice mDevice; |
| 514 | VkSemaphore mSemaphore; |
Greg Daniel | fd42939 | 2019-05-09 15:44:56 -0400 | [diff] [blame] | 515 | // We need to make sure we don't delete the VkSemaphore until it is done being used by both Skia |
| 516 | // (including by the GPU) and inside the VulkanManager. So we always start with two refs, one |
| 517 | // owned by Skia and one owned by the VulkanManager. The refs are decremented each time |
| 518 | // destroy_semaphore is called with this object. Skia will call destroy_semaphore once it is |
| 519 | // done with the semaphore and the GPU has finished work on the semaphore. The VulkanManager |
| 520 | // calls destroy_semaphore after sending the semaphore to Skia and exporting it if need be. |
| 521 | int mRefs = 2; |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 522 | |
| 523 | DestroySemaphoreInfo(PFN_vkDestroySemaphore destroyFunction, VkDevice device, |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 524 | VkSemaphore semaphore) |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 525 | : mDestroyFunction(destroyFunction), mDevice(device), mSemaphore(semaphore) {} |
| 526 | }; |
| 527 | |
| 528 | static void destroy_semaphore(void* context) { |
| 529 | DestroySemaphoreInfo* info = reinterpret_cast<DestroySemaphoreInfo*>(context); |
Greg Daniel | fd42939 | 2019-05-09 15:44:56 -0400 | [diff] [blame] | 530 | --info->mRefs; |
| 531 | if (!info->mRefs) { |
| 532 | info->mDestroyFunction(info->mDevice, info->mSemaphore, nullptr); |
| 533 | delete info; |
| 534 | } |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 535 | } |
| 536 | |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 537 | nsecs_t VulkanManager::finishFrame(SkSurface* surface) { |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 538 | ATRACE_NAME("Vulkan finish frame"); |
| 539 | ALOGE_IF(mSwapSemaphore != VK_NULL_HANDLE || mDestroySemaphoreContext != nullptr, |
| 540 | "finishFrame already has an outstanding semaphore"); |
Stan Iliev | bc5f06b | 2019-03-26 15:14:34 -0400 | [diff] [blame] | 541 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 542 | VkExportSemaphoreCreateInfo exportInfo; |
| 543 | exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO; |
| 544 | exportInfo.pNext = nullptr; |
| 545 | exportInfo.handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 546 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 547 | VkSemaphoreCreateInfo semaphoreInfo; |
| 548 | semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 549 | semaphoreInfo.pNext = &exportInfo; |
| 550 | semaphoreInfo.flags = 0; |
| 551 | VkSemaphore semaphore; |
| 552 | VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore); |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 553 | ALOGE_IF(VK_SUCCESS != err, "VulkanManager::makeSwapSemaphore(): Failed to create semaphore"); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 554 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 555 | GrBackendSemaphore backendSemaphore; |
| 556 | backendSemaphore.initVulkan(semaphore); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 557 | |
Greg Daniel | c7ad408 | 2020-05-14 15:38:26 -0400 | [diff] [blame] | 558 | GrFlushInfo flushInfo; |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 559 | if (err == VK_SUCCESS) { |
| 560 | mDestroySemaphoreContext = new DestroySemaphoreInfo(mDestroySemaphore, mDevice, semaphore); |
| 561 | flushInfo.fNumSemaphores = 1; |
| 562 | flushInfo.fSignalSemaphores = &backendSemaphore; |
| 563 | flushInfo.fFinishedProc = destroy_semaphore; |
| 564 | flushInfo.fFinishedContext = mDestroySemaphoreContext; |
| 565 | } else { |
| 566 | semaphore = VK_NULL_HANDLE; |
| 567 | } |
| 568 | GrSemaphoresSubmitted submitted = |
| 569 | surface->flush(SkSurface::BackendSurfaceAccess::kPresent, flushInfo); |
| 570 | GrDirectContext* context = GrAsDirectContext(surface->recordingContext()); |
Adlai Holler | 0375fee | 2020-09-15 12:31:22 -0400 | [diff] [blame] | 571 | ALOGE_IF(!context, "Surface is not backed by gpu"); |
| 572 | context->submit(); |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 573 | const nsecs_t submissionTime = systemTime(); |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 574 | if (semaphore != VK_NULL_HANDLE) { |
| 575 | if (submitted == GrSemaphoresSubmitted::kYes) { |
| 576 | mSwapSemaphore = semaphore; |
Hugues Evrard | b9510a0 | 2021-03-01 14:35:22 +0000 | [diff] [blame] | 577 | if (mFrameBoundaryANDROID) { |
| 578 | // retrieve VkImage used as render target |
| 579 | VkImage image = VK_NULL_HANDLE; |
| 580 | GrBackendRenderTarget backendRenderTarget = |
| 581 | surface->getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess); |
| 582 | if (backendRenderTarget.isValid()) { |
| 583 | GrVkImageInfo info; |
| 584 | if (backendRenderTarget.getVkImageInfo(&info)) { |
| 585 | image = info.fImage; |
| 586 | } else { |
| 587 | ALOGE("Frame boundary: backend is not vulkan"); |
| 588 | } |
| 589 | } else { |
| 590 | ALOGE("Frame boundary: invalid backend render target"); |
| 591 | } |
| 592 | // frameBoundaryANDROID needs to know about mSwapSemaphore, but |
| 593 | // it won't wait on it. |
| 594 | mFrameBoundaryANDROID(mDevice, mSwapSemaphore, image); |
| 595 | } |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 596 | } else { |
| 597 | destroy_semaphore(mDestroySemaphoreContext); |
| 598 | mDestroySemaphoreContext = nullptr; |
| 599 | } |
| 600 | } |
| 601 | skiapipeline::ShaderCache::get().onVkFrameFlushed(context); |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 602 | |
| 603 | return submissionTime; |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | void VulkanManager::swapBuffers(VulkanSurface* surface, const SkRect& dirtyRect) { |
| 607 | if (CC_UNLIKELY(Properties::waitForGpuCompletion)) { |
| 608 | ATRACE_NAME("Finishing GPU work"); |
| 609 | mDeviceWaitIdle(mDevice); |
| 610 | } |
| 611 | |
| 612 | int fenceFd = -1; |
| 613 | if (mSwapSemaphore != VK_NULL_HANDLE) { |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 614 | VkSemaphoreGetFdInfoKHR getFdInfo; |
| 615 | getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR; |
| 616 | getFdInfo.pNext = nullptr; |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 617 | getFdInfo.semaphore = mSwapSemaphore; |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 618 | getFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 619 | |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 620 | VkResult err = mGetSemaphoreFdKHR(mDevice, &getFdInfo, &fenceFd); |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 621 | ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to get semaphore Fd"); |
| 622 | } else { |
| 623 | ALOGE("VulkanManager::swapBuffers(): Semaphore submission failed"); |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 624 | |
| 625 | std::lock_guard<std::mutex> lock(mGraphicsQueueMutex); |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 626 | mQueueWaitIdle(mGraphicsQueue); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 627 | } |
Greg Daniel | e8dc397 | 2021-07-15 13:38:44 -0400 | [diff] [blame] | 628 | if (mDestroySemaphoreContext) { |
| 629 | destroy_semaphore(mDestroySemaphoreContext); |
| 630 | } |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 631 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 632 | surface->presentCurrentBuffer(dirtyRect, fenceFd); |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 633 | mSwapSemaphore = VK_NULL_HANDLE; |
| 634 | mDestroySemaphoreContext = nullptr; |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | void VulkanManager::destroySurface(VulkanSurface* surface) { |
| 638 | // Make sure all submit commands have finished before starting to destroy objects. |
Yiwei Zhang | 276d5fc | 2020-09-03 12:00:00 -0700 | [diff] [blame] | 639 | if (VK_NULL_HANDLE != mGraphicsQueue) { |
Alec Mouri | aa3e498 | 2020-12-14 14:47:57 -0800 | [diff] [blame] | 640 | std::lock_guard<std::mutex> lock(mGraphicsQueueMutex); |
Yiwei Zhang | 276d5fc | 2020-09-03 12:00:00 -0700 | [diff] [blame] | 641 | mQueueWaitIdle(mGraphicsQueue); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 642 | } |
Greg Daniel | 2ff20271 | 2018-06-14 11:50:10 -0400 | [diff] [blame] | 643 | mDeviceWaitIdle(mDevice); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 644 | |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 645 | delete surface; |
| 646 | } |
| 647 | |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 648 | VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, |
| 649 | ColorMode colorMode, |
Peiyong Lin | 3bff135 | 2018-12-11 07:56:07 -0800 | [diff] [blame] | 650 | sk_sp<SkColorSpace> surfaceColorSpace, |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 651 | SkColorType surfaceColorType, |
| 652 | GrDirectContext* grContext, |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 653 | uint32_t extraBuffers) { |
Stan Iliev | 981afe7 | 2019-02-13 14:24:33 -0500 | [diff] [blame] | 654 | LOG_ALWAYS_FATAL_IF(!hasVkContext(), "Not initialized"); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 655 | if (!window) { |
| 656 | return nullptr; |
| 657 | } |
| 658 | |
Derek Sollenberger | a19b71a | 2019-02-15 16:36:30 -0500 | [diff] [blame] | 659 | return VulkanSurface::Create(window, colorMode, surfaceColorType, surfaceColorSpace, grContext, |
John Reck | 0fa0cbc | 2019-04-05 16:57:46 -0700 | [diff] [blame] | 660 | *this, extraBuffers); |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 661 | } |
| 662 | |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 663 | status_t VulkanManager::fenceWait(int fence, GrDirectContext* grContext) { |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 664 | if (!hasVkContext()) { |
| 665 | ALOGE("VulkanManager::fenceWait: VkDevice not initialized"); |
| 666 | return INVALID_OPERATION; |
| 667 | } |
| 668 | |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 669 | // Block GPU on the fence. |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 670 | int fenceFd = ::dup(fence); |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 671 | if (fenceFd == -1) { |
| 672 | ALOGE("VulkanManager::fenceWait: error dup'ing fence fd: %d", errno); |
| 673 | return -errno; |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame] | 674 | } |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 675 | |
| 676 | VkSemaphoreCreateInfo semaphoreInfo; |
| 677 | semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 678 | semaphoreInfo.pNext = nullptr; |
| 679 | semaphoreInfo.flags = 0; |
| 680 | VkSemaphore semaphore; |
| 681 | VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore); |
| 682 | if (VK_SUCCESS != err) { |
Greg Daniel | d667077 | 2021-06-09 12:01:12 -0400 | [diff] [blame] | 683 | close(fenceFd); |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 684 | ALOGE("Failed to create import semaphore, err: %d", err); |
| 685 | return UNKNOWN_ERROR; |
| 686 | } |
| 687 | VkImportSemaphoreFdInfoKHR importInfo; |
| 688 | importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR; |
| 689 | importInfo.pNext = nullptr; |
| 690 | importInfo.semaphore = semaphore; |
| 691 | importInfo.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT; |
| 692 | importInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 693 | importInfo.fd = fenceFd; |
| 694 | |
| 695 | err = mImportSemaphoreFdKHR(mDevice, &importInfo); |
| 696 | if (VK_SUCCESS != err) { |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 697 | mDestroySemaphore(mDevice, semaphore, nullptr); |
Greg Daniel | d667077 | 2021-06-09 12:01:12 -0400 | [diff] [blame] | 698 | close(fenceFd); |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 699 | ALOGE("Failed to import semaphore, err: %d", err); |
| 700 | return UNKNOWN_ERROR; |
| 701 | } |
| 702 | |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 703 | GrBackendSemaphore beSemaphore; |
| 704 | beSemaphore.initVulkan(semaphore); |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 705 | |
Greg Daniel | d667077 | 2021-06-09 12:01:12 -0400 | [diff] [blame] | 706 | // Skia will take ownership of the VkSemaphore and delete it once the wait has finished. The |
| 707 | // VkSemaphore also owns the imported fd, so it will close the fd when it is deleted. |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 708 | grContext->wait(1, &beSemaphore); |
Greg Daniel | c7ad408 | 2020-05-14 15:38:26 -0400 | [diff] [blame] | 709 | grContext->flushAndSubmit(); |
Stan Iliev | 7a08127 | 2018-10-26 17:54:18 -0400 | [diff] [blame] | 710 | |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame] | 711 | return OK; |
| 712 | } |
| 713 | |
Adlai Holler | f8c434e | 2020-07-27 11:42:45 -0400 | [diff] [blame] | 714 | status_t VulkanManager::createReleaseFence(int* nativeFence, GrDirectContext* grContext) { |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 715 | *nativeFence = -1; |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 716 | if (!hasVkContext()) { |
| 717 | ALOGE("VulkanManager::createReleaseFence: VkDevice not initialized"); |
| 718 | return INVALID_OPERATION; |
| 719 | } |
| 720 | |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 721 | VkExportSemaphoreCreateInfo exportInfo; |
| 722 | exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO; |
| 723 | exportInfo.pNext = nullptr; |
| 724 | exportInfo.handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 725 | |
| 726 | VkSemaphoreCreateInfo semaphoreInfo; |
| 727 | semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 728 | semaphoreInfo.pNext = &exportInfo; |
| 729 | semaphoreInfo.flags = 0; |
| 730 | VkSemaphore semaphore; |
| 731 | VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore); |
| 732 | if (VK_SUCCESS != err) { |
| 733 | ALOGE("VulkanManager::createReleaseFence: Failed to create semaphore"); |
| 734 | return INVALID_OPERATION; |
| 735 | } |
| 736 | |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 737 | GrBackendSemaphore backendSemaphore; |
| 738 | backendSemaphore.initVulkan(semaphore); |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 739 | |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 740 | DestroySemaphoreInfo* destroyInfo = |
| 741 | new DestroySemaphoreInfo(mDestroySemaphore, mDevice, semaphore); |
Greg Daniel | fd42939 | 2019-05-09 15:44:56 -0400 | [diff] [blame] | 742 | // Even if Skia fails to submit the semaphore, it will still call the destroy_semaphore callback |
| 743 | // which will remove its ref to the semaphore. The VulkanManager must still release its ref, |
| 744 | // when it is done with the semaphore. |
Greg Daniel | c7ad408 | 2020-05-14 15:38:26 -0400 | [diff] [blame] | 745 | GrFlushInfo flushInfo; |
| 746 | flushInfo.fNumSemaphores = 1; |
| 747 | flushInfo.fSignalSemaphores = &backendSemaphore; |
| 748 | flushInfo.fFinishedProc = destroy_semaphore; |
| 749 | flushInfo.fFinishedContext = destroyInfo; |
| 750 | GrSemaphoresSubmitted submitted = grContext->flush(flushInfo); |
| 751 | grContext->submit(); |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 752 | |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 753 | if (submitted == GrSemaphoresSubmitted::kNo) { |
| 754 | ALOGE("VulkanManager::createReleaseFence: Failed to submit semaphore"); |
Greg Daniel | fd42939 | 2019-05-09 15:44:56 -0400 | [diff] [blame] | 755 | destroy_semaphore(destroyInfo); |
Greg Daniel | d92a9b1 | 2019-04-23 10:11:04 -0400 | [diff] [blame] | 756 | return INVALID_OPERATION; |
| 757 | } |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 758 | |
| 759 | VkSemaphoreGetFdInfoKHR getFdInfo; |
| 760 | getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR; |
| 761 | getFdInfo.pNext = nullptr; |
| 762 | getFdInfo.semaphore = semaphore; |
| 763 | getFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 764 | |
| 765 | int fenceFd = 0; |
| 766 | |
| 767 | err = mGetSemaphoreFdKHR(mDevice, &getFdInfo, &fenceFd); |
Greg Daniel | fd42939 | 2019-05-09 15:44:56 -0400 | [diff] [blame] | 768 | destroy_semaphore(destroyInfo); |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 769 | if (VK_SUCCESS != err) { |
| 770 | ALOGE("VulkanManager::createReleaseFence: Failed to get semaphore Fd"); |
| 771 | return INVALID_OPERATION; |
| 772 | } |
Stan Iliev | aaa9e83 | 2019-09-17 14:07:23 -0400 | [diff] [blame] | 773 | *nativeFence = fenceFd; |
Greg Daniel | 26e0dca | 2018-09-18 10:33:19 -0400 | [diff] [blame] | 774 | |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame] | 775 | return OK; |
| 776 | } |
| 777 | |
Derek Sollenberger | 0e3cba3 | 2016-11-09 11:58:36 -0500 | [diff] [blame] | 778 | } /* namespace renderthread */ |
| 779 | } /* namespace uirenderer */ |
| 780 | } /* namespace android */ |