From dac1573a3586565b8b78bd6aab3664921cc1adb1 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Wed, 25 Mar 2020 20:01:08 +1300 Subject: [PATCH] mesa/format_utils: Add a fast-path for RGBA to BGRA MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is similar to an existing fast-path, but this is for an array source while the existing one is for an array destination. Firefox can hit this case for WebGL when GL compositing is not used. For a WebGL sample on the Panfrost driver, the frame-rate increased from 19.4 fps to 20.6 fps, which is a 6% gain. Reviewed-by: Marek Olšák Reviewed-by: Alyssa Rosenzweig Tested-by: Marge Bot Part-of: --- src/mesa/main/format_utils.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c index 2bdb77c34fc..732e2424cbb 100644 --- a/src/mesa/main/format_utils.c +++ b/src/mesa/main/format_utils.c @@ -36,6 +36,10 @@ const mesa_array_format RGBA8_UBYTE = MESA_ARRAY_FORMAT(MESA_ARRAY_FORMAT_BASE_FORMAT_RGBA_VARIANTS, 1, 0, 0, 1, 4, 0, 1, 2, 3); +const mesa_array_format BGRA8_UBYTE = + MESA_ARRAY_FORMAT(MESA_ARRAY_FORMAT_BASE_FORMAT_RGBA_VARIANTS, + 1, 0, 0, 1, 4, 2, 1, 0, 3); + const mesa_array_format RGBA32_UINT = MESA_ARRAY_FORMAT(MESA_ARRAY_FORMAT_BASE_FORMAT_RGBA_VARIANTS, 4, 0, 0, 0, 4, 0, 1, 2, 3); @@ -350,6 +354,11 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride, dst += dst_stride; } return; + } else if (dst_array_format == BGRA8_UBYTE && + src_format == MESA_FORMAT_R8G8B8A8_UNORM) { + convert_ubyte_rgba_to_bgra(width, height, src, src_stride, + dst, dst_stride); + return; } else if (dst_array_format == RGBA32_UINT && _mesa_is_format_unsigned(src_format)) { assert(_mesa_is_format_integer_color(src_format)); -- 2.30.2