[Mesa-dev] [PATCH 05/19] radv: move subpass image transitions to radv_cmd_buffer_begin_subpass()

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Jan 29 21:18:50 UTC 2019


Instead of doing them in radv_cmd_buffer_set_subpass().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c      | 44 +++++++++++++--------------
 src/amd/vulkan/radv_meta_clear.c      |  5 +--
 src/amd/vulkan/radv_meta_resolve.c    |  2 +-
 src/amd/vulkan/radv_meta_resolve_fs.c |  2 +-
 src/amd/vulkan/radv_private.h         |  3 +-
 5 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index b054e105af1..003dcbd5fb2 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -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);
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 8805f0435e1..06f25aa46d7 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -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)
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 6a7cbfe8468..821f47c9671 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -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) {
diff --git a/src/amd/vulkan/radv_meta_resolve_fs.c b/src/amd/vulkan/radv_meta_resolve_fs.c
index af4a6fe7a66..47af4bb1d86 100644
--- a/src/amd/vulkan/radv_meta_resolve_fs.c
+++ b/src/amd/vulkan/radv_meta_resolve_fs.c
@@ -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,
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index aeb9bc735b7..d64eee80f65 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -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,
-- 
2.20.1



More information about the mesa-dev mailing list