I'm not entirely convinced we want this behaviour (the underlying nouveau_bo
doesn't support it either), but since certain parts of the mesa state
tracker appear to require it lets make it work for now.
struct nv50_transfer {
struct pipe_transfer base;
struct nouveau_bo *bo;
+ int map_refcnt;
unsigned level_offset;
unsigned level_tiling;
int level_pitch;
unsigned flags = 0;
int ret;
+ if (tx->map_refcnt++)
+ return tx->bo->map;
+
if (ptx->usage & PIPE_TRANSFER_WRITE)
flags |= NOUVEAU_BO_WR;
if (ptx->usage & PIPE_TRANSFER_READ)
flags |= NOUVEAU_BO_RD;
ret = nouveau_bo_map(tx->bo, flags);
- if (ret)
+ if (ret) {
+ tx->map_refcnt = 0;
return NULL;
+ }
return tx->bo->map;
}
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+ if (--tx->map_refcnt)
+ return;
nouveau_bo_unmap(tx->bo);
}