[Mesa-dev] [PATCH 17/19] radv: cleanup radv_device_finish_meta_XXX() helpers

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Sep 29 15:49:04 UTC 2017


Unnecessary to double check that handles are not NULL.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_meta_blit.c       | 91 ++++++++++++++-------------------
 src/amd/vulkan/radv_meta_blit2d.c     | 49 ++++++++----------
 src/amd/vulkan/radv_meta_buffer.c     | 45 ++++++----------
 src/amd/vulkan/radv_meta_bufimage.c   | 96 +++++++++++++----------------------
 src/amd/vulkan/radv_meta_clear.c      | 12 ++---
 src/amd/vulkan/radv_meta_decompress.c | 16 +++---
 src/amd/vulkan/radv_meta_fast_clear.c | 24 +++------
 src/amd/vulkan/radv_meta_resolve.c    | 15 ++----
 8 files changed, 133 insertions(+), 215 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index 7d9f7f9026..a0be498de5 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -635,65 +635,48 @@ void radv_CmdBlitImage(
 void
 radv_device_finish_meta_blit_state(struct radv_device *device)
 {
-	for (unsigned i = 0; i < NUM_META_FS_KEYS; ++i) {
-		if (device->meta_state.blit.render_pass[i])
-			radv_DestroyRenderPass(radv_device_to_handle(device),
-					       device->meta_state.blit.render_pass[i],
-					       &device->meta_state.alloc);
-		if (device->meta_state.blit.pipeline_1d_src[i])
-			radv_DestroyPipeline(radv_device_to_handle(device),
-					     device->meta_state.blit.pipeline_1d_src[i],
-					     &device->meta_state.alloc);
-		if (device->meta_state.blit.pipeline_2d_src[i])
-			radv_DestroyPipeline(radv_device_to_handle(device),
-					     device->meta_state.blit.pipeline_2d_src[i],
-					     &device->meta_state.alloc);
-		if (device->meta_state.blit.pipeline_3d_src[i])
-			radv_DestroyPipeline(radv_device_to_handle(device),
-					     device->meta_state.blit.pipeline_3d_src[i],
-					     &device->meta_state.alloc);
-	}
+	struct radv_meta_state *state = &device->meta_state;
 
-	if (device->meta_state.blit.depth_only_rp)
-		radv_DestroyRenderPass(radv_device_to_handle(device),
-				       device->meta_state.blit.depth_only_rp,
-				       &device->meta_state.alloc);
-	if (device->meta_state.blit.depth_only_1d_pipeline)
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.depth_only_1d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.depth_only_2d_pipeline)
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.depth_only_2d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.depth_only_3d_pipeline)
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.depth_only_3d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.stencil_only_rp)
+	for (unsigned i = 0; i < NUM_META_FS_KEYS; ++i) {
 		radv_DestroyRenderPass(radv_device_to_handle(device),
-				       device->meta_state.blit.stencil_only_rp,
-				       &device->meta_state.alloc);
-	if (device->meta_state.blit.stencil_only_1d_pipeline)
+				       state->blit.render_pass[i],
+				       &state->alloc);
 		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.stencil_only_1d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.stencil_only_2d_pipeline)
+				     state->blit.pipeline_1d_src[i],
+				     &state->alloc);
 		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.stencil_only_2d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.stencil_only_3d_pipeline)
+				     state->blit.pipeline_2d_src[i],
+				     &state->alloc);
 		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit.stencil_only_3d_pipeline,
-				     &device->meta_state.alloc);
-	if (device->meta_state.blit.pipeline_layout)
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.blit.pipeline_layout,
-					   &device->meta_state.alloc);
-	if (device->meta_state.blit.ds_layout)
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.blit.ds_layout,
-						&device->meta_state.alloc);
+				     state->blit.pipeline_3d_src[i],
+				     &state->alloc);
+	}
+
+	radv_DestroyRenderPass(radv_device_to_handle(device),
+			       state->blit.depth_only_rp, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.depth_only_1d_pipeline, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.depth_only_2d_pipeline, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.depth_only_3d_pipeline, &state->alloc);
+
+	radv_DestroyRenderPass(radv_device_to_handle(device),
+			       state->blit.stencil_only_rp, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.stencil_only_1d_pipeline,
+			     &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.stencil_only_2d_pipeline,
+			     &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->blit.stencil_only_3d_pipeline,
+			     &state->alloc);
+
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->blit.pipeline_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+					state->blit.ds_layout, &state->alloc);
 }
 
 static VkFormat pipeline_formats[] = {
diff --git a/src/amd/vulkan/radv_meta_blit2d.c b/src/amd/vulkan/radv_meta_blit2d.c
index 751f5914fc..946c741a27 100644
--- a/src/amd/vulkan/radv_meta_blit2d.c
+++ b/src/amd/vulkan/radv_meta_blit2d.c
@@ -584,48 +584,39 @@ build_nir_copy_fragment_shader_stencil(struct radv_device *device,
 void
 radv_device_finish_meta_blit2d_state(struct radv_device *device)
 {
+	struct radv_meta_state *state = &device->meta_state;
+
 	for(unsigned j = 0; j < NUM_META_FS_KEYS; ++j) {
-		if (device->meta_state.blit2d.render_passes[j]) {
-			radv_DestroyRenderPass(radv_device_to_handle(device),
-					       device->meta_state.blit2d.render_passes[j],
-					       &device->meta_state.alloc);
-		}
+		radv_DestroyRenderPass(radv_device_to_handle(device),
+				       state->blit2d.render_passes[j],
+				       &state->alloc);
 	}
 
 	radv_DestroyRenderPass(radv_device_to_handle(device),
-			       device->meta_state.blit2d.depth_only_rp,
-			       &device->meta_state.alloc);
+			       state->blit2d.depth_only_rp, &state->alloc);
 	radv_DestroyRenderPass(radv_device_to_handle(device),
-			       device->meta_state.blit2d.stencil_only_rp,
-			       &device->meta_state.alloc);
+			       state->blit2d.stencil_only_rp, &state->alloc);
 
 	for (unsigned src = 0; src < BLIT2D_NUM_SRC_TYPES; src++) {
-		if (device->meta_state.blit2d.p_layouts[src]) {
-			radv_DestroyPipelineLayout(radv_device_to_handle(device),
-						device->meta_state.blit2d.p_layouts[src],
-						&device->meta_state.alloc);
-		}
-
-		if (device->meta_state.blit2d.ds_layouts[src]) {
-			radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-							device->meta_state.blit2d.ds_layouts[src],
-							&device->meta_state.alloc);
-		}
+		radv_DestroyPipelineLayout(radv_device_to_handle(device),
+					   state->blit2d.p_layouts[src],
+					   &state->alloc);
+		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+						state->blit2d.ds_layouts[src],
+						&state->alloc);
 
 		for (unsigned j = 0; j < NUM_META_FS_KEYS; ++j) {
-			if (device->meta_state.blit2d.pipelines[src][j]) {
-				radv_DestroyPipeline(radv_device_to_handle(device),
-						     device->meta_state.blit2d.pipelines[src][j],
-						     &device->meta_state.alloc);
-			}
+			radv_DestroyPipeline(radv_device_to_handle(device),
+					     state->blit2d.pipelines[src][j],
+					     &state->alloc);
 		}
 
 		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit2d.depth_only_pipeline[src],
-				     &device->meta_state.alloc);
+				     state->blit2d.depth_only_pipeline[src],
+				     &state->alloc);
 		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.blit2d.stencil_only_pipeline[src],
-				     &device->meta_state.alloc);
+				     state->blit2d.stencil_only_pipeline[src],
+				     &state->alloc);
 	}
 }
 
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c
index f95d8823fc..ea11ed18c4 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -261,35 +261,22 @@ fail:
 
 void radv_device_finish_meta_buffer_state(struct radv_device *device)
 {
-	if (device->meta_state.buffer.copy_pipeline)
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.buffer.copy_pipeline,
-				     &device->meta_state.alloc);
-
-	if (device->meta_state.buffer.fill_pipeline)
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.buffer.fill_pipeline,
-				     &device->meta_state.alloc);
-
-	if (device->meta_state.buffer.copy_p_layout)
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.buffer.copy_p_layout,
-					   &device->meta_state.alloc);
-
-	if (device->meta_state.buffer.fill_p_layout)
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.buffer.fill_p_layout,
-					   &device->meta_state.alloc);
-
-	if (device->meta_state.buffer.copy_ds_layout)
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.buffer.copy_ds_layout,
-						&device->meta_state.alloc);
-
-	if (device->meta_state.buffer.fill_ds_layout)
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.buffer.fill_ds_layout,
-						&device->meta_state.alloc);
+	struct radv_meta_state *state = &device->meta_state;
+
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->buffer.copy_pipeline, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->buffer.fill_pipeline, &state->alloc);
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->buffer.copy_p_layout, &state->alloc);
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->buffer.fill_p_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+					state->buffer.copy_ds_layout,
+					&state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+					state->buffer.fill_ds_layout,
+					&state->alloc);
 }
 
 static void fill_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
diff --git a/src/amd/vulkan/radv_meta_bufimage.c b/src/amd/vulkan/radv_meta_bufimage.c
index d73420aef9..cb028dccdc 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -212,21 +212,15 @@ fail:
 static void
 radv_device_finish_meta_itob_state(struct radv_device *device)
 {
-	if (device->meta_state.itob.img_p_layout) {
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.itob.img_p_layout,
-					   &device->meta_state.alloc);
-	}
-	if (device->meta_state.itob.img_ds_layout) {
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.itob.img_ds_layout,
-						&device->meta_state.alloc);
-	}
-	if (device->meta_state.itob.pipeline) {
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.itob.pipeline,
-				     &device->meta_state.alloc);
-	}
+	struct radv_meta_state *state = &device->meta_state;
+
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->itob.img_p_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+				        state->itob.img_ds_layout,
+					&state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->itob.pipeline, &state->alloc);
 }
 
 static nir_shader *
@@ -410,21 +404,15 @@ fail:
 static void
 radv_device_finish_meta_btoi_state(struct radv_device *device)
 {
-	if (device->meta_state.btoi.img_p_layout) {
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.btoi.img_p_layout,
-					   &device->meta_state.alloc);
-	}
-	if (device->meta_state.btoi.img_ds_layout) {
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.btoi.img_ds_layout,
-						&device->meta_state.alloc);
-	}
-	if (device->meta_state.btoi.pipeline) {
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.btoi.pipeline,
-				     &device->meta_state.alloc);
-	}
+	struct radv_meta_state *state = &device->meta_state;
+
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->btoi.img_p_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+				        state->btoi.img_ds_layout,
+					&state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->btoi.pipeline, &state->alloc);
 }
 
 static nir_shader *
@@ -602,21 +590,15 @@ fail:
 static void
 radv_device_finish_meta_itoi_state(struct radv_device *device)
 {
-	if (device->meta_state.itoi.img_p_layout) {
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.itoi.img_p_layout,
-					   &device->meta_state.alloc);
-	}
-	if (device->meta_state.itoi.img_ds_layout) {
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.itoi.img_ds_layout,
-						&device->meta_state.alloc);
-	}
-	if (device->meta_state.itoi.pipeline) {
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.itoi.pipeline,
-				     &device->meta_state.alloc);
-	}
+	struct radv_meta_state *state = &device->meta_state;
+
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->itoi.img_p_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+				        state->itoi.img_ds_layout,
+					&state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->itoi.pipeline, &state->alloc);
 }
 
 static nir_shader *
@@ -749,21 +731,15 @@ fail:
 static void
 radv_device_finish_meta_cleari_state(struct radv_device *device)
 {
-	if (device->meta_state.cleari.img_p_layout) {
-		radv_DestroyPipelineLayout(radv_device_to_handle(device),
-					   device->meta_state.cleari.img_p_layout,
-					   &device->meta_state.alloc);
-	}
-	if (device->meta_state.cleari.img_ds_layout) {
-		radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
-						device->meta_state.cleari.img_ds_layout,
-						&device->meta_state.alloc);
-	}
-	if (device->meta_state.cleari.pipeline) {
-		radv_DestroyPipeline(radv_device_to_handle(device),
-				     device->meta_state.cleari.pipeline,
-				     &device->meta_state.alloc);
-	}
+	struct radv_meta_state *state = &device->meta_state;
+
+	radv_DestroyPipelineLayout(radv_device_to_handle(device),
+				   state->cleari.img_p_layout, &state->alloc);
+	radv_DestroyDescriptorSetLayout(radv_device_to_handle(device),
+				        state->cleari.img_ds_layout,
+					&state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->cleari.pipeline, &state->alloc);
 }
 
 void
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 72efe4608e..bc0b26f1a4 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -296,26 +296,26 @@ radv_device_finish_meta_clear_state(struct radv_device *device)
 		for (uint32_t j = 0; j < ARRAY_SIZE(state->clear[i].color_pipelines); ++j) {
 			radv_DestroyPipeline(radv_device_to_handle(device),
 					     state->clear[i].color_pipelines[j],
-					     &device->meta_state.alloc);
+					     &state->alloc);
 			radv_DestroyRenderPass(radv_device_to_handle(device),
 					       state->clear[i].render_pass[j],
-					       &device->meta_state.alloc);
+					       &state->alloc);
 		}
 
 		for (uint32_t j = 0; j < NUM_DEPTH_CLEAR_PIPELINES; j++) {
 			radv_DestroyPipeline(radv_device_to_handle(device),
 					     state->clear[i].depth_only_pipeline[j],
-					     &device->meta_state.alloc);
+					     &state->alloc);
 			radv_DestroyPipeline(radv_device_to_handle(device),
 					     state->clear[i].stencil_only_pipeline[j],
-					     &device->meta_state.alloc);
+					     &state->alloc);
 			radv_DestroyPipeline(radv_device_to_handle(device),
 					     state->clear[i].depthstencil_pipeline[j],
-					     &device->meta_state.alloc);
+					     &state->alloc);
 		}
 		radv_DestroyRenderPass(radv_device_to_handle(device),
 				      state->clear[i].depthstencil_rp,
-				      &device->meta_state.alloc);
+				      &state->alloc);
 	}
 	radv_DestroyPipelineLayout(radv_device_to_handle(device),
 				   state->clear_color_p_layout,
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index ff5a8404cc..dd8e70ed45 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -192,18 +192,14 @@ void
 radv_device_finish_meta_depth_decomp_state(struct radv_device *device)
 {
 	struct radv_meta_state *state = &device->meta_state;
-	VkDevice device_h = radv_device_to_handle(device);
-	const VkAllocationCallbacks *alloc = &device->meta_state.alloc;
 
 	for (uint32_t i = 0; i < ARRAY_SIZE(state->depth_decomp); ++i) {
-		VkRenderPass pass_h = state->depth_decomp[i].pass;
-		if (pass_h) {
-			radv_DestroyRenderPass(device_h, pass_h, alloc);
-		}
-		VkPipeline pipeline_h = state->depth_decomp[i].decompress_pipeline;
-		if (pipeline_h) {
-			radv_DestroyPipeline(device_h, pipeline_h, alloc);
-		}
+		radv_DestroyRenderPass(radv_device_to_handle(device),
+				       state->depth_decomp[i].pass,
+				       &state->alloc);
+		radv_DestroyPipeline(radv_device_to_handle(device),
+				     state->depth_decomp[i].decompress_pipeline,
+				     &state->alloc);
 	}
 }
 
diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
index 29de159dae..925512516d 100644
--- a/src/amd/vulkan/radv_meta_fast_clear.c
+++ b/src/amd/vulkan/radv_meta_fast_clear.c
@@ -242,23 +242,15 @@ void
 radv_device_finish_meta_fast_clear_flush_state(struct radv_device *device)
 {
 	struct radv_meta_state *state = &device->meta_state;
-	VkDevice device_h = radv_device_to_handle(device);
-	VkRenderPass pass_h = device->meta_state.fast_clear_flush.pass;
-	const VkAllocationCallbacks *alloc = &device->meta_state.alloc;
-
-	if (pass_h)
-		radv_DestroyRenderPass(device_h, pass_h,
-					     &device->meta_state.alloc);
 
-	VkPipeline pipeline_h = state->fast_clear_flush.cmask_eliminate_pipeline;
-	if (pipeline_h) {
-		radv_DestroyPipeline(device_h, pipeline_h, alloc);
-	}
-
-	pipeline_h = state->fast_clear_flush.fmask_decompress_pipeline;
-	if (pipeline_h) {
-		radv_DestroyPipeline(device_h, pipeline_h, alloc);
-	}
+	radv_DestroyRenderPass(radv_device_to_handle(device),
+			       state->fast_clear_flush.pass, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->fast_clear_flush.cmask_eliminate_pipeline,
+			     &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->fast_clear_flush.fmask_decompress_pipeline,
+			     &state->alloc);
 }
 
 VkResult
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 80b44c89e9..5141ae3baa 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -219,18 +219,11 @@ void
 radv_device_finish_meta_resolve_state(struct radv_device *device)
 {
 	struct radv_meta_state *state = &device->meta_state;
-	VkDevice device_h = radv_device_to_handle(device);
-	VkRenderPass pass_h = device->meta_state.resolve.pass;
-	const VkAllocationCallbacks *alloc = &device->meta_state.alloc;
 
-	if (pass_h)
-		radv_DestroyRenderPass(device_h, pass_h,
-					     &device->meta_state.alloc);
-
-	VkPipeline pipeline_h = state->resolve.pipeline;
-	if (pipeline_h) {
-		radv_DestroyPipeline(device_h, pipeline_h, alloc);
-	}
+	radv_DestroyRenderPass(radv_device_to_handle(device),
+			       state->resolve.pass, &state->alloc);
+	radv_DestroyPipeline(radv_device_to_handle(device),
+			     state->resolve.pipeline, &state->alloc);
 }
 
 VkResult
-- 
2.14.2



More information about the mesa-dev mailing list