Vulkan-Loader icon indicating copy to clipboard operation
Vulkan-Loader copied to clipboard

VK_LAYER_PATH equivalent for implicit layers

Open baldurk opened this issue 2 years ago • 2 comments

What enhancement are you suggesting for the Vulkan Loader? Please describe in detail. I built a local copy of Fossilize and I wanted to point at it temporarily for an application run, but VK_LAYER_PATH and VK_ADD_LAYER_PATH didn't function as I expected. It took a while and digging through the source to realise that they only apply to explicit layers - though I went back to the docs and noticed that it does indeed say "when looking for explicit layer manifest files.".

I'm not sure the reasoning for this exactly, but not all layers are natively explicit layers so it would be nice to be able to extend the search paths similarly for implicit layers. I don't think this is a security consideration since I was able to just force the layer as if it were explicit via VK_INSTANCE_LAYERS once I twigged.

As a side note, it would be helpful to have some extra debug text in VK_LOADER_DEBUG=all to indicate which types of manifests (implicit layer/explicit layer/driver) were being searched and which env vars are being included or not in each one. I got myself confused while digging in because when enabling that I saw it was searching the path I wanted but there are multiple searches listed so crucially it wasn't searching some of the time.

Is this specific to a single platform? I encountered this on linux but I think it probably applies everywhere.

baldurk avatar Nov 30 '23 14:11 baldurk

I am unsure of the historical decision as to why VK_LAYER_PATH only modifies explicit layer paths, but I am not keen to change it due to potential side effects across the ecosystem.

Still, a VK_IMPLICIT_LAYER_PATH and VK_ADD_IMPLICIT_LAYER_PATH would make sense and I do not think it is impossible to add. I'm no fan of adding more environment variables (there already are too many in my opinion) but they at least close an existing hole.

As a side note, it would be helpful to have some extra debug text in VK_LOADER_DEBUG=all to indicate which types of manifests

Looking at the log, we do print "looking for layer|driver manifests" but I always 'knew' what was being searched for because the paths involved said "explicit_layer.d/Vk_layer_foo.json". Still, that is a useful thing to print.

As for why it works the way it does, it may have to do with the loader's inability to distinguish implicit from explicit layers directly, instead expecting the different layer types to be in separate paths/registries. But I have no solid evidence of that fact.

charles-lunarg avatar Dec 01 '23 19:12 charles-lunarg

PR #1400 Is a quick addition to add "explicit" or "implicit" to the 'searching for layer manifests' log message. I think it would be better to open a separate issue to track more detailed logging suggestions, in order to prevent this issue from getting cluttered up.

EDIT: I went ahead and did that - let me know if that summarizes the intent of your suggestion. Cause I believe the root problem was not knowing where the search paths came from, rather than only knowing if any given env-var was the source.

charles-lunarg avatar Dec 01 '23 19:12 charles-lunarg

+1. I use multiple custom installation prefixes on Linux for development. Without something like VK_IMPLICIT_LAYER_PATH, it's impossible to add ${PREFIX}/share/vulkan/implciit_layer.d to the search path.

In some cases, this is critical for development. For example, when a gpu driver installs an implicit layer that requires version-lock with the driver version. Without VK_IMPLICIT_LAYER_PATH, the loader tries to use the system-installed layer instead, which may be incompatible with the driver version installed into the custom prefix.

linyaa-kiwi avatar Sep 09 '24 21:09 linyaa-kiwi