llvmpipe: fix crash when not all attachments are populated in a fb
[mesa.git] / src / gallium / drivers / identity / id_objects.c
index d50914e7d5dc637a2ce48254dfce7a5220c5f5b6..a26d9874870b9bc0b0f3f3f8953003ca6ee7c0a0 100644 (file)
@@ -71,7 +71,8 @@ identity_resource_destroy(struct identity_resource *id_resource)
 
 
 struct pipe_surface *
-identity_surface_create(struct identity_resource *id_resource,
+identity_surface_create(struct identity_context *id_context,
+                        struct identity_resource *id_resource,
                         struct pipe_surface *surface)
 {
    struct identity_surface *id_surface;
@@ -100,18 +101,57 @@ error:
 }
 
 void
-identity_surface_destroy(struct identity_surface *id_surface)
+identity_surface_destroy(struct identity_context *id_context,
+                         struct identity_surface *id_surface)
 {
    pipe_resource_reference(&id_surface->base.texture, NULL);
-   pipe_surface_reference(&id_surface->surface, NULL);
+   id_context->pipe->surface_destroy(id_context->pipe,
+                                     id_surface->surface);
    FREE(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 = CALLOC_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;
+   id_view->sampler_view = view;
+
+   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 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;
 
@@ -135,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;
 }
 
@@ -144,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);
 }