Mesa (staging/20.2): anv: fix source/destination layers for 3D blits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 2 16:09:40 UTC 2020


Module: Mesa
Branch: staging/20.2
Commit: 35b93d6f8aae0b5601e1886ee87c6fdfa0b12980
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=35b93d6f8aae0b5601e1886ee87c6fdfa0b12980

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Tue Sep 29 10:55:35 2020 +0300

anv: fix source/destination layers for 3D blits

When blitting from source depth range [0-3] into destination depth
range [0-2], we'll have to use a source layer that is in between 2
layers of the 3D source image.

Other than having an incorrect formula, we're also using integer which
prevent us from using the right source layer.

v2: Drop + 0.5 on application offsets

v3: Reuse num_layers (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3458
Cc: <mesa-stable at lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6909>
(cherry picked from commit ea326912575fad09af59486ad62d126c4ea0ede7)

---

 src/intel/vulkan/anv_blorp.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 8570879f37a..e313a6be87e 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -709,12 +709,19 @@ void anv_CmdBlitImage(
          }
 
          bool flip_z = flip_coords(&src_start, &src_end, &dst_start, &dst_end);
-         float src_z_step = (float)(src_end + 1 - src_start) /
-            (float)(dst_end + 1 - dst_start);
+         const unsigned num_layers = dst_end - dst_start;
+         float src_z_step = (float)(src_end - src_start) / (float)num_layers;
+
+         /* There is no interpolation to the pixel center during rendering, so
+          * add the 0.5 offset ourselves here. */
+         float depth_center_offset = 0;
+         if (src_image->type == VK_IMAGE_TYPE_3D)
+            depth_center_offset = 0.5 / num_layers * (src_end - src_start);
 
          if (flip_z) {
             src_start = src_end;
             src_z_step *= -1;
+            depth_center_offset *= -1;
          }
 
          unsigned src_x0 = pRegions[r].srcOffsets[0].x;
@@ -729,7 +736,6 @@ void anv_CmdBlitImage(
          unsigned dst_y1 = pRegions[r].dstOffsets[1].y;
          bool flip_y = flip_coords(&src_y0, &src_y1, &dst_y0, &dst_y1);
 
-         const unsigned num_layers = dst_end - dst_start;
          anv_cmd_buffer_mark_image_written(cmd_buffer, dst_image,
                                            1U << aspect_bit,
                                            dst.aux_usage,
@@ -738,7 +744,7 @@ void anv_CmdBlitImage(
 
          for (unsigned i = 0; i < num_layers; i++) {
             unsigned dst_z = dst_start + i;
-            unsigned src_z = src_start + i * src_z_step;
+            float src_z = src_start + i * src_z_step + depth_center_offset;
 
             blorp_blit(&batch, &src, src_res->mipLevel, src_z,
                        src_format.isl_format, src_format.swizzle,



More information about the mesa-commit mailing list