LWJGL Vulkan on Mac OS X

I’ve been trying to run the LWJGL Vulkan “TriangleDemo” from https://github.com/LWJGL/lwjgl3-demos/blob/master/src/org/lwjgl/demo/vulkan/TriangleDemo.java but just cannot get it to.

I’m using the latest LWJGL 3.1.7 and OS X 10.10.5.

The first problem I encountered was the warning that libvulkan.1.dylib was missing, so I downloaded LunarG and scavenged it from there. Now the demo at least runs, until an error check within the demo throws this exception: Failed to find list of required Vulkan extensions
Described code: https://github.com/LWJGL/lwjgl3-demos/blob/37c20a950c2daaa4ffbea9d14bc3e5f658afc4fa/src/org/lwjgl/demo/vulkan/TriangleDemo.java#L1129

Has anybody got Vulkan running on OS X reliably and what could be a possible solution?

LWJGL’s MoltenVK binary is probably missing from your module/class-path. You can get it via Maven with:

org.lwjgl lwjgl-vulkan 3.1.7-SNAPSHOT natives-macos

or equivalent for Gradle/Ivy, or get it from the LWJGL website.

This means that GLFW cannot find the Vulkan binary. Make sure libvulkan.1.dylib is in a location where dlopen can find it. If you use the above LWJGL artifact you don’t have to worry about it, GLFW will find it automatically.

Thanks. Added the lwjgl-vulkan natives to the Mac Maven profile of lwjgl3-demos. If you ran the demo from that Maven project, git pull and reimport the Maven dependencies.

Where did I go wrong with my approach:
I’m using IntelliJ IDEA and added the jars simply via Project Structure>Libraries>Add>… . And then I’m running the Triangle Demo with the VM options of -Djava.library.path=natives/mac/. In the folder natives/mac are all of the .git .sga1 and .dylib files that came with the LWJGL download.

Are my libraries/natives somehow misplaced? I just always used this setup for OpenGL and stuck with it.

Are you sure libMoltenVK.dylib is in there? What’s the output if you run the program with -Dorg.lwjgl.util.Debug=true -Dorg.lwjgl.util.DebugLoader=true?

These are all my natives:

That’s what the console spits out: That not-finding but seemingly still loading of lubvulkan.1.dylib is strange.

[LWJGL] Version: 3.1.7 build 2
[LWJGL] 	 OS: Mac OS X v10.10.5
[LWJGL] 	JRE: 9.0.4 x86_64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v9.0.4+11 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	Loaded from java.library.path: natives/mac/liblwjgl.dylib
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Loading library: glfw
[LWJGL] 	Loaded from java.library.path: natives/mac/libglfw.dylib
[LWJGL] Loading library: MoltenVK
[LWJGL] Loading library: libvulkan.1.dylib
[LWJGL] 	libvulkan.1.dylib not found in system paths
[LWJGL] 	Loaded from java.library.path: natives/mac/libvulkan.1.dylib

Plus the aformentioned Exception in line 1129.

MoltenVK requires macOS 10.11 or later. You’re on 10.10, so that’s the biggest issue.

This line here, without further output, means that the LWJGL shared library loader was able to find the MoltenVK binary in natives/mac, but loading failed (because of the macOS version). LWJGL currently silently captures the error and moves on to try loading libvulkan.1.dylib, if available on the system. In a future LWJGL build, I’ll make sure there’s some useful output in this case.

This works as intended. Sometimes it’s very useful to know on which paths the shared library was NOT found, before trying other paths. In this case, libvulkan.1.dylib is not a library bundled with LWJGL, so the system paths are examined first.

Important note: libvulkan.1.dylib is just the Vulkan ICD loader. It’s a library that discovers Vulkan drivers in your system. Loading it on its own is not enough without libMoltenVK.dylib. This is why LWJGL bundles libMoltenVK.dylib directly. It’s also more efficient, because it avoids an extra indirection on each Vulkan function call (see Best Application Performance Setup for details).

What happens in your case is this:

  • LWJGL finds libMoltenVK.dylib in natives/mac, tries to load it and fails (the error is suppressed).
  • LWJGL finds libvulkan.1.dylib in natives/mac, loads it successfully and configures GLFW to load it from there.
  • GLFW loads the Vulkan loader, but the loader cannot find a working ICD, so you get the failed to find list of required Vulkan extensions error.

Thank you very much!
Your help was very appreciated. At least this already helped somebody (other than me) and gave you something to consider (if you hadn’t had the intention to express the currently silently captured library loading failed error already).