radv: Add an early exit in the secure compile if we already have the cache entries.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 30 Oct 2019 02:29:21 +0000 (03:29 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 30 Oct 2019 10:38:50 +0000 (11:38 +0100)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/amd/vulkan/radv_pipeline.c

index 422b0771a7926927e1370e31ab0adefad8ffe9bc..55a5d2a3c53ea9ded31487697e4316aaf5059da7 100644 (file)
@@ -4644,6 +4644,20 @@ radv_secure_compile(struct radv_pipeline *pipeline,
                                       allowed_hashes[i]);
        }
 
+       /* Do an early exit if all cache entries are already there. */
+       bool may_need_copy_shader = pStages[MESA_SHADER_GEOMETRY];
+       void *main_entry = disk_cache_get(device->physical_device->disk_cache, allowed_hashes[0], 20);
+       void *copy_entry = NULL;
+       if (may_need_copy_shader)
+               copy_entry = disk_cache_get(device->physical_device->disk_cache, allowed_hashes[1], 20);
+
+       bool has_all_cache_entries = main_entry && (!may_need_copy_shader || copy_entry);
+       free(main_entry);
+       free(copy_entry);
+
+       if(has_all_cache_entries)
+               return VK_SUCCESS;
+
        unsigned process = 0;
        uint8_t sc_threads = device->instance->num_sc_threads;
        while (true) {