xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
691 stars 405 forks source link

vulkan-validationlayers is missing the layers at runtime #1455

Open teschnei opened 2 years ago

teschnei commented 2 years ago

Xmake Version

xmake v2.7.1+master.70fa2aa7e

Operating System Version and Architecture

Windows 11

Describe Bug

Depending on vulkan-validationlayer does not find the validation layer at runtime. In addition, it links with the validation layer library, when it shouldn't.

Expected Behavior

Vulkan loader can find VK_LAYER_KHRONOS_validation layer at runtime.

Project Configuration

vulkan-validationlayers-test.zip

Additional Information and Error Logs

The vulkan-validationlayer package compiles the validation layers and puts them into the lib directory. However, the library shouldn't be linked against the dependent project, instead it should simply have the library (dll/so) and json available at runtime. This probably means there should be no lib directory, and the bin directory should contain the library and json file. Additionally, the VK_ADD_LAYER_PATH environment variable (or VK_LAYER_PATH if older than 1.3.211) should probably get set to that directory so that the program can find the layer json file at runtime.

Since I'm already working on adding 1.3.224 to the VulkanSDK packages, I can submit a PR for this, but I'm not sure how to fix the library issue. The install script copies the output directly to lib, but I can't find where it decides that...

waruqi commented 2 years ago

https://github.com/xmake-io/xmake-repo/blob/bcd6ba140f11307da5840feb7f81ec54eafc574f/packages/v/vulkan-validationlayers/xmake.lua#L35

Add add_links("") to this location, you can try it first, if it's ok, you can open a pr.

please do not change lib/bin directory and files.

teschnei commented 2 years ago

add_links("") seems to work for removing the link. Should VK_ADD_LAYER_PATH/VK_LAYER_PATH point to the lib dir, then?

waruqi commented 2 years ago

you can use package:addenv("VK_ADD_LAYER_PATH", package:installdir("lib"))

but it just work for xmake run

kraydan commented 3 months ago

Has a solution been found for this error? I recently encountered the same problem. Can i expect a fix soon?

waruqi commented 3 months ago

open a pr to improve package.

package:addenv("VK_ADD_LAYER_PATH", "lib")
package:mark_as_pathenv("VK_ADD_LAYER_PATH")