[Mesa-stable] [PATCH] nvc0: when mapping directly, provide accurate xfer info + start

Ilia Mirkin imirkin at alum.mit.edu
Fri Jun 24 02:41:07 UTC 2016


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 at alum.mit.edu>
Cc: <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
index 02b2c18..119e114 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
@@ -394,15 +394,22 @@ nvc0_miptree_transfer_map_unlocked(
    }
    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;
-- 
2.7.3



More information about the mesa-stable mailing list