From 5f3642e9fd221524f48244e76a6146f08e41b4f1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 25 Aug 2020 19:07:12 +1000 Subject: [PATCH] VulkanLoader: Search frameworks directory for libvulkan.dylib --- dep/vulkan-loader/src/vulkan_loader.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dep/vulkan-loader/src/vulkan_loader.cpp b/dep/vulkan-loader/src/vulkan_loader.cpp index c1be6ae57..0d580c219 100644 --- a/dep/vulkan-loader/src/vulkan_loader.cpp +++ b/dep/vulkan-loader/src/vulkan_loader.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "vulkan_loader.h" @@ -14,6 +16,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + #define VULKAN_MODULE_ENTRY_POINT(name, required) PFN_##name name; #define VULKAN_INSTANCE_ENTRY_POINT(name, required) PFN_##name name; #define VULKAN_DEVICE_ENTRY_POINT(name, required) PFN_##name name; @@ -111,6 +117,25 @@ bool LoadVulkanLibrary() char* libvulkan_env = getenv("LIBVULKAN_PATH"); if (libvulkan_env) vulkan_module = dlopen(libvulkan_env, RTLD_NOW); + if (!vulkan_module) + { + unsigned path_size = 0; + _NSGetExecutablePath(nullptr, &path_size); + std::string path; + path.resize(path_size); + if (_NSGetExecutablePath(path.data(), &path_size) == 0) + { + path[path_size] = 0; + + size_t pos = path.rfind('/'); + if (pos != std::string::npos) + { + path.erase(pos); + path += "/../Frameworks/libvulkan.dylib"; + vulkan_module = dlopen(path.c_str(), RTLD_NOW); + } + } + } if (!vulkan_module) vulkan_module = dlopen("libvulkan.dylib", RTLD_NOW); #else