libvulkan: ensure layer discovery is triggered only once for a new process
After decoupling layer discovery from driver loading, the layer discovery is
triggered at each call of vkCreateInstance, vkEnumerateInstanceLayerProperties
and vkEnumerateInstanceExtensionProperties. However, it takes non-trivial time
to traverse the layer search path for priviledged apps and non-updated system
apps. So this change just makes sure the layer discovery logic is triggered only
once for a new process.
Bug: 139443653
Bug: 135536511
Test: preload Vulkan and atest CtsGpuToolsHostTestCases
Change-Id: Ibe502fd4b089acbbff6f4a2485fa61c736a484b5
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 4608be2..48f26e7 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -1177,9 +1177,13 @@
});
{
+ static pid_t pid = getpid() + 1;
static std::mutex layer_lock;
std::lock_guard<std::mutex> lock(layer_lock);
- DiscoverLayers();
+ if (pid != getpid()) {
+ pid = getpid();
+ DiscoverLayers();
+ }
}
return initialized;