summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/api.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r--vulkan/libvulkan/api.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 80166c8434..2d4690a2af 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -1174,23 +1174,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;