Mesa (main): v3dv: allow batching texel buffer copies for 3D images

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 13 10:35:01 UTC 2021


Module: Mesa
Branch: main
Commit: a89cd7f9bb2a25cb8ad428cbd0c4f6ffaa751bb2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a89cd7f9bb2a25cb8ad428cbd0c4f6ffaa751bb2

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Tue Jul 13 09:23:13 2021 +0200

v3dv: allow batching texel buffer copies for 3D images

For these we only need to check that the depth extent we are
copying is the same across regions in the batch, since we use
that to specify the number of layers in the framebuffer used
for the copy.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11843>

---

 src/broadcom/vulkan/v3dv_meta_copy.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c
index 793b704f0c6..a96ea5eec9a 100644
--- a/src/broadcom/vulkan/v3dv_meta_copy.c
+++ b/src/broadcom/vulkan/v3dv_meta_copy.c
@@ -2147,7 +2147,8 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
    /* Compute the number of layers to copy.
     *
     * If we are batching (region_count > 1) all our regions have the same
-    * image subresource so we can take this from the first region.
+    * image subresource so we can take this from the first region. For 3D
+    * images we require the same depth extent.
     */
    const VkImageSubresourceLayers *resource = &regions[0].imageSubresource;
    uint32_t num_layers;
@@ -2858,18 +2859,26 @@ v3dv_CmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer,
 
       /* Otherwise, we are copying subrects, so we fallback to copying
        * via shader and texel buffers and we try to batch the regions
-       * if possible. We can only batch copies if they target the same
-       * image subresource (so they have the same framebuffer spec).
+       * if possible. We can only batch copies if they have the same
+       * framebuffer spec, which is mostly determined by the image
+       * subresource of the region.
        */
       const VkImageSubresourceLayers *rsc = &info->pRegions[r].imageSubresource;
-      if (image->type != VK_IMAGE_TYPE_3D) {
-         for (uint32_t s = r + 1; s < info->regionCount; s++) {
-            const VkImageSubresourceLayers *rsc_s =
-               &info->pRegions[s].imageSubresource;
-            if (memcmp(rsc, rsc_s, sizeof(VkImageSubresourceLayers)) != 0)
+      for (uint32_t s = r + 1; s < info->regionCount; s++) {
+         const VkImageSubresourceLayers *rsc_s =
+            &info->pRegions[s].imageSubresource;
+
+         if (memcmp(rsc, rsc_s, sizeof(VkImageSubresourceLayers)) != 0)
+            break;
+
+         /* For 3D images we also need to check the depth extent */
+         if (image->type == VK_IMAGE_TYPE_3D &&
+             info->pRegions[s].imageExtent.depth !=
+             info->pRegions[r].imageExtent.depth) {
                break;
-            batch_size++;
          }
+
+         batch_size++;
       }
 
       if (copy_buffer_to_image_shader(cmd_buffer, image, buffer,



More information about the mesa-commit mailing list