From: Samuel Pitoiset Date: Thu, 28 Sep 2017 11:50:56 +0000 (+0200) Subject: radv: cleanup radv_device_finish_meta_XXX() helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=06dbe0722f8109d8cc7b1c7edf0dc3d4ce6f0d08;p=mesa.git radv: cleanup radv_device_finish_meta_XXX() helpers Unnecessary to double check that handles are not NULL. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c index 7d9f7f90263..a0be498de50 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 751f5914fce..946c741a27a 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 f95d8823fcc..ea11ed18c4f 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 d73420aef9c..cb028dccdcc 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 9b67c062d6c..64d3bac7f1b 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 fe18ddfb91f..c68be27f1f6 100644 --- a/src/amd/vulkan/radv_meta_decompress.c +++ b/src/amd/vulkan/radv_meta_decompress.c @@ -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); } } diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c index 902fc92972e..a10630173ee 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 80b44c89e97..5141ae3baae 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