I’m afraid vulkan support is a subject to further research. I’ve played a bit with it and got to a state where vulkaninfo properly reports Nvidia ICD. The problem was that ICD discovery is somewhat awkward and while you can pass a path to specific icd in VK_ICD_FILENAMES, I have not found a way to override the ICD search paths. I hope that we will be able to sort it out with proper layout adjustments.
I’ve had a bug report about a snap I’ve made which fails to run under 18.04, after an update from 17.10. I can’t reproduce the issue but the snap is complaining about gl libraries. I was wondering if it is significant that the reporter is running a laptop nvidia card? Would hybrid graphics/optimus be supported with your fix? Do you have any suggestions about what I could do to debug this?
IIRC @chipaca ran some snaps on a system with integrated nvidia card, albeit this might have been a 16.04 system at the time. As far as the snaps are concerned, the current setup will first probe if the NVIDIA driver is loaded and then verify if matching NVIDIA libraries are available in /usr/lib/<arch-tuple>/. That’s all there is to it.
If I correctly understand what PRIME does, you should be able to select your nvidia card as the sink and then set DRI_PRIME=<idx> to use the card. Given how messy (and useless) it has been for Linux users, I’d recommend to first get it working outside of snaps.
One thing to note is that you currently need to use snap-discard-ns on a snap if you run an app from the snap with the intel card and then switch to the nvidia card.
This doesn’t seem to be an issue when the application is linked against libGL like your glxinfo is (I don’t know yet how exactly GLVND is figuring out which driver to use in this case but maybe its talking to X11) but causes problems for those which load the GL driver via dlopen/dlsym at runtime. For those we need to have the egl_vendor.d dir available. Happily GLVND has a environment variable for this __EGL_VENDOR_LIBRARY_DIRS which can be used to provide access to a copy of possible vendor configurations within a snap.
However we should support this the right way by maybe mapping /usr/share/glvnd/egl_vendor.d onto something in /var/lib/snapd/ within the snap mount namespace and then set the __EGL_VENDOR_LIBRARY_DIRS environment variable automatically for this or let the desktop launchers do that. What do you think?
Thanks for finding this. Fortunately this looks much saner than Vulkan and should be an easy fix. Do you have a snap I could use to testing by any chance?