{
struct pipe_transfer *transfer = &xfer->base;
- struct virgl_resource *res = virgl_resource(transfer->resource);
unsigned stride;
unsigned layer_stride;
assert(!"Invalid virgl_transfer3d_encode_stride value");
}
- virgl_encoder_emit_resource(vs, buf, res);
+ /* We cannot use virgl_encoder_emit_resource with transfer->resource here
+ * because transfer->resource might have a different virgl_hw_res than what
+ * this transfer targets, which is saved in xfer->hw_res.
+ */
+ vs->vws->emit_res(vs->vws, buf, xfer->hw_res, TRUE);
virgl_encoder_write_dword(buf, transfer->level);
virgl_encoder_write_dword(buf, transfer->usage);
virgl_encoder_write_dword(buf, stride);
struct virgl_screen *vs = virgl_screen(ctx->base.screen);
transfer.base.resource = &res->u.b;
+ transfer.hw_res = res->hw_res;
transfer.base.level = level;
transfer.base.usage = usage;
transfer.base.box = *box;
unsigned level, unsigned usage,
const struct pipe_box *box)
{
+ struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws;
struct virgl_transfer *trans;
enum pipe_format format = pres->format;
const unsigned blocksy = box->y / util_format_get_blockheight(format);
/* note that trans is not zero-initialized */
trans->base.resource = NULL;
pipe_resource_reference(&trans->base.resource, pres);
+ trans->hw_res = NULL;
+ vws->resource_reference(vws, &trans->hw_res, virgl_resource(pres)->hw_res);
+
trans->base.level = level;
trans->base.usage = usage;
trans->base.box = *box;
void virgl_resource_destroy_transfer(struct virgl_context *vctx,
struct virgl_transfer *trans)
{
+ struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws;
+
pipe_resource_reference(&trans->copy_src_res, NULL);
util_range_destroy(&trans->range);
+ vws->resource_reference(vws, &trans->hw_res, NULL);
pipe_resource_reference(&trans->base.resource, NULL);
slab_free(&vctx->transfer_pool, trans);
}
struct util_range range;
struct list_head queue_link;
struct pipe_transfer *resolve_transfer;
+
+ struct virgl_hw_res *hw_res;
void *hw_res_map;
/* If not NULL, denotes that this is a copy transfer, i.e.,
* that the transfer source data should be taken from this
const struct pipe_box *box)
{
struct virgl_winsys *vws = virgl_screen(ctx->screen)->vws;
- vws->transfer_put(vws, virgl_resource(trans->base.resource)->hw_res, box,
+ vws->transfer_put(vws, trans->hw_res, box,
trans->base.stride, trans->l_stride, trans->offset,
trans->base.level);
}
struct virgl_transfer *current)
{
boolean tmp;
- struct pipe_resource *queued_res = queued->base.resource;
- struct pipe_resource *current_res = current->base.resource;
- if (queued_res != current_res)
+ if (queued->hw_res != current->hw_res)
return false;
tmp = u_box_test_intersection_2d(&queued->base.box, ¤t->base.box);
struct virgl_transfer *current)
{
boolean tmp;
- struct pipe_resource *queued_res = queued->base.resource;
- struct pipe_resource *current_res = current->base.resource;
- if (queued_res != current_res)
+ if (queued->hw_res != current->hw_res)
return false;
if (queued->base.level != current->base.level)
/*
* Special case for boxes with [x: 0, width: 1] and [x: 1, width: 1].
*/
- if (queued_res->target == PIPE_BUFFER) {
+ if (queued->base.resource->target == PIPE_BUFFER) {
if (queued->base.box.x + queued->base.box.width == current->base.box.x)
return false;
struct list_action_args *args)
{
struct virgl_transfer *queued = args->queued;
- struct virgl_resource *res = virgl_resource(queued->base.resource);
- queue->vs->vws->transfer_put(queue->vs->vws, res->hw_res, &queued->base.box,
+ queue->vs->vws->transfer_put(queue->vs->vws, queued->hw_res,
+ &queued->base.box,
queued->base.stride, queued->l_stride,
queued->offset, queued->base.level);
int virgl_transfer_queue_unmap(struct virgl_transfer_queue *queue,
struct virgl_transfer *transfer)
{
- struct pipe_resource *res = transfer->base.resource;
struct list_iteration_args iter;
/* We don't support copy transfers in the transfer queue. */
assert(!transfer->copy_src_res);
/* Attempt to merge multiple intersecting transfers into a single one. */
- if (res->target == PIPE_BUFFER) {
+ if (transfer->base.resource->target == PIPE_BUFFER) {
memset(&iter, 0, sizeof(iter));
iter.current = transfer;
iter.compare = transfers_intersect;