Hello Guest

Running Vulkan on macOS with MoltenVK

  • 7 Replies
  • 13081 Views
Running Vulkan on macOS with MoltenVK
« on: April 06, 2018, 11:50:48 »
Hello all,

I am trying to use the recently open sourced MoltenVK port of Vulkan on macOS. I downloaded the LunarG dev kit and setup the environment variables. The included binaries all work well.

I then tried one of the demos of LWJGL, and finaly found that to make it find the Vulkan dynamic library I had to add -Dorg.lwjgl.vulkan.libname=MoltenVK as a jvm argument.

All works well excepted that I cannot add any validation layers. If I do, I always get the following error :

VK_ERROR_LAYER_NOT_PRESENT: Vulkan layer VK_LAYER_LUNARG_standard_validation is not supported.

Am I missing something ? I found the -Dorg.lwjgk.vulkan.libname in the forum. Is this the correct way to tell LWJGL what to use ? Should I use something else or add something ? Is there a documentation I missed ?

I think my environment is correctly setup (VULKAN_SDK and VK_LAYER_PATH are set, correctly I hope).

Sorry if this is a silly or misinformed question.

Thanks a lot

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Running Vulkan on macOS with MoltenVK
« Reply #1 on: April 06, 2018, 16:23:37 »
finaly found that to make it find the Vulkan dynamic library I had to add -Dorg.lwjgl.vulkan.libname=MoltenVK as a jvm argument.

This is not required when lwjgl-vulkan-natives-macos.jar is available in the class/module-path. By default, LWJGL tries to load libMoltenVK.dylib and if that fails, tries libvulkan.1.dylib. The mentioned jar contains libMoltenVK.dylib, so you don't have to download it separately or build it on your own.

Specifying -Dorg.lwjgl.vulkan.libname overrides the above. Using libMoltenVK.dylib from LunarG should work fine. Note that the override can also be an absolute path to the .dylib you want to use.

All works well excepted that I cannot add any validation layers. If I do, I always get the following error :

VK_ERROR_LAYER_NOT_PRESENT: Vulkan layer VK_LAYER_LUNARG_standard_validation is not supported.

Am I missing something ?

From the list of known MoltenVK limitations:

Quote
MoltenVK is a Layer-0 driver implementation of Vulkan, and currently does not support the loading of higher level Vulkan Layers.

This may change soon, there has been some progress in porting the validation layers to macOS.

Re: Running Vulkan on macOS with MoltenVK
« Reply #2 on: April 07, 2018, 07:47:10 »
Thanks for this reply, it makes things clearer for me :)

In fact I searched for the org.lwjgl.vulkan.libname because the 3.1.6 release of lwjgl I use does not have any natives in the vulkan directory, so I imagined I had to provide the library by myself. But maybe I missed something else ? I downloaded it here : https://github.com/LWJGL/lwjgl3/releases

I also tried the 3.1.5 and a customized zip (selecting minimal vulkan).

From the list of known MoltenVK limitations:

Quote
MoltenVK is a Layer-0 driver implementation of Vulkan, and currently does not support the loading of higher level Vulkan Layers.

This may change soon, there has been some progress in porting the validation layers to macOS.

Thanks a lot, this is the part I missed indeed !

By the way I discovered LWJGL recently and played a lot with OpenGL, an now trying Vulkan. This library is a pleasure to work with :)

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Running Vulkan on macOS with MoltenVK
« Reply #3 on: April 07, 2018, 08:32:45 »
In fact I searched for the org.lwjgl.vulkan.libname because the 3.1.6 release of lwjgl I use does not have any natives in the vulkan directory, so I imagined I had to provide the library by myself. But maybe I missed something else ?

That's because the open source version of MoltenVK was released after 3.1.6 and is currently available only in 3.1.7 snapshots. The LWJGL build customizer has been updated to support this, if you choose Nightly + macOS + the Vulkan bindings, you'll get the MoltenVK binary.

Re: Running Vulkan on macOS with MoltenVK
« Reply #4 on: April 07, 2018, 08:58:29 »
Thanks a lot ! :D
« Last Edit: April 07, 2018, 09:11:41 by 4nt01n3 »

Re: Running Vulkan on macOS with MoltenVK
« Reply #5 on: April 08, 2020, 17:07:52 »
Hi, I've tried the above suggestions and am getting this error on the demos:

Code: [Select]
Exception in thread "main" java.lang.AssertionError: Failed to create VkInstance: A requested layer is not present or could not be loaded.
at org.lwjgl.demo.vulkan.ColoredRotatingQuadDemo.createInstance(ColoredRotatingQuadDemo.java:133)
at org.lwjgl.demo.vulkan.ColoredRotatingQuadDemo.main(ColoredRotatingQuadDemo.java:1173)

I'm on:
- OSX Catalina
- LWJGL demos master 0a28352
- vulkansdk-macos-1.2.135.0

I've exported
Code: [Select]
export VK_ICD_FILENAMES=/code/vulkansdk-macos-1.2.135.0/macOS/share/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=/code/vulkansdk-macos-1.2.135.0/macOS/share/vulkan/explicit_layer.d

The link in MoltenVK_icd.json makes no difference whether I'm pointing to the Vulkan SDK's copy or LWJGL's copy in:
/var/folders/ck/sc4tht4n62g1z6ml0dnkyjlc0000gn/T/lwjglcode/3.2.4-SNAPSHOT/libMoltenVK.dylib

Please help, thank you!

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Running Vulkan on macOS with MoltenVK
« Reply #6 on: April 09, 2020, 12:05:37 »
Hey windfall007,

Please follow these instructions and let me know how it goes.

Re: Running Vulkan on macOS with MoltenVK
« Reply #7 on: April 10, 2020, 09:16:27 »
Sorry, it doesn't work and still the same error.

The jvmArgs '-Dorg.lwjgl.vulkan.libname=<path to extracted SDK>/macOS/lib/libvulkan.dylib' in Gradle is the same as supplying it in command line:
Code: [Select]
java -Dorg.lwjgl.vulkan.libname=/code/vulkansdk-macos-1.2.135.0/macOS/lib/libvulkan.dylib -cp target/lwjgl3-demos.jar org.lwjgl.demo.vulkan.ColoredRotatingQuadDemo

The env variables are all exported and it makes no difference:
Code: [Select]
export VULKAN_SDK=<path to extracted SDK>/macOS
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d
Note that 'macos' should be 'macOS', 'etc' has been changed to 'share' in the latest SDK.

The only thing I don't know how to do is 'validation = false'. Where do I specify that?