mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
anv: simplify TRTT initialization
Drop usage of pthread mutex so initialization never fails. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Reviewed-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28975>
This commit is contained in:
parent
b754ad8f15
commit
8c7e1052a3
4 changed files with 14 additions and 20 deletions
|
|
@ -3246,17 +3246,14 @@ anv_device_destroy_context_or_vm(struct anv_device *device)
|
|||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
static void
|
||||
anv_device_init_trtt(struct anv_device *device)
|
||||
{
|
||||
struct anv_trtt *trtt = &device->trtt;
|
||||
|
||||
if (pthread_mutex_init(&trtt->mutex, NULL) != 0)
|
||||
return vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
|
||||
simple_mtx_init(&trtt->mutex, mtx_plain);
|
||||
|
||||
list_inithead(&trtt->in_flight_batches);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3290,7 +3287,7 @@ anv_device_finish_trtt(struct anv_device *device)
|
|||
fprintf(stderr, "TR-TT syncobj destroy failed!\n");
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&trtt->mutex);
|
||||
simple_mtx_destroy(&trtt->mutex);
|
||||
|
||||
vk_free(&device->vk.alloc, trtt->l3_mirror);
|
||||
vk_free(&device->vk.alloc, trtt->l2_mirror);
|
||||
|
|
@ -3849,16 +3846,12 @@ VkResult anv_CreateDevice(
|
|||
goto fail_trivial_batch_bo_and_scratch_pool;
|
||||
}
|
||||
|
||||
result = anv_device_init_trtt(device);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_btd_fifo_bo;
|
||||
|
||||
struct vk_pipeline_cache_create_info pcc_info = { .weak_ref = true, };
|
||||
device->vk.mem_cache =
|
||||
vk_pipeline_cache_create(&device->vk, &pcc_info, NULL);
|
||||
if (!device->vk.mem_cache) {
|
||||
result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
goto fail_trtt;
|
||||
goto fail_btd_fifo_bo;
|
||||
}
|
||||
|
||||
/* Internal shaders need their own pipeline cache because, unlike the rest
|
||||
|
|
@ -3936,6 +3929,8 @@ VkResult anv_CreateDevice(
|
|||
|
||||
anv_device_init_embedded_samplers(device);
|
||||
|
||||
anv_device_init_trtt(device);
|
||||
|
||||
BITSET_ONES(device->gfx_dirty_state);
|
||||
BITSET_CLEAR(device->gfx_dirty_state, ANV_GFX_STATE_INDEX_BUFFER);
|
||||
BITSET_CLEAR(device->gfx_dirty_state, ANV_GFX_STATE_SO_DECL_LIST);
|
||||
|
|
@ -3975,6 +3970,7 @@ VkResult anv_CreateDevice(
|
|||
return VK_SUCCESS;
|
||||
|
||||
fail_companion_cmd_pool:
|
||||
anv_device_finish_trtt(device);
|
||||
anv_device_finish_embedded_samplers(device);
|
||||
anv_device_utrace_finish(device);
|
||||
anv_device_finish_blorp(device);
|
||||
|
|
@ -3993,8 +3989,6 @@ VkResult anv_CreateDevice(
|
|||
vk_pipeline_cache_destroy(device->internal_cache, NULL);
|
||||
fail_default_pipeline_cache:
|
||||
vk_pipeline_cache_destroy(device->vk.mem_cache, NULL);
|
||||
fail_trtt:
|
||||
anv_device_finish_trtt(device);
|
||||
fail_btd_fifo_bo:
|
||||
if (ANV_SUPPORT_RT && device->info->has_ray_tracing)
|
||||
anv_device_release_bo(device, device->btd_fifo_bo);
|
||||
|
|
@ -4095,6 +4089,8 @@ void anv_DestroyDevice(
|
|||
|
||||
struct anv_physical_device *pdevice = device->physical;
|
||||
|
||||
anv_device_finish_trtt(device);
|
||||
|
||||
for (uint32_t i = 0; i < device->queue_count; i++)
|
||||
anv_queue_finish(&device->queues[i]);
|
||||
vk_free(&device->vk.alloc, device->queues);
|
||||
|
|
@ -4117,8 +4113,6 @@ void anv_DestroyDevice(
|
|||
|
||||
anv_device_finish_embedded_samplers(device);
|
||||
|
||||
anv_device_finish_trtt(device);
|
||||
|
||||
if (ANV_SUPPORT_RT && device->info->has_ray_tracing)
|
||||
anv_device_release_bo(device, device->btd_fifo_bo);
|
||||
|
||||
|
|
|
|||
|
|
@ -1996,7 +1996,7 @@ struct anv_device {
|
|||
VkCommandPool companion_rcs_cmd_pool;
|
||||
|
||||
struct anv_trtt {
|
||||
pthread_mutex_t mutex;
|
||||
simple_mtx_t mutex;
|
||||
|
||||
/* Sometimes we need to run batches from places where we don't have a
|
||||
* queue coming from the API, so we use this.
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ anv_sparse_bind_trtt(struct anv_device *device,
|
|||
.l1_binds_len = 0,
|
||||
};
|
||||
|
||||
pthread_mutex_lock(&trtt->mutex);
|
||||
simple_mtx_lock(&trtt->mutex);
|
||||
|
||||
if (!trtt->l3_addr)
|
||||
anv_trtt_init_context_state(sparse_submit->queue);
|
||||
|
|
@ -608,7 +608,7 @@ anv_sparse_bind_trtt(struct anv_device *device,
|
|||
ANV_RMV(vm_binds, device, sparse_submit->binds, sparse_submit->binds_len);
|
||||
|
||||
out:
|
||||
pthread_mutex_unlock(&trtt->mutex);
|
||||
simple_mtx_unlock(&trtt->mutex);
|
||||
STACK_ARRAY_FINISH(l1_binds);
|
||||
STACK_ARRAY_FINISH(l3l2_binds);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ anv_execbuf_add_trtt_bos(struct anv_device *device,
|
|||
if (!trtt->l3_addr)
|
||||
return VK_SUCCESS;
|
||||
|
||||
pthread_mutex_lock(&trtt->mutex);
|
||||
simple_mtx_lock(&trtt->mutex);
|
||||
|
||||
for (int i = 0; i < trtt->num_page_table_bos; i++) {
|
||||
result = anv_execbuf_add_bo(device, execbuf, trtt->page_table_bos[i],
|
||||
|
|
@ -357,7 +357,7 @@ anv_execbuf_add_trtt_bos(struct anv_device *device,
|
|||
}
|
||||
|
||||
out:
|
||||
pthread_mutex_unlock(&trtt->mutex);
|
||||
simple_mtx_unlock(&trtt->mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue