radv: make use of on-disk cache

If the app provided in-memory pipeline cache doesn't yet contain
what we are looking for, or it doesn't provide one at all then we
fallback to the on-disk cache.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Timothy Arceri 2017-10-11 12:10:31 +11:00
parent 1421625292
commit fd24be134f

View File

@ -23,6 +23,7 @@
#include "util/mesa-sha1.h"
#include "util/debug.h"
#include "util/disk_cache.h"
#include "util/u_atomic.h"
#include "radv_debug.h"
#include "radv_private.h"
@ -165,8 +166,16 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
else
entry = radv_pipeline_cache_search(device->mem_cache, sha1);
if (!entry) {
uint8_t disk_sha1[20];
disk_cache_compute_key(device->physical_device->disk_cache,
sha1, 20, disk_sha1);
entry = (struct cache_entry *)
disk_cache_get(device->physical_device->disk_cache,
disk_sha1, NULL);
if (!entry)
return NULL;
}
if (!entry->variant) {
struct radv_shader_variant *variant;
@ -301,6 +310,20 @@ radv_pipeline_cache_insert_shader(struct radv_device *device,
entry->rsrc1 = variant->rsrc1;
entry->rsrc2 = variant->rsrc2;
entry->code_size = code_size;
/* Set variant to NULL so we have reproducible cache items */
entry->variant = NULL;
/* Always add cache items to disk. This will allow collection of
* 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);
entry->variant = variant;
p_atomic_inc(&variant->ref_count);