Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 519b44c8 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

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
parent b215bf6c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1177,10 +1177,14 @@ bool EnsureInitialized() {
    });

    {
        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();
        }
    }

    return initialized;
}