summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv30/nv30_miptree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv30/nv30_miptree.c')
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index 9700fa8cb4b..e89725feb2f 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -218,14 +218,16 @@ nv30_blit(struct pipe_context *pipe,
util_blitter_blit(nv30->blitter, &info);
}
-static struct pipe_transfer *
-nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
+static void *
+nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
unsigned level, unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct nv30_context *nv30 = nv30_context(pipe);
struct nouveau_device *dev = nv30->screen->base.device;
struct nv30_transfer *tx;
+ unsigned access = 0;
int ret;
tx = CALLOC_STRUCT(nv30_transfer);
@@ -270,42 +272,24 @@ nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
if (usage & PIPE_TRANSFER_READ)
nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp);
- return &tx->base;
-}
-
-static void
-nv30_miptree_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
- struct nv30_context *nv30 = nv30_context(pipe);
- struct nv30_transfer *tx = nv30_transfer(ptx);
-
- if (ptx->usage & PIPE_TRANSFER_WRITE)
- nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
-
- nouveau_bo_ref(NULL, &tx->tmp.bo);
- pipe_resource_reference(&ptx->resource, NULL);
- FREE(tx);
-}
-
-static void *
-nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
- struct nv30_context *nv30 = nv30_context(pipe);
- struct nv30_transfer *tx = nv30_transfer(ptx);
- unsigned access = 0;
- int ret;
-
- if (tx->tmp.bo->map)
+ if (tx->tmp.bo->map) {
+ *ptransfer = &tx->base;
return tx->tmp.bo->map;
+ }
- if (ptx->usage & PIPE_TRANSFER_READ)
+ if (usage & PIPE_TRANSFER_READ)
access |= NOUVEAU_BO_RD;
- if (ptx->usage & PIPE_TRANSFER_WRITE)
+ if (usage & PIPE_TRANSFER_WRITE)
access |= NOUVEAU_BO_WR;
ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
- if (ret)
+ if (ret) {
+ pipe_resource_reference(&tx->base.resource, NULL);
+ FREE(tx);
return NULL;
+ }
+
+ *ptransfer = &tx->base;
return tx->tmp.bo->map;
}
@@ -313,13 +297,20 @@ static void
nv30_miptree_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *ptx)
{
+ struct nv30_context *nv30 = nv30_context(pipe);
+ struct nv30_transfer *tx = nv30_transfer(ptx);
+
+ if (ptx->usage & PIPE_TRANSFER_WRITE)
+ nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
+
+ nouveau_bo_ref(NULL, &tx->tmp.bo);
+ pipe_resource_reference(&ptx->resource, NULL);
+ FREE(tx);
}
const struct u_resource_vtbl nv30_miptree_vtbl = {
nv30_miptree_get_handle,
nv30_miptree_destroy,
- nv30_miptree_transfer_new,
- nv30_miptree_transfer_del,
nv30_miptree_transfer_map,
u_default_transfer_flush_region,
nv30_miptree_transfer_unmap,