From f00b54bc9e70e49f546ac2efeceb59540ff4a6fd Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Fri, 8 Oct 2021 02:11:19 +0200 Subject: [PATCH] radv: Rework modification detection of the meta cache. Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_meta.c | 9 +++++++-- src/amd/vulkan/radv_pipeline_cache.c | 2 -- src/amd/vulkan/radv_private.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c index ea55b31aa89..7db1fbdd0cc 100644 --- a/src/amd/vulkan/radv_meta.c +++ b/src/amd/vulkan/radv_meta.c @@ -322,7 +322,8 @@ radv_load_meta_pipeline(struct radv_device *device) fail: result = radv_CreatePipelineCache(radv_device_to_handle(device), &create_info, NULL, &device->meta_state.cache); if (result == VK_SUCCESS) { - ret = radv_pipeline_cache_from_handle(device->meta_state.cache)->kernel_count > 0; + device->meta_state.initial_cache_entries = radv_pipeline_cache_from_handle(device->meta_state.cache)->kernel_count; + ret = device->meta_state.initial_cache_entries > 0; } free(data); @@ -340,7 +341,11 @@ radv_store_meta_pipeline(struct radv_device *device) size_t size; void *data = NULL; - if (!radv_pipeline_cache_from_handle(device->meta_state.cache)->modified) + if (device->meta_state.cache == VK_NULL_HANDLE) + return; + + /* Skip serialization if no entries were added. */ + if (radv_pipeline_cache_from_handle(device->meta_state.cache)->kernel_count <= device->meta_state.initial_cache_entries) return; if (radv_GetPipelineCacheData(radv_device_to_handle(device), diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 9e0e445a6a0..06b825b98b6 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -82,7 +82,6 @@ radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device * mtx_init(&cache->mutex, mtx_plain); cache->flags = 0; - cache->modified = false; cache->kernel_count = 0; cache->total_size = 0; cache->table_size = 1024; @@ -571,7 +570,6 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel radv_pipeline_cache_add_entry(cache, entry); - cache->modified = true; radv_pipeline_cache_unlock(cache); return; } diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 7aaace60fa6..880e33fd322 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -377,7 +377,6 @@ struct radv_pipeline_cache { uint32_t table_size; uint32_t kernel_count; struct cache_entry **hash_table; - bool modified; VkAllocationCallbacks alloc; }; @@ -442,6 +441,7 @@ struct radv_meta_state { VkAllocationCallbacks alloc; VkPipelineCache cache; + uint32_t initial_cache_entries; /* * For on-demand pipeline creation, makes sure that