Module: Mesa Branch: staging/23.0 Commit: 1d82337a2ba8a998b4c26bed7a6cedec604f1957 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d82337a2ba8a998b4c26bed7a6cedec604f1957
Author: Iago Toral Quiroga <[email protected]> Date: Tue Feb 7 13:06:48 2023 +0100 v3dv: ensure we apply binning syncs to secondary command buffers Currently, we postpone binning syncs until we record draw calls and can validate if any of them require accessing protected resources in the binning stage, however, if the draw calls are recorded in a secondary command buffer and the barriers have been recorded in the primary command buffer, we won't apply the binning sync in the secondary when we record the draw calls and so we must apply it when we execute the secondary in the primary. Fixes flakyness in: dEQP-VK.api.command_buffers.record_many_draws_secondary_2 cc: mesa-stable Reviewed-by: Alejandro PiƱeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21162> (cherry picked from commit fec15a225f603f7a980241ce6b7fad35dfc6aff4) --- .pick_status.json | 2 +- src/broadcom/vulkan/v3dv_cmd_buffer.c | 7 ++++--- src/broadcom/vulkan/v3dv_private.h | 3 +++ src/broadcom/vulkan/v3dvx_cmd_buffer.c | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c93bfe7bc68..e3a29cda706 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -40,7 +40,7 @@ "description": "v3dv: ensure we apply binning syncs to secondary command buffers", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 2edf1610ac7..55e4255d212 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -2809,8 +2809,9 @@ cmd_buffer_binning_sync_required(struct v3dv_cmd_buffer *cmd_buffer, return false; } -static void -consume_bcl_sync(struct v3dv_cmd_buffer *cmd_buffer, struct v3dv_job *job) +void +v3dv_cmd_buffer_consume_bcl_sync(struct v3dv_cmd_buffer *cmd_buffer, + struct v3dv_job *job) { job->needs_bcl_sync = true; cmd_buffer->state.barrier.bcl_buffer_access = 0; @@ -2910,7 +2911,7 @@ v3dv_cmd_buffer_emit_pre_draw(struct v3dv_cmd_buffer *cmd_buffer, assert(!job->needs_bcl_sync); if (cmd_buffer_binning_sync_required(cmd_buffer, pipeline, indexed, indirect)) { - consume_bcl_sync(cmd_buffer, job); + v3dv_cmd_buffer_consume_bcl_sync(cmd_buffer, job); } } diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index cad2520ba21..4ef931fd9b6 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -1711,6 +1711,9 @@ void v3dv_cmd_buffer_add_private_obj(struct v3dv_cmd_buffer *cmd_buffer, void v3dv_cmd_buffer_merge_barrier_state(struct v3dv_barrier_state *dst, struct v3dv_barrier_state *src); +void v3dv_cmd_buffer_consume_bcl_sync(struct v3dv_cmd_buffer *cmd_buffer, + struct v3dv_job *job); + bool v3dv_cmd_buffer_check_needs_load(const struct v3dv_cmd_buffer_state *state, VkImageAspectFlags aspect, uint32_t first_subpass_idx, diff --git a/src/broadcom/vulkan/v3dvx_cmd_buffer.c b/src/broadcom/vulkan/v3dvx_cmd_buffer.c index 8ad5ef3bce6..7bafd42f0ae 100644 --- a/src/broadcom/vulkan/v3dvx_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dvx_cmd_buffer.c @@ -1623,6 +1623,20 @@ v3dX(cmd_buffer_execute_inside_pass)(struct v3dv_cmd_buffer *primary, { assert(primary->state.job); + /* Typically we postpone applying binning syncs until we see a draw call + * that may actually access proteted resources in the binning stage. However, + * if the draw calls are recorded in a secondary command buffer and the + * barriers were recorded in a primary command buffer, that won't work + * and we will have to check if we need a binning sync when executing the + * secondary. + */ + struct v3dv_job *primary_job = primary->state.job; + if (primary_job->serialize && + (primary->state.barrier.bcl_buffer_access || + primary->state.barrier.bcl_image_access)) { + v3dv_cmd_buffer_consume_bcl_sync(primary, primary_job); + } + /* Emit occlusion query state if needed so the draw calls inside our * secondaries update the counters. */ @@ -1668,7 +1682,7 @@ v3dX(cmd_buffer_execute_inside_pass)(struct v3dv_cmd_buffer *primary, * the RETURN_FROM_SUB_LIST into the primary job to skip the * branch? */ - struct v3dv_job *primary_job = primary->state.job; + primary_job = primary->state.job; if (!primary_job || secondary_job->serialize || pending_barrier.dst_mask) { const bool needs_bcl_barrier =
