From dd5bf189ef84b938ebe1017333b4f00cc192b365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Marchesin?= Date: Sat, 26 Jun 2021 03:02:42 +0200 Subject: [PATCH] virgl: Flush context before waiting on fences The logic behind this change is intuitive: if we are waiting for something, we should probably flush all pending rendering so that it starts executing in the meantime. This prevents the GPU from sitting idle for long periods of time while we are also blocked in the app. With the gun3d trace: Before: 79 fps After: 215 fps Reviewed-by: Gert Wollny Reviewed-by: Chia-I Wu Part-of: --- src/gallium/drivers/virgl/virgl_context.c | 4 ++-- src/gallium/drivers/virgl/virgl_context.h | 2 ++ src/gallium/drivers/virgl/virgl_screen.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index e9b8c2430dc..b90674c1cc5 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -936,8 +936,8 @@ static void virgl_submit_cmd(struct virgl_winsys *vws, } } -static void virgl_flush_eq(struct virgl_context *ctx, void *closure, - struct pipe_fence_handle **fence) +void virgl_flush_eq(struct virgl_context *ctx, void *closure, + struct pipe_fence_handle **fence) { struct virgl_screen *rs = virgl_screen(ctx->base.screen); diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h index 638f0117f68..455af6240d5 100644 --- a/src/gallium/drivers/virgl/virgl_context.h +++ b/src/gallium/drivers/virgl/virgl_context.h @@ -138,4 +138,6 @@ void virgl_rebind_resource(struct virgl_context *vctx, struct pipe_resource *res); +void virgl_flush_eq(struct virgl_context *ctx, void *closure, + struct pipe_fence_handle **fence); #endif diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index 80af635ba1b..45b2a14a063 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -802,6 +802,10 @@ static bool virgl_fence_finish(struct pipe_screen *screen, { struct virgl_screen *vscreen = virgl_screen(screen); struct virgl_winsys *vws = vscreen->vws; + struct virgl_context *vctx = virgl_context(ctx); + + if (vctx && timeout) + virgl_flush_eq(vctx, NULL, NULL); return vws->fence_wait(vws, fence, timeout); }