diff options
| author | 2021-10-07 23:50:28 +0000 | |
|---|---|---|
| committer | 2021-10-07 23:50:28 +0000 | |
| commit | 9243f909f67b7c46c23b94f2b05ce4476ba295d5 (patch) | |
| tree | c2f19f92e4503b2de0afeebdd9bf7aeb1bb2e9c1 /vulkan/libvulkan/api.cpp | |
| parent | cbfb18e134845deeace954bbba818acda48cb80f (diff) | |
| parent | 097d2a50873100486d65a69cb1cbabf37fb3b188 (diff) | |
Merge "Merge Android 12"
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
| -rw-r--r-- | vulkan/libvulkan/api.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index 9aaac5f1d6..d1cd397da4 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -1184,23 +1184,18 @@ const LayerChain::ActiveLayer* LayerChain::GetActiveLayers( // ---------------------------------------------------------------------------- bool EnsureInitialized() { - static std::once_flag once_flag; - static bool initialized; - - std::call_once(once_flag, []() { - if (driver::OpenHAL()) { - initialized = true; - } - }); - - { - static pid_t pid = getpid() + 1; - static std::mutex layer_lock; - std::lock_guard<std::mutex> lock(layer_lock); - if (pid != getpid()) { - pid = getpid(); - DiscoverLayers(); - } + static bool initialized = false; + static pid_t init_attempted_for_pid = 0; + static std::mutex init_lock; + + std::lock_guard<std::mutex> lock(init_lock); + if (init_attempted_for_pid == getpid()) + return initialized; + + init_attempted_for_pid = getpid(); + if (driver::OpenHAL()) { + DiscoverLayers(); + initialized = true; } return initialized; @@ -1266,7 +1261,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(); @@ -1290,7 +1285,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); @@ -1466,6 +1461,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; } |