From 188402e12968b83fd25dc214a18159f80feee040 Mon Sep 17 00:00:00 2001 From: dvab-sarma Date: Fri, 5 Dec 2025 13:04:33 -0600 Subject: [PATCH] panvk: Use the build SHA for the pipeline/binary cache UUIDs This way we get the same cache UUIDs for identical sources and build environments, even if they're built at different times. Acked-by: default avatarEric R. Smith Reviewed-by: default avatarLars-Ivar Hesselberg Simonsen Part-of: This resolves the error when integrating vulkan.panfrost as an apex - Dawn : Warning: external/mesa3d-panfrost/src/panfrost/vulkan/panvk_physical_device.c:304: cannot generate UUID (VK_ERROR_INITIALIZATION_FAILED) --- src/panfrost/vulkan/panvk_physical_device.c | 55 +++++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 48b79970f7f..fada17f53a8 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -135,22 +135,43 @@ get_drm_device_ids(struct panvk_physical_device *device, return VK_SUCCESS; } -static int -get_cache_uuid(uint16_t family, void *uuid) +// static int +// get_cache_uuid(uint16_t family, void *uuid) +// { +// uint32_t mesa_timestamp; +// uint16_t f = family; + +// if (!disk_cache_get_function_timestamp(get_cache_uuid, &mesa_timestamp)) +// return -1; + +// memset(uuid, 0, VK_UUID_SIZE); +// memcpy(uuid, &mesa_timestamp, 4); +// memcpy((char *)uuid + 4, &f, 2); +// snprintf((char *)uuid + 6, VK_UUID_SIZE - 10, "pan"); +// return 0; +// } + +static void +get_cache_sha1(struct panvk_physical_device *device, + const struct panvk_instance *instance) { - uint32_t mesa_timestamp; - uint16_t f = family; + struct mesa_sha1 sha_ctx; + _mesa_sha1_init(&sha_ctx); - if (!disk_cache_get_function_timestamp(get_cache_uuid, &mesa_timestamp)) - return -1; + _mesa_sha1_update(&sha_ctx, instance->driver_build_sha, + sizeof(instance->driver_build_sha)); - memset(uuid, 0, VK_UUID_SIZE); - memcpy(uuid, &mesa_timestamp, 4); - memcpy((char *)uuid + 4, &f, 2); - snprintf((char *)uuid + 6, VK_UUID_SIZE - 10, "pan"); - return 0; + _mesa_sha1_update(&sha_ctx, &device->kmod.props.gpu_id, + sizeof(device->kmod.props.gpu_id)); + + unsigned char sha[SHA1_DIGEST_LENGTH]; + _mesa_sha1_final(&sha_ctx, sha); + + STATIC_ASSERT(VK_UUID_SIZE <= SHA1_DIGEST_LENGTH); + memcpy(device->cache_uuid, sha, VK_UUID_SIZE); } + static VkResult get_core_mask(struct panvk_physical_device *device, const struct panvk_instance *instance, const char *option_name, @@ -299,11 +320,13 @@ panvk_physical_device_init(struct panvk_physical_device *device, memset(device->name, 0, sizeof(device->name)); sprintf(device->name, "%s", device->model->name); - if (get_cache_uuid(device->kmod.props.gpu_id, device->cache_uuid)) { - result = panvk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, - "cannot generate UUID"); - goto fail; - } + // if (get_cache_uuid(device->kmod.props.gpu_id, device->cache_uuid)) { + // result = panvk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, + // "cannot generate UUID"); + // goto fail; + // } + + get_cache_sha1(device, instance); result = get_core_masks(device, instance); if (result != VK_SUCCESS)