Module: Mesa Branch: main Commit: 41a9af4819daaa8573e2726bca838f32dfce2726 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=41a9af4819daaa8573e2726bca838f32dfce2726
Author: Karmjit Mahil <[email protected]> Date: Sun Sep 24 14:14:15 2023 +0100 pvr: Refactor subpass ds and sample count setup Now we first check the sample count from the ds attachment as well as setting it up. 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 | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/imagination/vulkan/pvr_pass.c b/src/imagination/vulkan/pvr_pass.c index 7c8d9aec132..027ac7af73c 100644 --- a/src/imagination/vulkan/pvr_pass.c +++ b/src/imagination/vulkan/pvr_pass.c @@ -520,10 +520,8 @@ 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: @@ -535,6 +533,18 @@ VkResult pvr_CreateRenderPass2(VkDevice _device, * not VK_ATTACHMENT_UNUSED must have the same sample count" * */ + subpass->sample_count = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM; + + if (desc->pDepthStencilAttachment) { + uint32_t index = desc->pDepthStencilAttachment->attachment; + + if (index != VK_ATTACHMENT_UNUSED) + subpass->sample_count = pass->attachments[index].sample_count; + + subpass->depth_stencil_attachment = index; + } else { + subpass->depth_stencil_attachment = VK_ATTACHMENT_UNUSED; + } subpass->color_count = desc->colorAttachmentCount; if (subpass->color_count > 0) { @@ -542,26 +552,22 @@ VkResult pvr_CreateRenderPass2(VkDevice _device, 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; if (subpass->color_attachments[j] == VK_ATTACHMENT_UNUSED) continue; - index = subpass->color_attachments[j]; - subpass->sample_count = pass->attachments[index].sample_count; - has_used_color_attachment = true; + if (subpass->sample_count == VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM) { + uint32_t index; + index = subpass->color_attachments[j]; + 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 (subpass->sample_count == VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM) + subpass->sample_count = VK_SAMPLE_COUNT_1_BIT; if (desc->pResolveAttachments) { subpass->resolve_attachments = subpass_attachments; @@ -584,13 +590,6 @@ VkResult pvr_CreateRenderPass2(VkDevice _device, } } - if (desc->pDepthStencilAttachment) { - subpass->depth_stencil_attachment = - desc->pDepthStencilAttachment->attachment; - } else { - subpass->depth_stencil_attachment = VK_ATTACHMENT_UNUSED; - } - /* Give the dependencies a slice of the subpass_attachments array. */ subpass->dep_list = dep_list; dep_list += subpass->dep_count;
