virgl: pass virgl transfer to virgl_res_needs_flush_wait
authorGurchetan Singh <gurchetansingh@chromium.org>
Sat, 9 Feb 2019 02:07:37 +0000 (18:07 -0800)
committerGert Wollny <gert.wollny@collabora.com>
Fri, 15 Feb 2019 10:19:05 +0000 (11:19 +0100)
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_texture.c

index e46c9f504fd378984154c9bec6cf59b03690178a..269a451ac18c91e71fb5e0d093dac2fac2ca3372 100644 (file)
@@ -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,
index 664f0fe915b90687d902b715e3b326034ec41d52..a4d4ab704ebda52eb7cfccc1db6d211423bce780 100644 (file)
@@ -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);
index e9ccf66f8d04fdd44bc909c9e21c16f0baf9e913..9b42bd14c420e52ea938232a6a638dca688d3689 100644 (file)
 #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;
index 3a017ef23557cd26dfbac642bff536fd7fbe99e4..acc046ac442eb9203202a51e15a3735b5272602e 100644 (file)
@@ -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);
index ac937ec36d15f5bccd36e73cc45374e51492cfc9..3bffee9b7a54955938622108623612e2228d5e60 100644 (file)
@@ -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,