Lines Matching refs:cache
55 cache_dump_stats(struct v3dv_pipeline_cache *cache)
57 fprintf(stderr, " NIR cache entries: %d\n", cache->nir_stats.count);
58 fprintf(stderr, " NIR cache miss count: %d\n", cache->nir_stats.miss);
59 fprintf(stderr, " NIR cache hit count: %d\n", cache->nir_stats.hit);
61 fprintf(stderr, " cache entries: %d\n", cache->stats.count);
62 fprintf(stderr, " cache miss count: %d\n", cache->stats.miss);
63 fprintf(stderr, " cache hit count: %d\n", cache->stats.hit);
65 fprintf(stderr, " on-disk cache hit count: %d\n", cache->stats.on_disk_hit);
69 pipeline_cache_lock(struct v3dv_pipeline_cache *cache)
71 if (!cache->externally_synchronized)
72 mtx_lock(&cache->mutex);
76 pipeline_cache_unlock(struct v3dv_pipeline_cache *cache)
78 if (!cache->externally_synchronized)
79 mtx_unlock(&cache->mutex);
84 struct v3dv_pipeline_cache *cache,
88 if (!cache || !cache->nir_cache)
91 if (cache->nir_stats.count > V3DV_MAX_PIPELINE_CACHE_ENTRIES)
94 pipeline_cache_lock(cache);
96 _mesa_hash_table_search(cache->nir_cache, sha1_key);
97 pipeline_cache_unlock(cache);
110 pipeline_cache_lock(cache);
115 entry = _mesa_hash_table_search(cache->nir_cache, sha1_key);
118 pipeline_cache_unlock(cache);
123 ralloc_size(cache->nir_cache, sizeof(*snir) + blob.size);
130 cache->nir_stats.count++;
134 fprintf(stderr, "pipeline cache %p, new nir entry %s\n", cache, sha1buf);
136 cache_dump_stats(cache);
139 _mesa_hash_table_insert(cache->nir_cache, snir->sha1_key, snir);
141 pipeline_cache_unlock(cache);
146 struct v3dv_pipeline_cache *cache,
150 if (!cache || !cache->nir_cache)
157 fprintf(stderr, "pipeline cache %p, search for nir %s\n", cache, sha1buf);
162 pipeline_cache_lock(cache);
164 _mesa_hash_table_search(cache->nir_cache, sha1_key);
167 pipeline_cache_unlock(cache);
175 * after cache creation
181 cache->nir_stats.hit++;
183 fprintf(stderr, "[v3dv nir cache] hit: %p\n", nir);
185 cache_dump_stats(cache);
191 cache->nir_stats.miss++;
193 fprintf(stderr, "[v3dv nir cache] miss\n");
195 cache_dump_stats(cache);
202 v3dv_pipeline_cache_init(struct v3dv_pipeline_cache *cache,
207 cache->device = device;
208 mtx_init(&cache->mutex, mtx_plain);
211 cache->nir_cache = _mesa_hash_table_create(NULL, sha1_hash_func,
213 cache->nir_stats.miss = 0;
214 cache->nir_stats.hit = 0;
215 cache->nir_stats.count = 0;
217 cache->cache = _mesa_hash_table_create(NULL, sha1_hash_func,
219 cache->stats.miss = 0;
220 cache->stats.hit = 0;
221 cache->stats.count = 0;
223 cache->externally_synchronized = flags &
226 cache->nir_cache = NULL;
227 cache->cache = NULL;
233 v3dv_pipeline_shared_data_create_from_blob(struct v3dv_pipeline_cache *cache,
237 pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache,
251 v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache,
255 if (!cache || !cache->cache)
262 fprintf(stderr, "pipeline cache %p, search pipeline with key %s\n", cache, sha1buf);
265 pipeline_cache_lock(cache);
268 _mesa_hash_table_search(cache->cache, sha1_key);
275 cache->stats.hit++;
278 fprintf(stderr, "[v3dv cache] hit: %p\n", cache_entry);
280 cache_dump_stats(cache);
286 pipeline_cache_unlock(cache);
291 cache->stats.miss++;
293 fprintf(stderr, "[v3dv cache] miss\n");
295 cache_dump_stats(cache);
298 pipeline_cache_unlock(cache);
301 struct v3dv_device *device = cache->device;
303 /* Note that the on-disk-cache can be independently disabled, while keeping
304 * the pipeline cache working, by using the environment variable
317 fprintf(stderr, "[v3dv on-disk cache] %s %s\n",
327 shared_data = v3dv_pipeline_shared_data_create_from_blob(cache, &blob);
335 cache->stats.on_disk_hit++;
336 if (cache)
337 pipeline_cache_upload_shared_data(cache, shared_data, true);
373 v3dv_pipeline_shared_data_new(struct v3dv_pipeline_cache *cache,
382 * and unref by both the pipeline and the pipeline cache, so we can't
383 * ensure that the cache or pipeline alloc will be available on the last
387 vk_zalloc2(&cache->device->vk.alloc, NULL, size, 8,
401 struct v3dv_bo *bo = v3dv_bo_alloc(cache->device, total_assembly_size,
408 bool ok = v3dv_bo_map(cache->device, bo, total_assembly_size);
421 v3dv_pipeline_shared_data_unref(cache->device, new_entry);
426 pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache,
432 if (!cache || !cache->cache)
435 if (cache->stats.count > V3DV_MAX_PIPELINE_CACHE_ENTRIES)
438 pipeline_cache_lock(cache);
441 /* If this is being called from the disk cache, we already know that the
445 entry = _mesa_hash_table_search(cache->cache, shared_data->sha1_key);
448 pipeline_cache_unlock(cache);
453 _mesa_hash_table_insert(cache->cache, shared_data->sha1_key, shared_data);
454 cache->stats.count++;
459 fprintf(stderr, "pipeline cache %p, new cache entry with sha1 key %s:%p\n\n",
460 cache, sha1buf, shared_data);
462 cache_dump_stats(cache);
465 pipeline_cache_unlock(cache);
468 /* If we are being called from a on-disk-cache hit, we can skip writing to
469 * the disk cache
474 struct v3dv_device *device = cache->device;
486 fprintf(stderr, "[v3dv on-disk cache] storing %s\n", sha1buf);
499 struct v3dv_pipeline_cache *cache)
501 pipeline_cache_upload_shared_data(cache, pipeline->shared_data, false);
505 serialized_nir_create_from_blob(struct v3dv_pipeline_cache *cache,
515 ralloc_size(cache->nir_cache, sizeof(*snir) + snir_size);
575 v3dv_pipeline_shared_data_create_from_blob(struct v3dv_pipeline_cache *cache,
593 maps[stage] = vk_zalloc2(&cache->device->vk.alloc, NULL,
613 shader_variant_create_from_blob(cache->device, blob);
625 v3dv_pipeline_shared_data_new(cache, sha1_key, maps, variants,
636 vk_free2(&cache->device->vk.alloc, NULL, maps[i]);
638 v3dv_shader_variant_destroy(cache->device, variants[i]);
644 pipeline_cache_load(struct v3dv_pipeline_cache *cache,
648 struct v3dv_device *device = cache->device;
652 if (cache->cache == NULL || cache->nir_cache == NULL)
679 serialized_nir_create_from_blob(cache, &blob);
684 _mesa_hash_table_insert(cache->nir_cache, snir->sha1_key, snir);
685 cache->nir_stats.count++;
694 v3dv_pipeline_shared_data_create_from_blob(cache, &blob);
698 _mesa_hash_table_insert(cache->cache, cache_entry->sha1_key, cache_entry);
699 cache->stats.count++;
703 fprintf(stderr, "pipeline cache %p, loaded %i nir shaders and "
704 "%i entries\n", cache, nir_count, count);
706 cache_dump_stats(cache);
717 struct v3dv_pipeline_cache *cache;
721 cache = vk_object_zalloc(&device->vk, pAllocator,
722 sizeof(*cache),
725 if (cache == NULL)
728 v3dv_pipeline_cache_init(cache, device, pCreateInfo->flags,
732 pipeline_cache_load(cache,
737 *pPipelineCache = v3dv_pipeline_cache_to_handle(cache);
743 v3dv_pipeline_cache_finish(struct v3dv_pipeline_cache *cache)
745 mtx_destroy(&cache->mutex);
748 cache_dump_stats(cache);
750 if (cache->nir_cache) {
751 hash_table_foreach(cache->nir_cache, entry)
754 _mesa_hash_table_destroy(cache->nir_cache, NULL);
757 if (cache->cache) {
758 hash_table_foreach(cache->cache, entry) {
761 v3dv_pipeline_shared_data_unref(cache->device, cache_entry);
764 _mesa_hash_table_destroy(cache->cache, NULL);
774 V3DV_FROM_HANDLE(v3dv_pipeline_cache, cache, _cache);
776 if (!cache)
779 v3dv_pipeline_cache_finish(cache);
781 vk_object_free(&device->vk, pAllocator, cache);
792 if (!dst->cache || !dst->nir_cache)
797 if (!src->cache || !src->nir_cache)
808 * convenient to create and store on the cache, but requires to do a
825 fprintf(stderr, "pipeline cache %p, added nir entry %s "
826 "from pipeline cache %p\n",
833 hash_table_foreach(src->cache, entry) {
837 if (_mesa_hash_table_search(dst->cache, cache_entry->sha1_key))
841 _mesa_hash_table_insert(dst->cache, cache_entry->sha1_key, cache_entry);
848 fprintf(stderr, "pipeline cache %p, added entry %s "
849 "from pipeline cache %p\n",
956 V3DV_FROM_HANDLE(v3dv_pipeline_cache, cache, _cache);
968 pipeline_cache_lock(cache);
986 if (cache->nir_cache) {
987 hash_table_foreach(cache->nir_cache, entry) {
1013 if (cache->cache) {
1014 hash_table_foreach(cache->cache, entry) {
1035 assert(count <= cache->stats.count);
1036 fprintf(stderr, "GetPipelineCacheData: serializing cache %p, "
1039 cache, nir_count, count, (uint32_t) *pDataSize);
1045 pipeline_cache_unlock(cache);