summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv50/nv50_transfer.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-04-07 15:41:17 +1000
committerBen Skeggs <bskeggs@redhat.com>2010-04-07 15:51:13 +1000
commit2d606c13ff68286b201f8d574d9cc645b8b8f2e2 (patch)
tree666b3bfc22ef7f2425be4dc44994c08129326294 /src/gallium/drivers/nv50/nv50_transfer.c
parent841b327a51a5bc5968a8ddb0e867b6c552ac67c7 (diff)
nouveau: allow multiple simultaneous maps of a pipe_transfer
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.
Diffstat (limited to 'src/gallium/drivers/nv50/nv50_transfer.c')
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index 9eb223eca6..6d16c1354b 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -9,6 +9,7 @@
struct nv50_transfer {
struct pipe_transfer base;
struct nouveau_bo *bo;
+ int map_refcnt;
unsigned level_offset;
unsigned level_tiling;
int level_pitch;
@@ -225,14 +226,19 @@ nv50_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
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;
}
@@ -241,6 +247,8 @@ nv50_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+ if (--tx->map_refcnt)
+ return;
nouveau_bo_unmap(tx->bo);
}