Lines Matching refs:cache

144 vk_pipeline_cache_lock(struct vk_pipeline_cache *cache)
147 if (!(cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT))
148 simple_mtx_lock(&cache->lock);
152 vk_pipeline_cache_unlock(struct vk_pipeline_cache *cache)
154 if (!(cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT))
155 simple_mtx_unlock(&cache->lock);
159 vk_pipeline_cache_remove_object(struct vk_pipeline_cache *cache,
163 vk_pipeline_cache_lock(cache);
165 _mesa_set_search_pre_hashed(cache->object_cache, hash, object);
167 /* Drop the reference owned by the cache */
170 _mesa_set_remove(cache->object_cache, entry);
172 vk_pipeline_cache_unlock(cache);
180 vk_pipeline_cache_replace_object(struct vk_pipeline_cache *cache,
187 vk_pipeline_cache_lock(cache);
189 _mesa_set_search_pre_hashed(cache->object_cache, hash, search);
194 /* Drop the reference owned by the cache */
202 /* I guess the object was purged? Re-add it to the cache */
204 _mesa_set_add_pre_hashed(cache->object_cache, hash, replace);
206 vk_pipeline_cache_unlock(cache);
219 vk_pipeline_cache_object_serialize(struct vk_pipeline_cache *cache,
233 * cache or where we've already serialized the cache once.
244 vk_logw(VK_LOG_OBJS(cache),
245 "Failed to serialize pipeline cache object");
251 vk_logw(VK_LOG_OBJS(cache),
257 vk_logw(VK_LOG_OBJS(cache),
258 "Insufficient memory for pipeline cache data");
269 vk_pipeline_cache_object_deserialize(struct vk_pipeline_cache *cache,
278 vk_logw(VK_LOG_OBJS(cache),
279 "Pipeline cache object cannot be deserialized");
287 ops->deserialize(cache->base.device, key_data, key_size, &reader);
290 vk_logw(VK_LOG_OBJS(cache),
291 "Deserializing pipeline cache object failed");
296 assert(object->device == cache->base.device);
306 vk_pipeline_cache_lookup_object(struct vk_pipeline_cache *cache,
325 if (cache != NULL && cache->object_cache != NULL) {
326 vk_pipeline_cache_lock(cache);
328 _mesa_set_search_pre_hashed(cache->object_cache, hash, &key);
334 vk_pipeline_cache_unlock(cache);
339 struct disk_cache *disk_cache = cache->base.device->physical->disk_cache;
340 if (disk_cache != NULL && cache->object_cache != NULL) {
347 object = vk_pipeline_cache_object_deserialize(cache,
353 return vk_pipeline_cache_add_object(cache, object);
358 /* No disk cache or not found in the disk cache */
370 vk_pipeline_cache_object_deserialize(cache,
376 vk_pipeline_cache_remove_object(cache, hash, object);
380 object = vk_pipeline_cache_replace_object(cache, hash, object,
390 vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache,
395 if (cache->object_cache == NULL)
400 vk_pipeline_cache_lock(cache);
403 _mesa_set_search_or_add_pre_hashed(cache->object_cache,
410 /* The cache now owns a reference */
413 vk_pipeline_cache_unlock(cache);
419 /* If it wasn't in the object cache, it might not be in the disk cache
424 struct disk_cache *disk_cache = cache->base.device->physical->disk_cache;
446 vk_pipeline_cache_lookup_nir(struct vk_pipeline_cache *cache,
452 vk_pipeline_cache_lookup_object(cache, key_data, key_size,
475 vk_pipeline_cache_add_nir(struct vk_pipeline_cache *cache,
484 vk_logw(VK_LOG_OBJS(cache), "Ran out of memory serializing NIR shader");
490 raw_data_object_create(cache->base.device,
496 vk_pipeline_cache_add_object(cache, &data_obj->base);
532 vk_pipeline_cache_load(struct vk_pipeline_cache *cache,
544 if (memcmp(&header, &cache->header, sizeof(header)) != 0)
558 find_ops_for_type(cache->base.device->physical, type);
561 vk_pipeline_cache_object_deserialize(cache,
567 object = vk_pipeline_cache_add_object(cache, object);
580 struct vk_pipeline_cache *cache;
587 cache = vk_object_zalloc(device, pAllocator, sizeof(*cache),
589 if (cache == NULL)
592 cache->flags = pCreateInfo->flags;
598 cache->header = (struct vk_pipeline_cache_header) {
604 memcpy(cache->header.uuid, pdevice_props.pipelineCacheUUID, VK_UUID_SIZE);
606 simple_mtx_init(&cache->lock, mtx_plain);
610 cache->object_cache = _mesa_set_create(NULL, object_key_hash,
614 if (cache->object_cache && pCreateInfo->initialDataSize > 0) {
615 vk_pipeline_cache_load(cache, pCreateInfo->pInitialData,
619 return cache;
629 vk_pipeline_cache_destroy(struct vk_pipeline_cache *cache,
632 if (cache->object_cache)
633 _mesa_set_destroy(cache->object_cache, object_unref_cb);
634 simple_mtx_destroy(&cache->lock);
635 vk_object_free(cache->base.device, pAllocator, cache);
645 struct vk_pipeline_cache *cache;
650 cache = vk_pipeline_cache_create(device, &info, pAllocator);
651 if (cache == NULL)
654 *pPipelineCache = vk_pipeline_cache_to_handle(cache);
664 VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache);
666 if (cache == NULL)
669 assert(cache->base.device == vk_device_from_handle(device));
670 vk_pipeline_cache_destroy(cache, pAllocator);
680 VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache);
689 blob_write_bytes(&blob, &cache->header, sizeof(cache->header));
699 vk_pipeline_cache_lock(cache);
702 if (cache->object_cache != NULL) {
703 set_foreach(cache->object_cache, entry) {
720 if (!vk_pipeline_cache_object_serialize(cache, object,
740 vk_pipeline_cache_unlock(cache);