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/trace/tr_context.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/trace/tr_context.c')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index affdfca228f..dd1b5a00de7 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1377,18 +1377,20 @@ trace_context_destroy(struct pipe_context *_pipe) */ -static struct pipe_transfer * -trace_context_get_transfer(struct pipe_context *_context, +static void * +trace_context_transfer_map(struct pipe_context *_context, struct pipe_resource *_resource, unsigned level, unsigned usage, - const struct pipe_box *box) + const struct pipe_box *box, + struct pipe_transfer **transfer) { struct trace_context *tr_context = trace_context(_context); struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *context = tr_context->pipe; struct pipe_resource *texture = tr_res->resource; struct pipe_transfer *result = NULL; + void *map; assert(texture->screen == context->screen); @@ -1397,48 +1399,21 @@ trace_context_get_transfer(struct pipe_context *_context, * to transfer_inline_write and ignore read transfers. */ - result = context->get_transfer(context, texture, level, usage, box); - - if (result) - result = trace_transfer_create(tr_context, tr_res, result); - - return result; -} - - -static void -trace_context_transfer_destroy(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct trace_context *tr_context = trace_context(_context); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - - trace_transfer_destroy(tr_context, tr_trans); -} + map = context->transfer_map(context, texture, level, usage, box, &result); + if (!map) + return NULL; + *transfer = trace_transfer_create(tr_context, tr_res, result); -static void * -trace_context_transfer_map(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct trace_context *tr_context = trace_context(_context); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_context *context = tr_context->pipe; - struct pipe_transfer *transfer = tr_trans->transfer; - void *map; - - map = context->transfer_map(context, transfer); - if(map) { - if(transfer->usage & PIPE_TRANSFER_WRITE) { - assert(!tr_trans->map); - tr_trans->map = map; + if (map) { + if(usage & PIPE_TRANSFER_WRITE) { + trace_transfer(*transfer)->map = map; } } - return map; + return *transfer ? map : NULL; } - static void trace_context_transfer_flush_region( struct pipe_context *_context, struct pipe_transfer *_transfer, @@ -1500,6 +1475,7 @@ trace_context_transfer_unmap(struct pipe_context *_context, } context->transfer_unmap(context, transfer); + trace_transfer_destroy(tr_ctx, tr_trans); } @@ -1667,8 +1643,6 @@ trace_context_create(struct trace_screen *tr_scr, TR_CTX_INIT(render_condition); TR_CTX_INIT(texture_barrier); - TR_CTX_INIT(get_transfer); - TR_CTX_INIT(transfer_destroy); TR_CTX_INIT(transfer_map); TR_CTX_INIT(transfer_unmap); TR_CTX_INIT(transfer_flush_region); |