mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 19:58:09 +02:00
identity: Move sampler view create and destroy to id_objects.c
This commit is contained in:
parent
59b160d286
commit
c2c1f60391
3 changed files with 67 additions and 34 deletions
|
|
@ -700,43 +700,31 @@ identity_is_resource_referenced(struct pipe_context *_pipe,
|
|||
}
|
||||
|
||||
static struct pipe_sampler_view *
|
||||
identity_create_sampler_view(struct pipe_context *pipe,
|
||||
struct pipe_resource *resource,
|
||||
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(resource);
|
||||
struct pipe_context *pipe_unwrapped = id_pipe->pipe;
|
||||
struct pipe_resource *resource_unwrapped = id_resource->resource;
|
||||
struct identity_sampler_view *view = MALLOC(sizeof(struct identity_sampler_view));
|
||||
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->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
|
||||
resource_unwrapped,
|
||||
templ);
|
||||
result = pipe->create_sampler_view(pipe,
|
||||
resource,
|
||||
templ);
|
||||
|
||||
view->base = *templ;
|
||||
view->base.reference.count = 1;
|
||||
view->base.texture = NULL;
|
||||
pipe_resource_reference(&view->base.texture, resource);
|
||||
view->base.context = pipe;
|
||||
|
||||
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 *
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,42 @@ 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,
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,15 @@ 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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue