Vulkan/Loader: Prioritize system libvulkan dylib, fallback to MoltenVK

This commit is contained in:
Connor McLaughlin 2022-08-01 23:07:23 +10:00
parent e1383d15aa
commit ca1512f47a

View file

@ -118,9 +118,14 @@ bool LoadVulkanLibrary()
#if defined(__APPLE__) #if defined(__APPLE__)
// Check if a path to a specific Vulkan library has been specified. // Check if a path to a specific Vulkan library has been specified.
// Otherwise, try for a system-wide libvulkan.
char* libvulkan_env = getenv("LIBVULKAN_PATH"); char* libvulkan_env = getenv("LIBVULKAN_PATH");
if (libvulkan_env) if (libvulkan_env)
vulkan_module = dlopen(libvulkan_env, RTLD_NOW); vulkan_module = dlopen(libvulkan_env, RTLD_NOW);
else
vulkan_module = dlopen("libvulkan.dylib", RTLD_NOW);
// Fall back to the packaged MoltenVK.
if (!vulkan_module) if (!vulkan_module)
{ {
unsigned path_size = 0; unsigned path_size = 0;
@ -135,13 +140,11 @@ bool LoadVulkanLibrary()
if (pos != std::string::npos) if (pos != std::string::npos)
{ {
path.erase(pos); path.erase(pos);
path += "/../Frameworks/libvulkan.dylib"; path += "/../Frameworks/libMoltenVK.dylib";
vulkan_module = dlopen(path.c_str(), RTLD_NOW); vulkan_module = dlopen(path.c_str(), RTLD_NOW);
} }
} }
} }
if (!vulkan_module)
vulkan_module = dlopen("libvulkan.dylib", RTLD_NOW);
#else #else
// Names of libraries to search. Desktop should use libvulkan.so.1 or libvulkan.so. // Names of libraries to search. Desktop should use libvulkan.so.1 or libvulkan.so.
static const char* search_lib_names[] = {"libvulkan.so.1", "libvulkan.so"}; static const char* search_lib_names[] = {"libvulkan.so.1", "libvulkan.so"};