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))
157 /* Default to 1GB for maximum cache size. */
162 cache->max_size = max_size;
167 * avoiding excessive memory use due to a backlog of cache entrys building
174 if (!util_queue_init(&cache->cache_queue, "disk$", 32, 4,
181 cache->path_init_failed = false;
185 cache->driver_keys_blob_size = cv_size;
190 cache->driver_keys_blob_size += id_size;
191 cache->driver_keys_blob_size += gpu_name_size;
193 /* We sometimes store entire structs that contains a pointers in the cache,
198 cache->driver_keys_blob_size += ptr_size_size;
201 cache->driver_keys_blob_size += driver_flags_size;
203 cache->driver_keys_blob =
204 ralloc_size(cache, cache->driver_keys_blob_size);
205 if (!cache->driver_keys_blob)
208 uint8_t *drv_key_blob = cache->driver_keys_blob;
216 s_rand_xorshift128plus(cache->seed_xorshift128plus, true);
220 return cache;
223 if (cache)
224 ralloc_free(cache);
231 disk_cache_destroy(struct disk_cache *cache)
233 if (cache && !cache->path_init_failed) {
234 util_queue_finish(&cache->cache_queue);
235 util_queue_destroy(&cache->cache_queue);
238 foz_destroy(&cache->foz_db);
240 disk_cache_destroy_mmap(cache);
243 ralloc_free(cache);
247 disk_cache_wait_for_idle(struct disk_cache *cache)
249 util_queue_finish(&cache->cache_queue);
253 disk_cache_remove(struct disk_cache *cache, const cache_key key)
255 char *filename = disk_cache_get_cache_filename(cache, key);
260 disk_cache_evict_item(cache, filename);
264 create_put_job(struct disk_cache *cache, const cache_key key,
273 dc_job->cache = cache;
283 /* Copy the cache item metadata */
343 filename = disk_cache_get_cache_filename(dc_job->cache, dc_job->key);
347 /* If the cache is too large, evict something else first. */
348 while (*dc_job->cache->size + dc_job->size > dc_job->cache->max_size &&
350 disk_cache_evict_lru_item(dc_job->cache);
362 disk_cache_put(struct disk_cache *cache, const cache_key key,
366 if (cache->blob_put_cb) {
367 cache->blob_put_cb(key, CACHE_KEY_SIZE, data, size);
371 if (cache->path_init_failed)
375 create_put_job(cache, key, (void*)data, size, cache_item_metadata, false);
379 util_queue_add_job(&cache->cache_queue, dc_job, &dc_job->fence,
385 disk_cache_put_nocopy(struct disk_cache *cache, const cache_key key,
389 if (cache->blob_put_cb) {
390 cache->blob_put_cb(key, CACHE_KEY_SIZE, data, size);
395 if (cache->path_init_failed) {
401 create_put_job(cache, key, data, size, cache_item_metadata, true);
405 util_queue_add_job(&cache->cache_queue, dc_job, &dc_job->fence,
411 disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size)
416 if (cache->blob_get_cb) {
426 cache->blob_get_cb(key, CACHE_KEY_SIZE, blob, max_blob_size);
439 return disk_cache_load_item_foz(cache, key, size);
441 char *filename = disk_cache_get_cache_filename(cache, key);
445 return disk_cache_load_item(cache, filename, size);
450 disk_cache_put_key(struct disk_cache *cache, const cache_key key)
456 if (cache->blob_put_cb) {
457 cache->blob_put_cb(key, CACHE_KEY_SIZE, key_chunk, sizeof(uint32_t));
461 if (cache->path_init_failed)
464 entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
470 * stored in the cache with disk_cache_put_key(). The implement is
473 * calling disk_cache_put_key, then that's just an extra cache miss and an
477 disk_cache_has_key(struct disk_cache *cache, const cache_key key)
483 if (cache->blob_get_cb) {
485 return cache->blob_get_cb(key, CACHE_KEY_SIZE, &blob, sizeof(uint32_t));
488 if (cache->path_init_failed)
491 entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
497 disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
503 _mesa_sha1_update(&ctx, cache->driver_keys_blob,
504 cache->driver_keys_blob_size);
510 disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_put_cb put,
513 cache->blob_put_cb = put;
514 cache->blob_get_cb = get;