char code[0];
};
+static void
+radv_pipeline_cache_lock(struct radv_pipeline_cache *cache)
+{
+ if (cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT_EXT)
+ return;
+
+ pthread_mutex_lock(&cache->mutex);
+}
+
+static void
+radv_pipeline_cache_unlock(struct radv_pipeline_cache *cache)
+{
+ if (cache->flags & VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT_EXT)
+ return;
+
+ pthread_mutex_unlock(&cache->mutex);
+}
+
void
radv_pipeline_cache_init(struct radv_pipeline_cache *cache,
struct radv_device *device)
{
cache->device = device;
pthread_mutex_init(&cache->mutex, NULL);
+ cache->flags = 0;
cache->modified = false;
cache->kernel_count = 0;
{
struct cache_entry *entry;
- pthread_mutex_lock(&cache->mutex);
+ radv_pipeline_cache_lock(cache);
entry = radv_pipeline_cache_search_unlocked(cache, sha1);
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return entry;
}
*found_in_application_cache = false;
}
- pthread_mutex_lock(&cache->mutex);
+ radv_pipeline_cache_lock(cache);
entry = radv_pipeline_cache_search_unlocked(cache, sha1);
* present in the cache.
*/
if (radv_is_cache_disabled(device) || !device->physical_device->disk_cache) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return false;
}
}
if (!entry) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return false;
} else {
size_t size = entry_size(entry);
VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
if (!new_entry) {
free(entry);
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return false;
}
p_atomic_inc(&entry->variants[i]->ref_count);
}
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return true;
}
if (!cache)
cache = device->mem_cache;
- pthread_mutex_lock(&cache->mutex);
+ radv_pipeline_cache_lock(cache);
struct cache_entry *entry = radv_pipeline_cache_search_unlocked(cache, sha1);
if (entry) {
for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
if (variants[i])
p_atomic_inc(&variants[i]->ref_count);
}
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return;
}
* present in the cache.
*/
if (radv_is_cache_disabled(device)) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return;
}
entry = vk_alloc(&cache->alloc, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
if (!entry) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return;
}
if (device->instance->debug_flags & RADV_DEBUG_NO_MEMORY_CACHE &&
cache == device->mem_cache) {
vk_free2(&cache->alloc, NULL, entry);
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return;
}
radv_pipeline_cache_add_entry(cache, entry);
cache->modified = true;
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return;
}
cache->alloc = device->vk.alloc;
radv_pipeline_cache_init(cache, device);
+ cache->flags = pCreateInfo->flags;
if (pCreateInfo->initialDataSize > 0) {
radv_pipeline_cache_load(cache,
struct cache_header *header;
VkResult result = VK_SUCCESS;
- pthread_mutex_lock(&cache->mutex);
+ radv_pipeline_cache_lock(cache);
const size_t size = sizeof(*header) + cache->total_size;
if (pData == NULL) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
*pDataSize = size;
return VK_SUCCESS;
}
if (*pDataSize < sizeof(*header)) {
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
*pDataSize = 0;
return VK_INCOMPLETE;
}
}
*pDataSize = p - pData;
- pthread_mutex_unlock(&cache->mutex);
+ radv_pipeline_cache_unlock(cache);
return result;
}