Mesa (master): mesa: Make _mesa_unpack_rgba_block() use the u_format pack/unpack.

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


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov  7 10:56:06 2019 -0800

mesa: Make _mesa_unpack_rgba_block() use the u_format pack/unpack.

This moves it to non-generated code, since there wasn't any codegen
anyway.

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.py | 36 ------------------------------------
 src/mesa/main/pack.c           | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/src/mesa/main/format_unpack.py b/src/mesa/main/format_unpack.py
index ec826652268..e1a9a8d76b2 100644
--- a/src/mesa/main/format_unpack.py
+++ b/src/mesa/main/format_unpack.py
@@ -242,42 +242,6 @@ _mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
    }
 }
 
-/**
- * Unpack a 2D rect of pixels returning float RGBA colors.
- * \param format  the source image format
- * \param src  start address of the source image
- * \param srcRowStride  source image row stride in bytes
- * \param dst  start address of the dest image
- * \param dstRowStride  dest image row stride in bytes
- * \param x  source image start X pos
- * \param y  source image start Y pos
- * \param width  width of rect region to convert
- * \param height  height of rect region to convert
- */
-void
-_mesa_unpack_rgba_block(mesa_format format,
-                        const void *src, int32_t srcRowStride,
-                        float dst[][4], int32_t dstRowStride,
-                        uint32_t x, uint32_t y, uint32_t width, uint32_t height)
-{
-   const uint32_t srcPixStride = _mesa_get_format_bytes(format);
-   const uint32_t dstPixStride = 4 * sizeof(float);
-   const uint8_t *srcRow;
-   uint8_t *dstRow;
-   uint32_t i;
-
-   /* XXX needs to be fixed for compressed formats */
-
-   srcRow = ((const uint8_t *) src) + srcRowStride * y + srcPixStride * x;
-   dstRow = ((uint8_t *) dst) + dstRowStride * y + dstPixStride * x;
-
-   for (i = 0; i < height; i++) {
-      _mesa_unpack_rgba_row(format, width, srcRow, (float (*)[4]) dstRow);
-
-      dstRow += dstRowStride;
-      srcRow += srcRowStride;
-   }
-}
 
 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
 struct z32f_x24s8
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 6ebca5a6c99..4fb0b17aea8 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1632,3 +1632,37 @@ _mesa_unpack_color_index_to_rgba_ubyte(struct gl_context *ctx, GLuint dims,
 
    return dst;
 }
+
+/**
+ * Unpack a 2D rect of pixels returning float RGBA colors.
+ * \param format  the source image format
+ * \param src  start address of the source image
+ * \param srcRowStride  source image row stride in bytes
+ * \param dst  start address of the dest image
+ * \param dstRowStride  dest image row stride in bytes
+ * \param x  source image start X pos
+ * \param y  source image start Y pos
+ * \param width  width of rect region to convert
+ * \param height  height of rect region to convert
+ */
+void
+_mesa_unpack_rgba_block(mesa_format format,
+                        const void *src, int32_t srcRowStride,
+                        float dst[][4], int32_t dstRowStride,
+                        uint32_t x, uint32_t y, uint32_t width, uint32_t height)
+{
+   const uint32_t srcPixStride = _mesa_get_format_bytes(format);
+   const uint32_t dstPixStride = 4 * sizeof(float);
+   const struct util_format_unpack_description *unpack =
+      util_format_unpack_description((enum pipe_format)format);
+   const uint8_t *srcRow;
+   uint8_t *dstRow;
+
+   /* XXX needs to be fixed for compressed formats */
+
+   srcRow = ((const uint8_t *) src) + srcRowStride * y + srcPixStride * x;
+   dstRow = ((uint8_t *) dst) + dstRowStride * y + dstPixStride * x;
+
+   unpack->unpack_rgba(dstRow, dstPixStride,
+                       srcRow, srcRowStride, width, height);
+}



More information about the mesa-commit mailing list