Commit e6e99c54 by Jamie Madill Committed by Angle LUCI CQ

Vulkan: Load custom Vk Loader.

Uses a GN copy rule to duplicate the loader. Also updates volk to load using the new custom loader. Once both are in place we can go back and remove the copy. Bug: chromium:1219969 Change-Id: I8c48d168a842539f7cdba1ebfdaf3b08c3e1990d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2982499 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 18e99f4a
......@@ -149,7 +149,8 @@ def flattened_target(target_name: str, descs: dict, stop_at_lib: bool =True) ->
return ((),)
if dep_type == 'copy':
assert not deps, (target_name, dep['deps'])
# Note that the original script blocked deps in copy rules.
pass
else:
assert dep_type in EXPECTED_TYPES, (k, dep_type)
for (k,v) in dep.items():
......
......@@ -26,6 +26,34 @@ angle_source_set("angle_vulkan_headers") {
public_configs = [ ":angle_vulkan_headers_config" ]
}
# TODO(jmadill): Transition to custom name. http://crbug.com/1219969
if (!is_android && !is_fuchsia && !is_ggp) {
if (angle_shared_libvulkan) {
if (is_linux) {
_libvulkan_name = "libvulkan.so.1"
_libvulkan_ext = "so"
} else if (is_win) {
_libvulkan_name = "vulkan-1.dll"
_libvulkan_ext = "dll"
} else if (is_mac) {
_libvulkan_name = "libvulkan.dylib"
_libvulkan_ext = "dylib"
} else {
_libvulkan_name = "error"
_libvulkan_ext = "error"
}
copy("angle_libvulkan") {
deps = [ "$angle_vulkan_loader_dir:libvulkan" ]
sources = [ "$root_out_dir/$_libvulkan_name" ]
outputs = [ "$root_out_dir/vkloader.$_libvulkan_ext" ]
}
} else {
group("angle_libvulkan") {
deps = [ "$angle_vulkan_loader_dir:libvulkan" ]
}
}
}
group("angle_vulkan_entry_points") {
public_deps = [ ":angle_vulkan_headers" ]
if (is_fuchsia) {
......@@ -36,7 +64,8 @@ group("angle_vulkan_entry_points") {
]
} else if (!is_android && !is_ggp) {
if (angle_shared_libvulkan) {
data_deps = [ "$angle_vulkan_loader_dir:libvulkan" ]
# TODO(jmadill): Transition to custom name. http://crbug.com/1219969
data_deps = [ ":angle_libvulkan" ]
} else {
deps = [ "$angle_vulkan_loader_dir:libvulkan" ]
}
......@@ -66,7 +95,8 @@ angle_source_set("vulkan") {
if (!is_android && !is_fuchsia && !is_ggp) {
if (angle_shared_libvulkan) {
data_deps += [ "$angle_vulkan_loader_dir:libvulkan" ]
# TODO(jmadill): Transition to custom name. http://crbug.com/1219969
data_deps += [ ":angle_libvulkan" ]
} else {
deps += [ "$angle_vulkan_loader_dir:libvulkan" ]
}
......
......@@ -18,9 +18,9 @@
#include "common/system_utils.h"
#if defined(ANGLE_PLATFORM_WINDOWS)
const char *kLibVulkanNames[] = {"vulkan-1.dll"};
const char *kLibVulkanNames[] = {"vkloader.dll"};
#else
const char *kLibVulkanNames[] = {"libvulkan.so", "libvulkan.so.1"};
const char *kLibVulkanNames[] = {"vkloader.so", "libvulkan.so", "libvulkan.so.1"};
#endif
namespace angle
......
......@@ -606,7 +606,7 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name,
#if defined(ANGLE_USE_UTIL_LOADER) && !defined(ANGLE_PLATFORM_WINDOWS)
mGLWindow = EGLWindow::New(testParams.majorVersion, testParams.minorVersion);
mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension(
GetNativeEGLLibraryNameWithExtension(), SearchType::SystemDir));
GetNativeEGLLibraryNameWithExtension(), angle::SearchType::ApplicationDir));
#else
std::cerr << "Not implemented." << std::endl;
mSkipTest = true;
......
......@@ -45,23 +45,20 @@ static PFN_vkVoidFunction vkGetDeviceProcAddrStub(void* context, const char* nam
VkResult volkInitialize(void)
{
#if defined(_WIN32)
HMODULE module = LoadLibraryA("vulkan-1.dll");
HMODULE module = LoadLibraryA("vkloader.dll");
if (!module)
return VK_ERROR_INITIALIZATION_FAILED;
// note: function pointer is cast through void function pointer to silence cast-function-type warning on gcc8
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)(void(*)(void))GetProcAddress(module, "vkGetInstanceProcAddr");
#elif defined(__APPLE__)
void* module = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
if (!module)
module = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
if (!module)
module = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL);
void* module = dlopen("vkloader.dylib", RTLD_NOW | RTLD_LOCAL);
if (!module)
return VK_ERROR_INITIALIZATION_FAILED;
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
#else
#elif defined(__Fuchsia__) || defined(ANDROID)
// Include extra fallbacks for Android and Fuchsia which use the native loader.
void* module = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
if (!module)
module = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
......@@ -69,6 +66,12 @@ VkResult volkInitialize(void)
return VK_ERROR_INITIALIZATION_FAILED;
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
#else
void* module = dlopen("vkloader.so", RTLD_NOW | RTLD_LOCAL);
if (!module)
return VK_ERROR_INITIALIZATION_FAILED;
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
#endif
volkGenLoadLoader(NULL, vkGetInstanceProcAddrStub);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment