radv: record if a render pass has depth/stencil resolve attachments
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 20 May 2019 09:47:02 +0000 (11:47 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Jun 2019 12:50:12 +0000 (14:50 +0200)
Only supported with vkCreateRenderPass2().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_pass.c
src/amd/vulkan/radv_private.h

index 728b611320686f1994f3669724ef4c740436869e..688a17919bd482d1be660fe33afbdb03596bd3fd 100644 (file)
@@ -91,6 +91,10 @@ radv_render_pass_compile(struct radv_render_pass *pass)
                    subpass->depth_stencil_attachment->attachment == VK_ATTACHMENT_UNUSED)
                        subpass->depth_stencil_attachment = NULL;
 
+               if (subpass->ds_resolve_attachment &&
+                   subpass->ds_resolve_attachment->attachment == VK_ATTACHMENT_UNUSED)
+                       subpass->ds_resolve_attachment = NULL;
+
                for (uint32_t j = 0; j < subpass->attachment_count; j++) {
                        struct radv_subpass_attachment *subpass_att =
                                &subpass->attachments[j];
@@ -309,10 +313,15 @@ VkResult radv_CreateRenderPass(
 static unsigned
 radv_num_subpass_attachments2(const VkSubpassDescription2KHR *desc)
 {
+       const VkSubpassDescriptionDepthStencilResolveKHR *ds_resolve =
+               vk_find_struct_const(desc->pNext,
+                                    SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR);
+
        return desc->inputAttachmentCount +
               desc->colorAttachmentCount +
               (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
-              (desc->pDepthStencilAttachment != NULL);
+              (desc->pDepthStencilAttachment != NULL) +
+              (ds_resolve && ds_resolve->pDepthStencilResolveAttachment);
 }
 
 VkResult radv_CreateRenderPass2KHR(
@@ -429,6 +438,22 @@ VkResult radv_CreateRenderPass2KHR(
                                .layout = desc->pDepthStencilAttachment->layout,
                        };
                }
+
+               const VkSubpassDescriptionDepthStencilResolveKHR *ds_resolve =
+                       vk_find_struct_const(desc->pNext,
+                                            SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR);
+
+               if (ds_resolve && ds_resolve->pDepthStencilResolveAttachment) {
+                       subpass->ds_resolve_attachment = p++;
+
+                       *subpass->ds_resolve_attachment = (struct radv_subpass_attachment) {
+                               .attachment =  ds_resolve->pDepthStencilResolveAttachment->attachment,
+                               .layout =      ds_resolve->pDepthStencilResolveAttachment->layout,
+                       };
+
+                       subpass->depth_resolve_mode = ds_resolve->depthResolveMode;
+                       subpass->stencil_resolve_mode = ds_resolve->stencilResolveMode;
+               }
        }
 
        for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
index 6cebc738d49aef25b45bd38f7da8e3215fde3465..1b7191c1b99bc7e4473e37d00ac66893e3015122 100644 (file)
@@ -1953,6 +1953,9 @@ struct radv_subpass {
        struct radv_subpass_attachment *             color_attachments;
        struct radv_subpass_attachment *             resolve_attachments;
        struct radv_subpass_attachment *             depth_stencil_attachment;
+       struct radv_subpass_attachment *             ds_resolve_attachment;
+       VkResolveModeFlagBitsKHR                     depth_resolve_mode;
+       VkResolveModeFlagBitsKHR                     stencil_resolve_mode;
 
        /** Subpass has at least one color resolve attachment */
        bool                                         has_color_resolve;