From 9dfc93ace276102af4973b62823454fcc5a653cd Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 9 Aug 2019 17:25:24 -0700 Subject: libvulkan: refactor the layer discovery logic Previously, the layer discovery logic is only executed once along with the driver loading. However, once Vulkan driver is preloaded in Zygote, new layers pushed to the system or shipped with the App's apk won't be discovered at runtime. This change refactors the logic of layer discovery. It doesn't hurt to keep finding new layers available in the layer search path, because the app apk itself won't change at runtime. Even if we push new layers to the system search path, that's only on the debug build of the system. Bug: 135536511 Test: preload Vulkan and atest CtsGpuToolsHostTestCases Change-Id: I915b78dacfd9b637a202f76969d559a31eded686 --- vulkan/libvulkan/api.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'vulkan/libvulkan/api.cpp') diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index 368130d13b..4608be2907 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -1172,11 +1172,16 @@ bool EnsureInitialized() { std::call_once(once_flag, []() { if (driver::OpenHAL()) { - DiscoverLayers(); initialized = true; } }); + { + static std::mutex layer_lock; + std::lock_guard lock(layer_lock); + DiscoverLayers(); + } + return initialized; } -- cgit v1.2.3-59-g8ed1b