From: Rob Clark Date: Sat, 1 Apr 2023 14:38:40 +0000 (-0700) Subject: util/disk_cache: Move blob_put_cb to the async queue X-Git-Tag: upstream/23.3.3~10469 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66d4dbd960e695d4b7db11a9fd57d3225079605f;p=platform%2Fupstream%2Fmesa.git util/disk_cache: Move blob_put_cb to the async queue Move deflate and put to the queue for the blob cache case. This moves the overhead out of the app thread when storing new shaders. Signed-off-by: Rob Clark Part-of: --- diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index cd338f8..c4872e5 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -427,6 +427,10 @@ destroy_put_job_nocopy(void *job, void *gdata, int thread_index) } static void +blob_put_compressed(struct disk_cache *cache, const cache_key key, + const void *data, size_t size); + +static void cache_put(void *job, void *gdata, int thread_index) { assert(job); @@ -435,7 +439,9 @@ cache_put(void *job, void *gdata, int thread_index) char *filename = NULL; struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job; - if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) { + if (dc_job->cache->blob_put_cb) { + blob_put_compressed(dc_job->cache, dc_job->key, dc_job->data, dc_job->size); + } else if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) { disk_cache_write_item_to_disk_foz(dc_job); } else if (dc_job->cache->type == DISK_CACHE_DATABASE) { disk_cache_db_write_item_to_disk(dc_job); @@ -546,11 +552,6 @@ disk_cache_put(struct disk_cache *cache, const cache_key key, const void *data, size_t size, struct cache_item_metadata *cache_item_metadata) { - if (cache->blob_put_cb) { - blob_put_compressed(cache, key, data, size); - return; - } - if (!util_queue_is_initialized(&cache->cache_queue)) return; @@ -569,12 +570,6 @@ disk_cache_put_nocopy(struct disk_cache *cache, const cache_key key, void *data, size_t size, struct cache_item_metadata *cache_item_metadata) { - if (cache->blob_put_cb) { - blob_put_compressed(cache, key, data, size); - free(data); - return; - } - if (!util_queue_is_initialized(&cache->cache_queue)) { free(data); return; @@ -691,6 +686,7 @@ disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_put_cb put, { cache->blob_put_cb = put; cache->blob_get_cb = get; + disk_cache_init_queue(cache); } #endif /* ENABLE_SHADER_CACHE */