vulkan/pipeline_cache: implement vk_pipeline_cache_create_and_insert_object()
This function directly inserts the serialized data into the disk cache before calling deserialize() and inserting into the pipeline cache. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21967>
This commit is contained in:
committed by
Marge Bot
parent
84fa7b1745
commit
f524f91d6f
@@ -452,6 +452,31 @@ vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache,
|
||||
return inserted;
|
||||
}
|
||||
|
||||
struct vk_pipeline_cache_object *
|
||||
vk_pipeline_cache_create_and_insert_object(struct vk_pipeline_cache *cache,
|
||||
const void *key_data, uint32_t key_size,
|
||||
const void *data, size_t data_size,
|
||||
const struct vk_pipeline_cache_object_ops *ops)
|
||||
{
|
||||
#ifdef ENABLE_SHADER_CACHE
|
||||
struct disk_cache *disk_cache = cache->base.device->physical->disk_cache;
|
||||
if (disk_cache) {
|
||||
cache_key cache_key;
|
||||
disk_cache_compute_key(disk_cache, key_data, key_size, cache_key);
|
||||
disk_cache_put(disk_cache, cache_key, data, data_size, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct vk_pipeline_cache_object *object =
|
||||
vk_pipeline_cache_object_deserialize(cache, key_data, key_size, data,
|
||||
data_size, ops);
|
||||
|
||||
if (object)
|
||||
object = vk_pipeline_cache_insert_object(cache, object);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
nir_shader *
|
||||
vk_pipeline_cache_lookup_nir(struct vk_pipeline_cache *cache,
|
||||
const void *key_data, size_t key_size,
|
||||
|
||||
@@ -241,6 +241,23 @@ struct vk_pipeline_cache_object * MUST_CHECK
|
||||
vk_pipeline_cache_add_object(struct vk_pipeline_cache *cache,
|
||||
struct vk_pipeline_cache_object *object);
|
||||
|
||||
/** Creates and inserts an object into the pipeline cache
|
||||
*
|
||||
* This function takes serialized data and emplaces the deserialized object
|
||||
* into the pipeline cache. It is the responsibility of the caller to
|
||||
* specify a deserialize() function that properly initializes the object.
|
||||
*
|
||||
* This function can be used to avoid an extra serialize() step for
|
||||
* disk-cache insertion. For the intended usage pattern, see
|
||||
* vk_pipeline_cache_add_object().
|
||||
*
|
||||
*/
|
||||
struct vk_pipeline_cache_object *
|
||||
vk_pipeline_cache_create_and_insert_object(struct vk_pipeline_cache *cache,
|
||||
const void *key_data, uint32_t key_size,
|
||||
const void *data, size_t data_size,
|
||||
const struct vk_pipeline_cache_object_ops *ops);
|
||||
|
||||
struct nir_shader *
|
||||
vk_pipeline_cache_lookup_nir(struct vk_pipeline_cache *cache,
|
||||
const void *key_data, size_t key_size,
|
||||
|
||||
Reference in New Issue
Block a user