Mesa (master): mesa: Deduplicate _mesa_pack_uint_z_row().
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 21 20:26:04 UTC 2021
Module: Mesa
Branch: master
Commit: 90f98b56f8541a3e7bc96e1121f404350bb68cf8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=90f98b56f8541a3e7bc96e1121f404350bb68cf8
Author: Eric Anholt <eric at anholt.net>
Date: Fri Apr 16 12:31:53 2021 -0700
mesa: Deduplicate _mesa_pack_uint_z_row().
util_format_pack_z_32unorm() does the same thing but supports more
formats.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10336>
---
src/mesa/main/format_pack.h | 7 ++--
src/mesa/main/format_pack.py | 76 --------------------------------------------
2 files changed, 5 insertions(+), 78 deletions(-)
diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
index 64b462a8471..4caa2d75d2c 100644
--- a/src/mesa/main/format_pack.h
+++ b/src/mesa/main/format_pack.h
@@ -89,9 +89,12 @@ _mesa_pack_float_z_row(mesa_format format, uint32_t n,
util_format_pack_z_float(format, dst, src, n);
}
-extern void
+static inline void
_mesa_pack_uint_z_row(mesa_format format, uint32_t n,
- const uint32_t *src, void *dst);
+ const uint32_t *src, void *dst)
+{
+ util_format_pack_z_32unorm(format, dst, src, n);
+}
static inline void
_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py
index 798836c1a45..a0086e9dfc7 100644
--- a/src/mesa/main/format_pack.py
+++ b/src/mesa/main/format_pack.py
@@ -441,82 +441,6 @@ _mesa_get_pack_ubyte_stencil_func(mesa_format format)
}
-/**
- * The incoming Z values are always in the range [0, 0xffffffff].
- */
-void
-_mesa_pack_uint_z_row(mesa_format format, uint32_t n,
- const uint32_t *src, void *dst)
-{
- switch (format) {
- case MESA_FORMAT_S8_UINT_Z24_UNORM:
- case MESA_FORMAT_X8_UINT_Z24_UNORM:
- {
- /* don't disturb the stencil values */
- uint32_t *d = ((uint32_t *) dst);
- uint32_t i;
- for (i = 0; i < n; i++) {
- uint32_t s = d[i] & 0xff;
- uint32_t z = src[i] & 0xffffff00;
- d[i] = z | s;
- }
- }
- break;
- case MESA_FORMAT_Z24_UNORM_S8_UINT:
- case MESA_FORMAT_Z24_UNORM_X8_UINT:
- {
- /* don't disturb the stencil values */
- uint32_t *d = ((uint32_t *) dst);
- uint32_t i;
- for (i = 0; i < n; i++) {
- uint32_t s = d[i] & 0xff000000;
- uint32_t z = src[i] >> 8;
- d[i] = s | z;
- }
- }
- break;
- case MESA_FORMAT_Z_UNORM16:
- {
- uint16_t *d = ((uint16_t *) dst);
- uint32_t i;
- for (i = 0; i < n; i++) {
- d[i] = src[i] >> 16;
- }
- }
- break;
- case MESA_FORMAT_Z_UNORM32:
- memcpy(dst, src, n * sizeof(float));
- break;
- case MESA_FORMAT_Z_FLOAT32:
- {
- uint32_t *d = ((uint32_t *) dst);
- const double scale = 1.0 / (double) 0xffffffff;
- uint32_t i;
- for (i = 0; i < n; i++) {
- d[i] = (uint32_t) (src[i] * scale);
- assert(d[i] >= 0.0f);
- assert(d[i] <= 1.0f);
- }
- }
- break;
- case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
- {
- struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
- const double scale = 1.0 / (double) 0xffffffff;
- uint32_t i;
- for (i = 0; i < n; i++) {
- d[i].z = (float) (src[i] * scale);
- assert(d[i].z >= 0.0f);
- assert(d[i].z <= 1.0f);
- }
- }
- break;
- default:
- unreachable("unexpected format in _mesa_pack_uint_z_row()");
- }
-}
-
-
/**
* Incoming Z/stencil values are always in uint_24_8 format.
*/
More information about the mesa-commit
mailing list