diff options
author | Timothy Arceri <[email protected]> | 2017-10-11 12:10:31 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-10-12 08:52:38 +1100 |
commit | fd24be134ffda15c82d163cf9b7e9da8d65407d4 (patch) | |
tree | 6f0071062ad315e80e4cd358c7f13a19844aa942 /src/amd | |
parent | 142162529233680631a246c8920e66d02ee4e94b (diff) |
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 <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_pipeline_cache.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 625c58e66c7..94437e2b30c 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -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) - return NULL; + 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); |