Mesa (master): radv: add debug option to turn off in memory cache

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Oct 26 02:39:18 UTC 2019


Module: Mesa
Branch: master
Commit: 6571000071dd5e60a277200c8d12179a63be41b0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6571000071dd5e60a277200c8d12179a63be41b0

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Jul 12 14:45:16 2019 +1000

radv: add debug option to turn off in memory cache

This can be usefull for debugging the on disk cache, but is also
useful in the following patch for secure compiles which will be
used to compile huge pipeline collections. These pipeline
collections can be multiple GBs and the in memory cache grows to
multiple GBs very quickly when they are compiled so we want to
be able to turn off the in memory cache.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/amd/vulkan/radv_debug.h          |  1 +
 src/amd/vulkan/radv_device.c         |  1 +
 src/amd/vulkan/radv_pipeline_cache.c | 25 ++++++++++++++++++++-----
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index 2d35f4e1386..2ec460ec15a 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -56,6 +56,7 @@ enum {
 	RADV_DEBUG_NO_SHADER_BALLOT  = 0x4000000,
 	RADV_DEBUG_ALL_ENTRYPOINTS   = 0x8000000,
 	RADV_DEBUG_DUMP_META_SHADERS = 0x10000000,
+	RADV_DEBUG_NO_MEMORY_CACHE   = 0x20000000,
 };
 
 enum {
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index b7dddd27a3a..eeac9d3adca 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -434,6 +434,7 @@ static const struct debug_control radv_debug_options[] = {
 	{"nodcc", RADV_DEBUG_NO_DCC},
 	{"shaders", RADV_DEBUG_DUMP_SHADERS},
 	{"nocache", RADV_DEBUG_NO_CACHE},
+	{"nomemorycache", RADV_DEBUG_NO_MEMORY_CACHE},
 	{"shaderstats", RADV_DEBUG_DUMP_SHADER_STATS},
 	{"nohiz", RADV_DEBUG_NO_HIZ},
 	{"nocompute", RADV_DEBUG_NO_COMPUTE_QUEUE},
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index db7afe5a48c..031d910550c 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -295,7 +295,9 @@ radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
 			free(entry);
 			entry = new_entry;
 
-			radv_pipeline_cache_add_entry(cache, new_entry);
+			if (!(device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE) ||
+			    cache != device->mem_cache)
+				radv_pipeline_cache_add_entry(cache, new_entry);
 		}
 	}
 
@@ -314,11 +316,17 @@ radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
 
 	}
 
-	for (int i = 0; i < MESA_SHADER_STAGES; ++i)
-		if (entry->variants[i])
-			p_atomic_inc(&entry->variants[i]->ref_count);
-
 	memcpy(variants, entry->variants, sizeof(entry->variants));
+
+	if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE &&
+	    cache == device->mem_cache)
+		vk_free(&cache->alloc, entry);
+	else {
+		for (int i = 0; i < MESA_SHADER_STAGES; ++i)
+			if (entry->variants[i])
+				p_atomic_inc(&entry->variants[i]->ref_count);
+	}
+
 	pthread_mutex_unlock(&cache->mutex);
 	return true;
 }
@@ -398,6 +406,13 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device,
 			       disk_sha1, entry, entry_size(entry), NULL);
 	}
 
+	if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE &&
+	    cache == device->mem_cache) {
+		vk_free2(&cache->alloc, NULL, entry);
+		pthread_mutex_unlock(&cache->mutex);
+		return;
+	}
+
 	/* We delay setting the variant so we have reproducible disk cache
 	 * items.
 	 */




More information about the mesa-commit mailing list