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)
ptr = vs->vws->resource_map(vs->vws, vbuf->hw_res);
if (!ptr) {
+ virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
return NULL;
}
}
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,
}
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,
{
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);
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;
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,
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,
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;
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;
}
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 =