isl: Add a swizzle parameter to isl_buffer_fill_state()
[mesa.git] / src / intel / vulkan / anv_pass.c
index 83c57d0697dcd3ae15f3d6e9f1eb21cf5475b1fb..02f2be60e0299849e0d7364ccb705ba2c9aa4c74 100644 (file)
@@ -74,6 +74,10 @@ anv_render_pass_compile(struct anv_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 anv_subpass_attachment *subpass_att = &subpass->attachments[j];
          if (subpass_att->attachment == VK_ATTACHMENT_UNUSED)
@@ -100,7 +104,7 @@ anv_render_pass_compile(struct anv_render_pass *pass)
       }
 
       /* We have to handle resolve attachments specially */
-      subpass->has_resolve = false;
+      subpass->has_color_resolve = false;
       if (subpass->resolve_attachments) {
          for (uint32_t j = 0; j < subpass->color_count; j++) {
             struct anv_subpass_attachment *color_att =
@@ -110,12 +114,22 @@ anv_render_pass_compile(struct anv_render_pass *pass)
             if (resolve_att->attachment == VK_ATTACHMENT_UNUSED)
                continue;
 
-            subpass->has_resolve = true;
+            subpass->has_color_resolve = true;
 
             assert(resolve_att->usage == VK_IMAGE_USAGE_TRANSFER_DST_BIT);
             color_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
          }
       }
+
+      if (subpass->ds_resolve_attachment) {
+         struct anv_subpass_attachment *ds_att =
+            subpass->depth_stencil_attachment;
+         UNUSED struct anv_subpass_attachment *resolve_att =
+            subpass->ds_resolve_attachment;
+
+         assert(resolve_att->usage == VK_IMAGE_USAGE_TRANSFER_DST_BIT);
+         ds_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+      }
    }
 
    /* From the Vulkan 1.0.39 spec:
@@ -342,10 +356,15 @@ VkResult anv_CreateRenderPass(
 static unsigned
 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 anv_CreateRenderPass2KHR(
@@ -460,6 +479,22 @@ VkResult anv_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 = subpass_attachments++;
+
+         *subpass->ds_resolve_attachment = (struct anv_subpass_attachment) {
+            .usage =       VK_IMAGE_USAGE_TRANSFER_DST_BIT,
+            .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 (uint32_t i = 0; i < pCreateInfo->dependencyCount; i++)