radv: cleanup radv_device_finish_meta_XXX() helpers
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 28 Sep 2017 11:50:56 +0000 (13:50 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 2 Oct 2017 09:56:20 +0000 (11:56 +0200)
Unnecessary to double check that handles are not NULL.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_blit.c
src/amd/vulkan/radv_meta_blit2d.c
src/amd/vulkan/radv_meta_buffer.c
src/amd/vulkan/radv_meta_bufimage.c
src/amd/vulkan/radv_meta_clear.c
src/amd/vulkan/radv_meta_decompress.c
src/amd/vulkan/radv_meta_fast_clear.c
src/amd/vulkan/radv_meta_resolve.c

index 7d9f7f902638145346f1223d2261061854629a8e..a0be498de504c61b44d7effe7415e188f37593d1 100644 (file)
@@ -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[] = {
index 751f5914fcef67c0e82bd50b3bdf3a5591625864..946c741a27add23a1998ad22fbb7471127b71273 100644 (file)
@@ -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);
        }
 }
 
index f95d8823fcc476a9c6b1c06259a0a85750c62272..ea11ed18c4ff443bdd7b1675ae744afd606ac9c1 100644 (file)
@@ -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,
index d73420aef9c5681329b81b81b2809c24136ed729..cb028dccdcc8a0d7e51d1414a8ffd6127050a17f 100644 (file)
@@ -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
index 9b67c062d6c8eab7de4f77a179045f92a4c1f72a..64d3bac7f1bdf4fee428bf74832a41a528afc370 100644 (file)
@@ -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,
index fe18ddfb91f5144c633e3d5711f76accbf53339f..c68be27f1f6bdf9e5eee07f4ee23ae497980de3e 100644 (file)
@@ -207,22 +207,17 @@ 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);
-               }
-               pipeline_h = state->depth_decomp[i].resummarize_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);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->depth_decomp[i].resummarize_pipeline,
+                                    &state->alloc);
        }
 }
 
index 902fc92972ed041e875a37e4ca3931b2957dc569..a10630173eee3c9e4e6745c7e88ee04a7782b607 100644 (file)
@@ -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
index 80b44c89e97def72cd2f5fc6bba88bc953fef186..5141ae3baaee525674a736888804d59173ff19f0 100644 (file)
@@ -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