Lines Matching refs:cache
51 /* The cache version should be bumped whenever a change is made to the
52 * structure of cache entries or the index. This will give any 3rd party
53 * applications reading the cache entries a chance to adjust to the changes.
55 * - The cache version is checked internally when reading a cache entry. If we
56 * ever have a mismatch we are in big trouble as this means we had a cache
60 * - There is no strict requirement that cache versions be backwards
76 struct disk_cache *cache = NULL;
91 cache = rzalloc(NULL, struct disk_cache);
92 if (cache == NULL)
96 cache->path_init_failed = true;
99 /* Android needs the "disk cache" to be enabled for
110 cache->path = ralloc_strdup(cache, path);
111 if (cache->path == NULL)
115 if (!disk_cache_load_cache_index(local, cache))
119 if (!disk_cache_mmap_cache_index(local, cache, path))
165 /* Default to 1GB for maximum cache size. */
170 cache->max_size = max_size;
175 * avoiding excessive memory use due to a backlog of cache entrys building
182 if (!util_queue_init(&cache->cache_queue, "disk$", 32, 4,
189 cache->path_init_failed = false;
193 cache->driver_keys_blob_size = cv_size;
198 cache->driver_keys_blob_size += id_size;
199 cache->driver_keys_blob_size += gpu_name_size;
201 /* We sometimes store entire structs that contains a pointers in the cache,
206 cache->driver_keys_blob_size += ptr_size_size;
209 cache->driver_keys_blob_size += driver_flags_size;
211 cache->driver_keys_blob =
212 ralloc_size(cache, cache->driver_keys_blob_size);
213 if (!cache->driver_keys_blob)
216 uint8_t *drv_key_blob = cache->driver_keys_blob;
224 s_rand_xorshift128plus(cache->seed_xorshift128plus, true);
228 return cache;
231 if (cache)
232 ralloc_free(cache);
239 disk_cache_destroy(struct disk_cache *cache)
241 if (cache && !cache->path_init_failed) {
242 util_queue_finish(&cache->cache_queue);
243 util_queue_destroy(&cache->cache_queue);
246 foz_destroy(&cache->foz_db);
248 disk_cache_destroy_mmap(cache);
251 ralloc_free(cache);
255 disk_cache_wait_for_idle(struct disk_cache *cache)
257 util_queue_finish(&cache->cache_queue);
261 disk_cache_remove(struct disk_cache *cache, const cache_key key)
263 char *filename = disk_cache_get_cache_filename(cache, key);
268 disk_cache_evict_item(cache, filename);
272 create_put_job(struct disk_cache *cache, const cache_key key,
281 dc_job->cache = cache;
291 /* Copy the cache item metadata */
351 filename = disk_cache_get_cache_filename(dc_job->cache, dc_job->key);
355 /* If the cache is too large, evict something else first. */
356 while (*dc_job->cache->size + dc_job->size > dc_job->cache->max_size &&
358 disk_cache_evict_lru_item(dc_job->cache);
370 disk_cache_put(struct disk_cache *cache, const cache_key key,
374 if (cache->blob_put_cb) {
375 cache->blob_put_cb(key, CACHE_KEY_SIZE, data, size);
379 if (cache->path_init_failed)
383 create_put_job(cache, key, (void*)data, size, cache_item_metadata, false);
387 util_queue_add_job(&cache->cache_queue, dc_job, &dc_job->fence,
393 disk_cache_put_nocopy(struct disk_cache *cache, const cache_key key,
397 if (cache->blob_put_cb) {
398 cache->blob_put_cb(key, CACHE_KEY_SIZE, data, size);
403 if (cache->path_init_failed) {
409 create_put_job(cache, key, data, size, cache_item_metadata, true);
413 util_queue_add_job(&cache->cache_queue, dc_job, &dc_job->fence,
419 disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size)
424 if (cache->blob_get_cb) {
434 cache->blob_get_cb(key, CACHE_KEY_SIZE, blob, max_blob_size);
447 return disk_cache_load_item_foz(cache, key, size);
449 char *filename = disk_cache_get_cache_filename(cache, key);
453 return disk_cache_load_item(cache, filename, size);
458 disk_cache_put_key(struct disk_cache *cache, const cache_key key)
464 if (cache->blob_put_cb) {
465 cache->blob_put_cb(key, CACHE_KEY_SIZE, key_chunk, sizeof(uint32_t));
469 if (cache->path_init_failed)
472 entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
478 * stored in the cache with disk_cache_put_key(). The implement is
481 * calling disk_cache_put_key, then that's just an extra cache miss and an
485 disk_cache_has_key(struct disk_cache *cache, const cache_key key)
491 if (cache->blob_get_cb) {
493 return cache->blob_get_cb(key, CACHE_KEY_SIZE, &blob, sizeof(uint32_t));
496 if (cache->path_init_failed)
499 entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
505 disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
511 _mesa_sha1_update(&ctx, cache->driver_keys_blob,
512 cache->driver_keys_blob_size);
518 disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_put_cb put,
521 cache->blob_put_cb = put;
522 cache->blob_get_cb = get;