radv: Add RGP barrier markers for render pass transition and copy.
authorTatsuyuki Ishi <ishitatsuyuki@gmail.com>
Wed, 1 Feb 2023 08:27:26 +0000 (17:27 +0900)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Jun 2023 11:55:03 +0000 (11:55 +0000)
This allows them to be attributed to the correct event instead of being
blend to the previous barrier.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21033>

src/amd/vulkan/meta/radv_meta_copy.c
src/amd/vulkan/radv_cmd_buffer.c

index 1f90698..b29aeb4 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "radv_meta.h"
+#include "radv_private.h"
 #include "vk_format.h"
 
 static VkFormat
@@ -142,6 +143,8 @@ copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buf
          radv_layout_dcc_compressed(cmd_buffer->device, image, region->imageSubresource.mipLevel,
                                     layout, queue_mask);
       if (compressed) {
+         radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_UNKNOWN_REASON);
+
          radv_decompress_dcc(cmd_buffer, image,
                              &(VkImageSubresourceRange){
                                 .aspectMask = region->imageSubresource.aspectMask,
@@ -151,6 +154,8 @@ copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buf
                                 .layerCount = region->imageSubresource.layerCount,
                              });
          img_bsurf.disable_compression = true;
+
+         radv_describe_barrier_end(cmd_buffer);
       }
       img_bsurf.format = vk_format_for_size(vk_format_get_blocksize(img_bsurf.format));
    }
@@ -292,6 +297,8 @@ copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buf
       bool compressed = radv_layout_dcc_compressed(device, image, region->imageSubresource.mipLevel,
                                                    layout, queue_mask);
       if (compressed) {
+         radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_UNKNOWN_REASON);
+
          radv_decompress_dcc(cmd_buffer, image,
                              &(VkImageSubresourceRange){
                                 .aspectMask = region->imageSubresource.aspectMask,
@@ -301,6 +308,8 @@ copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buf
                                 .layerCount = region->imageSubresource.layerCount,
                              });
          img_info.disable_compression = true;
+
+         radv_describe_barrier_end(cmd_buffer);
       }
       img_info.format = vk_format_for_size(vk_format_get_blocksize(img_info.format));
    }
@@ -393,7 +402,9 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
            region->extent.width != dst_image->vk.extent.width ||
            region->extent.height != dst_image->vk.extent.height ||
            region->extent.depth != dst_image->vk.extent.depth)) {
-         u_foreach_bit(i, region->dstSubresource.aspectMask) {
+         radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_UNKNOWN_REASON);
+
+         u_foreach_bit (i, region->dstSubresource.aspectMask) {
             unsigned aspect_mask = 1u << i;
             radv_expand_depth_stencil(cmd_buffer, dst_image,
                                       &(VkImageSubresourceRange){
@@ -402,8 +413,11 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
                                          .levelCount = 1,
                                          .baseArrayLayer = region->dstSubresource.baseArrayLayer,
                                          .layerCount = region->dstSubresource.layerCount,
-                                      }, NULL);
+                                      },
+                                      NULL);
          }
+
+         radv_describe_barrier_end(cmd_buffer);
       }
    }
 
@@ -454,6 +468,8 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
       } else if (!dst_compressed) {
          b_dst.format = b_src.format;
       } else {
+         radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_UNKNOWN_REASON);
+
          radv_decompress_dcc(cmd_buffer, dst_image,
                              &(VkImageSubresourceRange){
                                 .aspectMask = dst_aspects[a],
@@ -464,6 +480,8 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
                              });
          b_dst.format = b_src.format;
          b_dst.disable_compression = true;
+
+         radv_describe_barrier_end(cmd_buffer);
       }
 
       /**
@@ -537,6 +555,7 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
 
       if (radv_layout_is_htile_compressed(cmd_buffer->device, dst_image, dst_image_layout,
                                           queue_mask)) {
+         radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_UNKNOWN_REASON);
 
          cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_INV_VCACHE;
 
@@ -551,6 +570,8 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
          uint32_t htile_value = radv_get_htile_initial_value(cmd_buffer->device, dst_image);
 
          cmd_buffer->state.flush_bits |= radv_clear_htile(cmd_buffer, dst_image, &range, htile_value);
+
+         radv_describe_barrier_end(cmd_buffer);
       }
    }
 
index cb5731b..d2644a4 100644 (file)
@@ -7856,6 +7856,12 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe
                    sample_locs_info->sampleLocationsCount);
    }
 
+   /* Implicit transitions only happens if traditional render passes are used.
+    * Some meta shaders invoked during barrier handling could call CmdBeginRendering, and we need to
+    * take care to not call radv_describe_barrier_start recursively.
+    */
+   if (cmd_buffer->vk.render_pass)
+      radv_describe_barrier_start(cmd_buffer, RGP_BARRIER_EXTERNAL_RENDER_PASS_SYNC);
    uint32_t color_samples = 0, ds_samples = 0;
    struct radv_attachment color_att[MAX_RTS];
    for (uint32_t i = 0; i < pRenderingInfo->colorAttachmentCount; i++) {
@@ -7951,6 +7957,8 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe
                                                 &sample_locations);
       }
    }
+   if (cmd_buffer->vk.render_pass)
+      radv_describe_barrier_end(cmd_buffer);
 
    const VkRenderingFragmentShadingRateAttachmentInfoKHR *fsr_info =
       vk_find_struct_const(pRenderingInfo->pNext,