radv: bind the VS input state for prologs created with GPL
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 9 Sep 2022 14:55:23 +0000 (16:55 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Sep 2022 08:22:16 +0000 (08:22 +0000)
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 <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18519>

src/amd/vulkan/radv_cmd_buffer.c

index 4abcbb8..3993cf4 100644 (file)
@@ -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)