From c199a5160a08b118df6ba6d3bb211f5e2debcf83 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 9 Sep 2022 16:55:23 +0200 Subject: [PATCH] radv: bind the VS input state for prologs created with GPL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we have a VS that needs a prolog without using the dynamic state, that means that it comes from a library, so we can overwrite the cmdbuf VS input state. Signed-off-by: Samuel Pitoiset Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 4abcbb8daf6..3993cf4e945 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5082,6 +5082,27 @@ radv_mark_descriptor_sets_dirty(struct radv_cmd_buffer *cmd_buffer, VkPipelineBi descriptors_state->dirty |= descriptors_state->valid; } +static void +radv_bind_vs_input_state(struct radv_cmd_buffer *cmd_buffer, + const struct radv_graphics_pipeline *pipeline) +{ + const struct radv_shader *vs_shader = radv_get_shader(&pipeline->base, MESA_SHADER_VERTEX); + const struct radv_vs_input_state *src = &pipeline->vs_input_state; + + /* Bind the vertex input state from the pipeline when the VS has a prolog and the state isn't + * dynamic. This can happen when the pre-rasterization stages and the vertex input state are from + * two different libraries. Otherwise, if the VS has a prolog, the state is dynamic and there is + * nothing to bind. + */ + if (!vs_shader || !vs_shader->info.vs.has_prolog || + (pipeline->dynamic_states & RADV_DYNAMIC_VERTEX_INPUT)) + return; + + cmd_buffer->state.dynamic_vs_input = *src; + + cmd_buffer->state.dirty |= RADV_CMD_DIRTY_DYNAMIC_VERTEX_INPUT; +} + VKAPI_ATTR void VKAPI_CALL radv_CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline _pipeline) @@ -5178,6 +5199,8 @@ radv_CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipeline radv_bind_dynamic_state(cmd_buffer, &graphics_pipeline->dynamic_state); + radv_bind_vs_input_state(cmd_buffer, graphics_pipeline); + if (graphics_pipeline->esgs_ring_size > cmd_buffer->esgs_ring_size_needed) cmd_buffer->esgs_ring_size_needed = graphics_pipeline->esgs_ring_size; if (graphics_pipeline->gsvs_ring_size > cmd_buffer->gsvs_ring_size_needed)