anv: support alternative push descriptor sets

Do not assume anv_cmd_pipeline_state::push_descriptor is the currently
bound push descriptor set.  With this and anv_push_descriptor_set_init,
it is possible to initialize a temporary push descriptor set on stack
for internal use.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25467>
This commit is contained in:
Chia-I Wu 2023-10-09 16:43:36 -07:00 committed by Marge Bot
parent a86a4e5fcf
commit 7a4903626b
3 changed files with 22 additions and 13 deletions

View file

@ -845,6 +845,7 @@ anv_pipeline_sets_layout_init(struct anv_pipeline_sets_layout *layout,
memset(layout, 0, sizeof(*layout));
layout->device = device;
layout->push_descriptor_set_index = -1;
layout->independent_sets = independent_sets;
}
@ -874,6 +875,12 @@ anv_pipeline_sets_layout_add(struct anv_pipeline_sets_layout *layout,
layout->num_dynamic_buffers += set_layout->dynamic_offset_count;
assert(layout->num_dynamic_buffers < MAX_DYNAMIC_BUFFERS);
if (set_layout->flags &
VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) {
assert(layout->push_descriptor_set_index == -1);
layout->push_descriptor_set_index = set_idx;
}
}
void

View file

@ -2574,6 +2574,7 @@ struct anv_pipeline_sets_layout {
uint32_t num_sets;
uint32_t num_dynamic_buffers;
int push_descriptor_set_index;
bool independent_sets;

View file

@ -2444,25 +2444,26 @@ flush_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
struct anv_cmd_pipeline_state *state,
struct anv_pipeline *pipeline)
{
struct anv_descriptor_set *set = &state->push_descriptor.set;
struct anv_descriptor_set_layout *layout = set->layout;
assert(pipeline->use_push_descriptor &&
pipeline->layout.push_descriptor_set_index != -1);
if (pipeline->use_push_descriptor) {
while (set->generate_surface_states) {
int desc_idx = u_bit_scan(&set->generate_surface_states);
struct anv_descriptor *desc = &set->descriptors[desc_idx];
struct anv_buffer_view *bview = desc->set_buffer_view;
struct anv_descriptor_set *set =
state->descriptors[pipeline->layout.push_descriptor_set_index];
while (set->generate_surface_states) {
int desc_idx = u_bit_scan(&set->generate_surface_states);
struct anv_descriptor *desc = &set->descriptors[desc_idx];
struct anv_buffer_view *bview = desc->set_buffer_view;
if (bview != NULL) {
bview->general.state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
anv_descriptor_write_surface_state(cmd_buffer->device, desc,
bview->general.state);
}
if (bview != NULL) {
bview->general.state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
anv_descriptor_write_surface_state(cmd_buffer->device, desc,
bview->general.state);
}
}
if (pipeline->use_push_descriptor_buffer) {
struct anv_descriptor_set_layout *layout = set->layout;
enum isl_format format =
anv_isl_format_for_descriptor_type(cmd_buffer->device,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);