diff options
author | Gurchetan Singh <[email protected]> | 2019-01-03 16:20:47 -0800 |
---|---|---|
committer | Gert Wollny <[email protected]> | 2019-02-15 11:19:04 +0100 |
commit | 168c3ffce34e8c0f81d6bf32da82c0b5427f5c89 (patch) | |
tree | 8e60c88aa0edb26e231fc27c10dd2d1bd3293ac9 | |
parent | d5c2dacc155912ad6e78afe9022aabc9af6ee697 (diff) |
virgl: when creating / freeing transfers, pass slab pool directly
This will allow us to destroy transfers w/o having a pointer
to the context.
Reviewed-by: Gert Wollny <[email protected]>
-rw-r--r-- | src/gallium/drivers/virgl/virgl_buffer.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.c | 9 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_texture.c | 8 |
4 files changed, 14 insertions, 14 deletions
diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c index 3c732c90132..e46c9f504fd 100644 --- a/src/gallium/drivers/virgl/virgl_buffer.c +++ b/src/gallium/drivers/virgl/virgl_buffer.c @@ -50,8 +50,8 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx, if (doflushwait) ctx->flush(ctx, NULL, 0); - trans = virgl_resource_create_transfer(ctx, resource, &vbuf->metadata, level, - usage, box); + trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource, + &vbuf->metadata, level, usage, box); readback = virgl_res_needs_readback(vctx, vbuf, usage, 0); if (readback) @@ -66,6 +66,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx, ptr = vs->vws->resource_map(vs->vws, vbuf->hw_res); if (!ptr) { + virgl_resource_destroy_transfer(&vctx->transfer_pool, trans); return NULL; } @@ -100,7 +101,7 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx, } out: - virgl_resource_destroy_transfer(vctx, trans); + virgl_resource_destroy_transfer(&vctx->transfer_pool, 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 40f70be8036..e9ccf66f8d0 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -192,7 +192,7 @@ void virgl_resource_layout(struct pipe_resource *pt, } struct virgl_transfer * -virgl_resource_create_transfer(struct pipe_context *ctx, +virgl_resource_create_transfer(struct slab_child_pool *pool, struct pipe_resource *pres, const struct virgl_resource_metadata *metadata, unsigned level, unsigned usage, @@ -200,7 +200,6 @@ virgl_resource_create_transfer(struct pipe_context *ctx, { struct virgl_transfer *trans; enum pipe_format format = pres->format; - struct virgl_context *vctx = virgl_context(ctx); const unsigned blocksy = box->y / util_format_get_blockheight(format); const unsigned blocksx = box->x / util_format_get_blockwidth(format); @@ -223,7 +222,7 @@ virgl_resource_create_transfer(struct pipe_context *ctx, offset += blocksy * metadata->stride[level]; offset += blocksx * util_format_get_blocksize(format); - trans = slab_alloc(&vctx->transfer_pool); + trans = slab_alloc(pool); if (!trans) return NULL; @@ -248,11 +247,11 @@ virgl_resource_create_transfer(struct pipe_context *ctx, return trans; } -void virgl_resource_destroy_transfer(struct virgl_context *vctx, +void virgl_resource_destroy_transfer(struct slab_child_pool *pool, struct virgl_transfer *trans) { util_range_destroy(&trans->range); - slab_free(&vctx->transfer_pool, trans); + slab_free(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 4aa2e71ecee..3a017ef2355 100644 --- a/src/gallium/drivers/virgl/virgl_resource.h +++ b/src/gallium/drivers/virgl/virgl_resource.h @@ -122,13 +122,13 @@ void virgl_resource_layout(struct pipe_resource *pt, struct virgl_resource_metadata *metadata); struct virgl_transfer * -virgl_resource_create_transfer(struct pipe_context *ctx, +virgl_resource_create_transfer(struct slab_child_pool *pool, 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 virgl_context *vctx, +void virgl_resource_destroy_transfer(struct slab_child_pool *pool, 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 9a402056e7a..ac937ec36d1 100644 --- a/src/gallium/drivers/virgl/virgl_texture.c +++ b/src/gallium/drivers/virgl/virgl_texture.c @@ -114,8 +114,8 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx, if (doflushwait) ctx->flush(ctx, NULL, 0); - trans = virgl_resource_create_transfer(ctx, resource, &vtex->metadata, - level, usage, box); + trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource, + &vtex->metadata, level, usage, box); if (resource->nr_samples > 1) { struct pipe_resource tmp_resource; @@ -147,7 +147,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx, ptr = vs->vws->resource_map(vs->vws, hw_res); if (!ptr) { - slab_free(&vctx->transfer_pool, trans); + virgl_resource_destroy_transfer(&vctx->transfer_pool, trans); return NULL; } @@ -177,7 +177,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx, if (trans->resolve_tmp) pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL); - virgl_resource_destroy_transfer(vctx, trans); + virgl_resource_destroy_transfer(&vctx->transfer_pool, trans); } static const struct u_resource_vtbl virgl_texture_vtbl = |