anv: don't lazy allocate surface states in descriptor sets

In 4001d9ce1a we started lazily allocating surface states in the
descriptor sets rather than upfront in the descriptor pool. This was
to workaround vkd3d-proton allocating more than we could handle at the
HW level.

The issue introduced in that change is that we didn't protect the
descriptor pool free list as well as the anv_state_stream which are
now potentially used from different threads through the descriptor set
write functions.

This reverts the lazy allocation part of that change. Host only
descriptor sets changes remain.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 4001d9ce1a ("anv: Handle VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE for descriptor sets")
Reviewed-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15241>
This commit is contained in:
Lionel Landwerlin 2022-03-08 16:56:50 +02:00 committed by Marge Bot
parent 71cd6a7b84
commit 87f59b18cf
1 changed files with 12 additions and 8 deletions

View File

@ -1230,9 +1230,11 @@ anv_descriptor_set_create(struct anv_device *device,
/* Allocate null surface state for the buffer views since
* we lazy allocate this in the write anyway.
*/
for (uint32_t b = 0; b < set->buffer_view_count; b++) {
set->buffer_views[b].surface_state = ANV_STATE_NULL;
set->buffer_views[b].range = 0;
if (pool->allocate_surface_states) {
for (uint32_t b = 0; b < set->buffer_view_count; b++) {
set->buffer_views[b].surface_state =
anv_descriptor_pool_alloc_state(pool);
}
}
list_addtail(&set->pool_link, &pool->desc_sets);
@ -1257,9 +1259,11 @@ anv_descriptor_set_destroy(struct anv_device *device,
anv_descriptor_pool_free_state(pool, set->desc_surface_state);
}
for (uint32_t b = 0; b < set->buffer_view_count; b++) {
if (set->buffer_views[b].surface_state.alloc_size)
anv_descriptor_pool_free_state(pool, set->buffer_views[b].surface_state);
if (pool->allocate_surface_states) {
for (uint32_t b = 0; b < set->buffer_view_count; b++) {
if (set->buffer_views[b].surface_state.alloc_size)
anv_descriptor_pool_free_state(pool, set->buffer_views[b].surface_state);
}
}
list_del(&set->pool_link);
@ -1637,10 +1641,10 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
* vkAllocateDescriptorSets. */
if (alloc_stream) {
bview->surface_state = anv_state_stream_alloc(alloc_stream, 64, 64);
} else if (bview->surface_state.alloc_size == 0) {
bview->surface_state = anv_descriptor_pool_alloc_state(set->pool);
}
assert(bview->surface_state.alloc_size);
isl_surf_usage_flags_t usage =
(type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ?