v3dv: flush at the end of each subpass
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 3 Jan 2020 10:27:01 +0000 (11:27 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:26 +0000 (21:21 +0000)
We can't start a new BCL if we haven't flushed the current one, so
make sure we do that at the end of each subpass for now.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_cmd_buffer.c

index c0a1377..10a7cba 100644 (file)
@@ -879,7 +879,7 @@ emit_rcl(struct v3dv_cmd_buffer *cmd_buffer)
 }
 
 static void
-setup_subpass(struct v3dv_cmd_buffer *cmd_buffer)
+subpass_start(struct v3dv_cmd_buffer *cmd_buffer)
 {
    const struct v3dv_cmd_buffer_state *state = &cmd_buffer->state;
 
@@ -920,10 +920,25 @@ setup_subpass(struct v3dv_cmd_buffer *cmd_buffer)
 }
 
 static void
+subpass_finish(struct v3dv_cmd_buffer *cmd_buffer)
+{
+   v3dv_cl_ensure_space_with_branch(&cmd_buffer->bcl, cl_packet_length(FLUSH));
+
+   /* We need to emit a flush between binning jobs, so do this before we start
+    * recording the next subpass.
+    *
+    * FIXME: if the next subpass draws to the same RTs, we could skip this
+    * and the binning setup for the next subpass.
+    */
+   cl_emit(&cmd_buffer->bcl, FLUSH, flush);
+}
+
+static void
 execute_subpass(struct v3dv_cmd_buffer *cmd_buffer)
 {
-   setup_subpass(cmd_buffer);
+   subpass_start(cmd_buffer);
    emit_rcl(cmd_buffer);
+   subpass_finish(cmd_buffer);
 }
 
 void
@@ -949,15 +964,6 @@ v3dv_EndCommandBuffer(VkCommandBuffer commandBuffer)
    if (v3dv_cl_offset(&cmd_buffer->bcl) == 0)
       return VK_SUCCESS; /* FIXME? */
 
-   v3dv_cl_ensure_space_with_branch(&cmd_buffer->bcl, cl_packet_length(FLUSH));
-
-   /* We just FLUSH here to tell the HW to cap the bin CLs with a
-    * return. Any remaining state changes won't be flushed to
-    * the bins first -- you would need FLUSH_ALL for that, but
-    * the HW for it hasn't been validated.
-    */
-   cl_emit(&cmd_buffer->bcl, FLUSH, flush);
-
    cmd_buffer->status = V3DV_CMD_BUFFER_STATUS_EXECUTABLE;
 
    return VK_SUCCESS;