From: Alyssa Rosenzweig Date: Fri, 14 Feb 2020 12:49:25 +0000 (-0500) Subject: panfrost: Simplify swizzle translation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c57456aab6974abc86e7e1b0aae958a8ab3dad27;p=mesa.git 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 Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c index f8e3277150f..b7f5e4449cf 100644 --- a/src/gallium/drivers/panfrost/pan_format.c +++ b/src/gallium/drivers/panfrost/pan_format.c @@ -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)); }