From 2efa5ad0f69eb346ee02f287cf7870063b5722bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 27 Jun 2023 17:47:18 +0200 Subject: [PATCH] vulkan/pipeline_cache: add 'skip_disk_cache' option Part-of: --- src/vulkan/runtime/vk_pipeline_cache.c | 17 ++++++++--------- src/vulkan/runtime/vk_pipeline_cache.h | 4 ++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/vulkan/runtime/vk_pipeline_cache.c b/src/vulkan/runtime/vk_pipeline_cache.c index 83f6e0a542e..d5988952a5b 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.c +++ b/src/vulkan/runtime/vk_pipeline_cache.c @@ -356,9 +356,8 @@ vk_pipeline_cache_lookup_object(struct vk_pipeline_cache *cache, } if (object == NULL) { -#ifdef ENABLE_SHADER_CACHE struct disk_cache *disk_cache = cache->base.device->physical->disk_cache; - if (disk_cache != NULL && cache->object_cache != NULL) { + if (!cache->skip_disk_cache && disk_cache && cache->object_cache) { cache_key cache_key; disk_cache_compute_key(disk_cache, key_data, key_size, cache_key); @@ -375,7 +374,6 @@ vk_pipeline_cache_lookup_object(struct vk_pipeline_cache *cache, } } } -#endif /* No disk cache or not found in the disk cache */ return NULL; @@ -422,14 +420,13 @@ vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache, struct vk_pipeline_cache_object *inserted = vk_pipeline_cache_insert_object(cache, object); -#ifdef ENABLE_SHADER_CACHE if (object == inserted) { /* If it wasn't in the object cache, it might not be in the disk cache * either. Better try and add it. */ struct disk_cache *disk_cache = cache->base.device->physical->disk_cache; - if (object->ops->serialize != NULL && disk_cache) { + if (!cache->skip_disk_cache && object->ops->serialize && disk_cache) { struct blob blob; blob_init(&blob); @@ -444,7 +441,6 @@ vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache, blob_finish(&blob); } } -#endif return inserted; } @@ -455,14 +451,12 @@ vk_pipeline_cache_create_and_insert_object(struct vk_pipeline_cache *cache, const void *data, size_t data_size, const struct vk_pipeline_cache_object_ops *ops) { -#ifdef ENABLE_SHADER_CACHE struct disk_cache *disk_cache = cache->base.device->physical->disk_cache; - if (disk_cache) { + if (!cache->skip_disk_cache && disk_cache) { cache_key cache_key; disk_cache_compute_key(disk_cache, key_data, key_size, cache_key); disk_cache_put(disk_cache, cache_key, data, data_size, NULL); } -#endif struct vk_pipeline_cache_object *object = vk_pipeline_cache_object_deserialize(cache, key_data, key_size, data, @@ -625,6 +619,11 @@ vk_pipeline_cache_create(struct vk_device *device, cache->flags = pCreateInfo->flags; cache->weak_ref = info->weak_ref; +#ifndef ENABLE_SHADER_CACHE + cache->skip_disk_cache = true; +#else + cache->skip_disk_cache = info->skip_disk_cache; +#endif struct VkPhysicalDeviceProperties pdevice_props; device->physical->dispatch_table.GetPhysicalDeviceProperties( diff --git a/src/vulkan/runtime/vk_pipeline_cache.h b/src/vulkan/runtime/vk_pipeline_cache.h index 2d92c237a17..993bbabb0be 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.h +++ b/src/vulkan/runtime/vk_pipeline_cache.h @@ -154,6 +154,7 @@ struct vk_pipeline_cache { /* pCreateInfo::flags */ VkPipelineCacheCreateFlags flags; bool weak_ref; + bool skip_disk_cache; struct vk_pipeline_cache_header header; @@ -194,6 +195,9 @@ struct vk_pipeline_cache_create_info { * owner when it's destroyed. */ bool weak_ref; + + /** If true, do not attempt to use the disk cache */ + bool skip_disk_cache; }; struct vk_pipeline_cache *