diff options
Diffstat (limited to 'src/gallium/drivers/identity')
-rw-r--r-- | src/gallium/drivers/identity/id_context.c | 136 | ||||
-rw-r--r-- | src/gallium/drivers/identity/id_objects.c | 42 | ||||
-rw-r--r-- | src/gallium/drivers/identity/id_objects.h | 13 | ||||
-rw-r--r-- | src/gallium/drivers/identity/id_screen.c | 34 |
4 files changed, 129 insertions, 96 deletions
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 0bc8bf2196..7e62213597 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -684,79 +684,67 @@ identity_flush(struct pipe_context *_pipe, static unsigned int identity_is_resource_referenced(struct pipe_context *_pipe, - struct pipe_resource *_resource, - unsigned face, - unsigned level) + struct pipe_resource *_resource, + unsigned face, + unsigned level) { struct identity_context *id_pipe = identity_context(_pipe); struct identity_resource *id_resource = identity_resource(_resource); struct pipe_context *pipe = id_pipe->pipe; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; return pipe->is_resource_referenced(pipe, - texture, - face, - level); + resource, + face, + level); } static struct pipe_sampler_view * -identity_create_sampler_view(struct pipe_context *pipe, - struct pipe_resource *texture, - const struct pipe_sampler_view *templ) +identity_context_create_sampler_view(struct pipe_context *_pipe, + struct pipe_resource *_resource, + const struct pipe_sampler_view *templ) { - struct identity_context *id_pipe = identity_context(pipe); - struct identity_resource *id_resource = identity_resource(texture); - struct pipe_context *pipe_unwrapped = id_pipe->pipe; - struct pipe_resource *texture_unwrapped = id_resource->resource; - struct identity_sampler_view *view = MALLOC(sizeof(struct identity_sampler_view)); - - view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped, - texture_unwrapped, - templ); + struct identity_context *id_context = identity_context(_pipe); + struct identity_resource *id_resource = identity_resource(_resource); + struct pipe_context *pipe = id_context->pipe; + struct pipe_resource *resource = id_resource->resource; + struct pipe_sampler_view *result; - view->base = *templ; - view->base.reference.count = 1; - view->base.texture = NULL; - pipe_resource_reference(&view->base.texture, texture); - view->base.context = pipe; + result = pipe->create_sampler_view(pipe, + resource, + templ); - return &view->base; + if (result) + return identity_sampler_view_create(id_context, id_resource, result); + return NULL; } static void -identity_sampler_view_destroy(struct pipe_context *pipe, - struct pipe_sampler_view *view) +identity_context_sampler_view_destroy(struct pipe_context *_pipe, + struct pipe_sampler_view *_view) { - struct identity_context *id_pipe = identity_context(pipe); - struct identity_sampler_view *id_view = identity_sampler_view(view); - struct pipe_context *pipe_unwrapped = id_pipe->pipe; - struct pipe_sampler_view *view_unwrapped = id_view->sampler_view; - - pipe_unwrapped->sampler_view_destroy(pipe_unwrapped, - view_unwrapped); - - pipe_resource_reference(&view->texture, NULL); - FREE(view); + identity_sampler_view_destroy(identity_context(_pipe), + identity_sampler_view(_view)); } static struct pipe_transfer * identity_context_get_transfer(struct pipe_context *_context, - struct pipe_resource *_resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box) + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box) { 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 *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; struct pipe_transfer *result; result = context->get_transfer(context, - texture, - sr, - usage, - box); + resource, + sr, + usage, + box); if (result) return identity_transfer_create(id_context, id_resource, result); @@ -765,7 +753,7 @@ identity_context_get_transfer(struct pipe_context *_context, static void identity_context_transfer_destroy(struct pipe_context *_pipe, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { identity_transfer_destroy(identity_context(_pipe), identity_transfer(_transfer)); @@ -773,7 +761,7 @@ identity_context_transfer_destroy(struct pipe_context *_pipe, static void * identity_context_transfer_map(struct pipe_context *_context, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -781,15 +769,15 @@ identity_context_transfer_map(struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; return context->transfer_map(context, - transfer); + transfer); } static void -identity_context_transfer_flush_region( struct pipe_context *_context, - struct pipe_transfer *_transfer, - const struct pipe_box *box) +identity_context_transfer_flush_region(struct pipe_context *_context, + struct pipe_transfer *_transfer, + const struct pipe_box *box) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -797,14 +785,14 @@ identity_context_transfer_flush_region( struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; context->transfer_flush_region(context, - transfer, - box); + transfer, + box); } static void identity_context_transfer_unmap(struct pipe_context *_context, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -812,33 +800,33 @@ identity_context_transfer_unmap(struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; context->transfer_unmap(context, - transfer); + transfer); } static void -identity_context_transfer_inline_write( struct pipe_context *_context, - struct pipe_resource *_resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box, - const void *data, - unsigned stride, - unsigned slice_stride) +identity_context_transfer_inline_write(struct pipe_context *_context, + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned slice_stride) { 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 *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; context->transfer_inline_write(context, - texture, - sr, - usage, - box, - data, - stride, - slice_stride); + resource, + sr, + usage, + box, + data, + stride, + slice_stride); } @@ -905,8 +893,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.clear = identity_clear; id_pipe->base.flush = identity_flush; id_pipe->base.is_resource_referenced = identity_is_resource_referenced; - id_pipe->base.create_sampler_view = identity_create_sampler_view; - id_pipe->base.sampler_view_destroy = identity_sampler_view_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; diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index d50914e7d5..ca4743f9ef 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -108,9 +108,45 @@ identity_surface_destroy(struct identity_surface *id_surface) } +struct pipe_sampler_view * +identity_sampler_view_create(struct identity_context *id_context, + struct identity_resource *id_resource, + struct pipe_sampler_view *view) +{ + struct identity_sampler_view *id_view; + + if (!view) + goto error; + + assert(view->texture == id_resource->resource); + + id_view = MALLOC(sizeof(struct identity_sampler_view)); + + id_view->base = *view; + id_view->base.reference.count = 1; + id_view->base.texture = NULL; + pipe_resource_reference(&id_view->base.texture, id_resource->resource); + id_view->base.context = id_context->pipe; + + return &id_view->base; +error: + return NULL; +} + +void +identity_sampler_view_destroy(struct identity_context *id_context, + struct identity_sampler_view *id_view) +{ + pipe_resource_reference(&id_view->base.texture, NULL); + id_context->pipe->sampler_view_destroy(id_context->pipe, + id_view->sampler_view); + FREE(id_view); +} + + struct pipe_transfer * identity_transfer_create(struct identity_context *id_context, - struct identity_resource *id_resource, + struct identity_resource *id_resource, struct pipe_transfer *transfer) { struct identity_transfer *id_transfer; @@ -144,8 +180,8 @@ 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); + id_transfer->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 058cf3009d..5eea10b0b5 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -142,7 +142,7 @@ identity_transfer_unwrap(struct pipe_transfer *_transfer) struct pipe_resource * identity_resource_create(struct identity_screen *id_screen, - struct pipe_resource *resource); + struct pipe_resource *resource); void identity_resource_destroy(struct identity_resource *id_resource); @@ -154,9 +154,18 @@ identity_surface_create(struct identity_resource *id_resource, void identity_surface_destroy(struct identity_surface *id_surface); +struct pipe_sampler_view * +identity_sampler_view_create(struct identity_context *id_context, + struct identity_resource *id_resource, + struct pipe_sampler_view *view); + +void +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, - struct identity_resource *id_resource, + struct identity_resource *id_resource, struct pipe_transfer *transfer); void diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 52573b211f..7671bded98 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -120,14 +120,14 @@ identity_screen_context_create(struct pipe_screen *_screen, static struct pipe_resource * identity_screen_resource_create(struct pipe_screen *_screen, - const struct pipe_resource *templat) + const struct pipe_resource *templat) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; struct pipe_resource *result; result = screen->resource_create(screen, - templat); + templat); if (result) return identity_resource_create(id_screen, result); @@ -136,8 +136,8 @@ identity_screen_resource_create(struct pipe_screen *_screen, static struct pipe_resource * identity_screen_resource_from_handle(struct pipe_screen *_screen, - const struct pipe_resource *templ, - struct winsys_handle *handle) + const struct pipe_resource *templ, + struct winsys_handle *handle) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; @@ -154,44 +154,44 @@ identity_screen_resource_from_handle(struct pipe_screen *_screen, static boolean identity_screen_resource_get_handle(struct pipe_screen *_screen, - struct pipe_resource *_texture, - struct winsys_handle *handle) + struct pipe_resource *_resource, + struct winsys_handle *handle) { struct identity_screen *id_screen = identity_screen(_screen); - struct identity_resource *id_resource = identity_resource(_texture); + struct identity_resource *id_resource = identity_resource(_resource); struct pipe_screen *screen = id_screen->screen; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; /* TODO trace call */ - return screen->resource_get_handle(screen, texture, handle); + return screen->resource_get_handle(screen, resource, handle); } static void identity_screen_resource_destroy(struct pipe_screen *screen, - struct pipe_resource *_texture) + struct pipe_resource *_resource) { - identity_resource_destroy(identity_resource(_texture)); + identity_resource_destroy(identity_resource(_resource)); } static struct pipe_surface * identity_screen_get_tex_surface(struct pipe_screen *_screen, - struct pipe_resource *_texture, + struct pipe_resource *_resource, unsigned face, unsigned level, unsigned zslice, unsigned usage) { struct identity_screen *id_screen = identity_screen(_screen); - struct identity_resource *id_resource = identity_resource(_texture); + struct identity_resource *id_resource = identity_resource(_resource); struct pipe_screen *screen = id_screen->screen; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; struct pipe_surface *result; result = screen->get_tex_surface(screen, - texture, + resource, face, level, zslice, @@ -214,7 +214,7 @@ static struct pipe_resource * identity_screen_user_buffer_create(struct pipe_screen *_screen, void *ptr, unsigned bytes, - unsigned usage) + unsigned usage) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; @@ -223,7 +223,7 @@ identity_screen_user_buffer_create(struct pipe_screen *_screen, result = screen->user_buffer_create(screen, ptr, bytes, - usage); + usage); if (result) return identity_resource_create(id_screen, result); |