macOS: Fixed MoltenVK dynamic library loading code.

This commit is contained in:
Alex Szpakowski 2018-10-12 23:23:52 -03:00
parent d9094421e1
commit d8022d19b4

View file

@ -58,8 +58,7 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
if (_this->vulkan_config.loader_handle) { if (_this->vulkan_config.loader_handle) {
SDL_SetError("Vulkan/MoltenVK already loaded"); return SDL_SetError("Vulkan/MoltenVK already loaded");
return -1;
} }
/* Load the Vulkan loader library */ /* Load the Vulkan loader library */
@ -80,6 +79,7 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
_this->vulkan_config.loader_handle = DEFAULT_HANDLE; _this->vulkan_config.loader_handle = DEFAULT_HANDLE;
} else { } else {
const char** paths; const char** paths;
const char *foundPath = NULL;
int numPaths; int numPaths;
int i; int i;
@ -92,18 +92,17 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
paths = defaultPaths; paths = defaultPaths;
numPaths = SDL_arraysize(defaultPaths); numPaths = SDL_arraysize(defaultPaths);
} }
for (i=0; i < numPaths; i++) {
_this->vulkan_config.loader_handle = SDL_LoadObject(paths[i]);
if (_this->vulkan_config.loader_handle)
break;
else
continue;
}
if (i == numPaths)
return -1;
SDL_strlcpy(_this->vulkan_config.loader_path, paths[i], for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) {
foundPath = paths[i];
_this->vulkan_config.loader_handle = SDL_LoadObject(foundPath);
}
if (_this->vulkan_config.loader_handle == NULL) {
return SDL_SetError("Failed to load Vulkan/MoltenVK library");
}
SDL_strlcpy(_this->vulkan_config.loader_path, foundPath,
SDL_arraysize(_this->vulkan_config.loader_path)); SDL_arraysize(_this->vulkan_config.loader_path));
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");