Mesa (master): mesa/main: Replace the uint format packing code with util/format's.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 19 20:20:00 UTC 2021


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jan 15 12:51:17 2021 -0800

mesa/main: Replace the uint format packing code with util/format's.

Cuts another 60kb of generated code from Mesa drivers.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8532>

---

 src/mesa/main/format_pack.h  |  7 ++--
 src/mesa/main/format_pack.py | 84 --------------------------------------------
 2 files changed, 5 insertions(+), 86 deletions(-)

diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
index 15b065611e5..2d628d20433 100644
--- a/src/mesa/main/format_pack.h
+++ b/src/mesa/main/format_pack.h
@@ -70,9 +70,12 @@ extern void
 _mesa_pack_ubyte_rgba_row(mesa_format format, uint32_t n,
                           const uint8_t src[][4], void *dst);
 
-extern void
+static inline void
 _mesa_pack_uint_rgba_row(mesa_format format, uint32_t n,
-                         const uint32_t src[][4], void *dst);
+                         const uint32_t src[][4], void *dst)
+{
+   util_format_pack_rgba(format, dst, src, n);
+}
 
 extern void
 _mesa_pack_ubyte_rgba_rect(mesa_format format, uint32_t width, uint32_t height,
diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py
index 8af349b4b66..2731ad111fe 100644
--- a/src/mesa/main/format_pack.py
+++ b/src/mesa/main/format_pack.py
@@ -160,59 +160,6 @@ pack_ubyte_r11g11b10_float(const uint8_t src[4], void *dst)
    *d = float3_to_r11g11b10f(rgb);
 }
 
-/* uint packing functions */
-
-%for f in rgb_formats:
-   %if not f.is_int():
-      <% continue %>
-   %elif f.is_normalized():
-      <% continue %>
-   %elif f.is_compressed():
-      <% continue %>
-   %endif
-
-static inline void
-pack_uint_${f.short_name()}(const uint32_t src[4], void *dst)
-{
-   %for (i, c) in enumerate(f.channels):
-      <% i = f.swizzle.inverse()[i] %>
-      %if c.type == 'x':
-         <% continue %>
-      %endif
-
-      ${c.datatype()} ${c.name} =
-      %if c.type == parser.SIGNED:
-         _mesa_signed_to_signed(src[${i}], ${c.size});
-      %elif c.type == parser.UNSIGNED:
-         _mesa_unsigned_to_unsigned(src[${i}], ${c.size});
-      %else:
-         assert(!"Invalid type: only integer types are allowed");
-      %endif
-   %endfor
-
-   %if f.layout == parser.ARRAY:
-      ${f.datatype()} *d = (${f.datatype()} *)dst;
-      %for (i, c) in enumerate(f.channels):
-         %if c.type == 'x':
-            <% continue %>
-         %endif
-         d[${i}] = ${c.name};
-      %endfor
-   %elif f.layout == parser.PACKED:
-      ${f.datatype()} d = 0;
-      %for (i, c) in enumerate(f.channels):
-         %if c.type == 'x':
-            <% continue %>
-         %endif
-         d |= PACK(${c.name}, ${c.shift}, ${c.size});
-      %endfor
-      (*(${f.datatype()} *)dst) = d;
-   %else:
-      <% assert False %>
-   %endif
-}
-%endfor
-
 
 /**
  * Pack a row of uint8_t rgba[4] values to the destination.
@@ -242,37 +189,6 @@ _mesa_pack_ubyte_rgba_row(mesa_format format, uint32_t n,
    }
 }
 
-/**
- * Pack a row of uint32_t rgba[4] values to the destination.
- */
-void
-_mesa_pack_uint_rgba_row(mesa_format format, uint32_t n,
-                          const uint32_t src[][4], void *dst)
-{
-   uint32_t i;
-   uint8_t *d = dst;
-
-   switch (format) {
-%for f in rgb_formats:
-   %if not f.is_int():
-      <% continue %>
-   %elif f.is_normalized():
-      <% continue %>
-   %elif f.is_compressed():
-      <% continue %>
-   %endif
-
-   case ${f.name}:
-      for (i = 0; i < n; ++i) {
-         pack_uint_${f.short_name()}(src[i], d);
-         d += ${f.block_size() // 8};
-      }
-      break;
-%endfor
-   default:
-      assert(!"Invalid format");
-   }
-}
 
 /**
  * Pack a 2D image of ubyte RGBA pixels in the given format.



More information about the mesa-commit mailing list