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/galahad/glhd_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/galahad/glhd_context.c')
-rw-r--r-- | src/gallium/drivers/galahad/glhd_context.c | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c index 354f20a3ad7..92ca4a63da9 100644 --- a/src/gallium/drivers/galahad/glhd_context.c +++ b/src/gallium/drivers/galahad/glhd_context.c @@ -877,58 +877,35 @@ galahad_context_surface_destroy(struct pipe_context *_pipe, } - -static struct pipe_transfer * -galahad_context_get_transfer(struct pipe_context *_context, - struct pipe_resource *_resource, - unsigned level, - unsigned usage, - const struct pipe_box *box) +static void * +galahad_context_transfer_map(struct pipe_context *_context, + struct pipe_resource *_resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + struct pipe_transfer **transfer) { struct galahad_context *glhd_context = galahad_context(_context); struct galahad_resource *glhd_resource = galahad_resource(_resource); struct pipe_context *context = glhd_context->pipe; struct pipe_resource *resource = glhd_resource->resource; struct pipe_transfer *result; - - result = context->get_transfer(context, - resource, - level, - usage, - box); - - if (result) - return galahad_transfer_create(glhd_context, glhd_resource, result); - return NULL; -} - -static void -galahad_context_transfer_destroy(struct pipe_context *_pipe, - struct pipe_transfer *_transfer) -{ - galahad_transfer_destroy(galahad_context(_pipe), - galahad_transfer(_transfer)); -} - -static void * -galahad_context_transfer_map(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct galahad_context *glhd_context = galahad_context(_context); - struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer); - struct pipe_context *context = glhd_context->pipe; - struct pipe_transfer *transfer = glhd_transfer->transfer; - - struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource); + void *map; + + map = context->transfer_map(context, + resource, + level, + usage, + box, &result); + if (!map) + return NULL; glhd_resource->map_count++; - return context->transfer_map(context, - transfer); + *transfer = galahad_transfer_create(glhd_context, glhd_resource, result); + return *transfer ? map : NULL; } - - static void galahad_context_transfer_flush_region(struct pipe_context *_context, struct pipe_transfer *_transfer, @@ -944,7 +921,6 @@ galahad_context_transfer_flush_region(struct pipe_context *_context, box); } - static void galahad_context_transfer_unmap(struct pipe_context *_context, struct pipe_transfer *_transfer) @@ -964,6 +940,9 @@ galahad_context_transfer_unmap(struct pipe_context *_context, context->transfer_unmap(context, transfer); + + galahad_transfer_destroy(galahad_context(_context), + galahad_transfer(_transfer)); } @@ -1088,8 +1067,6 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) GLHD_PIPE_INIT(sampler_view_destroy); GLHD_PIPE_INIT(create_surface); GLHD_PIPE_INIT(surface_destroy); - GLHD_PIPE_INIT(get_transfer); - GLHD_PIPE_INIT(transfer_destroy); GLHD_PIPE_INIT(transfer_map); GLHD_PIPE_INIT(transfer_flush_region); GLHD_PIPE_INIT(transfer_unmap); |