From 0dd06c74d6531d25eaa01f23ebccf151c303335e Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Fri, 10 Jan 2025 10:34:17 +0100 Subject: [PATCH] tu: Fix FDM patchpoint memory leak We can disable FDM in the renderpass based on `tu_render_pass_disable_fdm()` however a pipeline could have been bound before starting the renderpass which had `...RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT` set, in which case the shader is compiled with FDM support. We still need to apply the patchpoints. Previously `patchpoints_ctx` was created only based on whether FDM was enabled in the renderpass, which was leading to the patchpoints being allocated with no context so they were never getting freed. Now setup `patchpoint_ctx` regardless of FDM being disabled or not. Fixes memory leaks in some tests from: dEQP-VK.dynamic_rendering.*_cmd_buff.fragment_density_map.* e.g. dEQP-VK.dynamic_rendering.partial_secondary_cmd_buff .fragment_density_map.2_views .render.divisible_density_size .1_sample.static_subsampled_1_2 Fixes: 05f96dd00f3 ("tu: Add core FDM patchpoint infrastructure") Signed-off-by: Karmjit Mahil Part-of: --- src/freedreno/ci/freedreno-a630-skips.txt | 3 --- src/freedreno/vulkan/tu_cmd_buffer.cc | 8 +++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/freedreno/ci/freedreno-a630-skips.txt b/src/freedreno/ci/freedreno-a630-skips.txt index dd0551290a4..4d5264b0d06 100644 --- a/src/freedreno/ci/freedreno-a630-skips.txt +++ b/src/freedreno/ci/freedreno-a630-skips.txt @@ -19,6 +19,3 @@ spec@egl_khr_gl_colorspace@linear # The ones that weren't being skipped were causing leaks asan-dEQP-VK.image.swapchain_mutable.* asan-dEQP-VK.wsi.* - -# Leaky in Turnip -asan-dEQP-VK.dynamic_rendering.*_cmd_buff.fragment_density_map.* diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index ca88ab49b5f..3fa7431c62f 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -2690,7 +2690,7 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer, cmd_buffer->state.subpass->color_count); cmd_buffer->state.dirty |= TU_CMD_DIRTY_SUBPASS; - cmd_buffer->patchpoints_ctx = ralloc_parent(NULL); + cmd_buffer->patchpoints_ctx = ralloc_context(NULL); /* We can't set the gmem layout here, because the state.pass only has * to be compatible (same formats/sample counts) with the primary's @@ -4778,8 +4778,7 @@ tu_CmdBeginRenderPass2(VkCommandBuffer commandBuffer, tu_emit_renderpass_begin(cmd); tu_emit_subpass_begin(cmd); - if (pass->has_fdm) - cmd->patchpoints_ctx = ralloc_parent(NULL); + cmd->patchpoints_ctx = ralloc_context(NULL); } TU_GENX(tu_CmdBeginRenderPass2); @@ -4867,8 +4866,7 @@ tu_CmdBeginRendering(VkCommandBuffer commandBuffer, }; vk_cmd_set_rendering_attachment_locations(&cmd->vk, &ral_info); - if (cmd->dynamic_pass.has_fdm) - cmd->patchpoints_ctx = ralloc_context(NULL); + cmd->patchpoints_ctx = ralloc_context(NULL); a = cmd->dynamic_subpass.fsr_attachment; if (a != VK_ATTACHMENT_UNUSED) {