diff options
Diffstat (limited to 'src/gallium/drivers/nvc0')
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_miptree.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_resource.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_resource.h | 15 | ||||
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_transfer.c | 63 |
4 files changed, 33 insertions, 49 deletions
diff --git a/src/gallium/drivers/nvc0/nvc0_miptree.c b/src/gallium/drivers/nvc0/nvc0_miptree.c index 591ac4402db..b63f196eecd 100644 --- a/src/gallium/drivers/nvc0/nvc0_miptree.c +++ b/src/gallium/drivers/nvc0/nvc0_miptree.c @@ -259,8 +259,6 @@ const struct u_resource_vtbl nvc0_miptree_vtbl = { nv50_miptree_get_handle, /* get_handle */ nv50_miptree_destroy, /* resource_destroy */ - nvc0_miptree_transfer_new, /* get_transfer */ - nvc0_miptree_transfer_del, /* transfer_destroy */ nvc0_miptree_transfer_map, /* transfer_map */ u_default_transfer_flush_region, /* transfer_flush_region */ nvc0_miptree_transfer_unmap, /* transfer_unmap */ diff --git a/src/gallium/drivers/nvc0/nvc0_resource.c b/src/gallium/drivers/nvc0/nvc0_resource.c index daf5c907a05..162399f2e48 100644 --- a/src/gallium/drivers/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nvc0/nvc0_resource.c @@ -44,11 +44,9 @@ nvc0_surface_create(struct pipe_context *pipe, void nvc0_init_resource_functions(struct pipe_context *pcontext) { - pcontext->get_transfer = u_get_transfer_vtbl; pcontext->transfer_map = u_transfer_map_vtbl; pcontext->transfer_flush_region = u_transfer_flush_region_vtbl; pcontext->transfer_unmap = u_transfer_unmap_vtbl; - pcontext->transfer_destroy = u_transfer_destroy_vtbl; pcontext->transfer_inline_write = u_transfer_inline_write_vtbl; pcontext->create_surface = nvc0_surface_create; pcontext->surface_destroy = nv50_surface_destroy; diff --git a/src/gallium/drivers/nvc0/nvc0_resource.h b/src/gallium/drivers/nvc0/nvc0_resource.h index 41b1667b2e4..0d5f026d6e1 100644 --- a/src/gallium/drivers/nvc0/nvc0_resource.h +++ b/src/gallium/drivers/nvc0/nvc0_resource.h @@ -44,18 +44,13 @@ nvc0_miptree_surface_new(struct pipe_context *, unsigned nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z); -struct pipe_transfer * -nvc0_miptree_transfer_new(struct pipe_context *pcontext, - struct pipe_resource *pt, +void * +nvc0_miptree_transfer_map(struct pipe_context *pctx, + struct pipe_resource *res, unsigned level, unsigned usage, - const struct pipe_box *box); -void -nvc0_miptree_transfer_del(struct pipe_context *pcontext, - struct pipe_transfer *ptx); -void * -nvc0_miptree_transfer_map(struct pipe_context *pcontext, - struct pipe_transfer *ptx); + const struct pipe_box *box, + struct pipe_transfer **ptransfer); void nvc0_miptree_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx); diff --git a/src/gallium/drivers/nvc0/nvc0_transfer.c b/src/gallium/drivers/nvc0/nvc0_transfer.c index 58dcd862c99..66753c9135b 100644 --- a/src/gallium/drivers/nvc0/nvc0_transfer.c +++ b/src/gallium/drivers/nvc0/nvc0_transfer.c @@ -326,12 +326,13 @@ nve4_m2mf_copy_linear(struct nouveau_context *nv, nouveau_bufctx_reset(bctx, 0); } -struct pipe_transfer * -nvc0_miptree_transfer_new(struct pipe_context *pctx, +void * +nvc0_miptree_transfer_map(struct pipe_context *pctx, struct pipe_resource *res, unsigned level, unsigned usage, - const struct pipe_box *box) + const struct pipe_box *box, + struct pipe_transfer **ptransfer) { struct nvc0_context *nvc0 = nvc0_context(pctx); struct nouveau_device *dev = nvc0->screen->base.device; @@ -339,6 +340,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx, struct nvc0_transfer *tx; uint32_t size; int ret; + unsigned flags = 0; if (usage & PIPE_TRANSFER_MAP_DIRECTLY) return NULL; @@ -372,6 +374,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx, ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, size * tx->nlayers, NULL, &tx->rect[1].bo); if (ret) { + pipe_resource_reference(&tx->base.resource, NULL); FREE(tx); return NULL; } @@ -401,12 +404,31 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx, tx->rect[1].base = 0; } - return &tx->base; + if (tx->rect[1].bo->map) { + *ptransfer = &tx->base; + return tx->rect[1].bo->map; + } + + if (usage & PIPE_TRANSFER_READ) + flags = NOUVEAU_BO_RD; + if (usage & PIPE_TRANSFER_WRITE) + flags |= NOUVEAU_BO_WR; + + ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client); + if (ret) { + pipe_resource_reference(&tx->base.resource, NULL); + nouveau_bo_ref(NULL, &tx->rect[1].bo); + FREE(tx); + return NULL; + } + + *ptransfer = &tx->base; + return tx->rect[1].bo->map; } void -nvc0_miptree_transfer_del(struct pipe_context *pctx, - struct pipe_transfer *transfer) +nvc0_miptree_transfer_unmap(struct pipe_context *pctx, + struct pipe_transfer *transfer) { struct nvc0_context *nvc0 = nvc0_context(pctx); struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer; @@ -431,35 +453,6 @@ nvc0_miptree_transfer_del(struct pipe_context *pctx, FREE(tx); } -void * -nvc0_miptree_transfer_map(struct pipe_context *pctx, - struct pipe_transfer *transfer) -{ - struct nvc0_context *nvc0 = nvc0_context(pctx); - struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer; - int ret; - unsigned flags = 0; - - if (tx->rect[1].bo->map) - return tx->rect[1].bo->map; - - if (transfer->usage & PIPE_TRANSFER_READ) - flags = NOUVEAU_BO_RD; - if (transfer->usage & PIPE_TRANSFER_WRITE) - flags |= NOUVEAU_BO_WR; - - ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client); - if (ret) - return NULL; - return tx->rect[1].bo->map; -} - -void -nvc0_miptree_transfer_unmap(struct pipe_context *pctx, - struct pipe_transfer *transfer) -{ -} - void nvc0_cb_push(struct nouveau_context *nv, struct nouveau_bo *bo, unsigned domain, |