radv: fallback to an in-memory cache when no pipline cache is provided
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 15 Mar 2017 04:20:48 +0000 (15:20 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 17 Mar 2017 05:17:10 +0000 (16:17 +1100)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_pipeline_cache.c
src/amd/vulkan/radv_private.h

index 13ae87c3c49a567e41f61e913ea18e828001dbde..73a377657baf249e0b0a2b78e84aeda6927e4020 100644 (file)
@@ -559,7 +559,8 @@ radv_pipeline_compile(struct radv_pipeline *pipeline,
 
                if (pipeline->gs_copy_shader) {
                        pipeline->gs_copy_shader =
-                               radv_pipeline_cache_insert_shader(cache,
+                               radv_pipeline_cache_insert_shader(pipeline->device,
+                                                                 cache,
                                                                  gs_copy_sha1,
                                                                  pipeline->gs_copy_shader,
                                                                  gs_copy_code,
@@ -570,8 +571,10 @@ radv_pipeline_compile(struct radv_pipeline *pipeline,
                ralloc_free(nir);
 
        if (variant)
-               variant = radv_pipeline_cache_insert_shader(cache, sha1, variant,
-                                                           code, code_size);
+               variant = radv_pipeline_cache_insert_shader(pipeline->device,
+                                                           cache, sha1,
+                                                           variant, code,
+                                                           code_size);
 
        if (code)
                free(code);
index 5f6355f0d1a670981acc1954e342ec48058d9d23..1fb8450021b04a610ded004389975ec10239cf86 100644 (file)
@@ -156,6 +156,8 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
 
        if (cache)
                entry = radv_pipeline_cache_search(cache, sha1);
+       else
+               entry = radv_pipeline_cache_search(device->mem_cache, sha1);
 
        if (!entry)
                return NULL;
@@ -258,13 +260,14 @@ radv_pipeline_cache_add_entry(struct radv_pipeline_cache *cache,
 }
 
 struct radv_shader_variant *
-radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache,
+radv_pipeline_cache_insert_shader(struct radv_device *device,
+                                 struct radv_pipeline_cache *cache,
                                  const unsigned char *sha1,
                                  struct radv_shader_variant *variant,
                                  const void *code, unsigned code_size)
 {
        if (!cache)
-               return variant;
+               cache = device->mem_cache;
 
        pthread_mutex_lock(&cache->mutex);
        struct cache_entry *entry = radv_pipeline_cache_search_unlocked(cache, sha1);
index e4654bb4d4af7c95b739da95fbc92aac26872f7a..fd4edf665f2ddd02c9c0afc322ae7aaa50bf3582 100644 (file)
@@ -316,7 +316,8 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
                                               const unsigned char *sha1);
 
 struct radv_shader_variant *
-radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache,
+radv_pipeline_cache_insert_shader(struct radv_device *device,
+                                 struct radv_pipeline_cache *cache,
                                  const unsigned char *sha1,
                                  struct radv_shader_variant *variant,
                                  const void *code, unsigned code_size);