[Mesa-dev] [PATCH 2/2] radv: remove useless checks around radv_CmdBindPipeline()

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Oct 4 20:27:39 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_meta_blit.c       |  6 ++--
 src/amd/vulkan/radv_meta_blit2d.c     | 18 ++++------
 src/amd/vulkan/radv_meta_bufimage.c   | 65 +++++++----------------------------
 src/amd/vulkan/radv_meta_clear.c      | 12 +++----
 src/amd/vulkan/radv_meta_decompress.c |  8 ++---
 src/amd/vulkan/radv_meta_fast_clear.c |  6 ++--
 src/amd/vulkan/radv_meta_resolve.c    |  9 ++---
 src/amd/vulkan/radv_meta_resolve_cs.c |  7 ++--
 8 files changed, 34 insertions(+), 97 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index a0be498de5..88df1f7f41 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -409,10 +409,8 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer,
 		unreachable(!"bad VkImageType");
 	}
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
-	}
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
 
 	radv_meta_push_descriptor_set(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
 			              device->meta_state.blit.pipeline_layout,
diff --git a/src/amd/vulkan/radv_meta_blit2d.c b/src/amd/vulkan/radv_meta_blit2d.c
index 946c741a27..30f58abb5f 100644
--- a/src/amd/vulkan/radv_meta_blit2d.c
+++ b/src/amd/vulkan/radv_meta_blit2d.c
@@ -186,10 +186,8 @@ bind_pipeline(struct radv_cmd_buffer *cmd_buffer,
 	VkPipeline pipeline =
 		cmd_buffer->device->meta_state.blit2d.pipelines[src_type][fs_key];
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
-	}
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
 }
 
 static void
@@ -199,10 +197,8 @@ bind_depth_pipeline(struct radv_cmd_buffer *cmd_buffer,
 	VkPipeline pipeline =
 		cmd_buffer->device->meta_state.blit2d.depth_only_pipeline[src_type];
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
-	}
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
 }
 
 static void
@@ -212,10 +208,8 @@ bind_stencil_pipeline(struct radv_cmd_buffer *cmd_buffer,
 	VkPipeline pipeline =
 		cmd_buffer->device->meta_state.blit2d.stencil_only_pipeline[src_type];
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
-	}
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
 }
 
 static void
diff --git a/src/amd/vulkan/radv_meta_bufimage.c b/src/amd/vulkan/radv_meta_bufimage.c
index cb028dccdc..f5bbf3cb90 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -865,18 +865,6 @@ itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
 				      });
 }
 
-static void
-itob_bind_pipeline(struct radv_cmd_buffer *cmd_buffer)
-{
-	VkPipeline pipeline =
-		cmd_buffer->device->meta_state.itob.pipeline;
-
-	if (cmd_buffer->state.compute_pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
-	}
-}
-
 void
 radv_meta_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
 			  struct radv_meta_blit2d_surf *src,
@@ -884,6 +872,7 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
 			  unsigned num_rects,
 			  struct radv_meta_blit2d_rect *rects)
 {
+	VkPipeline pipeline = cmd_buffer->device->meta_state.itob.pipeline;
 	struct radv_device *device = cmd_buffer->device;
 	struct itob_temps temps;
 
@@ -891,7 +880,9 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
 	create_bview(cmd_buffer, dst->buffer, dst->offset, dst->format, &temps.dst_bview);
 	itob_bind_descriptors(cmd_buffer, &temps);
 
-	itob_bind_pipeline(cmd_buffer);
+
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
 
 	for (unsigned r = 0; r < num_rects; ++r) {
 		unsigned push_constants[3] = {
@@ -950,18 +941,6 @@ btoi_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
 				      });
 }
 
-static void
-btoi_bind_pipeline(struct radv_cmd_buffer *cmd_buffer)
-{
-	VkPipeline pipeline =
-		cmd_buffer->device->meta_state.btoi.pipeline;
-
-	if (cmd_buffer->state.compute_pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
-	}
-}
-
 void
 radv_meta_buffer_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 			     struct radv_meta_blit2d_buffer *src,
@@ -969,6 +948,7 @@ radv_meta_buffer_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 			     unsigned num_rects,
 			     struct radv_meta_blit2d_rect *rects)
 {
+	VkPipeline pipeline = cmd_buffer->device->meta_state.btoi.pipeline;
 	struct radv_device *device = cmd_buffer->device;
 	struct btoi_temps temps;
 
@@ -976,7 +956,8 @@ radv_meta_buffer_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 	create_iview(cmd_buffer, dst, &temps.dst_iview);
 	btoi_bind_descriptors(cmd_buffer, &temps);
 
-	btoi_bind_pipeline(cmd_buffer);
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
 
 	for (unsigned r = 0; r < num_rects; ++r) {
 		unsigned push_constants[3] = {
@@ -1041,18 +1022,6 @@ itoi_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
 				      });
 }
 
-static void
-itoi_bind_pipeline(struct radv_cmd_buffer *cmd_buffer)
-{
-	VkPipeline pipeline =
-		cmd_buffer->device->meta_state.itoi.pipeline;
-
-	if (cmd_buffer->state.compute_pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
-	}
-}
-
 void
 radv_meta_image_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 			    struct radv_meta_blit2d_surf *src,
@@ -1060,6 +1029,7 @@ radv_meta_image_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 			    unsigned num_rects,
 			    struct radv_meta_blit2d_rect *rects)
 {
+	VkPipeline pipeline = cmd_buffer->device->meta_state.itoi.pipeline;
 	struct radv_device *device = cmd_buffer->device;
 	struct itoi_temps temps;
 
@@ -1068,7 +1038,8 @@ radv_meta_image_to_image_cs(struct radv_cmd_buffer *cmd_buffer,
 
 	itoi_bind_descriptors(cmd_buffer, &temps);
 
-	itoi_bind_pipeline(cmd_buffer);
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
 
 	for (unsigned r = 0; r < num_rects; ++r) {
 		unsigned push_constants[4] = {
@@ -1115,30 +1086,20 @@ cleari_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
 				      });
 }
 
-static void
-cleari_bind_pipeline(struct radv_cmd_buffer *cmd_buffer)
-{
-	VkPipeline pipeline =
-		cmd_buffer->device->meta_state.cleari.pipeline;
-
-	if (cmd_buffer->state.compute_pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
-	}
-}
-
 void
 radv_meta_clear_image_cs(struct radv_cmd_buffer *cmd_buffer,
 			 struct radv_meta_blit2d_surf *dst,
 			 const VkClearColorValue *clear_color)
 {
+	VkPipeline pipeline = cmd_buffer->device->meta_state.cleari.pipeline;
 	struct radv_device *device = cmd_buffer->device;
 	struct radv_image_view dst_iview;
 
 	create_iview(cmd_buffer, dst, &dst_iview);
 	cleari_bind_descriptors(cmd_buffer, &dst_iview);
 
-	cleari_bind_pipeline(cmd_buffer);
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
 
 	unsigned push_constants[4] = {
 		clear_color->uint32[0],
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index fd2caf3d0c..3acb9e009a 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -374,10 +374,8 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer,
 
 	radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass, false);
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-					   pipeline);
-	}
+	radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+			     pipeline);
 
 	radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
 			.x = clear_rect->rect.offset.x,
@@ -644,10 +642,8 @@ emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer,
 							 clear_rect,
 							 clear_value);
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-				     pipeline);
-	}
+	radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+			     pipeline);
 
 	if (depth_view_can_fast_clear(cmd_buffer, iview, aspects,
 	                              subpass->depth_stencil_attachment.layout,
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index c68be27f1f..f4ed63f68b 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -269,12 +269,8 @@ emit_depth_decomp(struct radv_cmd_buffer *cmd_buffer,
 {
 	VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
 
-	RADV_FROM_HANDLE(radv_pipeline, pipeline, pipeline_h);
-
-	if (cmd_buffer->state.pipeline != pipeline) {
-		radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-				     pipeline_h);
-	}
+	radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+			     pipeline_h);
 
 	radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
 		.x = 0,
diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
index a10630173e..0efde627ed 100644
--- a/src/amd/vulkan/radv_meta_fast_clear.c
+++ b/src/amd/vulkan/radv_meta_fast_clear.c
@@ -292,10 +292,8 @@ emit_fast_clear_flush(struct radv_cmd_buffer *cmd_buffer,
 {
 	VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
 
-	if (cmd_buffer->state.pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-				     pipeline);
-	}
+	radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+			     pipeline);
 
 	radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
 			.x = 0,
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 5141ae3baa..50008baf94 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -268,13 +268,8 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer,
 
 	cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB;
 
-	VkPipeline pipeline_h = device->meta_state.resolve.pipeline;
-	RADV_FROM_HANDLE(radv_pipeline, pipeline, pipeline_h);
-
-	if (cmd_buffer->state.pipeline != pipeline) {
-		radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
-				     pipeline_h);
-	}
+	radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS,
+			     device->meta_state.resolve.pipeline);
 
 	radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) {
 		.x = dest_offset->x,
diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
index 55bf72071e..7104ccd35f 100644
--- a/src/amd/vulkan/radv_meta_resolve_cs.c
+++ b/src/amd/vulkan/radv_meta_resolve_cs.c
@@ -351,10 +351,9 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer,
 		pipeline = device->meta_state.resolve_compute.rc[samples_log2].srgb_pipeline;
 	else
 		pipeline = device->meta_state.resolve_compute.rc[samples_log2].pipeline;
-	if (cmd_buffer->state.compute_pipeline != radv_pipeline_from_handle(pipeline)) {
-		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
-				     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
-	}
+
+	radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+			     VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
 
 	unsigned push_constants[4] = {
 		src_offset->x,
-- 
2.14.2



More information about the mesa-dev mailing list