virgl: pass virgl_context to transfer create/destroy
authorChia-I Wu <olvaffe@gmail.com>
Wed, 15 May 2019 22:46:40 +0000 (15:46 -0700)
committerChia-I Wu <olvaffe@gmail.com>
Thu, 13 Jun 2019 01:20:30 +0000 (18:20 -0700)
A pipe_transfer is a context object.  It is fine for the
constructor/destructor to have access to the context.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_texture.c
src/gallium/drivers/virgl/virgl_transfer_queue.c

index 882fae2f8ba857cc27bfdfb3c6e7280961b1a941..ddb632db48334b399f404904f646a1a5a44388b2 100644 (file)
@@ -42,7 +42,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    enum virgl_transfer_map_type map_type;
    void *map_addr;
 
-   trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
+   trans = virgl_resource_create_transfer(vctx, resource,
                                           &vbuf->metadata, level, usage, box);
 
    map_type = virgl_resource_transfer_prepare(vctx, trans);
@@ -67,7 +67,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    }
 
    if (!map_addr) {
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
       return NULL;
    }
 
@@ -89,14 +89,14 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
    /* We don't need to transfer the contents of staging buffers, since they
     * don't have any host-side storage. */
    if (pipe_to_virgl_bind(vs, res->bind, res->flags) == VIRGL_BIND_STAGING) {
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
       return;
    }
 
    if (trans->base.usage & PIPE_TRANSFER_WRITE) {
       if (transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT) {
          if (trans->range.end <= trans->range.start) {
-            virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+            virgl_resource_destroy_transfer(vctx, trans);
             return;
          }
 
@@ -109,12 +109,12 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
          virgl_encode_copy_transfer(vctx, trans);
          /* It's now safe for other mappings to use the transfer_uploader. */
          vctx->transfer_uploader_in_use = false;
-         virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+         virgl_resource_destroy_transfer(vctx, trans);
       } else {
          virgl_transfer_queue_unmap(&vctx->queue, trans);
       }
    } else
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
 }
 
 static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
index e8baa4368e20beced6bf49054b5f6e7aaa0e9d8f..e840caa52a940b55521be0e654afbc8042d13903 100644 (file)
@@ -381,7 +381,7 @@ void virgl_resource_layout(struct pipe_resource *pt,
 }
 
 struct virgl_transfer *
-virgl_resource_create_transfer(struct slab_child_pool *pool,
+virgl_resource_create_transfer(struct virgl_context *vctx,
                                struct pipe_resource *pres,
                                const struct virgl_resource_metadata *metadata,
                                unsigned level, unsigned usage,
@@ -411,7 +411,7 @@ virgl_resource_create_transfer(struct slab_child_pool *pool,
    offset += blocksy * metadata->stride[level];
    offset += blocksx * util_format_get_blocksize(format);
 
-   trans = slab_alloc(pool);
+   trans = slab_alloc(&vctx->transfer_pool);
    if (!trans)
       return NULL;
 
@@ -438,12 +438,12 @@ virgl_resource_create_transfer(struct slab_child_pool *pool,
    return trans;
 }
 
-void virgl_resource_destroy_transfer(struct slab_child_pool *pool,
+void virgl_resource_destroy_transfer(struct virgl_context *vctx,
                                      struct virgl_transfer *trans)
 {
    pipe_resource_reference(&trans->copy_src_res, NULL);
    util_range_destroy(&trans->range);
-   slab_free(pool, trans);
+   slab_free(&vctx->transfer_pool, trans);
 }
 
 void virgl_resource_destroy(struct pipe_screen *screen,
index 2b9de1b4be476038e5a199fb753263b7e926fc26..710244d2c7fbf80b8644d0e8d83d30e077f6ced8 100644 (file)
@@ -155,13 +155,13 @@ void virgl_resource_layout(struct pipe_resource *pt,
                            struct virgl_resource_metadata *metadata);
 
 struct virgl_transfer *
-virgl_resource_create_transfer(struct slab_child_pool *pool,
+virgl_resource_create_transfer(struct virgl_context *vctx,
                                struct pipe_resource *pres,
                                const struct virgl_resource_metadata *metadata,
                                unsigned level, unsigned usage,
                                const struct pipe_box *box);
 
-void virgl_resource_destroy_transfer(struct slab_child_pool *pool,
+void virgl_resource_destroy_transfer(struct virgl_context *vctx,
                                      struct virgl_transfer *trans);
 
 void virgl_resource_destroy(struct pipe_screen *screen,
index 0d9c6a03e3517ab416017d97679cc068e484f2bf..6e26493cb61e5395983544a1a43b7b722eb1fa31 100644 (file)
@@ -126,7 +126,7 @@ static void *texture_transfer_map_plain(struct pipe_context *ctx,
    enum virgl_transfer_map_type map_type;
    void *map_addr;
 
-   trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
+   trans = virgl_resource_create_transfer(vctx, resource,
                                           &vtex->metadata, level, usage, box);
    trans->resolve_transfer = NULL;
 
@@ -154,7 +154,7 @@ static void *texture_transfer_map_plain(struct pipe_context *ctx,
    }
 
    if (!map_addr) {
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
       return NULL;
    }
 
@@ -174,7 +174,7 @@ static void *texture_transfer_map_resolve(struct pipe_context *ctx,
    struct pipe_resource templ, *resolve_tmp;
    struct virgl_transfer *trans;
 
-   trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
+   trans = virgl_resource_create_transfer(vctx, resource,
                                           &vtex->metadata, level, usage, box);
    if (!trans)
       return NULL;
@@ -260,7 +260,7 @@ static void *texture_transfer_map_resolve(struct pipe_context *ctx,
 
 fail:
    pipe_resource_reference(&resolve_tmp, NULL);
-   virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+   virgl_resource_destroy_transfer(vctx, trans);
    return NULL;
 }
 
@@ -313,7 +313,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
    /* We don't need to transfer the contents of staging buffers, since they
     * don't have any host-side storage. */
    if (pipe_to_virgl_bind(vs, res->bind, res->flags) == VIRGL_BIND_STAGING) {
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
       return;
    }
 
@@ -343,7 +343,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
 
    if (trans->resolve_transfer) {
       pipe_resource_reference(&trans->resolve_transfer->resource, NULL);
-      virgl_resource_destroy_transfer(&vctx->transfer_pool,
+      virgl_resource_destroy_transfer(vctx,
                                       virgl_transfer(trans->resolve_transfer));
    }
 
@@ -352,14 +352,13 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
          virgl_encode_copy_transfer(vctx, trans);
          /* It's now safe for other mappings to use the transfer_uploader. */
          vctx->transfer_uploader_in_use = false;
-         virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+         virgl_resource_destroy_transfer(vctx, trans);
       } else {
          virgl_transfer_queue_unmap(&vctx->queue, trans);
       }
    } else {
-      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
+      virgl_resource_destroy_transfer(vctx, trans);
    }
-
 }
 
 static const struct u_resource_vtbl virgl_texture_vtbl =
index 020c42ac14c698ec961464f902b0a0f82ebefe71..81edfe51ffb2f49f5121e14ffd70c454816f37e6 100644 (file)
@@ -123,7 +123,7 @@ static void remove_transfer(struct virgl_transfer_queue *queue,
    struct pipe_resource *pres = queued->base.resource;
    list_del(&queued->queue_link);
    pipe_resource_reference(&pres, NULL);
-   virgl_resource_destroy_transfer(&queue->vctx->transfer_pool, queued);
+   virgl_resource_destroy_transfer(queue->vctx, queued);
 }
 
 static void replace_unmapped_transfer(struct virgl_transfer_queue *queue,