Module: Mesa Branch: main Commit: e07cff4ac560a317457d39257565f72b041f8217 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e07cff4ac560a317457d39257565f72b041f8217
Author: Karmjit Mahil <[email protected]> Date: Sun Sep 24 13:54:49 2023 +0100 pvr: Fix subpass sample count on ds attachment only When no color attachments were used in a subpass, the sample count was left unchanged to `1` while we should instead have picked it up from the ds attachment if there was one. Signed-off-by: Karmjit Mahil <[email protected]> Reviewed-by: Frank Binns <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25584> --- src/imagination/vulkan/pvr_pass.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/imagination/vulkan/pvr_pass.c b/src/imagination/vulkan/pvr_pass.c index eca2934af84..7c8d9aec132 100644 --- a/src/imagination/vulkan/pvr_pass.c +++ b/src/imagination/vulkan/pvr_pass.c @@ -520,19 +520,30 @@ VkResult pvr_CreateRenderPass2(VkDevice _device, for (uint32_t i = 0; i < pass->subpass_count; i++) { const VkSubpassDescription2 *desc = &pCreateInfo->pSubpasses[i]; struct pvr_render_subpass *subpass = &pass->subpasses[i]; + bool has_used_color_attachment = false; subpass->pipeline_bind_point = desc->pipelineBindPoint; subpass->sample_count = 1; + /* From the Vulkan spec. 1.3.265 + * VUID-VkSubpassDescription2-multisampledRenderToSingleSampled-06872: + * + * "If none of the VK_AMD_mixed_attachment_samples extension, the + * VK_NV_framebuffer_mixed_samples extension, or the + * multisampledRenderToSingleSampled feature are enabled, all + * attachments in pDepthStencilAttachment or pColorAttachments that are + * not VK_ATTACHMENT_UNUSED must have the same sample count" + * + */ + subpass->color_count = desc->colorAttachmentCount; if (subpass->color_count > 0) { - bool has_used_color_attachment = false; - uint32_t index; - subpass->color_attachments = subpass_attachments; subpass_attachments += subpass->color_count; for (uint32_t j = 0; j < subpass->color_count; j++) { + uint32_t index; + subpass->color_attachments[j] = desc->pColorAttachments[j].attachment; @@ -543,13 +554,13 @@ VkResult pvr_CreateRenderPass2(VkDevice _device, subpass->sample_count = pass->attachments[index].sample_count; has_used_color_attachment = true; } + } - if (!has_used_color_attachment && desc->pDepthStencilAttachment && - desc->pDepthStencilAttachment->attachment != - VK_ATTACHMENT_UNUSED) { - index = desc->pDepthStencilAttachment->attachment; - subpass->sample_count = pass->attachments[index].sample_count; - } + if (!has_used_color_attachment && desc->pDepthStencilAttachment && + desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { + uint32_t index; + index = desc->pDepthStencilAttachment->attachment; + subpass->sample_count = pass->attachments[index].sample_count; } if (desc->pResolveAttachments) {
