From 6a7dc402d5fb831f57d01af3b8f06e37475d179b Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 31 Jul 2020 14:13:02 -0700 Subject: [PATCH] Zygote: preload Vulkan driver if hwui renders with Vulkan In Android 12, vkEnumerateInstanceVersion is made to trigger driver loading and the api itself neither has extra overhead nor talk to the driver. So this change uses vkEnumerateInstanceVersion to preload Vulkan driver in Zygote. Bug: 135536511 Test: atest CtsUiRenderingTestCases all pass on GL backend Test: atest CtsUiRenderingTestCases no regression on VK backend Change-Id: I5017b922843aadc2c4a4237711b8011857703129 --- libs/hwui/apex/jni_runtime.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/hwui/apex/jni_runtime.cpp b/libs/hwui/apex/jni_runtime.cpp index b933813550d4b..12e2e81352782 100644 --- a/libs/hwui/apex/jni_runtime.cpp +++ b/libs/hwui/apex/jni_runtime.cpp @@ -16,14 +16,14 @@ #include "android/graphics/jni_runtime.h" -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include #undef LOG_TAG #define LOG_TAG "AndroidGraphicsJNI" @@ -172,6 +172,11 @@ using android::uirenderer::RenderPipelineType; void zygote_preload_graphics() { if (Properties::peekRenderPipelineType() == RenderPipelineType::SkiaGL) { + // Preload GL driver if HWUI renders with GL backend. eglGetDisplay(EGL_DEFAULT_DISPLAY); + } else { + // Preload Vulkan driver if HWUI renders with Vulkan backend. + uint32_t apiVersion; + vkEnumerateInstanceVersion(&apiVersion); } -} \ No newline at end of file +}