Cocoa: Fix search path for private Vulkan loader

According to both Apple and LunarG, a private copy of the macOS Vulkan
loader libvulkan.1.dylib should be placed in the Frameworks directory
of the bundle and not its main executable directory.

This commit updates the dynamic loading path accordingly.

Fixes #2113
Closes #2120

(cherry picked from commit 9b7713cf92)
This commit is contained in:
Nikita Fediuchin 2022-05-26 09:27:39 +03:00 committed by Camilla Löwy
parent 109f836675
commit 1e49024e76
1 changed files with 11 additions and 3 deletions

View File

@ -475,11 +475,18 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
if (!bundle) if (!bundle)
return NULL; return NULL;
CFURLRef url = CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle);
CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib")); if (!frameworksUrl)
if (!url)
return NULL; return NULL;
CFURLRef url = CFURLCreateCopyAppendingPathComponent(
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
if (!url)
{
CFRelease(frameworksUrl);
return NULL;
}
char path[PATH_MAX]; char path[PATH_MAX];
void* handle = NULL; void* handle = NULL;
@ -487,6 +494,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
handle = _glfw_dlopen(path); handle = _glfw_dlopen(path);
CFRelease(url); CFRelease(url);
CFRelease(frameworksUrl);
return handle; return handle;
} }