bool readback;
bool doflushwait = false;
+ trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
+ &vbuf->metadata, level, usage, box);
if (usage & PIPE_TRANSFER_READ)
doflushwait = true;
else
- doflushwait = virgl_res_needs_flush_wait(vctx, vbuf, usage);
+ doflushwait = virgl_res_needs_flush_wait(vctx, trans);
if (doflushwait)
ctx->flush(ctx, NULL, 0);
- 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)
vs->vws->transfer_get(vs->vws, vbuf->hw_res, box, trans->base.stride,
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
struct virgl_resource *grres = virgl_resource(res);
+ struct virgl_transfer trans = { 0 };
+
+ trans.base.resource = res;
+ trans.base.level = level;
+ trans.base.usage = usage;
+ trans.base.box = *box;
+ trans.base.stride = stride;
+ trans.base.layer_stride = layer_stride;
+ trans.offset = box->x;
virgl_resource_dirty(grres, 0);
- if (virgl_res_needs_flush_wait(vctx, grres, usage)) {
+ if (virgl_res_needs_flush_wait(vctx, &trans)) {
ctx->flush(ctx, NULL, 0);
vs->vws->resource_wait(vs->vws, grres->hw_res);
#include "virgl_screen.h"
bool virgl_res_needs_flush_wait(struct virgl_context *vctx,
- struct virgl_resource *res,
- unsigned usage)
+ struct virgl_transfer *trans)
{
struct virgl_screen *vs = virgl_screen(vctx->base.screen);
+ struct virgl_resource *res = virgl_resource(trans->base.resource);
- if ((!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) && vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) {
+ if ((!(trans->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED)) &&
+ vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) {
return true;
}
return false;
}
bool virgl_res_needs_flush_wait(struct virgl_context *vctx,
- struct virgl_resource *res,
- unsigned usage);
+ struct virgl_transfer *transfer);
bool virgl_res_needs_readback(struct virgl_context *vctx,
struct virgl_resource *res,
unsigned usage, unsigned level);
struct virgl_hw_res *hw_res;
bool doflushwait;
- doflushwait = virgl_res_needs_flush_wait(vctx, vtex, usage);
- if (doflushwait)
- ctx->flush(ctx, NULL, 0);
-
trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
&vtex->metadata, level, usage, box);
+ doflushwait = virgl_res_needs_flush_wait(vctx, trans);
+ if (doflushwait)
+ ctx->flush(ctx, NULL, 0);
+
if (resource->nr_samples > 1) {
struct pipe_resource tmp_resource;
virgl_init_temp_resource_from_box(&tmp_resource, resource, box,