summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2021-04-16 12:25:14 -0700
committerMarge Bot <eric+marge@anholt.net>2021-04-21 19:59:10 +0000
commit0e20f6a1e99840f763c21988e723638b9a54000e (patch)
tree624ac23b009d2eba3ec85b22461d2da2c281024a
parent8bd91d1368815c5bbf975044df8bfcf3186ac3b7 (diff)
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@intel.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10336>
-rw-r--r--src/mesa/main/format_pack.h7
-rw-r--r--src/mesa/main/format_pack.py47
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.
*/