|
@@ -39,7 +39,10 @@
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
-#define DEFAULT_MOLTENVK "libMoltenVK.dylib"
|
|
|
+const char* defaultPaths[] = {
|
|
|
+ "libvulkan.dylib",
|
|
|
+};
|
|
|
+
|
|
|
/* Since libSDL is static, could use RTLD_SELF. Using RTLD_DEFAULT is future
|
|
|
* proofing. */
|
|
|
#define DEFAULT_HANDLE RTLD_DEFAULT
|
|
@@ -53,7 +56,7 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
|
|
|
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
|
|
|
|
|
|
if (_this->vulkan_config.loader_handle) {
|
|
|
- return SDL_SetError("MoltenVK/Vulkan already loaded");
|
|
|
+ return SDL_SetError("Vulkan Portability library is already loaded.");
|
|
|
}
|
|
|
|
|
|
/* Load the Vulkan loader library */
|
|
@@ -62,9 +65,7 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
|
|
|
}
|
|
|
|
|
|
if (!path) {
|
|
|
- /* MoltenVK framework, currently, v0.17.0, has a static library and is
|
|
|
- * the recommended way to use the package. There is likely no object to
|
|
|
- * load. */
|
|
|
+ /* Handle the case where Vulkan Portability is linked statically. */
|
|
|
vkGetInstanceProcAddr =
|
|
|
(PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE,
|
|
|
"vkGetInstanceProcAddr");
|
|
@@ -73,15 +74,29 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
|
|
|
if (vkGetInstanceProcAddr) {
|
|
|
_this->vulkan_config.loader_handle = DEFAULT_HANDLE;
|
|
|
} else {
|
|
|
- if (!path) {
|
|
|
+ const char** paths;
|
|
|
+ const char *foundPath = NULL;
|
|
|
+ int numPaths;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ if (path) {
|
|
|
+ paths = &path;
|
|
|
+ numPaths = 1;
|
|
|
+ } else {
|
|
|
/* Look for the .dylib packaged with the application instead. */
|
|
|
- path = DEFAULT_MOLTENVK;
|
|
|
+ paths = defaultPaths;
|
|
|
+ numPaths = SDL_arraysize(defaultPaths);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) {
|
|
|
+ foundPath = paths[i];
|
|
|
+ _this->vulkan_config.loader_handle = SDL_LoadObject(foundPath);
|
|
|
}
|
|
|
|
|
|
- _this->vulkan_config.loader_handle = SDL_LoadObject(path);
|
|
|
- if (!_this->vulkan_config.loader_handle) {
|
|
|
- return -1;
|
|
|
+ if (_this->vulkan_config.loader_handle == NULL) {
|
|
|
+ return SDL_SetError("Failed to load Vulkan Portability library");
|
|
|
}
|
|
|
+
|
|
|
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
|
|
SDL_arraysize(_this->vulkan_config.loader_path));
|
|
|
vkGetInstanceProcAddr =
|
|
@@ -93,7 +108,7 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
|
|
|
if (!vkGetInstanceProcAddr) {
|
|
|
SDL_SetError("Failed to find %s in either executable or %s: %s",
|
|
|
"vkGetInstanceProcAddr",
|
|
|
- DEFAULT_MOLTENVK,
|
|
|
+ "linked Vulkan Portability library",
|
|
|
(const char *) dlerror());
|
|
|
goto fail;
|
|
|
}
|
|
@@ -128,11 +143,11 @@ int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
|
|
|
SDL_free(extensions);
|
|
|
|
|
|
if (!hasSurfaceExtension) {
|
|
|
- SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
|
|
|
+ SDL_SetError("Installed Vulkan Portability doesn't implement the "
|
|
|
VK_KHR_SURFACE_EXTENSION_NAME " extension");
|
|
|
goto fail;
|
|
|
} else if (!hasIOSSurfaceExtension) {
|
|
|
- SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
|
|
|
+ SDL_SetError("Installed Vulkan Portability doesn't implement the "
|
|
|
VK_MVK_IOS_SURFACE_EXTENSION_NAME "extension");
|
|
|
goto fail;
|
|
|
}
|