anv: Refactor descriptor pushing a bit
Pull the common code out of the two entrypoints into the helper which fetches the push descriptor set for us. Now that it does more than just get a thing, call it anv_cmd_buffer_push_descriptor_set. Cc: "19.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -957,10 +957,11 @@ anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer)
|
||||
return iview;
|
||||
}
|
||||
|
||||
static struct anv_push_descriptor_set *
|
||||
anv_cmd_buffer_get_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
||||
VkPipelineBindPoint bind_point,
|
||||
uint32_t set)
|
||||
static struct anv_descriptor_set *
|
||||
anv_cmd_buffer_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
||||
VkPipelineBindPoint bind_point,
|
||||
struct anv_descriptor_set_layout *layout,
|
||||
uint32_t _set)
|
||||
{
|
||||
struct anv_cmd_pipeline_state *pipe_state;
|
||||
if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) {
|
||||
@@ -971,7 +972,7 @@ anv_cmd_buffer_get_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
||||
}
|
||||
|
||||
struct anv_push_descriptor_set **push_set =
|
||||
&pipe_state->push_descriptors[set];
|
||||
&pipe_state->push_descriptors[_set];
|
||||
|
||||
if (*push_set == NULL) {
|
||||
*push_set = vk_alloc(&cmd_buffer->pool->alloc,
|
||||
@@ -983,7 +984,14 @@ anv_cmd_buffer_get_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
||||
}
|
||||
}
|
||||
|
||||
return *push_set;
|
||||
struct anv_descriptor_set *set = &(*push_set)->set;
|
||||
|
||||
set->layout = layout;
|
||||
set->size = anv_descriptor_set_layout_size(layout);
|
||||
set->buffer_view_count = layout->buffer_view_count;
|
||||
set->buffer_views = (*push_set)->buffer_views;
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
void anv_CmdPushDescriptorSetKHR(
|
||||
@@ -1001,19 +1009,12 @@ void anv_CmdPushDescriptorSetKHR(
|
||||
|
||||
struct anv_descriptor_set_layout *set_layout = layout->set[_set].layout;
|
||||
|
||||
struct anv_push_descriptor_set *push_set =
|
||||
anv_cmd_buffer_get_push_descriptor_set(cmd_buffer,
|
||||
pipelineBindPoint, _set);
|
||||
if (!push_set)
|
||||
struct anv_descriptor_set *set =
|
||||
anv_cmd_buffer_push_descriptor_set(cmd_buffer, pipelineBindPoint,
|
||||
set_layout, _set);
|
||||
if (!set)
|
||||
return;
|
||||
|
||||
struct anv_descriptor_set *set = &push_set->set;
|
||||
|
||||
set->layout = set_layout;
|
||||
set->size = anv_descriptor_set_layout_size(set_layout);
|
||||
set->buffer_view_count = set_layout->buffer_view_count;
|
||||
set->buffer_views = push_set->buffer_views;
|
||||
|
||||
/* Go through the user supplied descriptors. */
|
||||
for (uint32_t i = 0; i < descriptorWriteCount; i++) {
|
||||
const VkWriteDescriptorSet *write = &pDescriptorWrites[i];
|
||||
@@ -1092,19 +1093,12 @@ void anv_CmdPushDescriptorSetWithTemplateKHR(
|
||||
|
||||
struct anv_descriptor_set_layout *set_layout = layout->set[_set].layout;
|
||||
|
||||
struct anv_push_descriptor_set *push_set =
|
||||
anv_cmd_buffer_get_push_descriptor_set(cmd_buffer,
|
||||
template->bind_point, _set);
|
||||
if (!push_set)
|
||||
struct anv_descriptor_set *set =
|
||||
anv_cmd_buffer_push_descriptor_set(cmd_buffer, template->bind_point,
|
||||
set_layout, _set);
|
||||
if (!set)
|
||||
return;
|
||||
|
||||
struct anv_descriptor_set *set = &push_set->set;
|
||||
|
||||
set->layout = set_layout;
|
||||
set->size = anv_descriptor_set_layout_size(set_layout);
|
||||
set->buffer_view_count = set_layout->buffer_view_count;
|
||||
set->buffer_views = push_set->buffer_views;
|
||||
|
||||
anv_descriptor_set_write_template(cmd_buffer->device, set,
|
||||
&cmd_buffer->surface_state_stream,
|
||||
template,
|
||||
|
Reference in New Issue
Block a user