From 43365502c4573af15a4e0e686052e3bd8ccfe69a Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 1 Aug 2024 00:01:46 +0200 Subject: [PATCH] nouveau: implement driver_uuid and device_uuid Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11592 Cc: mesa-stable Part-of: --- src/gallium/drivers/nouveau/meson.build | 2 +- src/gallium/drivers/nouveau/nouveau_screen.c | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/meson.build b/src/gallium/drivers/nouveau/meson.build index d3df4b701a1..5537fe5f1c6 100644 --- a/src/gallium/drivers/nouveau/meson.build +++ b/src/gallium/drivers/nouveau/meson.build @@ -163,7 +163,7 @@ files_libnouveau = files( libnouveau = static_library( 'nouveau', - files_libnouveau, + [files_libnouveau, sha1_h], include_directories : [ inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_mapi, inc_mesa, ], diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 33ac4d92374..bd074950289 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -1,3 +1,5 @@ +#include "git_sha1.h" + #include "pipe/p_defines.h" #include "pipe/p_screen.h" #include "pipe/p_state.h" @@ -281,6 +283,26 @@ nouveau_screen_get_fd(struct pipe_screen *pscreen) return screen->drm->fd; } +static void +nouveau_driver_uuid(struct pipe_screen *screen, char *uuid) +{ + const char* driver = PACKAGE_VERSION MESA_GIT_SHA1; + struct mesa_sha1 sha1_ctx; + uint8_t sha1[20]; + + _mesa_sha1_init(&sha1_ctx); + _mesa_sha1_update(&sha1_ctx, driver, strlen(driver)); + _mesa_sha1_final(&sha1_ctx, sha1); + memcpy(uuid, sha1, PIPE_UUID_SIZE); +} + +static void +nouveau_device_uuid(struct pipe_screen *pscreen, char *uuid) +{ + const struct nouveau_screen *screen = nouveau_screen(pscreen); + nv_device_uuid(&screen->device->info, (void *)uuid, PIPE_UUID_SIZE, false); +} + int nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) { @@ -421,6 +443,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->fence_finish = nouveau_screen_fence_finish; pscreen->query_memory_info = nouveau_query_memory_info; + pscreen->get_driver_uuid = nouveau_driver_uuid; + pscreen->get_device_uuid = nouveau_device_uuid; nouveau_disk_cache_create(screen);