[Mesa-dev] [PATCH] radv: use correct alloc function when loading from disk

Timothy Arceri tarceri at itsqueeze.com
Tue Oct 31 00:34:22 UTC 2017


Fixes regression in:

dEQP-VK.api.object_management.alloc_callback_fail.graphics_pipeline

Fixes: 1e84e53712ae "radv: add cache items to in memory cache when reading from disk"
---
 src/amd/vulkan/radv_pipeline_cache.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index 91470d1419..2904b62e6b 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -269,21 +269,34 @@ radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
 		uint8_t disk_sha1[20];
 		disk_cache_compute_key(device->physical_device->disk_cache,
 				       sha1, 20, disk_sha1);
 		entry = (struct cache_entry *)
 			disk_cache_get(device->physical_device->disk_cache,
 				       disk_sha1, NULL);
 		if (!entry) {
 			pthread_mutex_unlock(&cache->mutex);
 			return false;
 		} else {
-			radv_pipeline_cache_add_entry(cache, entry);
+			size_t size = entry_size(entry);
+			struct cache_entry *new_entry = vk_alloc(&cache->alloc, size, 8,
+								 VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
+			if (!new_entry) {
+				free(entry);
+				pthread_mutex_unlock(&cache->mutex);
+				return false;
+			}
+
+			memcpy(new_entry, entry, entry_size(entry));
+			free(entry);
+			entry = new_entry;
+
+			radv_pipeline_cache_add_entry(cache, new_entry);
 		}
 	}
 
 	char *p = entry->code;
 	for(int i = 0; i < MESA_SHADER_STAGES; ++i) {
 		if (!entry->variants[i] && entry->code_sizes[i]) {
 			struct radv_shader_variant *variant;
 			struct cache_entry_variant_info info;
 
 			variant = calloc(1, sizeof(struct radv_shader_variant));
-- 
2.14.3



More information about the mesa-dev mailing list