JuliaGL / GLFW.jl

Julia interface to GLFW, a multi-platform library for creating windows with OpenGL contexts and managing input and events.
http://www.glfw.org/
MIT License
138 stars 32 forks source link

[Vulkan] Creating window surface cannot work on macOS #207

Closed Gnimuc closed 4 years ago

Gnimuc commented 4 years ago

I'm following "vulkan-tutorial" to create window surface on macOS. Even though all of the extension checking steps are passed, glfwCreateWindowSurface fails with VK_ERROR_EXTENSION_NOT_PRESENT. Note that both Vulkan validation layer and GLFW error callback function yield nothing, only a Vulkan error code is returned.

julia> surfaceRef = Ref(VkSurfaceKHR(C_NULL))
Base.RefValue{Ptr{Nothing}}(Ptr{Nothing} @0x0000000000000000)

julia> ccall((:glfwCreateWindowSurface, GLFW.libglfw), VkResult, (VkInstance, GLFW.Window, Ptr{VkAllocationCallbacks}, Ref{VkSurfaceKHR}), instanceRef[], window, C_NULL, surfaceRef)
VK_ERROR_EXTENSION_NOT_PRESENT::VkResult = -7

After taking a look at the source code of glfw's implementation of glfwCreateWindowSurface, I found the only possibility to trigger the result above is that the code chunk below #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 is actually never compiled, which turns out to be an issue of GLFW_jll. I'm opening this issue here to warn other GLFW.jl users.

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
    // HACK: Dynamically load Core Animation to avoid adding an extra
    //       dependency for the majority who don't use MoltenVK
    NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
    if (!bundle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Cocoa: Failed to find QuartzCore.framework");
        return VK_ERROR_EXTENSION_NOT_PRESENT;
    }

...
...
...

#else
    return VK_ERROR_EXTENSION_NOT_PRESENT;
#endif
Gnimuc commented 4 years ago

Should be fixed with the latest GLFW_jll.