Module: Mesa
Branch: main
Commit: c199a5160a08b118df6ba6d3bb211f5e2debcf83
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c199a5160a08b118df6ba6d3bb211f5e2debcf83

Author: Samuel Pitoiset <[email protected]>
Date:   Fri Sep  9 16:55:23 2022 +0200

radv: bind the VS input state for prologs created with GPL

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 <[email protected]>
Reviewed-by: Timur Kristóf <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18519>

---

 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)

Reply via email to