From fee3c420b30eec36d414fe3f34622a81ada996fc Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 9 Feb 2026 14:52:04 -0500 Subject: [PATCH] panvk/meta: Set color_attachment_count based on bound attachments Reviewed-by: Lars-Ivar Hesselberg Simonsen Acked-by: Boris Brezillon Acked-by: Eric R. Smith Part-of: --- src/panfrost/vulkan/panvk_vX_cmd_meta.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_cmd_meta.c b/src/panfrost/vulkan/panvk_vX_cmd_meta.c index c6cfc1b69a9..672e5dea538 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_meta.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_meta.c @@ -236,16 +236,21 @@ panvk_per_arch(CmdClearAttachments)(VkCommandBuffer commandBuffer, struct vk_meta_rendering_info render = { .view_mask = cmdbuf->state.gfx.render.view_mask, .samples = cmdbuf->state.gfx.render.fb.nr_samples, - .color_attachment_count = cmdbuf->state.gfx.render.fb.layout.rt_count, .depth_attachment_format = cmdbuf->state.gfx.render.z_attachment.fmt, .stencil_attachment_format = cmdbuf->state.gfx.render.s_attachment.fmt, }; - for (uint32_t i = 0; i < render.color_attachment_count; i++) { - render.color_attachment_formats[i] = - cmdbuf->state.gfx.render.color_attachments.fmts[i]; - render.color_attachment_write_masks[i] = - VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | - VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + for (uint32_t i = 0; i < MAX_RTS; i++) { + if (!(cmdbuf->state.gfx.render.bound_attachments & + MESA_VK_RP_ATTACHMENT_COLOR_BIT(i))) + continue; + + render.color_attachment_count = + MAX2(render.color_attachment_count, i + 1); + render.color_attachment_formats[i] = + cmdbuf->state.gfx.render.color_attachments.fmts[i]; + render.color_attachment_write_masks[i] = + VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | + VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; } meta_gfx_start(cmdbuf, &save);