Lines Matching full:cache
40 #define vk_pipeline_cache_log(cache, ...) \ argument
41 if (cache->base.client_visible) \
42 vk_logw(VK_LOG_OBJS(cache), __VA_ARGS__)
45 get_disk_cache(const struct vk_pipeline_cache *cache) in get_disk_cache() argument
47 if (cache->disk_cache) in get_disk_cache()
48 return cache->disk_cache; in get_disk_cache()
50 return cache->base.device->physical->disk_cache; in get_disk_cache()
66 vk_raw_data_cache_object_deserialize(struct vk_pipeline_cache *cache, in vk_raw_data_cache_object_deserialize() argument
81 vk_raw_data_cache_object_create(cache->base.device, key_data, key_size, in vk_raw_data_cache_object_deserialize()
147 vk_pipeline_cache_lock(struct vk_pipeline_cache *cache) in vk_pipeline_cache_lock() argument
150 if (!(cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT)) in vk_pipeline_cache_lock()
151 simple_mtx_lock(&cache->lock); in vk_pipeline_cache_lock()
155 vk_pipeline_cache_unlock(struct vk_pipeline_cache *cache) in vk_pipeline_cache_unlock() argument
157 if (!(cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT)) in vk_pipeline_cache_unlock()
158 simple_mtx_unlock(&cache->lock); in vk_pipeline_cache_unlock()
161 /* cache->lock must be held when calling */
163 vk_pipeline_cache_remove_object(struct vk_pipeline_cache *cache, in vk_pipeline_cache_remove_object() argument
168 _mesa_set_search_pre_hashed(cache->object_cache, hash, object); in vk_pipeline_cache_remove_object()
170 /* Drop the reference owned by the cache */ in vk_pipeline_cache_remove_object()
171 if (!cache->weak_ref) in vk_pipeline_cache_remove_object()
172 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_remove_object()
174 _mesa_set_remove(cache->object_cache, entry); in vk_pipeline_cache_remove_object()
179 vk_pipeline_cache_object_weak_ref(struct vk_pipeline_cache *cache, in vk_pipeline_cache_object_weak_ref() argument
183 p_atomic_set(&object->weak_owner, cache); in vk_pipeline_cache_object_weak_ref()
210 vk_pipeline_cache_object_serialize(struct vk_pipeline_cache *cache, in vk_pipeline_cache_object_serialize() argument
224 * cache or where we've already serialized the cache once. in vk_pipeline_cache_object_serialize()
235 vk_pipeline_cache_log(cache, "Failed to serialize pipeline cache object"); in vk_pipeline_cache_object_serialize()
241 vk_pipeline_cache_log(cache, "Skipping giant (4 GiB or larger) object"); in vk_pipeline_cache_object_serialize()
246 vk_pipeline_cache_log(cache, in vk_pipeline_cache_object_serialize()
247 "Insufficient memory for pipeline cache data"); in vk_pipeline_cache_object_serialize()
258 vk_pipeline_cache_object_deserialize(struct vk_pipeline_cache *cache, in vk_pipeline_cache_object_deserialize() argument
267 vk_pipeline_cache_log(cache, in vk_pipeline_cache_object_deserialize()
268 "Pipeline cache object cannot be deserialized"); in vk_pipeline_cache_object_deserialize()
276 ops->deserialize(cache, key_data, key_size, &reader); in vk_pipeline_cache_object_deserialize()
291 vk_pipeline_cache_insert_object(struct vk_pipeline_cache *cache, in vk_pipeline_cache_insert_object() argument
296 if (cache->object_cache == NULL) in vk_pipeline_cache_insert_object()
301 vk_pipeline_cache_lock(cache); in vk_pipeline_cache_insert_object()
304 cache->object_cache, hash, object, &found); in vk_pipeline_cache_insert_object()
311 /* The found object in the cache isn't fully formed. Replace it. */ in vk_pipeline_cache_insert_object()
312 assert(!cache->weak_ref); in vk_pipeline_cache_insert_object()
322 if (!cache->weak_ref) in vk_pipeline_cache_insert_object()
325 vk_pipeline_cache_object_weak_ref(cache, result); in vk_pipeline_cache_insert_object()
327 vk_pipeline_cache_unlock(cache); in vk_pipeline_cache_insert_object()
330 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_insert_object()
336 vk_pipeline_cache_lookup_object(struct vk_pipeline_cache *cache, in vk_pipeline_cache_lookup_object() argument
355 if (cache != NULL && cache->object_cache != NULL) { in vk_pipeline_cache_lookup_object()
356 vk_pipeline_cache_lock(cache); in vk_pipeline_cache_lookup_object()
358 _mesa_set_search_pre_hashed(cache->object_cache, hash, &key); in vk_pipeline_cache_lookup_object()
364 vk_pipeline_cache_unlock(cache); in vk_pipeline_cache_lookup_object()
368 struct disk_cache *disk_cache = get_disk_cache(cache); in vk_pipeline_cache_lookup_object()
369 if (!cache->skip_disk_cache && disk_cache && cache->object_cache) { in vk_pipeline_cache_lookup_object()
376 object = vk_pipeline_cache_object_deserialize(cache, in vk_pipeline_cache_lookup_object()
382 return vk_pipeline_cache_insert_object(cache, object); in vk_pipeline_cache_lookup_object()
387 /* No disk cache or not found in the disk cache */ in vk_pipeline_cache_lookup_object()
400 vk_pipeline_cache_object_deserialize(cache, in vk_pipeline_cache_lookup_object()
406 vk_pipeline_cache_log(cache, in vk_pipeline_cache_lookup_object()
407 "Deserializing pipeline cache object failed"); in vk_pipeline_cache_lookup_object()
409 vk_pipeline_cache_lock(cache); in vk_pipeline_cache_lookup_object()
410 vk_pipeline_cache_remove_object(cache, hash, object); in vk_pipeline_cache_lookup_object()
411 vk_pipeline_cache_unlock(cache); in vk_pipeline_cache_lookup_object()
412 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_lookup_object()
416 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_lookup_object()
417 object = vk_pipeline_cache_insert_object(cache, real_object); in vk_pipeline_cache_lookup_object()
426 vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache, in vk_pipeline_cache_add_object() argument
430 vk_pipeline_cache_insert_object(cache, object); in vk_pipeline_cache_add_object()
433 /* If it wasn't in the object cache, it might not be in the disk cache in vk_pipeline_cache_add_object()
437 struct disk_cache *disk_cache = get_disk_cache(cache); in vk_pipeline_cache_add_object()
438 if (!cache->skip_disk_cache && object->ops->serialize && disk_cache) { in vk_pipeline_cache_add_object()
458 vk_pipeline_cache_create_and_insert_object(struct vk_pipeline_cache *cache, in vk_pipeline_cache_create_and_insert_object() argument
463 struct disk_cache *disk_cache = get_disk_cache(cache); in vk_pipeline_cache_create_and_insert_object()
464 if (!cache->skip_disk_cache && disk_cache) { in vk_pipeline_cache_create_and_insert_object()
471 vk_pipeline_cache_object_deserialize(cache, key_data, key_size, data, in vk_pipeline_cache_create_and_insert_object()
475 object = vk_pipeline_cache_insert_object(cache, object); in vk_pipeline_cache_create_and_insert_object()
481 vk_pipeline_cache_lookup_nir(struct vk_pipeline_cache *cache, in vk_pipeline_cache_lookup_nir() argument
487 vk_pipeline_cache_lookup_object(cache, key_data, key_size, in vk_pipeline_cache_lookup_nir()
500 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_lookup_nir()
511 vk_pipeline_cache_add_nir(struct vk_pipeline_cache *cache, in vk_pipeline_cache_add_nir() argument
520 vk_pipeline_cache_log(cache, "Ran out of memory serializing NIR shader"); in vk_pipeline_cache_add_nir()
526 vk_raw_data_cache_object_create(cache->base.device, in vk_pipeline_cache_add_nir()
531 vk_pipeline_cache_log(cache, "Ran out of memory creating NIR shader"); in vk_pipeline_cache_add_nir()
536 vk_pipeline_cache_add_object(cache, &data_obj->base); in vk_pipeline_cache_add_nir()
537 vk_pipeline_cache_object_unref(cache->base.device, cached); in vk_pipeline_cache_add_nir()
572 vk_pipeline_cache_load(struct vk_pipeline_cache *cache, in vk_pipeline_cache_load() argument
584 if (memcmp(&header, &cache->header, sizeof(header)) != 0) in vk_pipeline_cache_load()
598 find_ops_for_type(cache->base.device->physical, type); in vk_pipeline_cache_load()
601 vk_pipeline_cache_create_and_insert_object(cache, key_data, key_size, in vk_pipeline_cache_load()
605 vk_pipeline_cache_log(cache, "Failed to load pipeline cache object"); in vk_pipeline_cache_load()
609 vk_pipeline_cache_object_unref(cache->base.device, object); in vk_pipeline_cache_load()
621 struct vk_pipeline_cache *cache; in vk_pipeline_cache_create() local
628 cache = vk_object_zalloc(device, pAllocator, sizeof(*cache), in vk_pipeline_cache_create()
630 if (cache == NULL) in vk_pipeline_cache_create()
633 cache->flags = pCreateInfo->flags; in vk_pipeline_cache_create()
634 cache->weak_ref = info->weak_ref; in vk_pipeline_cache_create()
636 cache->skip_disk_cache = true; in vk_pipeline_cache_create()
638 cache->skip_disk_cache = info->skip_disk_cache; in vk_pipeline_cache_create()
639 cache->disk_cache = info->disk_cache; in vk_pipeline_cache_create()
646 cache->header = (struct vk_pipeline_cache_header) { in vk_pipeline_cache_create()
652 memcpy(cache->header.uuid, pdevice_props.pipelineCacheUUID, VK_UUID_SIZE); in vk_pipeline_cache_create()
654 simple_mtx_init(&cache->lock, mtx_plain); in vk_pipeline_cache_create()
658 cache->object_cache = _mesa_set_create(NULL, object_key_hash, in vk_pipeline_cache_create()
662 if (cache->object_cache && pCreateInfo->initialDataSize > 0) { in vk_pipeline_cache_create()
663 vk_pipeline_cache_load(cache, pCreateInfo->pInitialData, in vk_pipeline_cache_create()
667 return cache; in vk_pipeline_cache_create()
671 vk_pipeline_cache_destroy(struct vk_pipeline_cache *cache, in vk_pipeline_cache_destroy() argument
674 if (cache->object_cache) { in vk_pipeline_cache_destroy()
675 if (!cache->weak_ref) { in vk_pipeline_cache_destroy()
676 set_foreach(cache->object_cache, entry) { in vk_pipeline_cache_destroy()
677 vk_pipeline_cache_object_unref(cache->base.device, (void *)entry->key); in vk_pipeline_cache_destroy()
680 assert(cache->object_cache->entries == 0); in vk_pipeline_cache_destroy()
682 _mesa_set_destroy(cache->object_cache, NULL); in vk_pipeline_cache_destroy()
684 simple_mtx_destroy(&cache->lock); in vk_pipeline_cache_destroy()
685 vk_object_free(cache->base.device, pAllocator, cache); in vk_pipeline_cache_destroy()
695 struct vk_pipeline_cache *cache; in vk_common_CreatePipelineCache() local
701 cache = vk_pipeline_cache_create(device, &info, pAllocator); in vk_common_CreatePipelineCache()
702 if (cache == NULL) in vk_common_CreatePipelineCache()
705 *pPipelineCache = vk_pipeline_cache_to_handle(cache); in vk_common_CreatePipelineCache()
715 VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); in vk_common_DestroyPipelineCache()
717 if (cache == NULL) in vk_common_DestroyPipelineCache()
720 assert(cache->base.device == vk_device_from_handle(device)); in vk_common_DestroyPipelineCache()
721 vk_pipeline_cache_destroy(cache, pAllocator); in vk_common_DestroyPipelineCache()
731 VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); in vk_common_GetPipelineCacheData()
740 blob_write_bytes(&blob, &cache->header, sizeof(cache->header)); in vk_common_GetPipelineCacheData()
750 vk_pipeline_cache_lock(cache); in vk_common_GetPipelineCacheData()
753 if (cache->object_cache != NULL) { in vk_common_GetPipelineCacheData()
754 set_foreach(cache->object_cache, entry) { in vk_common_GetPipelineCacheData()
774 if (!vk_pipeline_cache_object_serialize(cache, object, in vk_common_GetPipelineCacheData()
796 vk_pipeline_cache_unlock(cache); in vk_common_GetPipelineCacheData()