panfrost: Simplify swizzle translation

It lines up anyway, and Gallium shouldn't change this. (And if it does,
we'll deal with that then since CI would start failing.)

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3824>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3824>
This commit is contained in:
Alyssa Rosenzweig 2020-02-14 07:49:25 -05:00 committed by Marge Bot
parent f3490a141c
commit c57456aab6

View file

@ -27,37 +27,10 @@
/* From panwrap/panwrap-decoder, but we don't want to bring in all those headers */
char *panwrap_format_name(enum mali_format format);
/* Construct a default swizzle based on the number of components */
static unsigned
panfrost_translate_swizzle(enum pipe_swizzle s)
{
switch (s) {
case PIPE_SWIZZLE_X:
return MALI_CHANNEL_RED;
case PIPE_SWIZZLE_Y:
return MALI_CHANNEL_GREEN;
case PIPE_SWIZZLE_Z:
return MALI_CHANNEL_BLUE;
case PIPE_SWIZZLE_W:
return MALI_CHANNEL_ALPHA;
case PIPE_SWIZZLE_0:
case PIPE_SWIZZLE_NONE:
return MALI_CHANNEL_ZERO;
case PIPE_SWIZZLE_1:
return MALI_CHANNEL_ONE;
default:
unreachable("INvalid swizzle");
}
}
/* Translate a Gallium swizzle quad to a 12-bit Mali swizzle code */
/* Translate a Gallium swizzle quad to a 12-bit Mali swizzle code. Gallium
* swizzles line up with Mali swizzles for the XYZW01, but Gallium has an
* additional "NONE" field that we have to mask out to zero. Additionally,
* Gallium swizzles are sparse but Mali swizzles are packed */
unsigned
panfrost_translate_swizzle_4(const unsigned char swizzle[4])
@ -65,7 +38,7 @@ panfrost_translate_swizzle_4(const unsigned char swizzle[4])
unsigned out = 0;
for (unsigned i = 0; i < 4; ++i) {
unsigned translated = panfrost_translate_swizzle(swizzle[i]);
unsigned translated = (swizzle[i] > PIPE_SWIZZLE_1) ? PIPE_SWIZZLE_0 : swizzle[i];
out |= (translated << (3*i));
}