From: Gurchetan Singh Date: Sat, 9 Feb 2019 02:07:37 +0000 (-0800) Subject: virgl: pass virgl transfer to virgl_res_needs_flush_wait X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab6ea6e9cee07dea561426d86f93eff670a53efd;p=mesa.git virgl: pass virgl transfer to virgl_res_needs_flush_wait Reviewed-by: Gert Wollny --- diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c index e46c9f504fd..269a451ac18 100644 --- a/src/gallium/drivers/virgl/virgl_buffer.c +++ b/src/gallium/drivers/virgl/virgl_buffer.c @@ -42,17 +42,16 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx, 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, diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 664f0fe915b..a4d4ab704eb 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -524,10 +524,19 @@ void virgl_transfer_inline_write(struct pipe_context *ctx, 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); diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index e9ccf66f8d0..9b42bd14c42 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -28,12 +28,13 @@ #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; diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h index 3a017ef2355..acc046ac442 100644 --- a/src/gallium/drivers/virgl/virgl_resource.h +++ b/src/gallium/drivers/virgl/virgl_resource.h @@ -112,8 +112,7 @@ static inline unsigned pipe_to_virgl_bind(unsigned pbind) } 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); diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c index ac937ec36d1..3bffee9b7a5 100644 --- a/src/gallium/drivers/virgl/virgl_texture.c +++ b/src/gallium/drivers/virgl/virgl_texture.c @@ -110,13 +110,13 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx, 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,