Mesa (master): virgl: add VIRGL_DEBUG_SYNC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 25 19:16:28 UTC 2019


Module: Mesa
Branch: master
Commit: e93d918b65ecd30b6973dd38b04b5c4324fd53de
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e93d918b65ecd30b6973dd38b04b5c4324fd53de

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Mon Jun 24 10:45:36 2019 -0700

virgl: add VIRGL_DEBUG_SYNC

When set, wait after every each flush.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-By: Gert Wollny <gert.wollny at collabora.com>
Reviewed-By: Alexandros Frantzis <alexandros.frantzis at collabora.com>

---

 src/gallium/drivers/virgl/virgl_context.c | 19 ++++++++++++++++++-
 src/gallium/drivers/virgl/virgl_screen.c  |  1 +
 src/gallium/drivers/virgl/virgl_screen.h  |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 987cdc38be2..3421c71a43d 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -869,6 +869,22 @@ static void virgl_draw_vbo(struct pipe_context *ctx,
 
 }
 
+static void virgl_submit_cmd(struct virgl_winsys *vws,
+                             struct virgl_cmd_buf *cbuf,
+			     struct pipe_fence_handle **fence)
+{
+   if (unlikely(virgl_debug & VIRGL_DEBUG_SYNC)) {
+      struct pipe_fence_handle *sync_fence = NULL;
+
+      vws->submit_cmd(vws, cbuf, &sync_fence);
+
+      vws->fence_wait(vws, sync_fence, PIPE_TIMEOUT_INFINITE);
+      vws->fence_reference(vws, &sync_fence, NULL);
+   } else {
+      vws->submit_cmd(vws, cbuf, fence);
+   }
+}
+
 static void virgl_flush_eq(struct virgl_context *ctx, void *closure,
 			   struct pipe_fence_handle **fence)
 {
@@ -887,7 +903,8 @@ static void virgl_flush_eq(struct virgl_context *ctx, void *closure,
    ctx->num_draws = ctx->num_compute = 0;
 
    virgl_transfer_queue_clear(&ctx->queue, ctx->cbuf);
-   rs->vws->submit_cmd(rs->vws, ctx->cbuf, fence);
+
+   virgl_submit_cmd(rs->vws, ctx->cbuf, fence);
 
    /* Reserve some space for transfers. */
    if (ctx->encoded_transfers)
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 684a2f98546..08e7fbe8b54 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -45,6 +45,7 @@ static const struct debug_named_value debug_options[] = {
    { "tgsi",      VIRGL_DEBUG_TGSI,                NULL },
    { "emubgra",   VIRGL_DEBUG_EMULATE_BGRA,        "Enable tweak to emulate BGRA as RGBA on GLES hosts"},
    { "bgraswz",   VIRGL_DEBUG_BGRA_DEST_SWIZZLE,   "Enable tweak to swizzle emulated BGRA on GLES hosts" },
+   { "sync",      VIRGL_DEBUG_SYNC,                "Sync after every flush" },
    DEBUG_NAMED_VALUE_END
 };
 DEBUG_GET_ONCE_FLAGS_OPTION(virgl_debug, "VIRGL_DEBUG", debug_options, 0)
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index e27ceee7bda..b466c632136 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -32,6 +32,7 @@ enum virgl_debug_flags {
    VIRGL_DEBUG_TGSI                 = 1 << 1,
    VIRGL_DEBUG_EMULATE_BGRA         = 1 << 2,
    VIRGL_DEBUG_BGRA_DEST_SWIZZLE    = 1 << 3,
+   VIRGL_DEBUG_SYNC                 = 1 << 4,
 };
 
 extern int virgl_debug;




More information about the mesa-commit mailing list