aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_screen_buffer.c
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/r300/r300_screen_buffer.c
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/r300/r300_screen_buffer.c')
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c80
1 files changed, 32 insertions, 48 deletions
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index f652bf72b0c..37a7c77010a 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -63,79 +63,63 @@ static void r300_buffer_destroy(struct pipe_screen *screen,
FREE(rbuf);
}
-static struct pipe_transfer*
-r300_buffer_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct r300_context *r300 = r300_context(context);
- struct pipe_transfer *transfer =
- util_slab_alloc(&r300->pool_transfers);
-
- transfer->resource = resource;
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
- 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 r300_buffer_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct r300_context *r300 = r300_context(pipe);
- util_slab_free(&r300->pool_transfers, transfer);
-}
-
static void *
-r300_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+r300_buffer_transfer_map( struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer )
{
- struct r300_context *r300 = r300_context(pipe);
- struct r300_screen *r300screen = r300_screen(pipe->screen);
- struct radeon_winsys *rws = r300screen->rws;
- struct r300_resource *rbuf = r300_resource(transfer->resource);
+ struct r300_context *r300 = r300_context(context);
+ struct radeon_winsys *rws = r300->screen->rws;
+ struct r300_resource *rbuf = r300_resource(resource);
+ struct pipe_transfer *transfer;
uint8_t *map;
- enum pipe_transfer_usage usage;
- if (rbuf->malloced_buffer)
- return (uint8_t *) rbuf->malloced_buffer + transfer->box.x;
+ transfer = util_slab_alloc(&r300->pool_transfers);
+ transfer->resource = resource;
+ transfer->level = level;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = 0;
+ transfer->layer_stride = 0;
+ transfer->data = NULL;
+
+ if (rbuf->malloced_buffer) {
+ *ptransfer = transfer;
+ return (uint8_t *) rbuf->malloced_buffer + box->x;
+ }
/* Buffers are never used for write, therefore mapping for read can be
* unsynchronized. */
- usage = transfer->usage;
if (!(usage & PIPE_TRANSFER_WRITE)) {
usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
}
map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
- if (map == NULL)
+ if (map == NULL) {
+ util_slab_free(&r300->pool_transfers, transfer);
return NULL;
+ }
- return map + transfer->box.x;
+ *ptransfer = transfer;
+ return map + box->x;
}
static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+ struct pipe_transfer *transfer )
{
- /* no-op */
+ struct r300_context *r300 = r300_context(pipe);
+
+ util_slab_free(&r300->pool_transfers, transfer);
}
static const struct u_resource_vtbl r300_buffer_vtbl =
{
NULL, /* get_handle */
r300_buffer_destroy, /* resource_destroy */
- r300_buffer_get_transfer, /* get_transfer */
- r300_buffer_transfer_destroy, /* transfer_destroy */
r300_buffer_transfer_map, /* transfer_map */
NULL, /* transfer_flush_region */
r300_buffer_transfer_unmap, /* transfer_unmap */