Mesa (master): mesa: Deduplicate _mesa_pack_ubyte_stencil_row()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 21 20:26:03 UTC 2021
Module: Mesa
Branch: master
Commit: 0e20f6a1e99840f763c21988e723638b9a54000e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e20f6a1e99840f763c21988e723638b9a54000e
Author: Eric Anholt <eric at anholt.net>
Date: Fri Apr 16 12:25:14 2021 -0700
mesa: Deduplicate _mesa_pack_ubyte_stencil_row()
util_format_pack_s_8uint() has the same behavior of replacing the s
values 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 | 47 --------------------------------------------
2 files changed, 5 insertions(+), 49 deletions(-)
diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
index 2d628d20433..a038a043d84 100644
--- a/src/mesa/main/format_pack.h
+++ b/src/mesa/main/format_pack.h
@@ -90,9 +90,12 @@ extern void
_mesa_pack_uint_z_row(mesa_format format, uint32_t n,
const uint32_t *src, void *dst);
-extern void
+static inline void
_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
- const uint8_t *src, void *dst);
+ const uint8_t *src, void *dst)
+{
+ util_format_pack_s_8uint(format, dst, src, n);
+}
extern void
_mesa_pack_uint_24_8_depth_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 2731ad111fe..8042a7c6619 100644
--- a/src/mesa/main/format_pack.py
+++ b/src/mesa/main/format_pack.py
@@ -591,53 +591,6 @@ _mesa_pack_uint_z_row(mesa_format format, uint32_t n,
}
-void
-_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
- const uint8_t *src, void *dst)
-{
- switch (format) {
- case MESA_FORMAT_S8_UINT_Z24_UNORM:
- {
- /* don't disturb the Z values */
- uint32_t *d = ((uint32_t *) dst);
- uint32_t i;
- for (i = 0; i < n; i++) {
- uint32_t s = src[i];
- uint32_t z = d[i] & 0xffffff00;
- d[i] = z | s;
- }
- }
- break;
- case MESA_FORMAT_Z24_UNORM_S8_UINT:
- {
- /* don't disturb the Z values */
- uint32_t *d = ((uint32_t *) dst);
- uint32_t i;
- for (i = 0; i < n; i++) {
- uint32_t s = src[i] << 24;
- uint32_t z = d[i] & 0xffffff;
- d[i] = s | z;
- }
- }
- break;
- case MESA_FORMAT_S_UINT8:
- memcpy(dst, src, n * sizeof(uint8_t));
- break;
- case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
- {
- struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
- uint32_t i;
- for (i = 0; i < n; i++) {
- d[i].x24s8 = src[i];
- }
- }
- break;
- default:
- unreachable("unexpected format in _mesa_pack_ubyte_stencil_row()");
- }
-}
-
-
/**
* Incoming Z/stencil values are always in uint_24_8 format.
*/
More information about the mesa-commit
mailing list