Support using `RUNPATH` to locate layer DSOs
**What enhancement are you suggesting for the Vulkan Loader? Please describe in detail. **
Currently layer DSOs can be found using LD_LIBRARY_PATH, VK_LAYER_PATH, or the paths determined by the system environment.
I propose extending this behaviour to also allow searching the RUNPATH embedded in the executable, in common with other dynamic dependencies. This makes it easier to deploy applications in sandboxed environments where an executable and accompanying libraries can be deployed but the runtime environment cannot be easily modified.
Is this specific to a single platform? Linux, Macos
First, a small clarification.
Vulkan-Loader doesn't search for DSO's, it searches for layer manifest files (json documents), which contain the field "library_path" that then is provided to dlopen(). At times, VK_LAYER_PATH is all that is needed because the Vulkan-Loader fixes up relative paths with an absolute path, using the location of the manifest file as the 'base' for the relative path. When no path is provided in `"library_path" (neither absolute nor relative), then it is passed directly into dlopen(), which requires setting LD_LIBRARY_PATH in order for the binary to be found.
Second, I am not against this proposal, as a mechanism to 'ship' layers with an application is useful. VK_LUNARG_direct_driver_loading exists to solve this problem for drivers. A similar extension for layers could exist but is more difficult due to layer manifest files, as there is a lot of info needed, which inflates the API (and could cause issues as manifest files may add new fields over time). Note that VK_LUNARG_direct_driver_loading allows statically linked binaries to be used by vulkan by passing just vkGetInstanceProcAddr, whereas layers have more info making this approach less appealing.
How possible is it to embed the path to the manifest file in the executable? That doesn't have the drawbacks associated with VK_LUNARG_direct_driver_loading. This kind of addition will need discussion in the Vulkan SI group, as it adds a new discovery mechanism for the Vulkan-Loader.