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: 05f96dd00f ("tu: Add core FDM patchpoint infrastructure")
Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32968>
This commit is contained in:
Karmjit Mahil 2025-01-10 10:34:17 +01:00 committed by Marge Bot
parent cfc09517b6
commit 0dd06c74d6
2 changed files with 3 additions and 8 deletions

View file

@ -19,6 +19,3 @@ spec@egl_khr_gl_colorspace@linear
# The ones that weren't being skipped were causing leaks # The ones that weren't being skipped were causing leaks
asan-dEQP-VK.image.swapchain_mutable.* asan-dEQP-VK.image.swapchain_mutable.*
asan-dEQP-VK.wsi.* asan-dEQP-VK.wsi.*
# Leaky in Turnip
asan-dEQP-VK.dynamic_rendering.*_cmd_buff.fragment_density_map.*

View file

@ -2690,7 +2690,7 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer,
cmd_buffer->state.subpass->color_count); cmd_buffer->state.subpass->color_count);
cmd_buffer->state.dirty |= TU_CMD_DIRTY_SUBPASS; 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 /* 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 * 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_renderpass_begin(cmd);
tu_emit_subpass_begin<CHIP>(cmd); tu_emit_subpass_begin<CHIP>(cmd);
if (pass->has_fdm) cmd->patchpoints_ctx = ralloc_context(NULL);
cmd->patchpoints_ctx = ralloc_parent(NULL);
} }
TU_GENX(tu_CmdBeginRenderPass2); TU_GENX(tu_CmdBeginRenderPass2);
@ -4867,7 +4866,6 @@ tu_CmdBeginRendering(VkCommandBuffer commandBuffer,
}; };
vk_cmd_set_rendering_attachment_locations(&cmd->vk, &ral_info); 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; a = cmd->dynamic_subpass.fsr_attachment;