summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2019-05-15 15:46:40 -0700
committerChia-I Wu <olvaffe@gmail.com>2019-06-12 18:20:30 -0700
commit74051efbea8f330fcd4b23bfe4d1ccf0c66d0e7e (patch)
treeebb2257adf5653ab72ea93f2ba191d37427cade6 /src/gallium
parent514e12b1b8fae55319cbc3702215a305e3d7d60f (diff)
virgl: pass virgl_context to transfer create/destroy
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>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/virgl/virgl_buffer.c12
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.c8
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.h4
-rw-r--r--src/gallium/drivers/virgl/virgl_texture.c17
-rw-r--r--src/gallium/drivers/virgl/virgl_transfer_queue.c2
5 files changed, 21 insertions, 22 deletions
diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index 882fae2f8ba..ddb632db483 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -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,
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index e8baa4368e2..e840caa52a9 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -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,
diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h
index 2b9de1b4be4..710244d2c7f 100644
--- a/src/gallium/drivers/virgl/virgl_resource.h
+++ b/src/gallium/drivers/virgl/virgl_resource.h
@@ -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,
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index 0d9c6a03e35..6e26493cb61 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -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 =
diff --git a/src/gallium/drivers/virgl/virgl_transfer_queue.c b/src/gallium/drivers/virgl/virgl_transfer_queue.c
index 020c42ac14c..81edfe51ffb 100644
--- a/src/gallium/drivers/virgl/virgl_transfer_queue.c
+++ b/src/gallium/drivers/virgl/virgl_transfer_queue.c
@@ -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,