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 <gert.wollny@collabora.com>
This commit is contained in:
parent
d5c2dacc15
commit
168c3ffce3
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue