panfrost: XMLify mali_channel
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Aug 2020 20:46:07 +0000 (16:46 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Aug 2020 11:43:52 +0000 (11:43 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6326>

src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml
src/panfrost/lib/pan_blit.c
src/panfrost/lib/pan_texture.c
src/panfrost/lib/pan_texture.h

index 34d3e98f5c41fcffd05ccf405cb0aa2e1ad5674d..c0d986f77ef68da0ea53838d7ce1957512fd294c 100644 (file)
@@ -147,18 +147,6 @@ struct mali_blend_equation {
         unsigned color_mask : 4;
 } __attribute__((packed));
 
-/* Used with channel swizzling */
-enum mali_channel {
-       MALI_CHANNEL_RED = 0,
-       MALI_CHANNEL_GREEN = 1,
-       MALI_CHANNEL_BLUE = 2,
-       MALI_CHANNEL_ALPHA = 3,
-       MALI_CHANNEL_ZERO = 4,
-       MALI_CHANNEL_ONE = 5,
-       MALI_CHANNEL_RESERVED_0 = 6,
-       MALI_CHANNEL_RESERVED_1 = 7,
-};
-
 /* Compressed per-pixel formats. Each of these formats expands to one to four
  * floating-point or integer numbers, as defined by the OpenGL specification.
  * There are various places in OpenGL where the user can specify a compressed
index 06b381626dc15a91faa23b2da0ce3b6e56e34f95..be18f2d0d95f731dc6696d6f804ffe705b346642 100644 (file)
@@ -756,12 +756,12 @@ static unsigned
 pandecode_access_mask_from_channel_swizzle(unsigned swizzle)
 {
         unsigned mask = 0;
-        assert(MALI_CHANNEL_RED == 0);
+        assert(MALI_CHANNEL_R == 0);
 
         for (unsigned c = 0; c < 4; ++c) {
                 enum mali_channel chan = (swizzle >> (3*c)) & 0x7;
 
-                if (chan <= MALI_CHANNEL_ALPHA)
+                if (chan <= MALI_CHANNEL_A)
                         mask |= (1 << chan);
         }
 
@@ -790,10 +790,10 @@ pandecode_validate_format_swizzle(enum mali_format fmt, unsigned swizzle)
          * useless printing for the defaults */
 
         unsigned default_swizzles[4] = {
-                MALI_CHANNEL_RED | (MALI_CHANNEL_ZERO  << 3) | (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE   << 9),
-                MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE   << 9),
-                MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ONE   << 9),
-                MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9)
+                MALI_CHANNEL_R | (MALI_CHANNEL_0  << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1   << 9),
+                MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1   << 9),
+                MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_1   << 9),
+                MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9)
         };
 
         return (swizzle == default_swizzles[nr_comp - 1]);
@@ -817,7 +817,7 @@ pandecode_swizzle(unsigned swizzle, enum mali_format format)
         for (unsigned c = 0; c < 4; ++c) {
                 enum mali_channel chan = (swizzle >> (3 * c)) & 0x7;
 
-                if (chan >= MALI_CHANNEL_RESERVED_0) {
+                if (chan > MALI_CHANNEL_1) {
                         pandecode_log("XXX: invalid swizzle channel %d\n", chan);
                         continue;
                 }
index cf5eb8e429e0aff479a9fb4df31ab90ee889d91c..8a6692f02cede300fe311652266a471433ae9699 100644 (file)
@@ -1,5 +1,14 @@
 <panxml>
 
+  <enum name="Channel">
+    <value name="R" value="0"/>
+    <value name="G" value="1"/>
+    <value name="B" value="2"/>
+    <value name="A" value="3"/>
+    <value name="0" value="4"/>
+    <value name="1" value="5"/>
+  </enum>
   <enum name="Job Type">
     <value name="Not started" value="0"/>
     <value name="Null" value="1"/>
index fbc346003906ef0766b726143d8f24261fd24b03..9aee7d81910c0f309874773153f4d7cbdfa8a9f9 100644 (file)
@@ -203,7 +203,7 @@ panfrost_load_midg(
         struct mali_attr_meta varying_meta = {
                 .index = 0,
                 .unknown1 = 2,
-                .format = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_RGBA32F << 12)
+                .format = (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) | (MALI_RGBA32F << 12)
         };
 
         struct mali_stencil_packed stencil;
@@ -299,7 +299,7 @@ panfrost_load_midg(
                         0, 0,
                         image->nr_samples,
                         0,
-                        (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9),
+                        (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
                         image->bo->gpu + image->first_layer *
                                 panfrost_get_layer_stride(image->slices,
                                         image->dim == MALI_TEXTURE_DIMENSION_3D,
index fce120803ac893ab98ef84a4b4d301c5d227da1b..5a54fd563b266f2c23b343bb38ad6ee04ea2f3be 100644 (file)
@@ -273,16 +273,16 @@ panfrost_emit_texture_payload(
 }
 
 #define MALI_SWIZZLE_R001 \
-        (MALI_CHANNEL_RED << 0) | \
-        (MALI_CHANNEL_ZERO << 3) | \
-        (MALI_CHANNEL_ZERO << 6) | \
-        (MALI_CHANNEL_ONE << 9)
+        (MALI_CHANNEL_R << 0) | \
+        (MALI_CHANNEL_0 << 3) | \
+        (MALI_CHANNEL_0 << 6) | \
+        (MALI_CHANNEL_1 << 9)
 
 #define MALI_SWIZZLE_A001 \
-        (MALI_CHANNEL_ALPHA << 0) | \
-        (MALI_CHANNEL_ZERO << 3) | \
-        (MALI_CHANNEL_ZERO << 6) | \
-        (MALI_CHANNEL_ONE << 9)
+        (MALI_CHANNEL_A << 0) | \
+        (MALI_CHANNEL_0 << 3) | \
+        (MALI_CHANNEL_0 << 6) | \
+        (MALI_CHANNEL_1 << 9)
 
 
 void
index 4d2d5478baa6123dec62d4b02c6fd2210adb5506..3765836385d9ba65614265cbd7f79edfdfe8e3a7 100644 (file)
@@ -158,17 +158,17 @@ panfrost_get_default_swizzle(unsigned components)
 {
         switch (components) {
         case 1:
-                return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_ZERO << 3) |
-                        (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9);
+                return (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_0 << 3) |
+                        (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9);
         case 2:
-                return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
-                        (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9);
+                return (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
+                        (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9);
         case 3:
-                return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
-                        (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ONE << 9);
+                return (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
+                        (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_1 << 9);
         case 4:
-                return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
-                        (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9);
+                return (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
+                        (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9);
         default:
                 unreachable("Invalid number of components");
         }