From 9aa833bafd37839498c40312033b3cee3f6fdf82 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Mon, 8 Apr 2019 17:25:47 -0700 Subject: [PATCH] vrend: prefer glGetTexImage on GL Given a source and destination image, consider the following sequence of events: 1) glTexImage with src 2) virgl_resource_copy_region copies src to dst using GL 3) mesa attempts to readback dst, which returns the correct result with vrend_transfer_send_getteximage only Commands that reproduce this scenario on i965/qemu: ./bin/arb_copy_image-formats -auto ./bin/fbo-generatemipmap-formats GL_ARB_texture_float -auto Signed-off-by: Gurchetan Singh Reviewed-by: Erik Faye-Lund --- src/vrend_renderer.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 17408fe..1c22551 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -6880,16 +6880,17 @@ static int vrend_renderer_transfer_send_iov(struct vrend_resource *res, can_readpixels = vrend_format_can_render(res->base.format) || vrend_format_is_ds(res->base.format); - if (can_readpixels) { + if (can_readpixels) ret = vrend_transfer_send_readpixels(res, iov, num_iovs, info); - } else { - ret = vrend_transfer_send_readonly(res, iov, num_iovs, info); - } /* Can hit this on a non-error path as well. */ - if (ret != 0 && !vrend_state.use_gles) { - ret = vrend_transfer_send_getteximage(res, iov, num_iovs, info); + if (ret) { + if (!vrend_state.use_gles) + ret = vrend_transfer_send_getteximage(res, iov, num_iovs, info); + else + ret = vrend_transfer_send_readonly(res, iov, num_iovs, info); } + return ret; } return 0;