From 3b29b0723d0c93513747acb9723b21a11cbe4014 Mon Sep 17 00:00:00 2001 From: Ryan Neph Date: Thu, 24 Jun 2021 19:10:15 +0000 Subject: [PATCH] vrend: force temp buffers for BGR* swizzles on small iovec transfers On GLES hosts, BGR* resources are manually swizzled to RGB* internal format on creation and swizzled back to BGR* format on readback. For small transfers, iovec data is directly passed to the host driver without staging in a temp buffer first. When swizzling for BGR* resources, this modifies the persistend iovec buffer when it should remain in the user-provided format. So we force temp buffers for all iovec transfers on BGR* resources on GLES hosts to fix this. Signed-off-by: Ryan Neph Reviewed-by: Lepton Wu --- src/vrend_renderer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 0106868..25bc69b 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7560,6 +7560,10 @@ static int vrend_renderer_transfer_write_iov(struct vrend_context *ctx, need_temp = true; } + if (vrend_state.use_gles && vrend_format_is_bgra(res->base.format) && + !vrend_resource_is_emulated_bgra(res)) + need_temp = true; + if (vrend_state.use_core_profile == true && (res->y_0_top || (res->base.format == VIRGL_FORMAT_Z24X8_UNORM))) { need_temp = true; @@ -7938,6 +7942,10 @@ static int vrend_transfer_send_readpixels(struct vrend_context *ctx, if (num_iovs > 1 || separate_invert) need_temp = 1; + if (vrend_state.use_gles && vrend_format_is_bgra(res->base.format) && + !vrend_resource_is_emulated_bgra(res)) + need_temp = true; + if (need_temp) { send_size = util_format_get_nblocks(res->base.format, info->box->width, info->box->height) * info->box->depth * util_format_get_blocksize(res->base.format); data = malloc(send_size);