From 6a44bda8795abdbacfcceeb79b73fb72d99edd5f Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Tue, 17 Mar 2020 10:14:08 +0000 Subject: [PATCH] intel/uuid: use git-sha1/package for the driver UUID We can't read information from the loaded shared object because we have different objects for Vulkan and OpenGL drivers, but we need to share the same UUID for both. Hence let's use SHA1 from the Git commit and package version. v2: use also package version for the case of building from tarball (Eric) v3: fix typos in comment (Tapani) Signed-off-by: Juan A. Suarez Romero Reviewed-by: Eric Engestrom Reviewed-by: Rohan Garg Part-of: --- src/intel/common/gen_uuid.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/intel/common/gen_uuid.c b/src/intel/common/gen_uuid.c index 02dfb540484..921c43d4a17 100644 --- a/src/intel/common/gen_uuid.c +++ b/src/intel/common/gen_uuid.c @@ -22,7 +22,7 @@ */ #include "gen_uuid.h" -#include "util/build_id.h" +#include "git_sha1.h" #include "util/mesa-sha1.h" void @@ -56,18 +56,20 @@ gen_uuid_compute_driver_id(uint8_t *uuid, const struct gen_device_info *devinfo, size_t size) { - const struct build_id_note *note = - build_id_find_nhdr_for_addr(gen_uuid_compute_driver_id); - assert(note && "Failed to find build-id"); + const char* intelDriver = PACKAGE_VERSION MESA_GIT_SHA1; + struct mesa_sha1 sha1_ctx; + uint8_t sha1[20]; - unsigned build_id_len = build_id_length(note); - assert(build_id_len >= size && "build-id too short"); + assert(size <= sizeof(sha1)); /* The driver UUID is used for determining sharability of images and memory - * between two Vulkan instances in separate processes, or for - * interoperability between Vulkan and OpenGL. People who want to * share - * memory need to also check the device UUID so all this * needs to be is - * the build-id. + * between two Vulkan instances in separate processes, but also to + * determining memory objects and sharability between Vulkan and OpenGL + * driver. People who want to share memory need to also check the device + * UUID. */ - memcpy(uuid, build_id_data(note), size); + _mesa_sha1_init(&sha1_ctx); + _mesa_sha1_update(&sha1_ctx, intelDriver, strlen(intelDriver) * sizeof(char)); + _mesa_sha1_final(&sha1_ctx, sha1); + memcpy(uuid, sha1, size); }