From c889d3c5763d34ecfff99cff8df1c6e85aac00d0 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 16 Jul 2020 13:51:12 -0700 Subject: libvulkan: make vkEnumerateInstanceVersion trigger driver loading This is a globally dispatched api, and it's the best option to preload the driver in Zygote with minimum overhead. This change also updates some return codes according to the spec. Bug: 135536511 Test: take a trace and verify driver is loaded Change-Id: I6fe425ec568b13577d3d9471aa5f181cff44c61c --- vulkan/libvulkan/api.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'vulkan/libvulkan/api.cpp') diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index 5b9affd03a..80166c8434 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -1256,7 +1256,7 @@ VkResult EnumerateInstanceLayerProperties(uint32_t* pPropertyCount, ATRACE_CALL(); if (!EnsureInitialized()) - return VK_ERROR_INITIALIZATION_FAILED; + return VK_ERROR_OUT_OF_HOST_MEMORY; uint32_t count = GetLayerCount(); @@ -1280,7 +1280,7 @@ VkResult EnumerateInstanceExtensionProperties( ATRACE_CALL(); if (!EnsureInitialized()) - return VK_ERROR_INITIALIZATION_FAILED; + return VK_ERROR_OUT_OF_HOST_MEMORY; if (pLayerName) { const Layer* layer = FindLayer(pLayerName); @@ -1456,6 +1456,11 @@ VkResult EnumerateDeviceExtensionProperties( VkResult EnumerateInstanceVersion(uint32_t* pApiVersion) { ATRACE_CALL(); + // Load the driver here if not done yet. This api will be used in Zygote + // for Vulkan driver pre-loading because of the minimum overhead. + if (!EnsureInitialized()) + return VK_ERROR_OUT_OF_HOST_MEMORY; + *pApiVersion = VK_API_VERSION_1_1; return VK_SUCCESS; } -- cgit v1.2.3-59-g8ed1b