• Home
  • Raw
  • Download

Lines Matching full:cache

48 radv_pipeline_cache_lock(struct radv_pipeline_cache *cache)  in radv_pipeline_cache_lock()  argument
50 if (cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT) in radv_pipeline_cache_lock()
53 mtx_lock(&cache->mutex); in radv_pipeline_cache_lock()
57 radv_pipeline_cache_unlock(struct radv_pipeline_cache *cache) in radv_pipeline_cache_unlock() argument
59 if (cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT) in radv_pipeline_cache_unlock()
62 mtx_unlock(&cache->mutex); in radv_pipeline_cache_unlock()
76 radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device *device) in radv_pipeline_cache_init() argument
78 vk_object_base_init(&device->vk, &cache->base, VK_OBJECT_TYPE_PIPELINE_CACHE); in radv_pipeline_cache_init()
80 cache->device = device; in radv_pipeline_cache_init()
81 mtx_init(&cache->mutex, mtx_plain); in radv_pipeline_cache_init()
82 cache->flags = 0; in radv_pipeline_cache_init()
84 cache->modified = false; in radv_pipeline_cache_init()
85 cache->kernel_count = 0; in radv_pipeline_cache_init()
86 cache->total_size = 0; in radv_pipeline_cache_init()
87 cache->table_size = 1024; in radv_pipeline_cache_init()
88 const size_t byte_size = cache->table_size * sizeof(cache->hash_table[0]); in radv_pipeline_cache_init()
89 cache->hash_table = malloc(byte_size); in radv_pipeline_cache_init()
92 * cache. Disable caching when we want to keep shader debug info, since in radv_pipeline_cache_init()
94 if (cache->hash_table == NULL || radv_is_cache_disabled(device)) in radv_pipeline_cache_init()
95 cache->table_size = 0; in radv_pipeline_cache_init()
97 memset(cache->hash_table, 0, byte_size); in radv_pipeline_cache_init()
101 radv_pipeline_cache_finish(struct radv_pipeline_cache *cache) in radv_pipeline_cache_finish() argument
103 for (unsigned i = 0; i < cache->table_size; ++i) in radv_pipeline_cache_finish()
104 if (cache->hash_table[i]) { in radv_pipeline_cache_finish()
106 if (cache->hash_table[i]->shaders[j]) in radv_pipeline_cache_finish()
107 radv_shader_destroy(cache->device, cache->hash_table[i]->shaders[j]); in radv_pipeline_cache_finish()
109 if (cache->hash_table[i]->slab) in radv_pipeline_cache_finish()
110 radv_pipeline_slab_destroy(cache->device, cache->hash_table[i]->slab); in radv_pipeline_cache_finish()
111 vk_free(&cache->alloc, cache->hash_table[i]); in radv_pipeline_cache_finish()
113 mtx_destroy(&cache->mutex); in radv_pipeline_cache_finish()
114 free(cache->hash_table); in radv_pipeline_cache_finish()
116 vk_object_base_finish(&cache->base); in radv_pipeline_cache_finish()
209 radv_pipeline_cache_search_unlocked(struct radv_pipeline_cache *cache, const unsigned char *sha1) in radv_pipeline_cache_search_unlocked() argument
211 const uint32_t mask = cache->table_size - 1; in radv_pipeline_cache_search_unlocked()
214 if (cache->table_size == 0) in radv_pipeline_cache_search_unlocked()
217 for (uint32_t i = 0; i < cache->table_size; i++) { in radv_pipeline_cache_search_unlocked()
219 struct cache_entry *entry = cache->hash_table[index]; in radv_pipeline_cache_search_unlocked()
233 radv_pipeline_cache_search(struct radv_pipeline_cache *cache, const unsigned char *sha1) in radv_pipeline_cache_search() argument
237 radv_pipeline_cache_lock(cache); in radv_pipeline_cache_search()
239 entry = radv_pipeline_cache_search_unlocked(cache, sha1); in radv_pipeline_cache_search()
241 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_search()
247 radv_pipeline_cache_set_entry(struct radv_pipeline_cache *cache, struct cache_entry *entry) in radv_pipeline_cache_set_entry() argument
249 const uint32_t mask = cache->table_size - 1; in radv_pipeline_cache_set_entry()
253 assert(cache->kernel_count < cache->table_size / 2); in radv_pipeline_cache_set_entry()
255 for (uint32_t i = 0; i < cache->table_size; i++) { in radv_pipeline_cache_set_entry()
257 if (!cache->hash_table[index]) { in radv_pipeline_cache_set_entry()
258 cache->hash_table[index] = entry; in radv_pipeline_cache_set_entry()
263 cache->total_size += entry_size(entry); in radv_pipeline_cache_set_entry()
264 cache->kernel_count++; in radv_pipeline_cache_set_entry()
268 radv_pipeline_cache_grow(struct radv_pipeline_cache *cache) in radv_pipeline_cache_grow() argument
270 const uint32_t table_size = cache->table_size * 2; in radv_pipeline_cache_grow()
271 const uint32_t old_table_size = cache->table_size; in radv_pipeline_cache_grow()
272 const size_t byte_size = table_size * sizeof(cache->hash_table[0]); in radv_pipeline_cache_grow()
274 struct cache_entry **old_table = cache->hash_table; in radv_pipeline_cache_grow()
278 return vk_error(cache, VK_ERROR_OUT_OF_HOST_MEMORY); in radv_pipeline_cache_grow()
280 cache->hash_table = table; in radv_pipeline_cache_grow()
281 cache->table_size = table_size; in radv_pipeline_cache_grow()
282 cache->kernel_count = 0; in radv_pipeline_cache_grow()
283 cache->total_size = 0; in radv_pipeline_cache_grow()
285 memset(cache->hash_table, 0, byte_size); in radv_pipeline_cache_grow()
291 radv_pipeline_cache_set_entry(cache, entry); in radv_pipeline_cache_grow()
300 radv_pipeline_cache_add_entry(struct radv_pipeline_cache *cache, struct cache_entry *entry) in radv_pipeline_cache_add_entry() argument
302 if (cache->kernel_count == cache->table_size / 2) in radv_pipeline_cache_add_entry()
303 radv_pipeline_cache_grow(cache); in radv_pipeline_cache_add_entry()
308 if (cache->kernel_count < cache->table_size / 2) in radv_pipeline_cache_add_entry()
309 radv_pipeline_cache_set_entry(cache, entry); in radv_pipeline_cache_add_entry()
314 struct radv_device *device, struct radv_pipeline_cache *cache, const unsigned char *sha1, in radv_create_shaders_from_pipeline_cache() argument
321 if (!cache) { in radv_create_shaders_from_pipeline_cache()
322 cache = device->mem_cache; in radv_create_shaders_from_pipeline_cache()
326 radv_pipeline_cache_lock(cache); in radv_create_shaders_from_pipeline_cache()
328 entry = radv_pipeline_cache_search_unlocked(cache, sha1); in radv_create_shaders_from_pipeline_cache()
333 /* Don't cache when we want debug info, since this isn't in radv_create_shaders_from_pipeline_cache()
334 * present in the cache. in radv_create_shaders_from_pipeline_cache()
337 radv_pipeline_cache_unlock(cache); in radv_create_shaders_from_pipeline_cache()
347 radv_pipeline_cache_unlock(cache); in radv_create_shaders_from_pipeline_cache()
352 vk_alloc(&cache->alloc, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE); in radv_create_shaders_from_pipeline_cache()
355 radv_pipeline_cache_unlock(cache); in radv_create_shaders_from_pipeline_cache()
364 cache != device->mem_cache) in radv_create_shaders_from_pipeline_cache()
365 radv_pipeline_cache_add_entry(cache, new_entry); in radv_create_shaders_from_pipeline_cache()
392 /* For the GS copy shader, RADV uses the compute shader slot to avoid a new cache entry. */ in radv_create_shaders_from_pipeline_cache()
408 radv_pipeline_cache_unlock(cache); in radv_create_shaders_from_pipeline_cache()
430 if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE && cache == device->mem_cache) in radv_create_shaders_from_pipeline_cache()
431 vk_free(&cache->alloc, entry); in radv_create_shaders_from_pipeline_cache()
440 radv_pipeline_cache_unlock(cache); in radv_create_shaders_from_pipeline_cache()
445 radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipeline_cache *cache, in radv_pipeline_cache_insert_shaders() argument
451 if (!cache) in radv_pipeline_cache_insert_shaders()
452 cache = device->mem_cache; in radv_pipeline_cache_insert_shaders()
454 radv_pipeline_cache_lock(cache); in radv_pipeline_cache_insert_shaders()
455 struct cache_entry *entry = radv_pipeline_cache_search_unlocked(cache, sha1); in radv_pipeline_cache_insert_shaders()
461 radv_shader_destroy(cache->device, pipeline->shaders[i]); in radv_pipeline_cache_insert_shaders()
467 radv_pipeline_slab_destroy(cache->device, pipeline->slab); in radv_pipeline_cache_insert_shaders()
472 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_insert_shaders()
476 /* Don't cache when we want debug info, since this isn't in radv_pipeline_cache_insert_shaders()
477 * present in the cache. in radv_pipeline_cache_insert_shaders()
480 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_insert_shaders()
491 entry = vk_alloc(&cache->alloc, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE); in radv_pipeline_cache_insert_shaders()
493 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_insert_shaders()
523 /* Always add cache items to disk. This will allow collection of in radv_pipeline_cache_insert_shaders()
525 * implements its own pipeline cache. in radv_pipeline_cache_insert_shaders()
527 * Make sure to exclude meta shaders because they are stored in a different cache file. in radv_pipeline_cache_insert_shaders()
529 if (device->physical_device->disk_cache && cache != &device->meta_state.cache) { in radv_pipeline_cache_insert_shaders()
537 if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE && cache == device->mem_cache) { in radv_pipeline_cache_insert_shaders()
538 vk_free2(&cache->alloc, NULL, entry); in radv_pipeline_cache_insert_shaders()
539 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_insert_shaders()
543 /* We delay setting the shader so we have reproducible disk cache in radv_pipeline_cache_insert_shaders()
557 radv_pipeline_cache_add_entry(cache, entry); in radv_pipeline_cache_insert_shaders()
559 cache->modified = true; in radv_pipeline_cache_insert_shaders()
560 radv_pipeline_cache_unlock(cache); in radv_pipeline_cache_insert_shaders()
565 radv_pipeline_cache_load(struct radv_pipeline_cache *cache, const void *data, size_t size) in radv_pipeline_cache_load() argument
567 struct radv_device *device = cache->device; in radv_pipeline_cache_load()
594 dest_entry = vk_alloc(&cache->alloc, size_of_entry, 8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE); in radv_pipeline_cache_load()
600 radv_pipeline_cache_add_entry(cache, dest_entry); in radv_pipeline_cache_load()
613 struct radv_pipeline_cache *cache; in radv_CreatePipelineCache() local
617 cache = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*cache), 8, in radv_CreatePipelineCache()
619 if (cache == NULL) in radv_CreatePipelineCache()
623 cache->alloc = *pAllocator; in radv_CreatePipelineCache()
625 cache->alloc = device->vk.alloc; in radv_CreatePipelineCache()
627 radv_pipeline_cache_init(cache, device); in radv_CreatePipelineCache()
628 cache->flags = pCreateInfo->flags; in radv_CreatePipelineCache()
631 radv_pipeline_cache_load(cache, pCreateInfo->pInitialData, pCreateInfo->initialDataSize); in radv_CreatePipelineCache()
634 *pPipelineCache = radv_pipeline_cache_to_handle(cache); in radv_CreatePipelineCache()
644 RADV_FROM_HANDLE(radv_pipeline_cache, cache, _cache); in radv_DestroyPipelineCache()
646 if (!cache) in radv_DestroyPipelineCache()
649 radv_pipeline_cache_finish(cache); in radv_DestroyPipelineCache()
650 vk_free2(&device->vk.alloc, pAllocator, cache); in radv_DestroyPipelineCache()
657 RADV_FROM_HANDLE(radv_pipeline_cache, cache, _cache); in radv_GetPipelineCacheData()
661 radv_pipeline_cache_lock(cache); in radv_GetPipelineCacheData()
663 const size_t size = sizeof(*header) + cache->total_size; in radv_GetPipelineCacheData()
665 radv_pipeline_cache_unlock(cache); in radv_GetPipelineCacheData()
670 radv_pipeline_cache_unlock(cache); in radv_GetPipelineCacheData()
684 for (uint32_t i = 0; i < cache->table_size; i++) { in radv_GetPipelineCacheData()
685 if (!cache->hash_table[i]) in radv_GetPipelineCacheData()
687 entry = cache->hash_table[i]; in radv_GetPipelineCacheData()
702 radv_pipeline_cache_unlock(cache); in radv_GetPipelineCacheData()