radv: fix generating the global key for pipeline binaries

The global key wasn't considering GPU family, Git revision etc and it
was mostly invariant.

Fixes: be06bfcbed ("radv: add initial support for pipeline binaries")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11995
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31576>
This commit is contained in:
Samuel Pitoiset 2024-10-09 07:47:24 -04:00 committed by Marge Bot
parent 47a78614ea
commit 1641db461f

View file

@ -75,16 +75,23 @@ radv_GetPipelineKeyKHR(VkDevice _device, const VkPipelineCreateInfoKHR *pPipelin
VkPipelineBinaryKeyKHR *pPipelineKey)
{
VK_FROM_HANDLE(radv_device, device, _device);
const struct radv_physical_device *pdev = radv_device_physical(device);
VkResult result;
memset(pPipelineKey->key, 0, sizeof(pPipelineKey->key));
/* Return the global key that applies to all pipelines. */
if (!pPipelineCreateInfo) {
static_assert(sizeof(device->cache_hash) <= sizeof(pPipelineKey->key), "mismatch pipeline binary key size");
struct mesa_blake3 ctx;
memcpy(pPipelineKey->key, device->cache_hash, sizeof(device->cache_hash));
pPipelineKey->keySize = sizeof(device->cache_hash);
static_assert(sizeof(blake3_hash) <= sizeof(pPipelineKey->key), "mismatch pipeline binary key size");
_mesa_blake3_init(&ctx);
_mesa_blake3_update(&ctx, pdev->cache_uuid, sizeof(pdev->cache_uuid));
_mesa_blake3_update(&ctx, device->cache_hash, sizeof(device->cache_hash));
_mesa_blake3_final(&ctx, pPipelineKey->key);
pPipelineKey->keySize = sizeof(blake3_hash);
return VK_SUCCESS;
}