static void
radv_bo_list_init(struct radv_bo_list *bo_list)
{
- pthread_mutex_init(&bo_list->mutex, NULL);
+ pthread_rwlock_init(&bo_list->rwlock, NULL);
bo_list->list.count = bo_list->capacity = 0;
bo_list->list.bos = NULL;
}
radv_bo_list_finish(struct radv_bo_list *bo_list)
{
free(bo_list->list.bos);
- pthread_mutex_destroy(&bo_list->mutex);
+ pthread_rwlock_destroy(&bo_list->rwlock);
}
VkResult radv_bo_list_add(struct radv_device *device,
if (unlikely(!device->use_global_bo_list))
return VK_SUCCESS;
- pthread_mutex_lock(&bo_list->mutex);
+ pthread_rwlock_wrlock(&bo_list->rwlock);
if (bo_list->list.count == bo_list->capacity) {
unsigned capacity = MAX2(4, bo_list->capacity * 2);
void *data = realloc(bo_list->list.bos, capacity * sizeof(struct radeon_winsys_bo*));
if (!data) {
- pthread_mutex_unlock(&bo_list->mutex);
+ pthread_rwlock_unlock(&bo_list->rwlock);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
}
bo_list->list.bos[bo_list->list.count++] = bo;
- pthread_mutex_unlock(&bo_list->mutex);
+ pthread_rwlock_unlock(&bo_list->rwlock);
return VK_SUCCESS;
}
if (unlikely(!device->use_global_bo_list))
return;
- pthread_mutex_lock(&bo_list->mutex);
+ pthread_rwlock_wrlock(&bo_list->rwlock);
/* Loop the list backwards so we find the most recently added
* memory first. */
for(unsigned i = bo_list->list.count; i-- > 0;) {
break;
}
}
- pthread_mutex_unlock(&bo_list->mutex);
+ pthread_rwlock_unlock(&bo_list->rwlock);
}
static void
sem_info.cs_emit_signal = j + advance == submission->cmd_buffer_count;
if (unlikely(queue->device->use_global_bo_list)) {
- pthread_mutex_lock(&queue->device->bo_list.mutex);
+ pthread_rwlock_rdlock(&queue->device->bo_list.rwlock);
bo_list = &queue->device->bo_list.list;
}
can_patch, base_fence);
if (unlikely(queue->device->use_global_bo_list))
- pthread_mutex_unlock(&queue->device->bo_list.mutex);
+ pthread_rwlock_unlock(&queue->device->bo_list.rwlock);
if (result != VK_SUCCESS)
goto fail;