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/identity | |
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/identity')
-rw-r--r-- | src/gallium/drivers/identity/id_context.c | 52 | ||||
-rw-r--r-- | src/gallium/drivers/identity/id_objects.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/identity/id_objects.h | 2 |
3 files changed, 22 insertions, 42 deletions
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index cf0a3f9aa40..fb2f78764a4 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -776,53 +776,34 @@ identity_context_surface_destroy(struct pipe_context *_pipe, identity_surface(_surf)); } -static struct pipe_transfer * -identity_context_get_transfer(struct pipe_context *_context, +static void * +identity_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 identity_context *id_context = identity_context(_context); struct identity_resource *id_resource = identity_resource(_resource); struct pipe_context *context = id_context->pipe; struct pipe_resource *resource = id_resource->resource; struct pipe_transfer *result; + void *map; - result = context->get_transfer(context, - resource, - level, - usage, - box); - - if (result) - return identity_transfer_create(id_context, id_resource, result); - return NULL; -} + map = context->transfer_map(context, + resource, + level, + usage, + box, &result); -static void -identity_context_transfer_destroy(struct pipe_context *_pipe, - struct pipe_transfer *_transfer) -{ - identity_transfer_destroy(identity_context(_pipe), - identity_transfer(_transfer)); -} - -static void * -identity_context_transfer_map(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct identity_context *id_context = identity_context(_context); - struct identity_transfer *id_transfer = identity_transfer(_transfer); - struct pipe_context *context = id_context->pipe; - struct pipe_transfer *transfer = id_transfer->transfer; + if (!map) + return NULL; - return context->transfer_map(context, - transfer); + *transfer = identity_transfer_map(id_context, id_resource, result); + return *transfer ? map : NULL; } - - static void identity_context_transfer_flush_region(struct pipe_context *_context, struct pipe_transfer *_transfer, @@ -850,6 +831,9 @@ identity_context_transfer_unmap(struct pipe_context *_context, context->transfer_unmap(context, transfer); + + identity_transfer_destroy(identity_context(_context), + identity_transfer(_transfer)); } @@ -945,8 +929,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.surface_destroy = identity_context_surface_destroy; id_pipe->base.create_sampler_view = identity_context_create_sampler_view; id_pipe->base.sampler_view_destroy = identity_context_sampler_view_destroy; - id_pipe->base.get_transfer = identity_context_get_transfer; - id_pipe->base.transfer_destroy = identity_context_transfer_destroy; id_pipe->base.transfer_map = identity_context_transfer_map; id_pipe->base.transfer_unmap = identity_context_transfer_unmap; id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region; diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index 63454410525..a26d9874870 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -149,9 +149,9 @@ identity_sampler_view_destroy(struct identity_context *id_context, struct pipe_transfer * -identity_transfer_create(struct identity_context *id_context, - struct identity_resource *id_resource, - struct pipe_transfer *transfer) +identity_transfer_map(struct identity_context *id_context, + struct identity_resource *id_resource, + struct pipe_transfer *transfer) { struct identity_transfer *id_transfer; @@ -175,7 +175,7 @@ identity_transfer_create(struct identity_context *id_context, return &id_transfer->base; error: - id_context->pipe->transfer_destroy(id_context->pipe, transfer); + id_context->pipe->transfer_unmap(id_context->pipe, transfer); return NULL; } @@ -184,8 +184,6 @@ identity_transfer_destroy(struct identity_context *id_context, struct identity_transfer *id_transfer) { pipe_resource_reference(&id_transfer->base.resource, NULL); - id_context->pipe->transfer_destroy(id_context->pipe, - id_transfer->transfer); FREE(id_transfer); } diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 181f2d6623e..67049436247 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -165,7 +165,7 @@ identity_sampler_view_destroy(struct identity_context *id_context, struct identity_sampler_view *id_sampler_view); struct pipe_transfer * -identity_transfer_create(struct identity_context *id_context, +identity_transfer_map(struct identity_context *id_context, struct identity_resource *id_resource, struct pipe_transfer *transfer); |