pvr: Add missing support for preserve attachments

In subpasses preserve attachments are not used by the subpass but
their contents must be preserved throughout the subpass.

Add a list for the preserve attachments info specified by a subpass
and when determining a subpass attachments total uses check the
preserve attachments list and add it uses to the total.

Partial fix for:
dEQP-VK.renderpass.*.attachment_allocation.input_output.71

Backport-to: 26.0

Signed-off-by: Nick Hamilton <nick.hamilton@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
(cherry picked from commit 0e01b9ef2d)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
Nick Hamilton 2026-02-20 16:40:39 +00:00 committed by Eric Engestrom
parent a965c71ec6
commit 022e34b5f3
4 changed files with 36 additions and 5 deletions

View file

@ -504,7 +504,7 @@
"description": "pvr: Add missing support for preserve attachments",
"nominated": true,
"nomination_type": 4,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -2290,6 +2290,10 @@ static VkResult pvr_schedule_subpass(const struct pvr_device *device,
subpass_num,
subpass->input_attachments,
subpass->input_count);
pvr_dereference_surface_list(ctx,
subpass_num,
subpass->preserve_attachments,
subpass->preserve_count);
if (subpass->depth_stencil_attachment != VK_ATTACHMENT_UNUSED) {
struct pvr_render_int_attachment *int_depth_attach =
&ctx->int_attach[subpass->depth_stencil_attachment];
@ -2595,6 +2599,11 @@ VkResult pvr_arch_create_renderpass_hwsetup(
subpass->input_count,
i);
const uint32_t preserve_attachment_uses =
pvr_count_uses_in_attachment_list(subpass->preserve_attachments,
subpass->preserve_count,
i);
uint32_t resolve_output_uses;
uint32_t color_output_uses;
uint32_t total_output_uses;
@ -2604,13 +2613,13 @@ VkResult pvr_arch_create_renderpass_hwsetup(
&color_output_uses,
&resolve_output_uses);
total_output_uses = color_output_uses + resolve_output_uses;
total_output_uses = color_output_uses + resolve_output_uses +
input_attachment_uses + preserve_attachment_uses;
if (total_output_uses != 0U || input_attachment_uses != 0U)
if (total_output_uses != 0U)
int_attach->last_read = j;
int_attach->remaining_count +=
total_output_uses + input_attachment_uses;
int_attach->remaining_count += total_output_uses;
if ((uint32_t)subpass->depth_stencil_attachment == i)
int_attach->remaining_count++;

View file

@ -763,7 +763,9 @@ PVR_PER_ARCH(CreateRenderPass2)(VkDevice _device,
const VkAllocationCallbacks *alloc;
size_t subpass_attachment_count;
size_t subpass_input_attachment_count;
size_t subpass_preserve_attachment_count;
struct pvr_render_attachment *subpass_input_attachments;
struct pvr_render_attachment *subpass_preserve_attachments;
uint32_t *subpass_attachments;
struct pvr_render_pass *pass;
uint32_t *dep_list;
@ -785,12 +787,14 @@ PVR_PER_ARCH(CreateRenderPass2)(VkDevice _device,
subpass_attachment_count = 0;
subpass_input_attachment_count = 0;
subpass_preserve_attachment_count = 0;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
const VkSubpassDescription2 *desc = &pCreateInfo->pSubpasses[i];
subpass_attachment_count +=
desc->colorAttachmentCount +
(desc->pResolveAttachments ? desc->colorAttachmentCount : 0);
subpass_input_attachment_count += desc->inputAttachmentCount;
subpass_preserve_attachment_count += desc->preserveAttachmentCount;
}
vk_multialloc_add(&ma,
@ -801,6 +805,10 @@ PVR_PER_ARCH(CreateRenderPass2)(VkDevice _device,
&subpass_input_attachments,
__typeof__(*subpass_input_attachments),
subpass_input_attachment_count);
vk_multialloc_add(&ma,
&subpass_preserve_attachments,
__typeof__(*subpass_preserve_attachments),
subpass_preserve_attachment_count);
vk_multialloc_add(&ma,
&dep_list,
__typeof__(*dep_list),
@ -989,6 +997,17 @@ PVR_PER_ARCH(CreateRenderPass2)(VkDevice _device,
}
}
subpass->preserve_count = desc->preserveAttachmentCount;
if (subpass->preserve_count > 0) {
subpass->preserve_attachments = subpass_preserve_attachments;
subpass_preserve_attachments += subpass->preserve_count;
for (uint32_t j = 0; j < subpass->preserve_count; j++) {
subpass->preserve_attachments[j].attachment_idx =
desc->pPreserveAttachments[j];
}
}
/* Give the dependencies a slice of the subpass_attachments array. */
subpass->dep_list = dep_list;
dep_list += subpass->dep_count;

View file

@ -71,6 +71,9 @@ struct pvr_render_subpass {
uint32_t input_count;
struct pvr_render_attachment *input_attachments;
uint32_t preserve_count;
struct pvr_render_attachment *preserve_attachments;
uint32_t depth_stencil_attachment;
uint32_t depth_stencil_resolve_attachment;