[Mesa-dev] [PATCH 1/3] anv: Suffix the intel_icd file with the host CPU

Jason Ekstrand jason at jlekstrand.net
Thu Oct 20 23:04:53 UTC 2016


Vulkan has a multi-arch problem... The idea behind the Vulkan loader is
that you have a little json file on your disk that tells the loader where
to find drivers.  The loader looks for these json files in standard
locations, and then goes and loads the my_driver.so's that they specify.
This allows you as a driver implementer to put their driver wherever on the
disk they want so long as the icd points in the right place.

Unfortunately, this system was not designed with multi-arch in mind.
Instead of having some way to tell the loader "here's the 32-bit version"
or "here's the 64-bit version", you give the loader a single .so.  This
means that if you install globally, your icd file somehow has to magically
point at both /usr/lib/libvulkan_intel.so and /usr/lib64/libvulkan_intel.so
on a multi-arch system.  If you use an absolute path, this is a problem
because the 32 and 64-bit versions of the packages stomp each other.

This patch solves this problem by taking advantage of the fact that the
loader dlopen()s each of the drivers and, if one dlopen() calls fails, it
silently continues on to open other drivers.  By suffixing the icd file, we
can provide two different json files: intel_icd.x86_64.json and
intel_icd.i686.json with different paths.  Since dlopen() will only succeed
on the libvulkan_intel.so of the right arch, the loader will happily ignore
the others and load that one.

I tested this on my Fedora 25 machine with 32 and 64-bit builds of our
Vulkan driver installed and 32 and 64-bit builds of crucible.  It seems to
work just fine.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Emil Velikov <emil.velikov at collabora.com>
Cc: Adam Jackson <ajax at redhat.com>
Cc: Timo Aaltonen <tjaalton at ubuntu.com>
Cc: Dave Airlie <airlied at redhat.com>
---
 src/intel/vulkan/Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 54a51be..1dee84b 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -166,7 +166,7 @@ libvulkan_intel_la_LDFLAGS = \
 
 
 icdconfdir = @VULKAN_ICD_INSTALL_DIR@
-icdconf_DATA = intel_icd.json
+icdconf_DATA = intel_icd. at host_cpu@.json
 # The following is used for development purposes, by setting VK_ICD_FILENAMES.
 noinst_DATA = dev_icd.json
 
@@ -181,7 +181,7 @@ else
 ICD_DRIVER_PATH="libvulkan_intel.so"
 endif
 
-intel_icd.json : intel_icd.json.in
+intel_icd. at host_cpu@.json : intel_icd.json.in
 	$(AM_V_GEN) $(SED) \
 		-e "s#@ICD_DRIVER_PATH@#${ICD_DRIVER_PATH}#" \
 		< $(srcdir)/intel_icd.json.in > $@
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list