Module: Mesa Branch: main Commit: fec15a225f603f7a980241ce6b7fad35dfc6aff4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fec15a225f603f7a980241ce6b7fad35dfc6aff4
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> --- src/broadcom/ci/broadcom-rpi4-flakes.txt | 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, 22 insertions(+), 6 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi4-flakes.txt b/src/broadcom/ci/broadcom-rpi4-flakes.txt index dea44efe71a..bcd94248e94 100644 --- a/src/broadcom/ci/broadcom-rpi4-flakes.txt +++ b/src/broadcom/ci/broadcom-rpi4-flakes.txt @@ -14,8 +14,6 @@ spec@egl 1.4@largest possible eglcreatepbuffersurface and then glclear # This test works alone, but fails when executing all the tests together dEQP-GLES3.functional.texture.specification.teximage2d_pbo.rgba32ui_2d -dEQP-VK.api.command_buffers.record_many_draws_secondary_2 - dEQP-VK.api.external.fence.opaque_fd.reset_permanent dEQP-VK.api.external.fence.opaque_fd.reset_temporary diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 6d24ff96def..6b667701a0f 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 b18313fd74c..8107e06e72d 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -1796,6 +1796,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 63c75e9b5e7..0c23a33b501 100644 --- a/src/broadcom/vulkan/v3dvx_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dvx_cmd_buffer.c @@ -1657,6 +1657,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. */ @@ -1702,7 +1716,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 =
