<div dir="ltr">Dave asked for a different commit message that describes the problem a bit better:<br><br> anv: Suffix the intel_icd file with the host CPU<br> <br> Vulkan has a multi-arch problem... The idea behind the Vulkan loader is<br> that you have a little json file on your disk that tells the loader where<br> to find drivers. The loader looks for these json files in standard<br> locations, and then goes and loads the my_driver.so's that they specify.<br> This allows you as a driver implementer to put their driver wherever on the<br> disk they want so long as the ICD points in the right place.<br> <br> For a multi-arch system, however, you may have multiple libvulkan_intel.so<br> files installed that the loader needs to pick depending on architecture.<br> Since the ICD file format does not specify any architecture information,<br> you can't tell the loader where to find the 32-bit version vs. the 64-bit<br> version. The way that packagers have been dealing with this is to place<br> libvulkan_intel.so in the top level lib directory and provide just a name<br> (and no path) to the loader. It will then use the regular system search<br> paths and find the correct driver. While this solution works fine for<br> distro-installed Vulkan drivers, it doesn't work so well for user-installed<br> drivers because they may put it in /usr/local or $HOME/.local or some other<br> more exotic location. In this case, you can't use an ICD json file with<br> just a library name because it doesn't know where to find it; you also have<br> to add that to your library lookup path via LD_LIBRARY_PATH or similar.<br> <br> This patch handles both use-cases by taking advantage of the fact that the<br> loader dlopen()s each of the drivers and, if one dlopen() calls fails, it<br> silently continues on to open other drivers. By suffixing the icd file, we<br> can provide two different json files: intel_icd.x86_64.json and<br> intel_icd.i686.json with different paths. Since dlopen() will only succeed<br> on the libvulkan_intel.so of the right arch, the loader will happily ignore<br> the others and load that one. This allows us to properly handle multi-arch<br> while still providing a full path so user installs will work fine.<br> <br> I tested this on my Fedora 25 machine with 32 and 64-bit builds of our<br> Vulkan driver installed and 32 and 64-bit builds of crucible. It seems to<br> work just fine.<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 20, 2016 at 4:04 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Vulkan has a multi-arch problem... The idea behind the Vulkan loader is<br>
that you have a little json file on your disk that tells the loader where<br>
to find drivers. The loader looks for these json files in standard<br>
locations, and then goes and loads the my_driver.so's that they specify.<br>
This allows you as a driver implementer to put their driver wherever on the<br>
disk they want so long as the icd points in the right place.<br>
<br>
Unfortunately, this system was not designed with multi-arch in mind.<br>
Instead of having some way to tell the loader "here's the 32-bit version"<br>
or "here's the 64-bit version", you give the loader a single .so. This<br>
means that if you install globally, your icd file somehow has to magically<br>
point at both /usr/lib/libvulkan_intel.so and /usr/lib64/libvulkan_intel.so<br>
on a multi-arch system. If you use an absolute path, this is a problem<br>
because the 32 and 64-bit versions of the packages stomp each other.<br>
<br>
This patch solves this problem by taking advantage of the fact that the<br>
loader dlopen()s each of the drivers and, if one dlopen() calls fails, it<br>
silently continues on to open other drivers. By suffixing the icd file, we<br>
can provide two different json files: intel_icd.x86_64.json and<br>
intel_icd.i686.json with different paths. Since dlopen() will only succeed<br>
on the libvulkan_intel.so of the right arch, the loader will happily ignore<br>
the others and load that one.<br>
<br>
I tested this on my Fedora 25 machine with 32 and 64-bit builds of our<br>
Vulkan driver installed and 32 and 64-bit builds of crucible. It seems to<br>
work just fine.<br>
<br>
Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
Cc: Matt Turner <<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>><br>
Cc: Emil Velikov <<a href="mailto:emil.velikov@collabora.com" target="_blank">emil.velikov@collabora.com</a>><br>
Cc: Adam Jackson <<a href="mailto:ajax@redhat.com" target="_blank">ajax@redhat.com</a>><br>
Cc: Timo Aaltonen <<a href="mailto:tjaalton@ubuntu.com" target="_blank">tjaalton@ubuntu.com</a>><br>
Cc: Dave Airlie <<a href="mailto:airlied@redhat.com" target="_blank">airlied@redhat.com</a>><br>
---<br>
src/intel/vulkan/Makefile.am | 4 ++--<br>
1 file changed, 2 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am<br>
index 54a51be..1dee84b 100644<br>
--- a/src/intel/vulkan/Makefile.am<br>
+++ b/src/intel/vulkan/Makefile.am<br>
@@ -166,7 +166,7 @@ libvulkan_intel_la_LDFLAGS = \<br>
<br>
<br>
icdconfdir = @VULKAN_ICD_INSTALL_DIR@<br>
-icdconf_DATA = intel_icd.json<br>
+icdconf_DATA = intel_icd.@host_cpu@.json<br>
# The following is used for development purposes, by setting VK_ICD_FILENAMES.<br>
noinst_DATA = dev_icd.json<br>
<br>
@@ -181,7 +181,7 @@ else<br>
ICD_DRIVER_PATH="libvulkan_in<wbr>tel.so"<br>
endif<br>
<br>
-intel_icd.json : <a href="http://intel_icd.json.in" rel="noreferrer" target="_blank">intel_icd.json.in</a><br>
+intel_icd.@host_cpu@.json : <a href="http://intel_icd.json.in" rel="noreferrer" target="_blank">intel_icd.json.in</a><br>
$(AM_V_GEN) $(SED) \<br>
-e "s#@ICD_DRIVER_PATH@#${ICD_DRI<wbr>VER_PATH}#" \<br>
< $(srcdir)/<a href="http://intel_icd.json.in" rel="noreferrer" target="_blank">intel_icd.json.in</a> > $@<br>
<span class="m_-3874936526643354600HOEnZb"><font color="#888888">--<br>
2.5.0.400.gff86faf<br>
<br>
</font></span></blockquote></div><br></div></div>