[Mesa-dev] [PATCH 1/4] radv: make use of radv_subpass_barrier() when resolving subpasses
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Fri Jul 20 00:16:05 UTC 2018
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
for the series.
On Wed, Jul 18, 2018 at 4:19 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> The goal is to use radv_barrier()/radv_subpass_barrier() as
> much as possible for further optimizations.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/amd/vulkan/radv_cmd_buffer.c | 3 ++-
> src/amd/vulkan/radv_meta_resolve_cs.c | 16 +++++++++-------
> src/amd/vulkan/radv_meta_resolve_fs.c | 13 ++++++-------
> src/amd/vulkan/radv_private.h | 3 +++
> 4 files changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index 041ebf0ca3..b67f0ffdbe 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -2048,7 +2048,8 @@ radv_dst_access_flush(struct radv_cmd_buffer *cmd_buffer,
> return flush_bits;
> }
>
> -static void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer, const struct radv_subpass_barrier *barrier)
> +void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer,
> + const struct radv_subpass_barrier *barrier)
> {
> cmd_buffer->state.flush_bits |= radv_src_access_flush(cmd_buffer, barrier->src_access_mask,
> NULL);
> diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
> index daf11e0576..ad02594614 100644
> --- a/src/amd/vulkan/radv_meta_resolve_cs.c
> +++ b/src/amd/vulkan/radv_meta_resolve_cs.c
> @@ -473,6 +473,8 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
> struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
> const struct radv_subpass *subpass = cmd_buffer->state.subpass;
> struct radv_meta_saved_state saved_state;
> + struct radv_subpass_barrier barrier;
> +
> /* FINISHME(perf): Skip clears for resolve attachments.
> *
> * From the Vulkan 1.0 spec:
> @@ -485,13 +487,13 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
> if (!subpass->has_resolve)
> return;
>
> - /* Resolves happen before the end-of-subpass barriers get executed,
> - * so we have to make the attachment shader-readable */
> - cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_PS_PARTIAL_FLUSH |
> - RADV_CMD_FLAG_FLUSH_AND_INV_CB |
> - RADV_CMD_FLAG_FLUSH_AND_INV_CB_META |
> - RADV_CMD_FLAG_INV_GLOBAL_L2 |
> - RADV_CMD_FLAG_INV_VMEM_L1;
> + /* Resolves happen before the end-of-subpass barriers get executed, so
> + * we have to make the attachment shader-readable.
> + */
> + barrier.src_stage_mask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
> + barrier.src_access_mask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
> + barrier.dst_access_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
> + radv_subpass_barrier(cmd_buffer, &barrier);
>
> radv_decompress_resolve_subpass_src(cmd_buffer);
>
> diff --git a/src/amd/vulkan/radv_meta_resolve_fs.c b/src/amd/vulkan/radv_meta_resolve_fs.c
> index 5f4f241893..0e4957b163 100644
> --- a/src/amd/vulkan/radv_meta_resolve_fs.c
> +++ b/src/amd/vulkan/radv_meta_resolve_fs.c
> @@ -580,6 +580,7 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
> struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
> const struct radv_subpass *subpass = cmd_buffer->state.subpass;
> struct radv_meta_saved_state saved_state;
> + struct radv_subpass_barrier barrier;
>
> /* FINISHME(perf): Skip clears for resolve attachments.
> *
> @@ -600,13 +601,11 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
>
> /* Resolves happen before the end-of-subpass barriers get executed,
> * so we have to make the attachment shader-readable */
> - cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_PS_PARTIAL_FLUSH |
> - RADV_CMD_FLAG_FLUSH_AND_INV_CB |
> - RADV_CMD_FLAG_FLUSH_AND_INV_CB_META |
> - RADV_CMD_FLAG_FLUSH_AND_INV_DB |
> - RADV_CMD_FLAG_FLUSH_AND_INV_DB_META |
> - RADV_CMD_FLAG_INV_GLOBAL_L2 |
> - RADV_CMD_FLAG_INV_VMEM_L1;
> + barrier.src_stage_mask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
> + barrier.src_access_mask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
> + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
> + barrier.dst_access_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
> + radv_subpass_barrier(cmd_buffer, &barrier);
>
> radv_decompress_resolve_subpass_src(cmd_buffer);
>
> diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
> index 338cb07b3e..f17efeeccd 100644
> --- a/src/amd/vulkan/radv_private.h
> +++ b/src/amd/vulkan/radv_private.h
> @@ -1713,6 +1713,9 @@ struct radv_subpass_barrier {
> VkAccessFlags dst_access_mask;
> };
>
> +void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer,
> + const struct radv_subpass_barrier *barrier);
> +
> struct radv_subpass_attachment {
> uint32_t attachment;
> VkImageLayout layout;
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list