nvc0: when mapping directly, provide accurate xfer info + start
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 24 Jun 2016 02:33:59 +0000 (22:33 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 24 Jun 2016 13:53:13 +0000 (09:53 -0400)
We were ignoring the incoming box parameters, and were providing totally
bogus stride/layer stride, and other bits, for when a non-full-surface
map was requested.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c

index 24d23d29bbf4ccfe7bad65e499d272b97e8a637e..14fb53cb8f7a25d71c71456d7f89ebadbaf6177d 100644 (file)
@@ -390,15 +390,22 @@ nvc0_miptree_transfer_map(struct pipe_context *pctx,
    }
    tx->nlayers = box->depth;
 
-   tx->base.stride = tx->nblocksx * util_format_get_blocksize(res->format);
-   tx->base.layer_stride = tx->nblocksy * tx->base.stride;
-
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY) {
-      tx->base.stride = align(tx->base.stride, 128);
+      tx->base.stride = mt->level[level].pitch;
+      tx->base.layer_stride = mt->layer_stride;
+      uint32_t offset = box->y * tx->base.stride +
+         util_format_get_stride(res->format, box->x);
+      if (!mt->layout_3d)
+         offset += mt->layer_stride * box->z;
+      else
+         offset += nvc0_mt_zslice_offset(mt, level, box->z);
       *ptransfer = &tx->base;
-      return mt->base.bo->map + mt->base.offset;
+      return mt->base.bo->map + mt->base.offset + offset;
    }
 
+   tx->base.stride = tx->nblocksx * util_format_get_blocksize(res->format);
+   tx->base.layer_stride = tx->nblocksy * tx->base.stride;
+
    nv50_m2mf_rect_setup(&tx->rect[0], res, level, box->x, box->y, box->z);
 
    size = tx->base.layer_stride;