summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/api.cpp
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@google.com>2019-08-09 17:25:24 -0700
committerYiwei Zhang <zzyiwei@google.com>2019-08-13 16:44:49 +0000
commit9dfc93ace276102af4973b62823454fcc5a653cd (patch)
tree4a8c2d786e27cf97d0cc11427dfd02739d2af178 /vulkan/libvulkan/api.cpp
parent54322025fb451c9e681add11e6d3a38770ff3c64 (diff)
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
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r--vulkan/libvulkan/api.cpp7
1 files changed, 6 insertions, 1 deletions
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<std::mutex> lock(layer_lock);
+ DiscoverLayers();
+ }
+
return initialized;
}