From 5594cb90acf128643738fdfe121168ece76e8149 Mon Sep 17 00:00:00 2001 From: Luigi Santivetti Date: Fri, 6 Feb 2026 21:52:13 +0000 Subject: [PATCH] pvr: keep compiler resources in sync with attachments Do not assume that the application always provides images for backing attachments. The app can provide a super set of attachments of which only some are actually backed with images. We want to filter-out attachments that aren't meaningful for rendering or sampling, and create compiler resources only for relevant ones. Fix assert in CTS: pvr_arch_mrt.c:215: pvr_rogue_init_usc_mrt_setup: Assertion `att_format != VK_FORMAT_UNDEFINED' failed. Seen in pipeline monolithic, for instance: dEQP-VK.pipeline.monolithic.multisample.misc.dynamic_rendering.multi_renderpass.r8g8b8a8_unorm_r16g16b16a16_sfloat_r16g16b16a16_sint_d32_sfloat_s8_uint.random_127 Fixes: d549c1d045 ("pvr: add pipeline handling to use dynamic rendering info") Signed-off-by: Luigi Santivetti Acked-by: Frank Binns (cherry picked from commit 5473ca3be3a692eca9474d0f250de2f95ebcba0d) Part-of: --- .pick_status.json | 2 +- src/imagination/vulkan/pvr_arch_pipeline.c | 46 ++++++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a87549ce9db..9060a9ff0c9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5254,7 +5254,7 @@ "description": "pvr: keep compiler resources in sync with attachments", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "d549c1d0455010664e8a28cb12654b75381fcfe8", "notes": null diff --git a/src/imagination/vulkan/pvr_arch_pipeline.c b/src/imagination/vulkan/pvr_arch_pipeline.c index 7185a48cda8..a0ed72438f2 100644 --- a/src/imagination/vulkan/pvr_arch_pipeline.c +++ b/src/imagination/vulkan/pvr_arch_pipeline.c @@ -2114,6 +2114,9 @@ pvr_init_fs_input_attachments_mrt(pco_data *data, VkFormat vk_format = rp->color_attachment_formats[u]; bool has_stencil = vk_format_has_stencil(vk_format); + if (vk_format == VK_FORMAT_UNDEFINED) + continue; + fs->ia_formats[u] = vk_format_to_pipe_format(vk_format); assert(fs->ia_formats[u] != PIPE_FORMAT_NONE); if (has_stencil) @@ -2743,18 +2746,53 @@ pvr_graphics_pipeline_compile(struct pvr_device *const device, &gfx_pipeline->shader_state.vertex; struct pvr_fragment_shader_state *fragment_state = &gfx_pipeline->shader_state.fragment; - struct usc_mrt_setup mrt_setup = { 0 }; if (!pCreateInfo->renderPass) { const struct vk_render_pass_state *rp = state->rp; + VkFormat attachment_formats[rp->color_attachment_count]; + uint32_t mrt_attachment_map[rp->color_attachment_count]; + struct usc_mrt_setup mrt_setup_tmp = { 0 }; + uint32_t mrt_count = 0; + + for (uint32_t i = 0; i < rp->color_attachment_count; i++) { + if (rp->color_attachment_formats[i] == VK_FORMAT_UNDEFINED) { + mrt_attachment_map[i] = VK_ATTACHMENT_UNUSED; + attachment_formats[mrt_count] = VK_FORMAT_UNDEFINED; + continue; + } + + mrt_attachment_map[i] = mrt_count; + attachment_formats[mrt_count++] = rp->color_attachment_formats[i]; + } result = pvr_arch_init_usc_mrt_setup(device, - rp->color_attachment_count, - rp->color_attachment_formats, - &mrt_setup); + mrt_count, + attachment_formats, + &mrt_setup_tmp); if (result != VK_SUCCESS) return result; + + result = + pvr_arch_mrt_setup_partial_init(device, + &mrt_setup, + rp->color_attachment_count, + mrt_setup_tmp.num_output_regs, + mrt_setup_tmp.num_tile_buffers); + if (result != VK_SUCCESS) { + pvr_arch_destroy_mrt_setup(device, &mrt_setup_tmp); + return result; + } + + for (uint32_t i = 0; i < rp->color_attachment_count; i++) { + if (mrt_attachment_map[i] != VK_ATTACHMENT_UNUSED) { + memcpy(&mrt_setup.mrt_resources[i], + &mrt_setup_tmp.mrt_resources[mrt_attachment_map[i]], + sizeof(mrt_setup_tmp.mrt_resources[0])); + } + } + + pvr_arch_destroy_mrt_setup(device, &mrt_setup_tmp); } pco_ctx *pco_ctx = device->pdevice->pco_ctx;