blob: c9290989865281f21b0af36068220a4c2b01ea93 [file] [log] [blame]
Derek Sollenberger0e3cba32016-11-09 11:58:36 -05001/*
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
Derek Sollenbergera19b71a2019-02-15 16:36:30 -050019#include <android/sync.h>
Stan Iliev305e13a2018-11-13 11:14:48 -050020#include <gui/Surface.h>
21
Greg Danielcd558522016-11-17 13:31:40 -050022#include "Properties.h"
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050023#include "RenderThread.h"
Greg Daniel45ec62b2017-01-04 14:27:00 -050024#include "renderstate/RenderState.h"
Ben Wagnereec27d52017-01-11 15:32:07 -050025#include "utils/FatVector.h"
John Reck322b8ab2019-03-14 13:15:28 -070026#include "utils/TraceUtils.h"
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050027
Derek Sollenbergera19b71a2019-02-15 16:36:30 -050028#include <GrBackendSemaphore.h>
Greg Danielac2d2322017-07-12 11:30:15 -040029#include <GrBackendSurface.h>
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050030#include <GrContext.h>
31#include <GrTypes.h>
Greg Daniela227dbb2018-08-20 09:19:48 -040032#include <GrTypes.h>
33#include <vk/GrVkExtensions.h>
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050034#include <vk/GrVkTypes.h>
35
36namespace android {
37namespace uirenderer {
38namespace renderthread {
39
Bo Liu7b8c1eb2019-01-08 20:17:55 -080040static void free_features_extensions_structs(const VkPhysicalDeviceFeatures2& features) {
41 // All Vulkan structs that could be part of the features chain will start with the
42 // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader
43 // so we can get access to the pNext for the next struct.
44 struct CommonVulkanHeader {
45 VkStructureType sType;
46 void* pNext;
47 };
48
49 void* pNext = features.pNext;
50 while (pNext) {
51 void* current = pNext;
52 pNext = static_cast<CommonVulkanHeader*>(current)->pNext;
53 free(current);
54 }
55}
56
Greg Daniel2ff202712018-06-14 11:50:10 -040057#define GET_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(VK_NULL_HANDLE, "vk" #F)
58#define GET_INST_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(mInstance, "vk" #F)
59#define GET_DEV_PROC(F) m##F = (PFN_vk##F)vkGetDeviceProcAddr(mDevice, "vk" #F)
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050060
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050061void VulkanManager::destroy() {
Greg Daniel26e0dca2018-09-18 10:33:19 -040062 // We don't need to explicitly free the command buffer since it automatically gets freed when we
63 // delete the VkCommandPool below.
64 mDummyCB = VK_NULL_HANDLE;
65
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050066 if (VK_NULL_HANDLE != mCommandPool) {
Greg Daniel2ff202712018-06-14 11:50:10 -040067 mDestroyCommandPool(mDevice, mCommandPool, nullptr);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050068 mCommandPool = VK_NULL_HANDLE;
69 }
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050070
Greg Daniel2ff202712018-06-14 11:50:10 -040071 if (mDevice != VK_NULL_HANDLE) {
72 mDeviceWaitIdle(mDevice);
73 mDestroyDevice(mDevice, nullptr);
John Reck1bcacfd2017-11-03 10:12:19 -070074 }
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050075
Greg Daniel2ff202712018-06-14 11:50:10 -040076 if (mInstance != VK_NULL_HANDLE) {
77 mDestroyInstance(mInstance, nullptr);
78 }
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050079
Greg Daniel2ff202712018-06-14 11:50:10 -040080 mGraphicsQueue = VK_NULL_HANDLE;
81 mPresentQueue = VK_NULL_HANDLE;
82 mDevice = VK_NULL_HANDLE;
83 mPhysicalDevice = VK_NULL_HANDLE;
84 mInstance = VK_NULL_HANDLE;
Roman Kiryanov74ace839e2019-03-07 18:22:19 -080085 mInstanceExtensionsOwner.clear();
Bo Liu7b8c1eb2019-01-08 20:17:55 -080086 mInstanceExtensions.clear();
Roman Kiryanov74ace839e2019-03-07 18:22:19 -080087 mDeviceExtensionsOwner.clear();
Bo Liu7b8c1eb2019-01-08 20:17:55 -080088 mDeviceExtensions.clear();
89 free_features_extensions_structs(mPhysicalDeviceFeatures2);
90 mPhysicalDeviceFeatures2 = {};
Greg Daniel2ff202712018-06-14 11:50:10 -040091}
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050092
Stan Iliev90276c82019-02-03 18:01:02 -050093void VulkanManager::setupDevice(GrVkExtensions& grExtensions, VkPhysicalDeviceFeatures2& features) {
Greg Daniel2ff202712018-06-14 11:50:10 -040094 VkResult err;
95
96 constexpr VkApplicationInfo app_info = {
97 VK_STRUCTURE_TYPE_APPLICATION_INFO, // sType
98 nullptr, // pNext
99 "android framework", // pApplicationName
100 0, // applicationVersion
101 "android framework", // pEngineName
102 0, // engineVerison
Greg Danieleaf310e2019-01-28 16:10:32 -0500103 mAPIVersion, // apiVersion
Greg Daniel2ff202712018-06-14 11:50:10 -0400104 };
105
Greg Daniel2ff202712018-06-14 11:50:10 -0400106 {
107 GET_PROC(EnumerateInstanceExtensionProperties);
108
109 uint32_t extensionCount = 0;
110 err = mEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
Stan Iliev90276c82019-02-03 18:01:02 -0500111 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err);
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800112 mInstanceExtensionsOwner.resize(extensionCount);
113 err = mEnumerateInstanceExtensionProperties(nullptr, &extensionCount,
114 mInstanceExtensionsOwner.data());
Stan Iliev90276c82019-02-03 18:01:02 -0500115 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err);
Greg Daniel2ff202712018-06-14 11:50:10 -0400116 bool hasKHRSurfaceExtension = false;
117 bool hasKHRAndroidSurfaceExtension = false;
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800118 for (const VkExtensionProperties& extension : mInstanceExtensionsOwner) {
119 mInstanceExtensions.push_back(extension.extensionName);
120 if (!strcmp(extension.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) {
Greg Daniel2ff202712018-06-14 11:50:10 -0400121 hasKHRSurfaceExtension = true;
122 }
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800123 if (!strcmp(extension.extensionName, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)) {
Greg Daniel2ff202712018-06-14 11:50:10 -0400124 hasKHRAndroidSurfaceExtension = true;
125 }
126 }
Stan Iliev90276c82019-02-03 18:01:02 -0500127 LOG_ALWAYS_FATAL_IF(!hasKHRSurfaceExtension || !hasKHRAndroidSurfaceExtension);
Greg Daniel2ff202712018-06-14 11:50:10 -0400128 }
129
130 const VkInstanceCreateInfo instance_create = {
131 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
132 nullptr, // pNext
133 0, // flags
134 &app_info, // pApplicationInfo
135 0, // enabledLayerNameCount
136 nullptr, // ppEnabledLayerNames
Bo Liu7b8c1eb2019-01-08 20:17:55 -0800137 (uint32_t) mInstanceExtensions.size(), // enabledExtensionNameCount
138 mInstanceExtensions.data(), // ppEnabledExtensionNames
Greg Daniel2ff202712018-06-14 11:50:10 -0400139 };
140
141 GET_PROC(CreateInstance);
142 err = mCreateInstance(&instance_create, nullptr, &mInstance);
Stan Iliev90276c82019-02-03 18:01:02 -0500143 LOG_ALWAYS_FATAL_IF(err < 0);
Greg Daniel2ff202712018-06-14 11:50:10 -0400144
145 GET_INST_PROC(DestroyInstance);
146 GET_INST_PROC(EnumeratePhysicalDevices);
Greg Daniel96259622018-10-01 14:42:56 -0400147 GET_INST_PROC(GetPhysicalDeviceProperties);
Greg Daniel2ff202712018-06-14 11:50:10 -0400148 GET_INST_PROC(GetPhysicalDeviceQueueFamilyProperties);
Greg Daniela227dbb2018-08-20 09:19:48 -0400149 GET_INST_PROC(GetPhysicalDeviceFeatures2);
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500150 GET_INST_PROC(GetPhysicalDeviceImageFormatProperties2);
Greg Daniel2ff202712018-06-14 11:50:10 -0400151 GET_INST_PROC(CreateDevice);
152 GET_INST_PROC(EnumerateDeviceExtensionProperties);
153 GET_INST_PROC(CreateAndroidSurfaceKHR);
154 GET_INST_PROC(DestroySurfaceKHR);
155 GET_INST_PROC(GetPhysicalDeviceSurfaceSupportKHR);
156 GET_INST_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
157 GET_INST_PROC(GetPhysicalDeviceSurfaceFormatsKHR);
158 GET_INST_PROC(GetPhysicalDeviceSurfacePresentModesKHR);
159
160 uint32_t gpuCount;
Stan Iliev90276c82019-02-03 18:01:02 -0500161 LOG_ALWAYS_FATAL_IF(mEnumeratePhysicalDevices(mInstance, &gpuCount, nullptr));
162 LOG_ALWAYS_FATAL_IF(!gpuCount);
Greg Daniel2ff202712018-06-14 11:50:10 -0400163 // Just returning the first physical device instead of getting the whole array. Since there
164 // should only be one device on android.
165 gpuCount = 1;
166 err = mEnumeratePhysicalDevices(mInstance, &gpuCount, &mPhysicalDevice);
167 // VK_INCOMPLETE is returned when the count we provide is less than the total device count.
Stan Iliev90276c82019-02-03 18:01:02 -0500168 LOG_ALWAYS_FATAL_IF(err && VK_INCOMPLETE != err);
Greg Daniel2ff202712018-06-14 11:50:10 -0400169
Greg Daniel96259622018-10-01 14:42:56 -0400170 VkPhysicalDeviceProperties physDeviceProperties;
171 mGetPhysicalDeviceProperties(mPhysicalDevice, &physDeviceProperties);
Stan Iliev90276c82019-02-03 18:01:02 -0500172 LOG_ALWAYS_FATAL_IF(physDeviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0));
Greg Daniel96259622018-10-01 14:42:56 -0400173
Greg Daniel2ff202712018-06-14 11:50:10 -0400174 // query to get the initial queue props size
175 uint32_t queueCount;
176 mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, nullptr);
Stan Iliev90276c82019-02-03 18:01:02 -0500177 LOG_ALWAYS_FATAL_IF(!queueCount);
Greg Daniel2ff202712018-06-14 11:50:10 -0400178
179 // now get the actual queue props
180 std::unique_ptr<VkQueueFamilyProperties[]> queueProps(new VkQueueFamilyProperties[queueCount]);
181 mGetPhysicalDeviceQueueFamilyProperties(mPhysicalDevice, &queueCount, queueProps.get());
182
183 // iterate to find the graphics queue
184 mGraphicsQueueIndex = queueCount;
185 for (uint32_t i = 0; i < queueCount; i++) {
186 if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
187 mGraphicsQueueIndex = i;
188 break;
189 }
190 }
Stan Iliev90276c82019-02-03 18:01:02 -0500191 LOG_ALWAYS_FATAL_IF(mGraphicsQueueIndex == queueCount);
Greg Daniel2ff202712018-06-14 11:50:10 -0400192
193 // All physical devices and queue families on Android must be capable of
194 // presentation with any native window. So just use the first one.
195 mPresentQueueIndex = 0;
196
Greg Daniel2ff202712018-06-14 11:50:10 -0400197 {
198 uint32_t extensionCount = 0;
199 err = mEnumerateDeviceExtensionProperties(mPhysicalDevice, nullptr, &extensionCount,
200 nullptr);
Stan Iliev90276c82019-02-03 18:01:02 -0500201 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err);
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800202 mDeviceExtensionsOwner.resize(extensionCount);
Greg Daniel2ff202712018-06-14 11:50:10 -0400203 err = mEnumerateDeviceExtensionProperties(mPhysicalDevice, nullptr, &extensionCount,
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800204 mDeviceExtensionsOwner.data());
Stan Iliev90276c82019-02-03 18:01:02 -0500205 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err);
Greg Daniel2ff202712018-06-14 11:50:10 -0400206 bool hasKHRSwapchainExtension = false;
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800207 for (const VkExtensionProperties& extension : mDeviceExtensionsOwner) {
208 mDeviceExtensions.push_back(extension.extensionName);
209 if (!strcmp(extension.extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
Greg Daniel2ff202712018-06-14 11:50:10 -0400210 hasKHRSwapchainExtension = true;
211 }
212 }
Stan Iliev90276c82019-02-03 18:01:02 -0500213 LOG_ALWAYS_FATAL_IF(!hasKHRSwapchainExtension);
Greg Daniel2ff202712018-06-14 11:50:10 -0400214 }
215
Greg Daniela227dbb2018-08-20 09:19:48 -0400216 auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) {
217 if (device != VK_NULL_HANDLE) {
218 return vkGetDeviceProcAddr(device, proc_name);
219 }
220 return vkGetInstanceProcAddr(instance, proc_name);
221 };
Roman Kiryanov74ace839e2019-03-07 18:22:19 -0800222
Bo Liu7b8c1eb2019-01-08 20:17:55 -0800223 grExtensions.init(getProc, mInstance, mPhysicalDevice, mInstanceExtensions.size(),
224 mInstanceExtensions.data(), mDeviceExtensions.size(), mDeviceExtensions.data());
Greg Daniela227dbb2018-08-20 09:19:48 -0400225
Stan Iliev90276c82019-02-03 18:01:02 -0500226 LOG_ALWAYS_FATAL_IF(!grExtensions.hasExtension(VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, 1));
Greg Daniel26e0dca2018-09-18 10:33:19 -0400227
Greg Daniela227dbb2018-08-20 09:19:48 -0400228 memset(&features, 0, sizeof(VkPhysicalDeviceFeatures2));
229 features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
230 features.pNext = nullptr;
231
232 // Setup all extension feature structs we may want to use.
233 void** tailPNext = &features.pNext;
234
235 if (grExtensions.hasExtension(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, 2)) {
236 VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT* blend;
237 blend = (VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT*) malloc(
238 sizeof(VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT));
239 LOG_ALWAYS_FATAL_IF(!blend);
240 blend->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT;
241 blend->pNext = nullptr;
242 *tailPNext = blend;
243 tailPNext = &blend->pNext;
244 }
245
Greg Daniel05036172018-11-28 17:08:04 -0500246 VkPhysicalDeviceSamplerYcbcrConversionFeatures* ycbcrFeature;
247 ycbcrFeature = (VkPhysicalDeviceSamplerYcbcrConversionFeatures*) malloc(
248 sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures));
249 LOG_ALWAYS_FATAL_IF(!ycbcrFeature);
250 ycbcrFeature->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
251 ycbcrFeature->pNext = nullptr;
252 *tailPNext = ycbcrFeature;
253 tailPNext = &ycbcrFeature->pNext;
254
Greg Daniela227dbb2018-08-20 09:19:48 -0400255 // query to get the physical device features
256 mGetPhysicalDeviceFeatures2(mPhysicalDevice, &features);
Greg Daniel2ff202712018-06-14 11:50:10 -0400257 // this looks like it would slow things down,
258 // and we can't depend on it on all platforms
Greg Daniela227dbb2018-08-20 09:19:48 -0400259 features.features.robustBufferAccess = VK_FALSE;
Greg Daniel2ff202712018-06-14 11:50:10 -0400260
261 float queuePriorities[1] = { 0.0 };
262
Stan Iliev7e733362019-02-28 13:16:36 -0500263 void* queueNextPtr = nullptr;
264
265 VkDeviceQueueGlobalPriorityCreateInfoEXT queuePriorityCreateInfo;
266
267 if (Properties::contextPriority != 0
268 && grExtensions.hasExtension(VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, 2)) {
269 memset(&queuePriorityCreateInfo, 0, sizeof(VkDeviceQueueGlobalPriorityCreateInfoEXT));
270 queuePriorityCreateInfo.sType =
271 VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT;
272 queuePriorityCreateInfo.pNext = nullptr;
273 switch (Properties::contextPriority) {
274 case EGL_CONTEXT_PRIORITY_LOW_IMG:
275 queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT;
276 break;
277 case EGL_CONTEXT_PRIORITY_MEDIUM_IMG:
278 queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
279 break;
280 case EGL_CONTEXT_PRIORITY_HIGH_IMG:
281 queuePriorityCreateInfo.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT;
282 break;
283 default:
284 LOG_ALWAYS_FATAL("Unsupported context priority");
285 }
286 queueNextPtr = &queuePriorityCreateInfo;
287 }
288
Greg Daniel2ff202712018-06-14 11:50:10 -0400289 const VkDeviceQueueCreateInfo queueInfo[2] = {
290 {
291 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
Stan Iliev7e733362019-02-28 13:16:36 -0500292 queueNextPtr, // pNext
Greg Daniel2ff202712018-06-14 11:50:10 -0400293 0, // VkDeviceQueueCreateFlags
294 mGraphicsQueueIndex, // queueFamilyIndex
295 1, // queueCount
296 queuePriorities, // pQueuePriorities
297 },
298 {
299 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
Stan Iliev7e733362019-02-28 13:16:36 -0500300 queueNextPtr, // pNext
Greg Daniel2ff202712018-06-14 11:50:10 -0400301 0, // VkDeviceQueueCreateFlags
302 mPresentQueueIndex, // queueFamilyIndex
303 1, // queueCount
304 queuePriorities, // pQueuePriorities
305 }
306 };
307 uint32_t queueInfoCount = (mPresentQueueIndex != mGraphicsQueueIndex) ? 2 : 1;
308
309 const VkDeviceCreateInfo deviceInfo = {
310 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
Greg Daniela227dbb2018-08-20 09:19:48 -0400311 &features, // pNext
Greg Daniel2ff202712018-06-14 11:50:10 -0400312 0, // VkDeviceCreateFlags
313 queueInfoCount, // queueCreateInfoCount
314 queueInfo, // pQueueCreateInfos
315 0, // layerCount
316 nullptr, // ppEnabledLayerNames
Bo Liu7b8c1eb2019-01-08 20:17:55 -0800317 (uint32_t) mDeviceExtensions.size(), // extensionCount
318 mDeviceExtensions.data(), // ppEnabledExtensionNames
Greg Daniela227dbb2018-08-20 09:19:48 -0400319 nullptr, // ppEnabledFeatures
Greg Daniel2ff202712018-06-14 11:50:10 -0400320 };
321
Stan Iliev90276c82019-02-03 18:01:02 -0500322 LOG_ALWAYS_FATAL_IF(mCreateDevice(mPhysicalDevice, &deviceInfo, nullptr, &mDevice));
Greg Daniel2ff202712018-06-14 11:50:10 -0400323
324 GET_DEV_PROC(GetDeviceQueue);
325 GET_DEV_PROC(DeviceWaitIdle);
326 GET_DEV_PROC(DestroyDevice);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500327 GET_DEV_PROC(CreateCommandPool);
328 GET_DEV_PROC(DestroyCommandPool);
329 GET_DEV_PROC(AllocateCommandBuffers);
330 GET_DEV_PROC(FreeCommandBuffers);
331 GET_DEV_PROC(ResetCommandBuffer);
332 GET_DEV_PROC(BeginCommandBuffer);
333 GET_DEV_PROC(EndCommandBuffer);
334 GET_DEV_PROC(CmdPipelineBarrier);
335 GET_DEV_PROC(GetDeviceQueue);
336 GET_DEV_PROC(QueueSubmit);
337 GET_DEV_PROC(QueueWaitIdle);
338 GET_DEV_PROC(DeviceWaitIdle);
339 GET_DEV_PROC(CreateSemaphore);
340 GET_DEV_PROC(DestroySemaphore);
Greg Daniel26e0dca2018-09-18 10:33:19 -0400341 GET_DEV_PROC(ImportSemaphoreFdKHR);
342 GET_DEV_PROC(GetSemaphoreFdKHR);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500343 GET_DEV_PROC(CreateFence);
344 GET_DEV_PROC(DestroyFence);
345 GET_DEV_PROC(WaitForFences);
346 GET_DEV_PROC(ResetFences);
Greg Daniel2ff202712018-06-14 11:50:10 -0400347}
348
349void VulkanManager::initialize() {
350 if (mDevice != VK_NULL_HANDLE) {
351 return;
352 }
353
Greg Daniela227dbb2018-08-20 09:19:48 -0400354 GET_PROC(EnumerateInstanceVersion);
Greg Danieleaf310e2019-01-28 16:10:32 -0500355 uint32_t instanceVersion;
356 LOG_ALWAYS_FATAL_IF(mEnumerateInstanceVersion(&instanceVersion));
357 LOG_ALWAYS_FATAL_IF(instanceVersion < VK_MAKE_VERSION(1, 1, 0));
Greg Daniela227dbb2018-08-20 09:19:48 -0400358
Stan Iliev981afe72019-02-13 14:24:33 -0500359 this->setupDevice(mExtensions, mPhysicalDeviceFeatures2);
Greg Daniel2ff202712018-06-14 11:50:10 -0400360
361 mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue);
362
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500363 // create the command pool for the command buffers
364 if (VK_NULL_HANDLE == mCommandPool) {
365 VkCommandPoolCreateInfo commandPoolInfo;
366 memset(&commandPoolInfo, 0, sizeof(VkCommandPoolCreateInfo));
367 commandPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
368 // this needs to be on the render queue
Greg Daniel2ff202712018-06-14 11:50:10 -0400369 commandPoolInfo.queueFamilyIndex = mGraphicsQueueIndex;
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500370 commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
Greg Daniel2ff202712018-06-14 11:50:10 -0400371 SkDEBUGCODE(VkResult res =) mCreateCommandPool(mDevice, &commandPoolInfo, nullptr,
372 &mCommandPool);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500373 SkASSERT(VK_SUCCESS == res);
374 }
Greg Daniel26e0dca2018-09-18 10:33:19 -0400375 LOG_ALWAYS_FATAL_IF(mCommandPool == VK_NULL_HANDLE);
376
377 if (!setupDummyCommandBuffer()) {
378 this->destroy();
Stan Iliev90276c82019-02-03 18:01:02 -0500379 // Pass through will crash on next line.
Greg Daniel26e0dca2018-09-18 10:33:19 -0400380 }
381 LOG_ALWAYS_FATAL_IF(mDummyCB == VK_NULL_HANDLE);
382
Greg Daniel2ff202712018-06-14 11:50:10 -0400383 mGetDeviceQueue(mDevice, mPresentQueueIndex, 0, &mPresentQueue);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500384
Greg Danielcd558522016-11-17 13:31:40 -0500385 if (Properties::enablePartialUpdates && Properties::useBufferAge) {
386 mSwapBehavior = SwapBehavior::BufferAge;
387 }
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500388}
389
Stan Iliev898123b2019-02-14 14:57:44 -0500390sk_sp<GrContext> VulkanManager::createContext(const GrContextOptions& options) {
Stan Iliev981afe72019-02-13 14:24:33 -0500391 auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) {
392 if (device != VK_NULL_HANDLE) {
393 return vkGetDeviceProcAddr(device, proc_name);
394 }
395 return vkGetInstanceProcAddr(instance, proc_name);
396 };
397
398 GrVkBackendContext backendContext;
399 backendContext.fInstance = mInstance;
400 backendContext.fPhysicalDevice = mPhysicalDevice;
401 backendContext.fDevice = mDevice;
402 backendContext.fQueue = mGraphicsQueue;
403 backendContext.fGraphicsQueueIndex = mGraphicsQueueIndex;
404 backendContext.fMaxAPIVersion = mAPIVersion;
405 backendContext.fVkExtensions = &mExtensions;
406 backendContext.fDeviceFeatures2 = &mPhysicalDeviceFeatures2;
407 backendContext.fGetProc = std::move(getProc);
408
409 return GrContext::MakeVulkan(backendContext, options);
410}
411
Bo Liu7b8c1eb2019-01-08 20:17:55 -0800412VkFunctorInitParams VulkanManager::getVkFunctorInitParams() const {
413 return VkFunctorInitParams{
414 .instance = mInstance,
415 .physical_device = mPhysicalDevice,
416 .device = mDevice,
417 .queue = mGraphicsQueue,
418 .graphics_queue_index = mGraphicsQueueIndex,
Greg Danieleaf310e2019-01-28 16:10:32 -0500419 .api_version = mAPIVersion,
Bo Liu7b8c1eb2019-01-08 20:17:55 -0800420 .enabled_instance_extension_names = mInstanceExtensions.data(),
421 .enabled_instance_extension_names_length =
422 static_cast<uint32_t>(mInstanceExtensions.size()),
423 .enabled_device_extension_names = mDeviceExtensions.data(),
424 .enabled_device_extension_names_length =
425 static_cast<uint32_t>(mDeviceExtensions.size()),
426 .device_features_2 = &mPhysicalDeviceFeatures2,
427 };
428}
429
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500430Frame VulkanManager::dequeueNextBuffer(VulkanSurface* surface) {
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500431
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500432 VulkanSurface::NativeBufferInfo* bufferInfo = surface->dequeueNativeBuffer();
433
434 if (bufferInfo == nullptr) {
435 ALOGE("VulkanSurface::dequeueNativeBuffer called with an invalid surface!");
436 return Frame(-1, -1, 0);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500437 }
438
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500439 LOG_ALWAYS_FATAL_IF(!bufferInfo->dequeued);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500440
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500441 if (bufferInfo->dequeue_fence != -1) {
Stan Iliev197843d2019-03-21 11:34:15 -0400442 struct sync_file_info* finfo = sync_file_info(bufferInfo->dequeue_fence);
443 bool isSignalPending = false;
444 if (finfo != NULL) {
445 isSignalPending = finfo->status != 1;
446 sync_file_info_free(finfo);
447 }
448 if (isSignalPending) {
449 int fence_clone = dup(bufferInfo->dequeue_fence);
450 if (fence_clone == -1) {
451 ALOGE("dup(fence) failed, stalling until signalled: %s (%d)", strerror(errno),
452 errno);
453 sync_wait(bufferInfo->dequeue_fence, -1 /* forever */);
454 } else {
455 VkSemaphoreCreateInfo semaphoreInfo;
456 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
457 semaphoreInfo.pNext = nullptr;
458 semaphoreInfo.flags = 0;
459 VkSemaphore semaphore;
460 VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
461 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err, "Failed to create import semaphore, err: %d",
462 err);
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500463
Stan Iliev197843d2019-03-21 11:34:15 -0400464 VkImportSemaphoreFdInfoKHR importInfo;
465 importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR;
466 importInfo.pNext = nullptr;
467 importInfo.semaphore = semaphore;
468 importInfo.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT;
469 importInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
470 importInfo.fd = fence_clone;
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500471
Stan Iliev197843d2019-03-21 11:34:15 -0400472 err = mImportSemaphoreFdKHR(mDevice, &importInfo);
473 LOG_ALWAYS_FATAL_IF(VK_SUCCESS != err, "Failed to import semaphore, err: %d", err);
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500474
Stan Iliev197843d2019-03-21 11:34:15 -0400475 GrBackendSemaphore backendSemaphore;
476 backendSemaphore.initVulkan(semaphore);
477 bufferInfo->skSurface->wait(1, &backendSemaphore);
478 // The following flush blocks the GPU immediately instead of waiting for other
479 // drawing ops. It seems dequeue_fence is not respected otherwise.
480 //TODO: remove the flush after finding why backendSemaphore is not working.
481 bufferInfo->skSurface->flush();
482 }
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500483 }
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500484 }
485
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500486 int bufferAge = (mSwapBehavior == SwapBehavior::Discard) ? 0 : surface->getCurrentBuffersAge();
487 return Frame(surface->logicalWidth(), surface->logicalHeight(), bufferAge);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500488}
489
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500490void VulkanManager::swapBuffers(VulkanSurface* surface, const SkRect& dirtyRect) {
491 if (CC_UNLIKELY(Properties::waitForGpuCompletion)) {
492 ATRACE_NAME("Finishing GPU work");
493 mDeviceWaitIdle(mDevice);
Stan Iliev305e13a2018-11-13 11:14:48 -0500494 }
495
Stan Ilievbc5f06b2019-03-26 15:14:34 -0400496 VulkanSurface::NativeBufferInfo* bufferInfo = surface->getCurrentBufferInfo();
497 if (!bufferInfo) {
498 // If VulkanSurface::dequeueNativeBuffer failed earlier, then swapBuffers is a no-op.
499 return;
500 }
501
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500502 VkExportSemaphoreCreateInfo exportInfo;
503 exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO;
504 exportInfo.pNext = nullptr;
505 exportInfo.handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500506
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500507 VkSemaphoreCreateInfo semaphoreInfo;
508 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
509 semaphoreInfo.pNext = &exportInfo;
510 semaphoreInfo.flags = 0;
511 VkSemaphore semaphore;
512 VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
513 ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to create semaphore");
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500514
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500515 GrBackendSemaphore backendSemaphore;
516 backendSemaphore.initVulkan(semaphore);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500517
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500518 int fenceFd = -1;
519 GrSemaphoresSubmitted submitted =
520 bufferInfo->skSurface->flush(SkSurface::BackendSurfaceAccess::kPresent,
521 SkSurface::kNone_FlushFlags, 1, &backendSemaphore);
522 if (submitted == GrSemaphoresSubmitted::kYes) {
523 VkSemaphoreGetFdInfoKHR getFdInfo;
524 getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR;
525 getFdInfo.pNext = nullptr;
526 getFdInfo.semaphore = semaphore;
527 getFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500528
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500529 err = mGetSemaphoreFdKHR(mDevice, &getFdInfo, &fenceFd);
530 ALOGE_IF(VK_SUCCESS != err, "VulkanManager::swapBuffers(): Failed to get semaphore Fd");
531 } else {
532 ALOGE("VulkanManager::swapBuffers(): Semaphore submission failed");
533 mQueueWaitIdle(mGraphicsQueue);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500534 }
535
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500536 surface->presentCurrentBuffer(dirtyRect, fenceFd);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500537
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500538 // Exporting a semaphore with copy transference via vkGetSemaphoreFdKHR, has the same effect of
539 // destroying the semaphore and creating a new one with the same handle, and the payloads
540 // ownership is move to the Fd we created. Thus the semaphore is in a state that we can delete
541 // it and we don't need to wait on the command buffer we submitted to finish.
542 mDestroySemaphore(mDevice, semaphore, nullptr);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500543}
544
545void VulkanManager::destroySurface(VulkanSurface* surface) {
546 // Make sure all submit commands have finished before starting to destroy objects.
547 if (VK_NULL_HANDLE != mPresentQueue) {
548 mQueueWaitIdle(mPresentQueue);
549 }
Greg Daniel2ff202712018-06-14 11:50:10 -0400550 mDeviceWaitIdle(mDevice);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500551
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500552 delete surface;
553}
554
Stan Iliev987a80c2018-12-04 10:07:21 -0500555VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode,
Peiyong Lin3bff1352018-12-11 07:56:07 -0800556 sk_sp<SkColorSpace> surfaceColorSpace,
Stan Iliev981afe72019-02-13 14:24:33 -0500557 SkColorType surfaceColorType,
558 GrContext* grContext) {
559 LOG_ALWAYS_FATAL_IF(!hasVkContext(), "Not initialized");
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500560 if (!window) {
561 return nullptr;
562 }
563
Derek Sollenbergera19b71a2019-02-15 16:36:30 -0500564 return VulkanSurface::Create(window, colorMode, surfaceColorType, surfaceColorSpace, grContext,
565 *this);
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500566}
567
Greg Daniel26e0dca2018-09-18 10:33:19 -0400568bool VulkanManager::setupDummyCommandBuffer() {
569 if (mDummyCB != VK_NULL_HANDLE) {
570 return true;
571 }
572
573 VkCommandBufferAllocateInfo commandBuffersInfo;
574 memset(&commandBuffersInfo, 0, sizeof(VkCommandBufferAllocateInfo));
575 commandBuffersInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
576 commandBuffersInfo.pNext = nullptr;
577 commandBuffersInfo.commandPool = mCommandPool;
578 commandBuffersInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
579 commandBuffersInfo.commandBufferCount = 1;
580
581 VkResult err = mAllocateCommandBuffers(mDevice, &commandBuffersInfo, &mDummyCB);
582 if (err != VK_SUCCESS) {
583 // It is probably unnecessary to set this back to VK_NULL_HANDLE, but we set it anyways to
584 // make sure the driver didn't set a value and then return a failure.
585 mDummyCB = VK_NULL_HANDLE;
586 return false;
587 }
588
589 VkCommandBufferBeginInfo beginInfo;
590 memset(&beginInfo, 0, sizeof(VkCommandBufferBeginInfo));
591 beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
592 beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
593
594 mBeginCommandBuffer(mDummyCB, &beginInfo);
595 mEndCommandBuffer(mDummyCB);
596 return true;
597}
598
Stan Iliev564ca3e2018-09-04 22:00:00 +0000599status_t VulkanManager::fenceWait(sp<Fence>& fence) {
Greg Daniel26e0dca2018-09-18 10:33:19 -0400600 if (!hasVkContext()) {
601 ALOGE("VulkanManager::fenceWait: VkDevice not initialized");
602 return INVALID_OPERATION;
603 }
604
Stan Iliev7a081272018-10-26 17:54:18 -0400605 // Block GPU on the fence.
606 int fenceFd = fence->dup();
607 if (fenceFd == -1) {
608 ALOGE("VulkanManager::fenceWait: error dup'ing fence fd: %d", errno);
609 return -errno;
Stan Iliev564ca3e2018-09-04 22:00:00 +0000610 }
Stan Iliev7a081272018-10-26 17:54:18 -0400611
612 VkSemaphoreCreateInfo semaphoreInfo;
613 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
614 semaphoreInfo.pNext = nullptr;
615 semaphoreInfo.flags = 0;
616 VkSemaphore semaphore;
617 VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
618 if (VK_SUCCESS != err) {
619 ALOGE("Failed to create import semaphore, err: %d", err);
620 return UNKNOWN_ERROR;
621 }
622 VkImportSemaphoreFdInfoKHR importInfo;
623 importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR;
624 importInfo.pNext = nullptr;
625 importInfo.semaphore = semaphore;
626 importInfo.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT;
627 importInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
628 importInfo.fd = fenceFd;
629
630 err = mImportSemaphoreFdKHR(mDevice, &importInfo);
631 if (VK_SUCCESS != err) {
632 ALOGE("Failed to import semaphore, err: %d", err);
633 return UNKNOWN_ERROR;
634 }
635
636 LOG_ALWAYS_FATAL_IF(mDummyCB == VK_NULL_HANDLE);
637
638 VkPipelineStageFlags waitDstStageFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
639
640 VkSubmitInfo submitInfo;
641 memset(&submitInfo, 0, sizeof(VkSubmitInfo));
642 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
643 submitInfo.waitSemaphoreCount = 1;
644 // Wait to make sure aquire semaphore set above has signaled.
645 submitInfo.pWaitSemaphores = &semaphore;
646 submitInfo.pWaitDstStageMask = &waitDstStageFlags;
647 submitInfo.commandBufferCount = 1;
648 submitInfo.pCommandBuffers = &mDummyCB;
649 submitInfo.signalSemaphoreCount = 0;
650
651 mQueueSubmit(mGraphicsQueue, 1, &submitInfo, VK_NULL_HANDLE);
652
653 // On Android when we import a semaphore, it is imported using temporary permanence. That
654 // means as soon as we queue the semaphore for a wait it reverts to its previous permanent
655 // state before importing. This means it will now be in an idle state with no pending
656 // signal or wait operations, so it is safe to immediately delete it.
657 mDestroySemaphore(mDevice, semaphore, nullptr);
Stan Iliev564ca3e2018-09-04 22:00:00 +0000658 return OK;
659}
660
661status_t VulkanManager::createReleaseFence(sp<Fence>& nativeFence) {
Greg Daniel26e0dca2018-09-18 10:33:19 -0400662 if (!hasVkContext()) {
663 ALOGE("VulkanManager::createReleaseFence: VkDevice not initialized");
664 return INVALID_OPERATION;
665 }
666
Greg Daniel26e0dca2018-09-18 10:33:19 -0400667 VkExportSemaphoreCreateInfo exportInfo;
668 exportInfo.sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO;
669 exportInfo.pNext = nullptr;
670 exportInfo.handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
671
672 VkSemaphoreCreateInfo semaphoreInfo;
673 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
674 semaphoreInfo.pNext = &exportInfo;
675 semaphoreInfo.flags = 0;
676 VkSemaphore semaphore;
677 VkResult err = mCreateSemaphore(mDevice, &semaphoreInfo, nullptr, &semaphore);
678 if (VK_SUCCESS != err) {
679 ALOGE("VulkanManager::createReleaseFence: Failed to create semaphore");
680 return INVALID_OPERATION;
681 }
682
683 LOG_ALWAYS_FATAL_IF(mDummyCB == VK_NULL_HANDLE);
684
685 VkSubmitInfo submitInfo;
686 memset(&submitInfo, 0, sizeof(VkSubmitInfo));
687 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
688 submitInfo.waitSemaphoreCount = 0;
689 submitInfo.pWaitSemaphores = nullptr;
690 submitInfo.pWaitDstStageMask = nullptr;
691 submitInfo.commandBufferCount = 1;
692 submitInfo.pCommandBuffers = &mDummyCB;
693 submitInfo.signalSemaphoreCount = 1;
694 submitInfo.pSignalSemaphores = &semaphore;
695
696 mQueueSubmit(mGraphicsQueue, 1, &submitInfo, VK_NULL_HANDLE);
697
698 VkSemaphoreGetFdInfoKHR getFdInfo;
699 getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR;
700 getFdInfo.pNext = nullptr;
701 getFdInfo.semaphore = semaphore;
702 getFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
703
704 int fenceFd = 0;
705
706 err = mGetSemaphoreFdKHR(mDevice, &getFdInfo, &fenceFd);
707 if (VK_SUCCESS != err) {
708 ALOGE("VulkanManager::createReleaseFence: Failed to get semaphore Fd");
709 return INVALID_OPERATION;
710 }
711 nativeFence = new Fence(fenceFd);
712
713 // Exporting a semaphore with copy transference via vkGetSemahporeFdKHR, has the same effect of
714 // destroying the semaphore and creating a new one with the same handle, and the payloads
715 // ownership is move to the Fd we created. Thus the semahpore is in a state that we can delete
716 // it and we don't need to wait on the command buffer we submitted to finish.
717 mDestroySemaphore(mDevice, semaphore, nullptr);
718
Stan Iliev564ca3e2018-09-04 22:00:00 +0000719 return OK;
720}
721
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500722} /* namespace renderthread */
723} /* namespace uirenderer */
724} /* namespace android */