From 90e96505855442fb235b50e29e548cbf8e559edd Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Tue, 5 Feb 2019 18:53:23 -0800 Subject: [PATCH] virgl: add extra checks in virgl_res_needs_flush_wait This is motivated by the following scenario: glSubBufferData(GL_ARRAY_BUFFER, ...) glFlush(..) glSubBufferData(GL_ARRAY_BUFFER, ...) glSubBufferData(GL_ARRAY_BUFFER, ...) glSubBufferData(GL_ARRAY_BUFFER, ...) This increases @davidriley's Team Fortress 2 apitrace from 1 fps to 6 fps and helps with the Chromium glbench microbenchmarks: Before: texture_update_rgba_texsubimage2d_2048 = 554.96 mtexel_sec buffer_upload_dynamic_array_12 = 0.02 mbytes_sec buffer_upload_dynamic_array_576 = 1.07 mbytes_sec After: texture_update_rgba_texsubimage2d_2048 = 612.29 mtexel_sec buffer_upload_dynamic_array_12 = 2.22 mbytes_sec buffer_upload_dynamic_array_576 = 164.89 mbytes_sec Reviewed-by: Gert Wollny --- src/gallium/drivers/virgl/virgl_resource.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index 9b42bd14c42..ddb6b77b769 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -33,11 +33,16 @@ bool virgl_res_needs_flush_wait(struct virgl_context *vctx, struct virgl_screen *vs = virgl_screen(vctx->base.screen); struct virgl_resource *res = virgl_resource(trans->base.resource); - if ((!(trans->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED)) && - vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) { - return true; + if (trans->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED) + return false; + if (!vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) + return false; + if (res->clean[trans->base.level]) { + if (vctx->num_draws == 0 && vctx->num_compute == 0) + return false; } - return false; + + return true; } bool virgl_res_needs_readback(struct virgl_context *vctx, -- 2.30.2