diff options
Diffstat (limited to 'runtime/test/vulkan_loader.h')
| -rw-r--r-- | runtime/test/vulkan_loader.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/test/vulkan_loader.h b/runtime/test/vulkan_loader.h index 43a54d242..a1a461ef0 100644 --- a/runtime/test/vulkan_loader.h +++ b/runtime/test/vulkan_loader.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // Loads the Vulkan loader at run time: vulkan-1.dll on Windows, libvulkan.so.1 elsewhere. No import library. | 1 | // Loads the Vulkan loader at run time: vulkan-1.dll on Windows, MoltenVK on macOS, libvulkan.so.1 elsewhere. No import library. |
| 2 | #pragma once | 2 | #pragma once |
| 3 | 3 | ||
| 4 | #ifndef VK_NO_PROTOTYPES | 4 | #ifndef VK_NO_PROTOTYPES |
| @@ -20,6 +20,15 @@ inline PFN_vkGetInstanceProcAddr load_vulkan() { | |||
| 20 | constexpr auto library_name = "vulkan-1.dll"; | 20 | constexpr auto library_name = "vulkan-1.dll"; |
| 21 | static const auto library = LoadLibraryA(library_name); | 21 | static const auto library = LoadLibraryA(library_name); |
| 22 | const auto entry = library ? GetProcAddress(library, "vkGetInstanceProcAddr") : nullptr; | 22 | const auto entry = library ? GetProcAddress(library, "vkGetInstanceProcAddr") : nullptr; |
| 23 | #elif defined(__APPLE__) | ||
| 24 | // MoltenVK directly: through the loader it is a portability driver, which every vkCreateInstance here would | ||
| 25 | // have to opt into. The Vulkan SDK installs it in /usr/local/lib (a default search path), Homebrew does not. | ||
| 26 | constexpr auto library_name = "libMoltenVK.dylib"; | ||
| 27 | static const auto library = [] { | ||
| 28 | auto handle = dlopen(library_name, RTLD_NOW | RTLD_LOCAL); | ||
| 29 | return handle ? handle : dlopen("/opt/homebrew/lib/libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL); | ||
| 30 | }(); | ||
| 31 | const auto entry = library ? dlsym(library, "vkGetInstanceProcAddr") : nullptr; | ||
| 23 | #else | 32 | #else |
| 24 | constexpr auto library_name = "libvulkan.so.1"; | 33 | constexpr auto library_name = "libvulkan.so.1"; |
| 25 | static const auto library = dlopen(library_name, RTLD_NOW | RTLD_LOCAL); | 34 | static const auto library = dlopen(library_name, RTLD_NOW | RTLD_LOCAL); |