nouveau: implement driver_uuid and device_uuid

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11592
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30455>
This commit is contained in:
Karol Herbst 2024-08-01 00:01:46 +02:00 committed by Marge Bot
parent 826d00617c
commit 43365502c4
2 changed files with 25 additions and 1 deletions

View file

@ -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,
],

View file

@ -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);