If the secondary buffers don't use any descriptors we don't
have to re-emit the ones from the primary command buffer.

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 22637950c4..69ca16b52d 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -2615,6 +2615,29 @@ void radv_CmdSetStencilReference(
        cmd_buffer->state.dirty |= RADV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE;
 }
 
+static bool
+radv_cmd_buffer_has_descriptors(struct radv_cmd_buffer *cmd_buffer)
+{
+       struct radv_cmd_state *state = &cmd_buffer->state;
+       int i;
+
+       for (i = 0; i < MAX_SETS; i++) {
+               if (cmd_buffer->state.descriptors[i])
+                       return true;
+       }
+
+       if ((state->pipeline &&
+            state->pipeline->need_indirect_descriptor_sets) ||
+           (state->compute_pipeline &&
+            state->compute_pipeline->need_indirect_descriptor_sets))
+               return true;
+
+       if (cmd_buffer->push_descriptors.capacity > 0)
+               return true;
+
+       return false;
+}
+
 void radv_CmdExecuteCommands(
        VkCommandBuffer                             commandBuffer,
        uint32_t                                    commandBufferCount,
@@ -2675,6 +2698,11 @@ void radv_CmdExecuteCommands(
                                secondary->state.last_primitive_reset_en;
                }
 
+               /* Only re-emit all descriptors when needed. */
+               if (radv_cmd_buffer_has_descriptors(secondary)) {
+                       radv_mark_descriptor_sets_dirty(primary);
+               }
+
                primary->state.last_primitive_reset_index = 
secondary->state.last_primitive_reset_index;
                primary->state.last_ia_multi_vgt_param = 
secondary->state.last_ia_multi_vgt_param;
        }
@@ -2684,7 +2712,6 @@ void radv_CmdExecuteCommands(
         */
        primary->state.dirty |= RADV_CMD_DIRTY_PIPELINE;
        primary->state.dirty |= RADV_CMD_DIRTY_DYNAMIC_ALL;
-       radv_mark_descriptor_sets_dirty(primary);
 }
 
 VkResult radv_CreateCommandPool(
-- 
2.14.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to