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 <luigi.santivetti@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
(cherry picked from commit 5473ca3be3)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Luigi Santivetti 2026-02-06 21:52:13 +00:00 committed by Eric Engestrom
parent ff902ec44b
commit 5594cb90ac
2 changed files with 43 additions and 5 deletions

View file

@ -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

View file

@ -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;