From 90409653542628319f79be9ca4b2d77334af8219 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 4 Dec 2020 18:07:42 -0800 Subject: [PATCH] vrend: fix copy transfers with gbm bo We don't know what internal format the GL driver uses and we have to glFinish and do a gbm transfer unless VREND_STORAGE_GL_IMMUTABLE is set. This is motivated by Mesa's internal format change from GL_RGB to GL_RGB8 for VIRGL_FORMAT_B8G8R8X8_UNORM in https://gitlab.freedesktop.org/mesa/mesa/-/commit/5e4d69ec786e56794a995be869b5a9b80d050f2d. That change caused glTexSubImage2D(..., GL_BGRA_EXT, GL_UNSIGNED_BYTE) to be rejected by _mesa_gles_error_check_format_and_type. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/vrend_renderer.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 35eed49..cdd03d8 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -8029,18 +8029,18 @@ int vrend_renderer_copy_transfer3d(struct vrend_context *ctx, bool use_gbm = true; /* The guest uses copy transfers against busy resources to avoid - * waiting. The host driver is usually smart enough to avoid blocking - * by putting the data in a staging buffer and doing a pipelined copy. - * - * However, we cannot do that with GBM. Use GBM only when we have to - * (until vrend_renderer_transfer_write_iov swizzles). + * waiting. The host GL driver is usually smart enough to avoid + * blocking by putting the data in a staging buffer and doing a + * pipelined copy. But when there is a GBM bo, we can only do that when + * VREND_STORAGE_GL_IMMUTABLE is set because it implies that the + * internal format is known and is known to be compatible with the + * subsequence glTexSubImage2D. Otherwise, we glFinish and use GBM. */ if (info->synchronized) { - if (tex_conv_table[dst_res->base.format].internalformat == 0 || - tex_conv_table[dst_res->base.format].flags & VIRGL_TEXTURE_NEED_SWIZZLE) - glFinish(); - else + if (has_bit(dst_res->storage_bits, VREND_STORAGE_GL_IMMUTABLE)) use_gbm = false; + else + glFinish(); } if (use_gbm) {