ctx->flush(ctx, NULL, 0);
readback = virgl_res_needs_readback(vctx, vbuf, usage, 0);
- if (readback) {
+ if (readback)
vs->vws->transfer_get(vs->vws, vbuf->hw_res, box, trans->base.stride,
trans->l_stride, trans->offset, level);
+ if (readback || flush)
vs->vws->resource_wait(vs->vws, vbuf->hw_res);
- }
ptr = vs->vws->resource_map(vs->vws, vbuf->hw_res);
if (!ptr) {
unsigned layer_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 };
virgl_resource_dirty(grres, 0);
- if (virgl_res_needs_flush(vctx, &trans))
+ if (virgl_res_needs_flush(vctx, &trans)) {
ctx->flush(ctx, NULL, 0);
+ vs->vws->resource_wait(vs->vws, grres->hw_res);
+ }
virgl_encoder_inline_write(vctx, grres, level, usage,
box, data, stride, layer_stride);
struct virgl_winsys *vws = virgl_screen(ctx->screen)->vws;
struct virgl_resource *vtex = virgl_resource(resource);
struct virgl_transfer *trans;
+ bool flush, readback;
trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
&vtex->metadata, level, usage, box);
assert(resource->nr_samples <= 1);
- if (virgl_res_needs_flush(vctx, trans))
+ flush = virgl_res_needs_flush(vctx, trans);
+ if (flush)
ctx->flush(ctx, NULL, 0);
- if (virgl_res_needs_readback(vctx, vtex, usage, level)) {
+ readback = virgl_res_needs_readback(vctx, vtex, usage, level);
+ if (readback)
vws->transfer_get(vws, vtex->hw_res, box, trans->base.stride,
trans->l_stride, trans->offset, level);
+ if (readback || flush)
vws->resource_wait(vws, vtex->hw_res);
- }
void *ptr = vws->resource_map(vws, vtex->hw_res);
if (!ptr) {