Mesa (master): i965/tiled_memcpy: change linear pointer from (0, 0) to (xt1, yt1)

Scott D Phillips scott-ph at kemper.freedesktop.org
Wed Feb 14 20:42:50 UTC 2018


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

Author: Scott D Phillips <scott.d.phillips at intel.com>
Date:   Tue Jan  9 23:16:58 2018 -0800

i965/tiled_memcpy: change linear pointer from (0, 0) to (xt1, yt1)

In all current uses, the linear surface is only allocated starting
at (xt1, yt1) anyway, so this improves the calling ergonomics.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/intel_pixel_read.c   |  2 +-
 src/mesa/drivers/dri/i965/intel_tex_image.c    |  4 ++--
 src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 16 ++++++++--------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c b/src/mesa/drivers/dri/i965/intel_pixel_read.c
index 4528d6d265..cf957378f9 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c
@@ -202,7 +202,7 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx,
    tiled_to_linear(
       xoffset * cpp, (xoffset + width) * cpp,
       yoffset, yoffset + height,
-      pixels - (ptrdiff_t) yoffset * dst_pitch - (ptrdiff_t) xoffset * cpp,
+      pixels,
       map + irb->mt->offset,
       dst_pitch, irb->mt->surf.row_pitch,
       brw->has_swizzling,
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 90b6519625..b53cdeefc3 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -294,7 +294,7 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
       xoffset * cpp, (xoffset + width) * cpp,
       yoffset, yoffset + height,
       map,
-      pixels - (ptrdiff_t) yoffset * src_pitch - (ptrdiff_t) xoffset * cpp,
+      pixels,
       image->mt->surf.row_pitch, src_pitch,
       brw->has_swizzling,
       image->mt->surf.tiling,
@@ -743,7 +743,7 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx,
    tiled_to_linear(
       xoffset * cpp, (xoffset + width) * cpp,
       yoffset, yoffset + height,
-      pixels - (ptrdiff_t) yoffset * dst_pitch - (ptrdiff_t) xoffset * cpp,
+      pixels,
       map,
       dst_pitch, image->mt->surf.row_pitch,
       brw->has_swizzling,
diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
index a362891d7e..69306828d7 100644
--- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
+++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
@@ -684,8 +684,8 @@ ytiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3,
  * copy function (\ref tile_copy_fn).
  * The X range is in bytes, i.e. pixels * bytes-per-pixel.
  * The Y range is in pixels (i.e. unitless).
- * 'dst' is the start of the texture and 'src' is the corresponding
- * address to copy from, though copying begins at (xt1, yt1).
+ * 'dst' is the address of (0, 0) in the destination tiled texture.
+ * 'src' is the address of (xt1, yt1) in the source linear texture.
  */
 void
 linear_to_tiled(uint32_t xt1, uint32_t xt2,
@@ -758,8 +758,8 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2,
          /* Translate by (xt,yt) for single-tile copier. */
          tile_copy(x0-xt, x1-xt, x2-xt, x3-xt,
                    y0-yt, y1-yt,
-                   dst + (ptrdiff_t) xt * th + (ptrdiff_t) yt * dst_pitch,
-                   src + (ptrdiff_t) xt      + (ptrdiff_t) yt * src_pitch,
+                   dst + (ptrdiff_t)xt * th  +  (ptrdiff_t)yt        * dst_pitch,
+                   src + (ptrdiff_t)xt - xt1 + ((ptrdiff_t)yt - yt1) * src_pitch,
                    src_pitch,
                    swizzle_bit,
                    mem_copy);
@@ -775,8 +775,8 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2,
  * copy function (\ref tile_copy_fn).
  * The X range is in bytes, i.e. pixels * bytes-per-pixel.
  * The Y range is in pixels (i.e. unitless).
- * 'dst' is the start of the texture and 'src' is the corresponding
- * address to copy from, though copying begins at (xt1, yt1).
+ * 'dst' is the address of (xt1, yt1) in the destination linear texture.
+ * 'src' is the address of (0, 0) in the source tiled texture.
  */
 void
 tiled_to_linear(uint32_t xt1, uint32_t xt2,
@@ -849,8 +849,8 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2,
          /* Translate by (xt,yt) for single-tile copier. */
          tile_copy(x0-xt, x1-xt, x2-xt, x3-xt,
                    y0-yt, y1-yt,
-                   dst + (ptrdiff_t) xt      + (ptrdiff_t) yt * dst_pitch,
-                   src + (ptrdiff_t) xt * th + (ptrdiff_t) yt * src_pitch,
+                   dst + (ptrdiff_t)xt - xt1 + ((ptrdiff_t)yt - yt1) * dst_pitch,
+                   src + (ptrdiff_t)xt * th  +  (ptrdiff_t)yt        * src_pitch,
                    dst_pitch,
                    swizzle_bit,
                    mem_copy);




More information about the mesa-commit mailing list