summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-05-31 04:23:45 -0700
committerStenzek <stenzek@gmail.com>2018-11-07 05:41:09 -0800
commit673f1963a068fb7d5cd8af9bb209c7633950e8f8 (patch)
tree1a14f48e96c8f58fe5e648282632e376cc711b24 /Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
parentc7a2b1572bba57d78bea78455f9cd1ab95cd36db (diff)
Vulkan: Support macOS via MoltenVK
The path to the MoltenVK library can be specified by the LIBMOLTENVK_PATH environment variable, otherwise it assumes it is located in the application bundle's Contents/MacOS directory.
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp')
-rw-r--r--Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
index 0c9fae677b..96f955ce2c 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
@@ -4,8 +4,10 @@
#include <atomic>
#include <cstdarg>
+#include <cstdlib>
#include "Common/CommonFuncs.h"
+#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
@@ -14,7 +16,8 @@
#if defined(VK_USE_PLATFORM_WIN32_KHR)
#include <Windows.h>
#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || \
- defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(USE_HEADLESS)
+ defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(VK_USE_PLATFORM_MACOS_MVK) || \
+ defined(USE_HEADLESS)
#include <dlfcn.h>
#endif
@@ -98,7 +101,8 @@ void UnloadVulkanLibrary()
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || \
- defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(USE_HEADLESS)
+ defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(VK_USE_PLATFORM_MACOS_MVK) || \
+ defined(USE_HEADLESS)
static void* vulkan_module;
static std::atomic_int vulkan_module_ref_count = {0};
@@ -112,15 +116,27 @@ bool LoadVulkanLibrary()
return true;
}
+#if defined(__APPLE__)
+ // Check if a path to a specific Vulkan library has been specified.
+ char* libvulkan_env = getenv("LIBVULKAN_PATH");
+ if (libvulkan_env)
+ vulkan_module = dlopen(libvulkan_env, RTLD_NOW);
+ if (!vulkan_module)
+ {
+ // Use the libvulkan.dylib from the application bundle.
+ std::string path = File::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib";
+ vulkan_module = dlopen(path.c_str(), RTLD_NOW);
+ }
+#else
// 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"};
-
for (size_t i = 0; i < ArraySize(search_lib_names); i++)
{
vulkan_module = dlopen(search_lib_names[i], RTLD_NOW);
if (vulkan_module)
break;
}
+#endif
if (!vulkan_module)
{
@@ -164,6 +180,7 @@ void UnloadVulkanLibrary()
dlclose(vulkan_module);
vulkan_module = nullptr;
}
+
#else
//#warning Unknown platform, not compiling loader.