macOS: Fixed MoltenVK dynamic library loading code.
authorAlex Szpakowski <slime73@gmail.com>
Fri, 12 Oct 2018 23:23:52 -0300
changeset 123214216eccf4ea2
parent 12320 758d4e1222a7
child 12322 b5074e5aaa49
macOS: Fixed MoltenVK dynamic library loading code.
src/video/cocoa/SDL_cocoavulkan.m
     1.1 --- a/src/video/cocoa/SDL_cocoavulkan.m	Fri Oct 12 17:55:42 2018 -0300
     1.2 +++ b/src/video/cocoa/SDL_cocoavulkan.m	Fri Oct 12 23:23:52 2018 -0300
     1.3 @@ -58,8 +58,7 @@
     1.4      PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
     1.5  
     1.6      if (_this->vulkan_config.loader_handle) {
     1.7 -        SDL_SetError("Vulkan/MoltenVK already loaded");
     1.8 -        return -1;
     1.9 +        return SDL_SetError("Vulkan/MoltenVK already loaded");
    1.10      }
    1.11  
    1.12      /* Load the Vulkan loader library */
    1.13 @@ -80,6 +79,7 @@
    1.14          _this->vulkan_config.loader_handle = DEFAULT_HANDLE;
    1.15      } else {
    1.16          const char** paths;
    1.17 +        const char *foundPath = NULL;
    1.18          int numPaths;
    1.19          int i;
    1.20  
    1.21 @@ -92,18 +92,17 @@
    1.22              paths = defaultPaths;
    1.23              numPaths = SDL_arraysize(defaultPaths);
    1.24          }
    1.25 -        
    1.26 -        for (i=0; i < numPaths; i++) {
    1.27 -            _this->vulkan_config.loader_handle = SDL_LoadObject(paths[i]);
    1.28 -            if (_this->vulkan_config.loader_handle)
    1.29 -                break;
    1.30 -            else
    1.31 -                continue;
    1.32 +
    1.33 +        for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) {
    1.34 +            foundPath = paths[i];
    1.35 +            _this->vulkan_config.loader_handle = SDL_LoadObject(foundPath);
    1.36          }
    1.37 -        if (i == numPaths)
    1.38 -            return -1;
    1.39  
    1.40 -        SDL_strlcpy(_this->vulkan_config.loader_path, paths[i],
    1.41 +        if (_this->vulkan_config.loader_handle == NULL) {
    1.42 +            return SDL_SetError("Failed to load Vulkan/MoltenVK library");
    1.43 +        }
    1.44 +
    1.45 +        SDL_strlcpy(_this->vulkan_config.loader_path, foundPath,
    1.46                      SDL_arraysize(_this->vulkan_config.loader_path));
    1.47          vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
    1.48              _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");