From cc53815ae10dc39c7e56a3801568794a6ad8b539 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 18 Apr 2019 15:34:46 -0700 Subject: [PATCH] virgl: skip empty cmdbufs Several empty cmdbufs are submitted by app/xserver per frame, from glamor_block_handler for example. Let's skip them. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/gallium/drivers/virgl/virgl_context.c | 8 ++++++++ src/gallium/drivers/virgl/virgl_context.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 69b56bfd036..b3119ee95cc 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -756,6 +756,12 @@ static void virgl_flush_eq(struct virgl_context *ctx, void *closure, { struct virgl_screen *rs = virgl_screen(ctx->base.screen); + /* skip empty cbuf */ + if (ctx->cbuf->cdw == ctx->cbuf_initial_cdw && + ctx->queue.num_dwords == 0 && + !fence) + return; + if (ctx->num_draws) u_upload_unmap(ctx->uploader); @@ -773,6 +779,8 @@ static void virgl_flush_eq(struct virgl_context *ctx, void *closure, /* add back current framebuffer resources to reference list? */ virgl_reemit_res(ctx); + + ctx->cbuf_initial_cdw = ctx->cbuf->cdw; } static void virgl_flush_from_st(struct pipe_context *ctx, diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h index 1ac4ddb0541..828e72514a4 100644 --- a/src/gallium/drivers/virgl/virgl_context.h +++ b/src/gallium/drivers/virgl/virgl_context.h @@ -59,6 +59,7 @@ struct virgl_rasterizer_state { struct virgl_context { struct pipe_context base; struct virgl_cmd_buf *cbuf; + unsigned cbuf_initial_cdw; struct virgl_textures_info samplers[PIPE_SHADER_TYPES]; struct virgl_vertex_elements_state *vertex_elements; -- 2.30.2