summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-10-08 04:06:42 +0200
committerMarek Olšák <[email protected]>2012-10-11 21:12:16 +0200
commit369e46888904c6d379b8b477d9242cff1608e30e (patch)
tree528b10f900f23af3acd22a0edcf50fde0eeee86e /src/gallium/drivers/nv50
parentec4c74a9dc10039d97ad24c4f16bd2400517991d (diff)
gallium: unify transfer functions
"get_transfer + transfer_map" becomes "transfer_map". "transfer_unmap + transfer_destroy" becomes "transfer_unmap". transfer_map must create and return the transfer object and transfer_unmap must destroy it. transfer_map is successful if the returned buffer pointer is not NULL. If transfer_map fails, the pointer to the transfer object remains unchanged (i.e. doesn't have to be NULL). Acked-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nv50')
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_resource.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_resource.h15
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c63
4 files changed, 32 insertions, 50 deletions
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index 70e8c7788ea..568526c5933 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -145,8 +145,6 @@ const struct u_resource_vtbl nv50_miptree_vtbl =
{
nv50_miptree_get_handle, /* get_handle */
nv50_miptree_destroy, /* resource_destroy */
- nv50_miptree_transfer_new, /* get_transfer */
- nv50_miptree_transfer_del, /* transfer_destroy */
nv50_miptree_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
nv50_miptree_transfer_unmap, /* transfer_unmap */
diff --git a/src/gallium/drivers/nv50/nv50_resource.c b/src/gallium/drivers/nv50/nv50_resource.c
index 9fe18a6d09d..42fefa61efc 100644
--- a/src/gallium/drivers/nv50/nv50_resource.c
+++ b/src/gallium/drivers/nv50/nv50_resource.c
@@ -86,11 +86,9 @@ nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps)
void
nv50_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 = nv50_surface_create;
pcontext->surface_destroy = nv50_surface_destroy;
diff --git a/src/gallium/drivers/nv50/nv50_resource.h b/src/gallium/drivers/nv50/nv50_resource.h
index c1b159e1244..48089557082 100644
--- a/src/gallium/drivers/nv50/nv50_resource.h
+++ b/src/gallium/drivers/nv50/nv50_resource.h
@@ -123,18 +123,13 @@ nv50_miptree_surface_new(struct pipe_context *,
struct pipe_resource *,
const struct pipe_surface *templ);
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pcontext,
- struct pipe_resource *pt,
+void *
+nv50_miptree_transfer_map(struct pipe_context *pctx,
+ struct pipe_resource *res,
unsigned level,
unsigned usage,
- const struct pipe_box *box);
-void
-nv50_miptree_transfer_del(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
-void *
-nv50_miptree_transfer_map(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer);
void
nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
struct pipe_transfer *ptx);
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index b960dc0d191..25319d785e4 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -246,19 +246,22 @@ nv50_m2mf_copy_linear(struct nouveau_context *nv,
nouveau_bufctx_reset(bctx, 0);
}
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pctx,
+void *
+nv50_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 nv50_screen *screen = nv50_screen(pctx->screen);
struct nv50_context *nv50 = nv50_context(pctx);
struct nouveau_device *dev = nv50->screen->base.device;
const struct nv50_miptree *mt = nv50_miptree(res);
struct nv50_transfer *tx;
uint32_t size;
int ret;
+ unsigned flags = 0;
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
return NULL;
@@ -320,12 +323,30 @@ nv50_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, screen->base.client);
+ if (ret) {
+ nouveau_bo_ref(NULL, &tx->rect[1].bo);
+ FREE(tx);
+ return NULL;
+ }
+
+ *ptransfer = &tx->base;
+ return tx->rect[1].bo->map;
}
void
-nv50_miptree_transfer_del(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
+nv50_miptree_transfer_unmap(struct pipe_context *pctx,
+ struct pipe_transfer *transfer)
{
struct nv50_context *nv50 = nv50_context(pctx);
struct nv50_transfer *tx = (struct nv50_transfer *)transfer;
@@ -350,36 +371,6 @@ nv50_miptree_transfer_del(struct pipe_context *pctx,
FREE(tx);
}
-void *
-nv50_miptree_transfer_map(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
- struct nv50_screen *screen = nv50_screen(pctx->screen);
- struct nv50_transfer *tx = (struct nv50_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, screen->base.client);
- if (ret)
- return NULL;
- return tx->rect[1].bo->map;
-}
-
-void
-nv50_miptree_transfer_unmap(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
- /* nothing to do */
-}
-
void
nv50_cb_push(struct nouveau_context *nv,
struct nouveau_bo *bo, unsigned domain,