Skip to content

Commit

Permalink
macOS: Fixed MoltenVK dynamic library loading code.
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Oct 13, 2018
1 parent d909442 commit d8022d1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/video/cocoa/SDL_cocoavulkan.m
Expand Up @@ -58,8 +58,7 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;

if (_this->vulkan_config.loader_handle) {
SDL_SetError("Vulkan/MoltenVK already loaded");
return -1;
return SDL_SetError("Vulkan/MoltenVK already loaded");
}

/* Load the Vulkan loader library */
Expand All @@ -80,6 +79,7 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
_this->vulkan_config.loader_handle = DEFAULT_HANDLE;
} else {
const char** paths;
const char *foundPath = NULL;
int numPaths;
int i;

Expand All @@ -92,18 +92,17 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
paths = 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;

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");
}
if (i == numPaths)
return -1;

SDL_strlcpy(_this->vulkan_config.loader_path, paths[i],
SDL_strlcpy(_this->vulkan_config.loader_path, foundPath,
SDL_arraysize(_this->vulkan_config.loader_path));
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
Expand Down

0 comments on commit d8022d1

Please sign in to comment.