Mesa (master): panfrost: Simplify swizzle translation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 14 13:09:37 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Fri Feb 14 07:49:25 2020 -0500

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 at 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>

---

 src/gallium/drivers/panfrost/pan_format.c | 37 +++++--------------------------
 1 file changed, 5 insertions(+), 32 deletions(-)

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));
         }
 



More information about the mesa-commit mailing list