Closed mmdurrant closed 4 months ago
OK... what do you want us to do? We can't really control the way the OS loads the MoltenVK dylib, nor the way the Vulkan loader goes about searching for ICD descriptions and loading the corresponding ICDs. All of that happens before MoltenVK gets to execute any code.
If I may make a suggestion, have you tried using a pathname relative to @loader_path
in the ICD description? This is a special dyld(1)
variable used in dependencies that expands to the directory containing the binary that requested the load. I don't know if it will work with dlopen(3)
, but it might be worth a shot.
In any case, this would seem to be a problem with the Vulkan loader. You should probably file this on that project.
I was expecting a response close to this. I wasn't certain if it was a Vulkan Loader issue or specific to MoltenVK and appreciate the clarity there. Thank you for the clear direction.
What I ended up doing - I thought it was important to share my solution because this comes up in search results - the loader allows specification of the driver ICD JSON path by way of VK_DRIVER_FILES
environment variable. I used dladdr
to locate the path to my library and was able to locate my bundle's Resources
directory from there. I used setenv
to specify the environment variable and everything works as I would hope. This ensures the loader is able to correctly locate the manifest and everything works as we would hope.
Closing issue per @cdavis5e - this is not a problem that can be resolved in MoltenVK and must be resolved by informing the loader of additional path locations via VK_DRIVER_FILES
.
BACKGROUND: libVulkan is a dependency of an Adobe After Effects plugin. After Effects loads plugins at runtime via
dlopen
.PROBLEM: This is actually 2-fold. The spec says that the loader looks in
<bundle>/Contents/Resources/vulkan
for layer and driver manifests. Which as you can see in the log below - it does. The problem is<bundle>
in this case is After Effects and not the path of our plugin bundle as we would hope and expect.BUT the log file tells us a few locations where we can put the files! We drop our trusty
MoltenVK_icd.json
file in$USER/.config/vulkan/icd.d
. And we're off to the races!It also works flawlessly if I have the Vulkan SDK installed. It finds the ICD in the usual place in
/usr/local/share
and gets the MoltenVK path from there.In theory, I could set an environment variable to tell the loader the right path to the ICD and do the hacky thing I did in the JSON above and have it work. I talked to some folks in the official Vulkan Discord and they recommend I create an issue here to see if perhaps there is a better solution.
For reference, here is the plugin in question:
https://github.com/Wunkolo/Vulkanator
Please let me know if I can provide more info. Thanks!