diff options
author | Yiwei Zhang <zzyiwei@google.com> | 2019-08-14 23:15:02 -0700 |
---|---|---|
committer | Yiwei Zhang <zzyiwei@google.com> | 2019-08-15 17:42:20 +0000 |
commit | 519b44c8398e1b237f72dbd8106cd0ea0a00d936 (patch) | |
tree | 5513ce293b68b4a9a8be7193d9e0eb7483045a05 /vulkan/libvulkan/api.cpp | |
parent | b215bf6c80f4ed8c429aa09d83d18325f7369cac (diff) |
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
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r-- | vulkan/libvulkan/api.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index 4608be2907..48f26e7e43 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -1177,9 +1177,13 @@ bool EnsureInitialized() { }); { + 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; |