summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv30
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/nv30
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/nv30')
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c59
-rw-r--r--src/gallium/drivers/nv30/nv30_resource.c2
2 files changed, 25 insertions, 36 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,
diff --git a/src/gallium/drivers/nv30/nv30_resource.c b/src/gallium/drivers/nv30/nv30_resource.c
index 4d2a2284a75..f3bc8f1ee1b 100644
--- a/src/gallium/drivers/nv30/nv30_resource.c
+++ b/src/gallium/drivers/nv30/nv30_resource.c
@@ -66,11 +66,9 @@ nv30_resource_screen_init(struct pipe_screen *pscreen)
void
nv30_resource_init(struct pipe_context *pipe)
{
- pipe->get_transfer = u_get_transfer_vtbl;
pipe->transfer_map = u_transfer_map_vtbl;
pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
pipe->transfer_unmap = u_transfer_unmap_vtbl;
- pipe->transfer_destroy = u_transfer_destroy_vtbl;
pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
pipe->create_surface = nv30_miptree_surface_new;
pipe->surface_destroy = nv30_miptree_surface_del;