radv: move subpass image transitions to radv_cmd_buffer_begin_subpass()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 29 Jan 2019 21:18:50 +0000 (22:18 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 4 Feb 2019 12:17:52 +0000 (13:17 +0100)
Instead of doing them in radv_cmd_buffer_set_subpass().

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_clear.c
src/amd/vulkan/radv_meta_resolve.c
src/amd/vulkan/radv_meta_resolve_fs.c
src/amd/vulkan/radv_private.h

index b054e105af1b8838a897403b67dfbcd5897652fb..003dcbd5fb28df9da44c7cd5de4596a82d694a4a 100644 (file)
@@ -2425,28 +2425,8 @@ static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buf
 
 void
 radv_cmd_buffer_set_subpass(struct radv_cmd_buffer *cmd_buffer,
-                           const struct radv_subpass *subpass, bool transitions)
+                           const struct radv_subpass *subpass)
 {
-       if (transitions) {
-               radv_subpass_barrier(cmd_buffer, &subpass->start_barrier);
-
-               for (unsigned i = 0; i < subpass->color_count; ++i) {
-                       if (subpass->color_attachments[i].attachment != VK_ATTACHMENT_UNUSED)
-                               radv_handle_subpass_image_transition(cmd_buffer,
-                                                                    subpass->color_attachments[i]);
-               }
-
-               for (unsigned i = 0; i < subpass->input_count; ++i) {
-                       radv_handle_subpass_image_transition(cmd_buffer,
-                                                       subpass->input_attachments[i]);
-               }
-
-               if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
-                       radv_handle_subpass_image_transition(cmd_buffer,
-                                                       subpass->depth_stencil_attachment);
-               }
-       }
-
        cmd_buffer->state.subpass = subpass;
 
        cmd_buffer->state.dirty |= RADV_CMD_DIRTY_FRAMEBUFFER;
@@ -2629,7 +2609,7 @@ VkResult radv_BeginCommandBuffer(
                if (result != VK_SUCCESS)
                        return result;
 
-               radv_cmd_buffer_set_subpass(cmd_buffer, subpass, false);
+               radv_cmd_buffer_set_subpass(cmd_buffer, subpass);
        }
 
        if (unlikely(cmd_buffer->device->trace_bo)) {
@@ -3419,7 +3399,25 @@ radv_cmd_buffer_begin_subpass(struct radv_cmd_buffer *cmd_buffer,
        MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws,
                                                           cmd_buffer->cs, 2048);
 
-       radv_cmd_buffer_set_subpass(cmd_buffer, subpass, true);
+       radv_subpass_barrier(cmd_buffer, &subpass->start_barrier);
+
+       for (unsigned i = 0; i < subpass->color_count; ++i) {
+               if (subpass->color_attachments[i].attachment != VK_ATTACHMENT_UNUSED)
+                       radv_handle_subpass_image_transition(cmd_buffer,
+                                                           subpass->color_attachments[i]);
+       }
+
+       for (unsigned i = 0; i < subpass->input_count; ++i) {
+               radv_handle_subpass_image_transition(cmd_buffer,
+                                                    subpass->input_attachments[i]);
+       }
+
+       if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
+               radv_handle_subpass_image_transition(cmd_buffer,
+                                                    subpass->depth_stencil_attachment);
+       }
+
+       radv_cmd_buffer_set_subpass(cmd_buffer, subpass);
        radv_cmd_buffer_clear_subpass(cmd_buffer);
 
        assert(cmd_buffer->cs->cdw <= cdw_max);
index 8805f0435e1d84322380fa27ab7bac9f070a4d04..06f25aa46d7972d7347507e04c3ec106dcd6f45a 100644 (file)
@@ -426,7 +426,7 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer,
                .depth_stencil_attachment = (struct radv_subpass_attachment) { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_UNDEFINED }
        };
 
-       radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass, false);
+       radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass);
 
        radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
                             pipeline);
@@ -450,7 +450,7 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer,
                radv_CmdDraw(cmd_buffer_h, 3, clear_rect->layerCount, 0, clear_rect->baseArrayLayer);
        }
 
-       radv_cmd_buffer_set_subpass(cmd_buffer, subpass, false);
+       radv_cmd_buffer_set_subpass(cmd_buffer, subpass);
 }
 
 
@@ -1287,6 +1287,7 @@ radv_clear_cmask(struct radv_cmd_buffer *cmd_buffer,
                                image->cmask.size, value);
 }
 
+
 uint32_t
 radv_clear_fmask(struct radv_cmd_buffer *cmd_buffer,
                 struct radv_image *image, uint32_t value)
index 6a7cbfe84688bd1616a7b0368dbfd9d29fb7fd93..821f47c96718bb3a122cb5b2853e9be6ff358bec 100644 (file)
@@ -678,7 +678,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
                        .depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
                };
 
-               radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass, false);
+               radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass);
 
                VkResult ret = build_resolve_pipeline(cmd_buffer->device, radv_format_meta_fs_key(dst_img->vk_format));
                if (ret != VK_SUCCESS) {
index af4a6fe7a66be032d806d0c8af96f3eb6092f11a..47af4bb1d86c2451f17ed4ec6506dcf989ea3281 100644 (file)
@@ -623,7 +623,7 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
                        .depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
                };
 
-               radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass, false);
+               radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass);
 
                emit_resolve(cmd_buffer,
                             src_iview,
index 4b2d27ac0b99189eb7db693a2c6a9b2a37a7069c..e2849b3a9015639bc8a6f3ff83030ac34b8a2e69 100644 (file)
@@ -1183,8 +1183,7 @@ radv_cmd_buffer_upload_alloc(struct radv_cmd_buffer *cmd_buffer,
                             void **ptr);
 void
 radv_cmd_buffer_set_subpass(struct radv_cmd_buffer *cmd_buffer,
-                           const struct radv_subpass *subpass,
-                           bool transitions);
+                           const struct radv_subpass *subpass);
 bool
 radv_cmd_buffer_upload_data(struct radv_cmd_buffer *cmd_buffer,
                            unsigned size, unsigned alignmnet,