diff options
author | Marek Olšák <[email protected]> | 2012-10-08 04:06:42 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-10-11 21:12:16 +0200 |
commit | 369e46888904c6d379b8b477d9242cff1608e30e (patch) | |
tree | 528b10f900f23af3acd22a0edcf50fde0eeee86e /src/gallium/drivers/radeonsi/r600_buffer.c | |
parent | ec4c74a9dc10039d97ad24c4f16bd2400517991d (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/radeonsi/r600_buffer.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/r600_buffer.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/src/gallium/drivers/radeonsi/r600_buffer.c b/src/gallium/drivers/radeonsi/r600_buffer.c index ec9d87e4866..7fae048d1f5 100644 --- a/src/gallium/drivers/radeonsi/r600_buffer.c +++ b/src/gallium/drivers/radeonsi/r600_buffer.c @@ -46,15 +46,24 @@ static void r600_buffer_destroy(struct pipe_screen *screen, FREE(rbuffer); } -static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box) +static void *r600_buffer_transfer_map(struct pipe_context *ctx, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + struct pipe_transfer **ptransfer) { struct r600_context *rctx = (struct r600_context*)ctx; - struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers); + struct pipe_transfer *transfer; + struct si_resource *rbuffer = si_resource(resource); + uint8_t *data; + data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, usage); + if (!data) { + return NULL; + } + + transfer = util_slab_alloc(&rctx->pool_transfers); transfer->resource = resource; transfer->level = level; transfer->usage = usage; @@ -62,31 +71,16 @@ static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx, transfer->stride = 0; transfer->layer_stride = 0; transfer->data = NULL; - - /* Note strides are zero, this is ok for buffers, but not for - * textures 2d & higher at least. - */ - return transfer; -} - -static void *r600_buffer_transfer_map(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - struct si_resource *rbuffer = si_resource(transfer->resource); - struct r600_context *rctx = (struct r600_context*)pipe; - uint8_t *data; - - data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, transfer->usage); - if (!data) - return NULL; + *ptransfer = transfer; return (uint8_t*)data + transfer->box.x; } -static void r600_buffer_transfer_unmap(struct pipe_context *pipe, +static void r600_buffer_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *transfer) { - /* no-op */ + struct r600_context *rctx = (struct r600_context*)ctx; + util_slab_free(&rctx->pool_transfers, transfer); } static void r600_buffer_transfer_flush_region(struct pipe_context *pipe, @@ -95,19 +89,10 @@ static void r600_buffer_transfer_flush_region(struct pipe_context *pipe, { } -static void r600_transfer_destroy(struct pipe_context *ctx, - struct pipe_transfer *transfer) -{ - struct r600_context *rctx = (struct r600_context*)ctx; - util_slab_free(&rctx->pool_transfers, transfer); -} - static const struct u_resource_vtbl r600_buffer_vtbl = { u_default_resource_get_handle, /* get_handle */ r600_buffer_destroy, /* resource_destroy */ - r600_get_transfer, /* get_transfer */ - r600_transfer_destroy, /* transfer_destroy */ r600_buffer_transfer_map, /* transfer_map */ r600_buffer_transfer_flush_region, /* transfer_flush_region */ r600_buffer_transfer_unmap, /* transfer_unmap */ |