From 6e2b01e5b806b3b0ec9df896f4ddc842a54f4fa6 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Thu, 25 Aug 2022 08:30:53 +0200 Subject: [PATCH] virgl: when reading back wait first, then do the transfer Otherwise the transfer from the host might not be finished when we try to read the data. v2: always wait before readback, but also keep the wait after a possible readback, Itherwise TF fails in the CI. Fixes: e87186fc679c146c5d521139bb79c8eafa0a22f0 virgl: add virgl_resource_transfer_prepare Signed-off-by: Gert Wollny Reviewed-by: Yiwei Zhang Reviewed-by: Ryan Neph Part-of: --- src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt | 2 -- src/gallium/drivers/virgl/virgl_resource.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt index 33387e6fd2c..e28ae57c131 100644 --- a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt +++ b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt @@ -434,8 +434,6 @@ spec@arb_point_sprite@arb_point_sprite-mipmap,Fail spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex,Fail spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex@'vs_input2[1][0]' on GL_PROGRAM_INPUT,Fail -spec@arb_shader_atomic_counters@fragment-discard,Fail - spec@arb_sample_shading@builtin-gl-sample-position 2,Fail spec@arb_shader_image_load_store@early-z,Fail spec@arb_shader_image_load_store@early-z@occlusion query test/early-z pass,Fail diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index 461c1768ed8..f8edcc182bc 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -253,11 +253,6 @@ virgl_resource_transfer_prepare(struct virgl_context *vctx, else return VIRGL_TRANSFER_MAP_WRITE_TO_STAGING_WITH_READBACK; } - /* Readback is yet another command and is transparent to the state - * trackers. It should be waited for in all cases, including when - * PIPE_MAP_UNSYNCHRONIZED is set. - */ - wait = true; /* When the transfer queue has pending writes to this transfer's region, * we have to flush before readback. @@ -281,8 +276,16 @@ virgl_resource_transfer_prepare(struct virgl_context *vctx, return VIRGL_TRANSFER_MAP_ERROR; if (readback) { + /* Readback is yet another command and is transparent to the state + * trackers. It should be waited for in all cases, including when + * PIPE_MAP_UNSYNCHRONIZED is set. + */ + vws->resource_wait(vws, res->hw_res); vws->transfer_get(vws, res->hw_res, &xfer->base.box, xfer->base.stride, xfer->l_stride, xfer->offset, xfer->base.level); + /* transfer_get puts the resource into a maybe_busy state, so we will have + * to wait another time if we want to use that resource. */ + wait = true; } if (wait)