Mesa (main): v3dv: remove deferred vkCmdClearAtachments path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 12 07:56:03 UTC 2021


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

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Thu Jul  8 13:35:34 2021 +0200

v3dv: remove deferred vkCmdClearAtachments path

This was required to handle the case of secondary command buffers that
did not have framebuffer information available from the primary, since
we used to have an implementation that required this information to
be available for the fallback path of vkCmdClearAttachments. Now that
we can handle our our attachment clears in the current subpass by
emitting draw calls, we no longer need the framebuffer information to
be available and we can remove this.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11783>

---

 src/broadcom/vulkan/v3dv_cmd_buffer.c  |  1 -
 src/broadcom/vulkan/v3dv_meta_clear.c  | 66 ----------------------------------
 src/broadcom/vulkan/v3dv_private.h     |  9 -----
 src/broadcom/vulkan/v3dvx_cmd_buffer.c | 13 -------
 4 files changed, 89 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c
index 42755a7923d..ed0f975a6ed 100644
--- a/src/broadcom/vulkan/v3dv_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c
@@ -1705,7 +1705,6 @@ cmd_buffer_execute_outside_pass(struct v3dv_cmd_buffer *primary,
       list_for_each_entry(struct v3dv_job, secondary_job,
                           &secondary->jobs, list_link) {
          /* These can only happen inside a render pass */
-         assert(secondary_job->type != V3DV_JOB_TYPE_CPU_CLEAR_ATTACHMENTS);
          assert(secondary_job->type != V3DV_JOB_TYPE_GPU_CL_SECONDARY);
          struct v3dv_job *job = v3dv_job_clone_in_cmd_buffer(secondary_job, primary);
          if (!job)
diff --git a/src/broadcom/vulkan/v3dv_meta_clear.c b/src/broadcom/vulkan/v3dv_meta_clear.c
index 9d6a39e074c..270314e5db3 100644
--- a/src/broadcom/vulkan/v3dv_meta_clear.c
+++ b/src/broadcom/vulkan/v3dv_meta_clear.c
@@ -1019,50 +1019,6 @@ emit_subpass_ds_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
    v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dynamic_states, false);
 }
 
-static void
-handle_deferred_clear_attachments(struct v3dv_cmd_buffer *cmd_buffer,
-                                  uint32_t attachmentCount,
-                                  const VkClearAttachment *pAttachments,
-                                  uint32_t rectCount,
-                                  const VkClearRect *pRects)
-{
-   /* Finish the current job */
-   v3dv_cmd_buffer_finish_job(cmd_buffer);
-
-   /* Add a deferred clear attachments job right after that we will process
-    * when we execute this secondary command buffer into a primary.
-    */
-   struct v3dv_job *job =
-      v3dv_cmd_buffer_create_cpu_job(cmd_buffer->device,
-                                     V3DV_JOB_TYPE_CPU_CLEAR_ATTACHMENTS,
-                                     cmd_buffer,
-                                     cmd_buffer->state.subpass_idx);
-   v3dv_return_if_oom(cmd_buffer, NULL);
-
-   job->cpu.clear_attachments.rects =
-      vk_alloc(&cmd_buffer->device->vk.alloc,
-               sizeof(VkClearRect) * rectCount, 8,
-               VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
-   if (!job->cpu.clear_attachments.rects) {
-      v3dv_flag_oom(cmd_buffer, NULL);
-      return;
-   }
-
-   job->cpu.clear_attachments.attachment_count = attachmentCount;
-   memcpy(job->cpu.clear_attachments.attachments, pAttachments,
-          sizeof(VkClearAttachment) * attachmentCount);
-
-   job->cpu.clear_attachments.rect_count = rectCount;
-   memcpy(job->cpu.clear_attachments.rects, pRects,
-          sizeof(VkClearRect) * rectCount);
-
-   list_addtail(&job->list_link, &cmd_buffer->jobs);
-
-   /* Resume the subpass so we can continue recording commands */
-   v3dv_cmd_buffer_subpass_resume(cmd_buffer,
-                                  cmd_buffer->state.subpass_idx);
-}
-
 static void
 gather_layering_info(uint32_t rect_count, const VkClearRect *rects,
                      bool *is_layered, bool *all_rects_same_layers)
@@ -1096,28 +1052,6 @@ v3dv_CmdClearAttachments(VkCommandBuffer commandBuffer,
    /* We can only clear attachments in the current subpass */
    assert(attachmentCount <= 5); /* 4 color + D/S */
 
-   /* For secondary command buffers the framebuffer state may not be available
-    * until they are executed inside a primary command buffer, so in that case
-    * we need to defer recording of the command until that moment.
-    *
-    * FIXME: once we add support for geometry shaders in the driver we could
-    * avoid emitting a job per layer to implement this by always using the clear
-    * rect path below with a passthrough geometry shader to select the layer to
-    * clear. If we did that we would not need to special case secondary command
-    * buffers here and we could ensure that any secondary command buffer in a
-    * render pass only has on job with a partial CL, which would simplify things
-    * quite a bit.
-    */
-   if (!cmd_buffer->state.framebuffer) {
-      assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY);
-      handle_deferred_clear_attachments(cmd_buffer,
-                                        attachmentCount, pAttachments,
-                                        rectCount, pRects);
-      return;
-   }
-
-   assert(cmd_buffer->state.framebuffer);
-
    struct v3dv_render_pass *pass = cmd_buffer->state.pass;
 
    assert(cmd_buffer->state.subpass_idx < pass->subpass_count);
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index e53a2f9f5a0..6032a28f976 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -850,7 +850,6 @@ enum v3dv_job_type {
    V3DV_JOB_TYPE_CPU_COPY_QUERY_RESULTS,
    V3DV_JOB_TYPE_CPU_SET_EVENT,
    V3DV_JOB_TYPE_CPU_WAIT_EVENTS,
-   V3DV_JOB_TYPE_CPU_CLEAR_ATTACHMENTS,
    V3DV_JOB_TYPE_CPU_COPY_BUFFER_TO_IMAGE,
    V3DV_JOB_TYPE_CPU_CSD_INDIRECT,
    V3DV_JOB_TYPE_CPU_TIMESTAMP_QUERY,
@@ -891,13 +890,6 @@ struct v3dv_event_wait_cpu_job_info {
    bool sem_wait;
 };
 
-struct v3dv_clear_attachments_cpu_job_info {
-   uint32_t attachment_count;
-   VkClearAttachment attachments[V3D_MAX_DRAW_BUFFERS + 1]; /* 4 color + D/S */
-   uint32_t rect_count;
-   VkClearRect *rects;
-};
-
 struct v3dv_copy_buffer_to_image_cpu_job_info {
    struct v3dv_image *image;
    struct v3dv_buffer *buffer;
@@ -1002,7 +994,6 @@ struct v3dv_job {
       struct v3dv_copy_query_results_cpu_job_info   query_copy_results;
       struct v3dv_event_set_cpu_job_info            event_set;
       struct v3dv_event_wait_cpu_job_info           event_wait;
-      struct v3dv_clear_attachments_cpu_job_info    clear_attachments;
       struct v3dv_copy_buffer_to_image_cpu_job_info copy_buffer_to_image;
       struct v3dv_csd_indirect_cpu_job_info         csd_indirect;
       struct v3dv_timestamp_query_cpu_job_info      query_timestamp;
diff --git a/src/broadcom/vulkan/v3dvx_cmd_buffer.c b/src/broadcom/vulkan/v3dvx_cmd_buffer.c
index 933f55b2737..b52e0327834 100644
--- a/src/broadcom/vulkan/v3dvx_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dvx_cmd_buffer.c
@@ -1597,19 +1597,6 @@ v3dX(cmd_buffer_execute_inside_pass)(struct v3dv_cmd_buffer *primary,
             }
 
             primary_job->tmu_dirty_rcl |= secondary_job->tmu_dirty_rcl;
-         } else if (secondary_job->type == V3DV_JOB_TYPE_CPU_CLEAR_ATTACHMENTS) {
-            if (pending_barrier) {
-               cmd_buffer_subpass_split_for_barrier(primary, pending_bcl_barrier);
-               v3dv_return_if_oom(primary, NULL);
-            }
-
-            const struct v3dv_clear_attachments_cpu_job_info *info =
-               &secondary_job->cpu.clear_attachments;
-            v3dv_CmdClearAttachments(v3dv_cmd_buffer_to_handle(primary),
-                                     info->attachment_count,
-                                     info->attachments,
-                                     info->rect_count,
-                                     info->rects);
          } else {
             /* This is a regular job (CPU or GPU), so just finish the current
              * primary job (if any) and then add the secondary job to the



More information about the mesa-commit mailing list