Programming => Vulkan => Topic started by: Graou on February 21, 2019, 17:17:11

Title: Every sample code i tried generate ERROR_LAYER_NOT_PRESENT
Post by: Graou on February 21, 2019, 17:17:11
Hello everybody,

I am trying Vulkan in order to replace OpenGl in my Java application.

I develop on Mac OS with Eclipse and OpenJdk 11.

I downloaded many LWJGL examples that fail because the layers are not found.

It's been almost two days that I'm searching without finding out how to give the Java runtime environment this information.

The vkCreateInstance() method fails because its VkInstanceCreateInfo argument contains only MoltenVK and not the expected VK_LAYER_LUNARG_standard_validation.

Does anyone know a solution to this problem?
Title: Re: Every sample code i tried generate ERROR_LAYER_NOT_PRESENT
Post by: spasi on February 21, 2019, 19:28:24
Validation layers like VK_LAYER_LUNARG_standard_validation are provided by the Vulkan SDK (https://vulkan.lunarg.com/sdk/home). Have you installed (https://vulkan.lunarg.com/doc/sdk/ it?
Title: Re: Every sample code i tried generate ERROR_LAYER_NOT_PRESENT
Post by: Graou on February 22, 2019, 15:59:17
Thank you for the quick return. Following your question I checked the installation of the SDK which now seems correct. But the problem persists.

I think I have filled in all the environment variables. Here is a trace of the execution of the program with at the beginning a Java println() of the environment variables and then the stacktrace. Afterwards there is a printenv to show that environment variables are there.

Code: [Select]
PATH : /Users/fbmac/anaconda3/bin:/Users/fbmac/Documents/_projets/Zulu-java-11/com/ondine/libs/vulkansdk-macos-
DYLD_LIBRARY_PATH : /Users/fbmac/Documents/_projets/Zulu-java-11/com/ondine/libs/vulkansdk-macos-
VK_LAYER_PATH : /Users/fbmac/Documents/_projets/Zulu-java-11/com/ondine/libs/vulkansdk-macos-
VK_ICD_FILENAMES : /Users/fbmac/Documents/_projets/Zulu-java-11/com/ondine/libs/vulkansdk-macos-

Code: [Select]
[***MoltenVK ERROR***] VK_ERROR_LAYER_NOT_PRESENT: Vulkan layer VK_LAYER_LUNARG_standard_validation is not supported.
[***MoltenVK ERROR***] VK_ERROR_EXTENSION_NOT_PRESENT: Vulkan extension VK_EXT_debug_utils is not supported.
[***MoltenVK ERROR***] VK_ERROR_INCOMPATIBLE_DRIVER: Request for driver version 401000 is not compatible with provided version 40005f.
févr. 22, 2019 3:58:17 PM com.justindriggers.example.Application main
GRAVE: An fatal error occurred
com.justindriggers.vulkan.instance.models.VulkanException: ERROR_LAYER_NOT_PRESENT (-6)
at java.base/java.util.Optional.map(Optional.java:265)
at com.justindriggers.vulkan.instance.VulkanFunction.execute(VulkanFunction.java:18)
at com.justindriggers.vulkan.instance.VulkanFunction.execute(VulkanFunction.java:25)
at com.justindriggers.vulkan.instance.VulkanInstance.createVulkanInstance(VulkanInstance.java:174)
at com.justindriggers.vulkan.instance.VulkanInstance.<init>(VulkanInstance.java:54)
at com.justindriggers.example.window.GLFWWindow.<init>(GLFWWindow.java:98)
at com.justindriggers.example.Application.main(Application.java:73)

Code: [Select]
iMac-de-Franck:~ fbmac$ printenv
Title: Re: Every sample code i tried generate ERROR_LAYER_NOT_PRESENT
Post by: spasi on February 22, 2019, 21:21:02
Right, the problem is that LWJGL loads and uses MoltenVK directly, bypassing the Vulkan loader. To fix this, pass -Dorg.lwjgl.vulkan.libname=<path_to_vulkan_sdk>/macOS/lib/libvulkan.dylib to your program (or set it programmatically using Configuration.VULKAN_LIBRARY_NAME). This will make LWJGL load the Vulkan loader instead, which knows how to discover the validation loaders and forward Vulkan function calls to the ICD (i.e. MoltenVK).

Note that you'll also need to export VK_LAYER_PATH & VK_ICD_FILENAMES (like you've done already). Modifying PATH or DYLD_LIBRARY_PATH is not necessary.

Finally, <vulkan_sdk>/macOS/etc/vulkan/icd.d/MoltenVK_icd.json points to the MoltenVK build that comes with the Vulkan SDK. This is usually behind the build that comes with the latest LWJGL snapshot (MoltenVK is updated frequently). However, you can modify the json to make it point to the LWJGL build instead.
Title: Re: Every sample code i tried generate ERROR_LAYER_NOT_PRESENT
Post by: Graou on February 23, 2019, 10:14:41
Thank you very much for your expertise and your quick response. You have solved my problem.