u_tile: Skip the packed temporary and just store tiles directly.
authorEric Anholt <eric@anholt.net>
Tue, 4 Feb 2020 18:59:19 +0000 (10:59 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 6 Feb 2020 20:48:03 +0000 (20:48 +0000)
We were generating a packed copy and then memcpying it, but we can just
pack directly to the destination.  Change on glmark2 -b build:use-vbo=true
is modest: 1.06328% +/- 0.994771% (n=84) but does remove the function that
was .6% of CPU time.

I'm not doing the equivalent "get" path at this time because softpipe's
texture cache has some clipping issues that get revealed.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3698>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3698>

src/gallium/auxiliary/util/u_tile.c

index ca2ccb0b9a81c8a1002340e53797453bef3fe7ad..d954301a961e9d27bcbb76e6b35b5f2a71afb636 100644 (file)
@@ -361,15 +361,10 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
                    enum pipe_format format, const void *p)
 {
    unsigned src_stride = w * 4;
-   void *packed;
 
    if (u_clip_tile(x, y, &w, &h, &pt->box))
       return;
 
-   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
-
-   if (!packed)
-      return;
    /* softpipe's S8_UINT texture cache fetch needs to take the rgba_format
     * path, not ui (since there's no ui unpack for s8, but it's technically
     * pure integer).
@@ -377,47 +372,42 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
    if (util_format_is_pure_uint(format)) {
       util_format_write_4ui(format,
                             p, src_stride * sizeof(float),
-                            packed, util_format_get_stride(format, w),
-                            0, 0, w, h);
+                            dst, pt->stride,
+                            x, y, w, h);
    } else if (util_format_is_pure_sint(format)) {
       util_format_write_4i(format,
                            p, src_stride * sizeof(float),
-                           packed, util_format_get_stride(format, w),
-                           0, 0, w, h);
+                           dst, pt->stride,
+                           x, y, w, h);
    } else {
       switch (format) {
       case PIPE_FORMAT_Z16_UNORM:
-         /*z16_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/
+         /*z16_put_tile_rgba((ushort *) dst, w, h, p, src_stride);*/
          break;
       case PIPE_FORMAT_Z32_UNORM:
-         /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+         /*z32_put_tile_rgba((unsigned *) dst, w, h, p, src_stride);*/
          break;
       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
       case PIPE_FORMAT_Z24X8_UNORM:
-         /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+         /*s8z24_put_tile_rgba((unsigned *) dst, w, h, p, src_stride);*/
          break;
       case PIPE_FORMAT_S8_UINT_Z24_UNORM:
       case PIPE_FORMAT_X8Z24_UNORM:
-         /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+         /*z24s8_put_tile_rgba((unsigned *) dst, w, h, p, src_stride);*/
          break;
       case PIPE_FORMAT_Z32_FLOAT:
-         /*z32f_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+         /*z32f_put_tile_rgba((unsigned *) dst, w, h, p, src_stride);*/
          break;
       case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-         /*z32f_s8x24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+         /*z32f_s8x24_put_tile_rgba((unsigned *) dst, w, h, p, src_stride);*/
          break;
       default:
          util_format_write_4f(format,
                               p, src_stride * sizeof(float),
-                              packed, util_format_get_stride(format, w),
-                              0, 0, w, h);
+                              dst, pt->stride,
+                              x, y, w, h);
       }
    }
-
-
-   pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
-
-   FREE(packed);
 }
 
 void