Mesa (master): mesa: Reuse util_format's unpack functions for pure integer formats.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 15 19:15:28 UTC 2021


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov  7 11:55:11 2019 -0800

mesa: Reuse util_format's unpack functions for pure integer formats.

Drops 5k of compiled text from all GL drivers.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297>

---

 src/mesa/main/format_unpack.h  |  7 ++--
 src/mesa/main/format_unpack.py | 72 ------------------------------------------
 2 files changed, 5 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/format_unpack.h b/src/mesa/main/format_unpack.h
index 829505314dd..8b2813fd675 100644
--- a/src/mesa/main/format_unpack.h
+++ b/src/mesa/main/format_unpack.h
@@ -43,9 +43,12 @@ extern void
 _mesa_unpack_ubyte_rgba_row(mesa_format format, uint32_t n,
                             const void *src, uint8_t dst[][4]);
 
-void
+static inline void
 _mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
-                           const void *src, uint32_t dst[][4]);
+                           const void *src, uint32_t dst[][4])
+{
+   util_format_unpack_rgba(format, dst, src, n);
+}
 
 extern void
 _mesa_unpack_rgba_block(mesa_format format,
diff --git a/src/mesa/main/format_unpack.py b/src/mesa/main/format_unpack.py
index 3cae58d0078..2b3acf81819 100644
--- a/src/mesa/main/format_unpack.py
+++ b/src/mesa/main/format_unpack.py
@@ -68,78 +68,6 @@ for f in formats:
    rgb_formats.append(f)
 %>
 
-/* integer packing functions */
-
-%for f in rgb_formats:
-   %if not f.is_int():
-      <% continue %>
-   %elif f.is_normalized():
-      <% continue %>
-   %endif
-
-static inline void
-unpack_int_${f.short_name()}(const void *void_src, uint32_t dst[4])
-{
-   ${f.datatype()} *src = (${f.datatype()} *)void_src;
-   %if f.layout == parser.PACKED:
-      %for c in f.channels:
-         %if c.type != 'x':
-            ${c.datatype()} ${c.name} = UNPACK(*src, ${c.shift}, ${c.size});
-         %endif
-      %endfor
-   %elif f.layout == parser.ARRAY:
-      %for (i, c) in enumerate(f.channels):
-         %if c.type != 'x':
-            ${c.datatype()} ${c.name} = src[${i}];
-         %endif
-      %endfor
-   %else:
-      <% assert False %>
-   %endif
-
-   %for i in range(4):
-      <% s = f.swizzle[i] %>
-      %if 0 <= s and s <= parser.Swizzle.SWIZZLE_W:
-         dst[${i}] = ${f.channels[s].name};
-      %elif s == parser.Swizzle.SWIZZLE_ZERO:
-         dst[${i}] = 0;
-      %elif s == parser.Swizzle.SWIZZLE_ONE:
-         dst[${i}] = 1;
-      %else:
-         <% assert False %>
-      %endif
-   %endfor
-}
-%endfor
-
-
-void
-_mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
-                           const void *src, uint32_t dst[][4])
-{
-   uint8_t *s = (uint8_t *)src;
-   uint32_t i;
-
-   switch (format) {
-%for f in rgb_formats:
-   %if not f.is_int():
-      <% continue %>
-   %elif f.is_normalized():
-      <% continue %>
-   %endif
-
-   case ${f.name}:
-      for (i = 0; i < n; ++i) {
-         unpack_int_${f.short_name()}(s, dst[i]);
-         s += ${f.block_size() // 8};
-      }
-      break;
-%endfor
-   default:
-      unreachable("bad format");
-   }
-}
-
 
 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
 struct z32f_x24s8



More information about the mesa-commit mailing list