}
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));
-
- view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
- resource_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, resource);
- 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 *
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;
}
+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_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);
}
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,