summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-01-31 15:53:37 +0100
committerSamuel Pitoiset <[email protected]>2018-02-01 09:40:11 +0100
commit2ef5ce11985c7ccd34887d00ab57e32d4036dbed (patch)
tree8c9fc27ba7309b143e7fb81f351c1c96765ec40f /src/amd/vulkan
parent4922e7f25c1a42779bab11aff6489d8a39a17061 (diff)
radv: do not insert shaders in cache when it's disabled
When the application doesn't provide its own pipeline cache, the driver uses a in-memory cache but it shouldn't insert any entries when the cache is explicitely disabled by the user. Found while running my experimental pipeline-db tool with a ton of shaders, the memory footprint was just huge, and sometimes the process was even killed... Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_pipeline_cache.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index db48895817e..7205a3d8969 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -241,6 +241,17 @@ radv_pipeline_cache_add_entry(struct radv_pipeline_cache *cache,
radv_pipeline_cache_set_entry(cache, entry);
}
+static bool
+radv_is_cache_disabled(struct radv_device *device)
+{
+ /* Pipeline caches can be disabled with RADV_DEBUG=nocache, with
+ * MESA_GLSL_CACHE_DISABLE=1, and when VK_AMD_shader_info is requested.
+ */
+ return (device->instance->debug_flags & RADV_DEBUG_NO_CACHE) ||
+ !device->physical_device->disk_cache ||
+ device->keep_shader_info;
+}
+
bool
radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
struct radv_pipeline_cache *cache,
@@ -257,11 +268,10 @@ radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
entry = radv_pipeline_cache_search_unlocked(cache, sha1);
if (!entry) {
- /* Again, don't cache when we want debug info, since this isn't
- * present in the cache. */
- if (!device->physical_device->disk_cache ||
- (device->instance->debug_flags & RADV_DEBUG_NO_CACHE) ||
- device->keep_shader_info) {
+ /* Don't cache when we want debug info, since this isn't
+ * present in the cache.
+ */
+ if (radv_is_cache_disabled(device)) {
pthread_mutex_unlock(&cache->mutex);
return false;
}
@@ -362,6 +372,15 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device,
pthread_mutex_unlock(&cache->mutex);
return;
}
+
+ /* Don't cache when we want debug info, since this isn't
+ * present in the cache.
+ */
+ if (radv_is_cache_disabled(device)) {
+ pthread_mutex_unlock(&cache->mutex);
+ return;
+ }
+
size_t size = sizeof(*entry);
for (int i = 0; i < MESA_SHADER_STAGES; ++i)
if (variants[i])