Mesa (master): mesa: Skip 3-byte array formats in _mesa_array_format_flip_channels

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 27 14:33:32 UTC 2020


Module: Mesa
Branch: master
Commit: c50bbfa0ab513a771167b3885fdbb2b5c75d2384
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c50bbfa0ab513a771167b3885fdbb2b5c75d2384

Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Apr 24 11:40:14 2020 +0200

mesa: Skip 3-byte array formats in _mesa_array_format_flip_channels

Byte swapping makes no sense for 3-byte formats: Swapping the order of 2
or 4 bytes at a time would inevitably result in bytes getting mixed up
between neighbouring pixels.

Fixes crash with a debugging build on a big endian machine due hitting
the unreachable() at the end of the function.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2665
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4735>

---

 src/mesa/main/formats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 114ea5218be..0bca52fde50 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -404,7 +404,7 @@ _mesa_array_format_flip_channels(mesa_array_format format)
    num_channels = _mesa_array_format_get_num_channels(format);
    _mesa_array_format_get_swizzle(format, swizzle);
 
-   if (num_channels == 1)
+   if (num_channels == 1 || num_channels == 3)
       return format;
 
    if (num_channels == 2) {



More information about the mesa-commit mailing list