radv: make use of radv_subpass_barrier() when resolving subpasses
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 18 Jul 2018 14:19:04 +0000 (16:19 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 20 Jul 2018 08:17:11 +0000 (10:17 +0200)
The goal is to use radv_barrier()/radv_subpass_barrier() as
much as possible for further optimizations.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_meta_resolve_cs.c
src/amd/vulkan/radv_meta_resolve_fs.c
src/amd/vulkan/radv_private.h

index f6ab5e6c7538df7b14df1e366182e0666d552604..032b701561fe4834525d707814d943fc7d08a149 100644 (file)
@@ -2053,7 +2053,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);
index daf11e057688096bbcfc274903afae5b964b80ea..ad02594614ceb29e50959af8d63b03a701178bfe 100644 (file)
@@ -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);
 
index 5f4f241893236bf24ee8328cc6bd53f96f450c0d..0e4957b163cbeccb7d2add7de1503e004d4e9a63 100644 (file)
@@ -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);
 
index d8443cb7bb0d005310fc70d8a0f6767c61c18081..a187f76be491a65c5cd534afa80ffb7308aaaa2e 100644 (file)
@@ -1718,6 +1718,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;