1
0
Fork 0

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 <eric.smith@collabora.com>
Reviewed-by: default avatarLars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <!38019>

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)
This commit is contained in:
dvab-sarma 2025-12-05 13:04:33 -06:00
parent 30bbf52f82
commit 188402e129

View file

@ -135,22 +135,43 @@ get_drm_device_ids(struct panvk_physical_device *device,
return VK_SUCCESS; return VK_SUCCESS;
} }
static int // static int
get_cache_uuid(uint16_t family, void *uuid) // 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; struct mesa_sha1 sha_ctx;
uint16_t f = family; _mesa_sha1_init(&sha_ctx);
if (!disk_cache_get_function_timestamp(get_cache_uuid, &mesa_timestamp)) _mesa_sha1_update(&sha_ctx, instance->driver_build_sha,
return -1; sizeof(instance->driver_build_sha));
memset(uuid, 0, VK_UUID_SIZE); _mesa_sha1_update(&sha_ctx, &device->kmod.props.gpu_id,
memcpy(uuid, &mesa_timestamp, 4); sizeof(device->kmod.props.gpu_id));
memcpy((char *)uuid + 4, &f, 2);
snprintf((char *)uuid + 6, VK_UUID_SIZE - 10, "pan"); unsigned char sha[SHA1_DIGEST_LENGTH];
return 0; _mesa_sha1_final(&sha_ctx, sha);
STATIC_ASSERT(VK_UUID_SIZE <= SHA1_DIGEST_LENGTH);
memcpy(device->cache_uuid, sha, VK_UUID_SIZE);
} }
static VkResult static VkResult
get_core_mask(struct panvk_physical_device *device, get_core_mask(struct panvk_physical_device *device,
const struct panvk_instance *instance, const char *option_name, 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)); memset(device->name, 0, sizeof(device->name));
sprintf(device->name, "%s", device->model->name); sprintf(device->name, "%s", device->model->name);
if (get_cache_uuid(device->kmod.props.gpu_id, device->cache_uuid)) { // if (get_cache_uuid(device->kmod.props.gpu_id, device->cache_uuid)) {
result = panvk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, // result = panvk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
"cannot generate UUID"); // "cannot generate UUID");
goto fail; // goto fail;
} // }
get_cache_sha1(device, instance);
result = get_core_masks(device, instance); result = get_core_masks(device, instance);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)