Module: Mesa
Branch: staging/22.2
Commit: 066c68264784bdb39a01e8e0987778a4e671c420
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=066c68264784bdb39a01e8e0987778a4e671c420

Author: Jason Ekstrand <[email protected]>
Date:   Thu Jun  2 11:12:14 2022 -0500

radv: Use both aspects for depth/stencil blit destinations

Even with dynamic rendering, you have to bind both aspects of the image
if the image contains both depth and stencil.  One day, we may see this
restriction lifted but that will require deeper driver surgery into the
way we handle depth/stencil layouts.

Fixes: 42db5900061c ("radv: convert the meta blit 2d path to dynamic rendering")
Reviewed-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18084>
(cherry picked from commit 76b8b854a514bc515ddba47f4fbbf6ea80bcf0f2)

---

 .pick_status.json                 |  2 +-
 src/amd/vulkan/radv_meta_blit.c   | 73 +++++++++++++++++++++------------------
 src/amd/vulkan/radv_meta_blit2d.c |  4 +++
 3 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index fb4f19bb43e..3ef87a83084 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -11767,7 +11767,7 @@
         "description": "radv: Use both aspects for depth/stencil blit 
destinations",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "42db5900061c80154652237347285fee703d4a7c"
     },
diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index c07d86f242c..a95466c9485 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -267,21 +267,11 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct 
radv_image *src_image,
    unsigned fs_key = 0;
    VkFormat format = VK_FORMAT_UNDEFINED;
 
-   VkRenderingAttachmentInfo color_att = {0}, depth_att = {0}, stencil_att = 
{0};
-
    switch (src_iview->vk.aspects) {
    case VK_IMAGE_ASPECT_COLOR_BIT: {
-      unsigned dst_layout = 
radv_meta_dst_layout_from_layout(dest_image_layout);
-      VkImageLayout layout = radv_meta_dst_layout_to_layout(dst_layout);
       fs_key = radv_format_meta_fs_key(device, dest_image->vk.format);
       format = radv_fs_key_format_exemplars[fs_key];
 
-      color_att.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
-      color_att.imageView = radv_image_view_to_handle(dest_iview);
-      color_att.imageLayout = layout;
-      color_att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
-      color_att.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
-
       switch (src_image->vk.image_type) {
       case VK_IMAGE_TYPE_1D:
          pipeline = &device->meta_state.blit.pipeline_1d_src[fs_key];
@@ -298,16 +288,8 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct 
radv_image *src_image,
       break;
    }
    case VK_IMAGE_ASPECT_DEPTH_BIT: {
-      enum radv_blit_ds_layout ds_layout = 
radv_meta_blit_ds_to_type(dest_image_layout);
-      VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
       format = VK_FORMAT_D32_SFLOAT;
 
-      depth_att.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
-      depth_att.imageView = radv_image_view_to_handle(dest_iview);
-      depth_att.imageLayout = layout;
-      depth_att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
-      depth_att.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
-
       switch (src_image->vk.image_type) {
       case VK_IMAGE_TYPE_1D:
          pipeline = &device->meta_state.blit.depth_only_1d_pipeline;
@@ -324,16 +306,8 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct 
radv_image *src_image,
       break;
    }
    case VK_IMAGE_ASPECT_STENCIL_BIT: {
-      enum radv_blit_ds_layout ds_layout = 
radv_meta_blit_ds_to_type(dest_image_layout);
-      VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
       format = VK_FORMAT_S8_UINT;
 
-      stencil_att.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
-      stencil_att.imageView = radv_image_view_to_handle(dest_iview);
-      stencil_att.imageLayout = layout;
-      stencil_att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
-      stencil_att.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
-
       switch (src_image->vk.image_type) {
       case VK_IMAGE_TYPE_1D:
          pipeline = &device->meta_state.blit.stencil_only_1d_pipeline;
@@ -408,17 +382,50 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct 
radv_image *src_image,
       .layerCount = 1,
    };
 
-   switch (src_iview->image->vk.aspects) {
-   case VK_IMAGE_ASPECT_COLOR_BIT:
+   VkRenderingAttachmentInfo color_att;
+   if (src_iview->image->vk.aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
+      unsigned dst_layout = 
radv_meta_dst_layout_from_layout(dest_image_layout);
+      VkImageLayout layout = radv_meta_dst_layout_to_layout(dst_layout);
+
+      color_att = (VkRenderingAttachmentInfo) {
+         .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
+         .imageView = radv_image_view_to_handle(dest_iview),
+         .imageLayout = layout,
+         .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+         .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+      };
       rendering_info.colorAttachmentCount = 1;
       rendering_info.pColorAttachments = &color_att;
-      break;
-   case VK_IMAGE_ASPECT_DEPTH_BIT:
+   }
+
+   VkRenderingAttachmentInfo depth_att;
+   if (src_iview->image->vk.aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
+      enum radv_blit_ds_layout ds_layout = 
radv_meta_blit_ds_to_type(dest_image_layout);
+      VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
+
+      depth_att = (VkRenderingAttachmentInfo) {
+         .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
+         .imageView = radv_image_view_to_handle(dest_iview),
+         .imageLayout = layout,
+         .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+         .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+      };
       rendering_info.pDepthAttachment = &depth_att;
-      break;
-   case VK_IMAGE_ASPECT_STENCIL_BIT:
+   }
+
+   VkRenderingAttachmentInfo stencil_att;
+   if (src_iview->image->vk.aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
+      enum radv_blit_ds_layout ds_layout = 
radv_meta_blit_ds_to_type(dest_image_layout);
+      VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
+
+      stencil_att = (VkRenderingAttachmentInfo) {
+         .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
+         .imageView = radv_image_view_to_handle(dest_iview),
+         .imageLayout = layout,
+         .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+         .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+      };
       rendering_info.pStencilAttachment = &stencil_att;
-      break;
    }
 
    radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), 
&rendering_info);
diff --git a/src/amd/vulkan/radv_meta_blit2d.c 
b/src/amd/vulkan/radv_meta_blit2d.c
index 7580e6b0fd2..8a90bfd1478 100644
--- a/src/amd/vulkan/radv_meta_blit2d.c
+++ b/src/amd/vulkan/radv_meta_blit2d.c
@@ -298,6 +298,8 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer 
*cmd_buffer,
                },
                .layerCount = 1,
                .pDepthAttachment = &depth_att_info,
+               .pStencilAttachment = (dst->image->vk.aspects & 
VK_IMAGE_ASPECT_STENCIL_BIT) ?
+                                     &depth_att_info : NULL,
             };
 
             radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), 
&rendering_info);
@@ -329,6 +331,8 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer 
*cmd_buffer,
                   .extent = { rects[r].width, rects[r].height },
                },
                .layerCount = 1,
+               .pDepthAttachment = (dst->image->vk.aspects & 
VK_IMAGE_ASPECT_DEPTH_BIT) ?
+                                   &stencil_att_info : NULL,
                .pStencilAttachment = &stencil_att_info,
             };
 

Reply via email to