radv: don't crash if cache is disabled.
authorDave Airlie <airlied@redhat.com>
Thu, 12 Oct 2017 04:24:41 +0000 (14:24 +1000)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 12 Oct 2017 12:14:43 +0000 (14:14 +0200)
If you set MESA_GLSL_CACHE_DISABLE, radv crashed.

Fixes: fd24be134f (radv: make use of on-disk cache)
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/amd/vulkan/radv_pipeline_cache.c

index 51fa3f1b31f30a9621afb84e129a58765399eb8f..fabff9ed8158109b5900b7d610b970ce37923458 100644 (file)
@@ -167,6 +167,8 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
                entry = radv_pipeline_cache_search(device->mem_cache, sha1);
 
        if (!entry) {
+               if (!device->physical_device->disk_cache)
+                       return NULL;
                uint8_t disk_sha1[20];
                disk_cache_compute_key(device->physical_device->disk_cache,
                                       sha1, 20, disk_sha1);
@@ -317,11 +319,13 @@ radv_pipeline_cache_insert_shader(struct radv_device *device,
         * compiled shaders by third parties such as steam, even if the app
         * implements its own pipeline cache.
         */
-       uint8_t disk_sha1[20];
-       disk_cache_compute_key(device->physical_device->disk_cache, sha1, 20,
-                              disk_sha1);
-       disk_cache_put(device->physical_device->disk_cache,
-                      disk_sha1, entry, entry_size(entry), NULL);
+       if (device->physical_device->disk_cache) {
+               uint8_t disk_sha1[20];
+               disk_cache_compute_key(device->physical_device->disk_cache, sha1, 20,
+                                      disk_sha1);
+               disk_cache_put(device->physical_device->disk_cache,
+                              disk_sha1, entry, entry_size(entry), NULL);
+       }
 
        entry->variant = variant;
        p_atomic_inc(&variant->ref_count);