panvk: Enable the disk cache

Assuming disk I/O isn't painfully slow compared to running the whole
compiler (OS file system caching should help), this should massively
reduce the number of shaders compiled.

Acked-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38019>
This commit is contained in:
Faith Ekstrand 2025-10-23 12:37:17 -04:00 committed by Marge Bot
parent 9912c9a842
commit fd55e874ed

View file

@ -155,6 +155,37 @@ get_cache_sha1(struct panvk_physical_device *device,
memcpy(device->cache_uuid, sha, VK_UUID_SIZE); memcpy(device->cache_uuid, sha, VK_UUID_SIZE);
} }
static void
init_disk_cache(struct panvk_physical_device *device,
const struct panvk_instance *instance)
{
#ifdef ENABLE_SHADER_CACHE
char renderer[17];
ASSERTED int len = snprintf(renderer, sizeof(renderer), "panvk_0x%08x",
device->kmod.props.gpu_id);
assert(len == sizeof(renderer) - 1);
char timestamp[SHA1_DIGEST_STRING_LENGTH];
_mesa_sha1_format(timestamp, instance->driver_build_sha);
const uint64_t driver_flags = 0;
device->vk.disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
#endif
}
static void
free_disk_cache(struct panvk_physical_device *device)
{
#ifdef ENABLE_SHADER_CACHE
if (device->vk.disk_cache) {
disk_cache_destroy(device->vk.disk_cache);
device->vk.disk_cache = NULL;
}
#else
assert(device->vk.disk_cache == NULL);
#endif
}
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,
@ -239,6 +270,8 @@ panvk_physical_device_finish(struct panvk_physical_device *device)
{ {
panvk_wsi_finish(device); panvk_wsi_finish(device);
free_disk_cache(device);
pan_kmod_dev_destroy(device->kmod.dev); pan_kmod_dev_destroy(device->kmod.dev);
vk_physical_device_finish(&device->vk); vk_physical_device_finish(&device->vk);
@ -350,6 +383,8 @@ panvk_physical_device_init(struct panvk_physical_device *device,
device->vk.supported_sync_types = device->sync_types; device->vk.supported_sync_types = device->sync_types;
init_disk_cache(device, instance);
result = panvk_wsi_init(device); result = panvk_wsi_init(device);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
goto fail; goto fail;
@ -357,6 +392,8 @@ panvk_physical_device_init(struct panvk_physical_device *device,
return VK_SUCCESS; return VK_SUCCESS;
fail: fail:
free_disk_cache(device);
if (device->vk.instance) if (device->vk.instance)
vk_physical_device_finish(&device->vk); vk_physical_device_finish(&device->vk);