[Mesa-dev] [PATCH] mesa/formats: Fix swizzle flipping for big-endian targets
Jason Ekstrand
jason at jlekstrand.net
Sun Aug 9 23:52:30 PDT 2015
For those of you tracking the big-endian stuff, I've pushed a couple
patches to a branch:
http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/be-fixes
I've removed the patch to change the way gallium converts PIPE_FORMAT
to MESA_FORMAT because it was clearly wrong. As I work on this, I'll
try and keep this branch updated to the current "best known patches".
Hopefully, we can find/fix all of the bogus code and get BE at least
sort-of working again.
--Jason
On Sun, Aug 9, 2015 at 11:50 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> The swizzle defines where in the format you should look for any given
> channel. When we flip the format around for BE targets, we need to change
> the destinations of the swizzles, not the sources. For example, say the
> format is an RGBX format with a swizzle of xyz1 on LE. Then it should be
> wzy1 on BE; however, the code as it was before, would have made it 1zyx on
> BE which is clearly wrong.
>
> Cc: Iago Toral <itoral at igalia.com>
> Cc: Oded Gabbay <oded.gabbay at gmail.com>
> ---
> src/mesa/main/formats.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index d927073..27590ed 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -354,14 +354,22 @@ _mesa_array_format_flip_channels(mesa_array_format format)
> return format;
>
> if (num_channels == 2) {
> - _mesa_array_format_set_swizzle(&format, swizzle[1], swizzle[0],
> - swizzle[2], swizzle[3]);
> + /* Assert that the swizzle makes sense for 2 channels */
> + for (unsigned i = 0; i < 4; i++)
> + assert(swizzle[i] != 2 && swizzle[i] != 3);
> +
> + static const uint8_t flip_xy[6] = { 1, 0, 2, 3, 4, 5 };
> + _mesa_array_format_set_swizzle(&format,
> + flip_xy[swizzle[0]], flip_xy[swizzle[1]],
> + flip_xy[swizzle[2]], flip_xy[swizzle[3]]);
> return format;
> }
>
> if (num_channels == 4) {
> - _mesa_array_format_set_swizzle(&format, swizzle[3], swizzle[2],
> - swizzle[1], swizzle[0]);
> + static const uint8_t flip[6] = { 3, 2, 1, 0, 4, 5 };
> + _mesa_array_format_set_swizzle(&format,
> + flip[swizzle[0]], flip[swizzle[1]],
> + flip[swizzle[2]], flip[swizzle[3]]);
> return format;
> }
>
> --
> 2.4.3
>
More information about the mesa-dev
mailing list