#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"
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;
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);