vrend: don't change the readback format for emulated BGRA unless bgraswz is active

When reading back a BGRA surface the client expects the data in BGRA
order, and when we emulate the format by using a swizzled BGRA on GLES
we still have to use the original format information to read back the
data.

However, this results in mesa internally swizzling the RGBA data to BGRA
ordering on the CPU. This performance hit can be avoided for
applications that only blit or render to BGRA surfaces, because here we
can set the bgraswz tweak that does the szizzling on the GPU when
drawing or blitting to a BGRA surface and then we can read the data back
as is.

With that for vtest the bgraswz tweak becomes purley a performance
tweak. Replaying a trace of The Raven Remastered showed a 1% increase
of performance when enabling the bgraswz tweak.

Closes #174

v2: Fix typo (Gurchetan)
v3: fix more typos (Gurchetan)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gert Wollny 4 years ago
parent 2dc844a4ca
commit a15838e456
  1. 13
      src/vrend_renderer.c

@ -7572,7 +7572,18 @@ static int vrend_transfer_send_readpixels(struct vrend_context *ctx,
else else
glUseProgram(0); glUseProgram(0);
enum virgl_formats fmt = vrend_format_replace_emulated(res->base.bind, res->base.format); /* If the emubgra tweak is active then reading back the BGRA format emulated
* by swizzling a RGBA format will take a performance hit because mesa will
* manually swizzling the RGBA data. This can be avoided by setting the
* tweak bgraswz that does this swizzling already on the GPU when blitting
* or rendering to an emulated BGRA surface and reading back the data as
* RGBA. The check whether we are on gles and emugbra is active is done
* in vrend_format_replace_emulated, so no need to repeat the test here */
enum virgl_formats fmt = res->base.format;
if (vrend_get_tweak_is_active(&ctx->sub->tweaks,
virgl_tweak_gles_brga_apply_dest_swizzle))
fmt = vrend_format_replace_emulated(res->base.bind, res->base.format);
format = tex_conv_table[fmt].glformat; format = tex_conv_table[fmt].glformat;
type = tex_conv_table[fmt].gltype; type = tex_conv_table[fmt].gltype;
/* if we are asked to invert and reading from a front then don't */ /* if we are asked to invert and reading from a front then don't */

Loading…
Cancel
Save