Hash :
48da1c35
Author :
Date :
2021-07-16T13:24:34
Vulkan: Prefer the local vulkan loader over the system one. Load the Vulkan loader ourselves and give vkGetInstanceProcAddr to volk. This allows us to always prefer loading from the current module directory instead of using the platform-specific ordering. Refactor angle::Library loading to use ModuleDir instead of ApplicationDir. CL originally authored by Geoff Lang. Bug: chromium:1219969 Change-Id: I21d1926e90fd66e1c23cea7323991ae55f3d22d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3035444 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// libvulkan_loader.cpp:
// Helper functions for the loading Vulkan libraries.
//
#include "common/vulkan/libvulkan_loader.h"
#include "common/system_utils.h"
namespace angle
{
namespace vk
{
std::unique_ptr<Library> OpenLibVulkan()
{
constexpr const char *kLibVulkanNames[] = {
#if defined(ANGLE_PLATFORM_WINDOWS)
"vulkan-1.dll",
#elif defined(ANGLE_PLATFORM_APPLE)
"libvulkan.dylib",
"libvulkan.1.dylib",
"libMoltenVK.dylib"
#else
"libvulkan.so",
"libvulkan.so.1",
#endif
};
constexpr SearchType kSearchTypes[] = {
// On Android, Fuchsia and GGP we use the system libvulkan.
#if defined(ANGLE_USE_CUSTOM_LIBVULKAN)
SearchType::ModuleDir,
#else
SearchType::SystemDir,
#endif // defined(ANGLE_USE_CUSTOM_LIBVULKAN)
};
for (angle::SearchType searchType : kSearchTypes)
{
for (const char *libraryName : kLibVulkanNames)
{
std::unique_ptr<Library> library(
OpenSharedLibraryWithExtension(libraryName, searchType));
if (library && library->getNative())
{
return library;
}
}
}
return nullptr;
}
} // namespace vk
} // namespace angle