Mesa (master): panfrost: Use SATURATE
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 26 22:57:28 UTC 2020
Module: Mesa
Branch: master
Commit: 9983c4cd68edab08e8bc03480c3fdd518637a3f6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9983c4cd68edab08e8bc03480c3fdd518637a3f6
Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date: Tue May 19 11:02:09 2020 -0400
panfrost: Use SATURATE
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5100>
---
src/gallium/drivers/panfrost/pan_job.c | 22 +++++++++++-----------
src/panfrost/bifrost/test/bi_interpret.c | 2 +-
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index a9c2a31a5ea..2d41123c7e9 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -1234,27 +1234,27 @@ pan_pack_color(uint32_t *packed, const union pipe_color_union *color, enum pipe_
((uint32_t) float_to_ubyte(color->f[0]) << 0));
} else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
/* First, we convert the components to R5, G6, B5 separately */
- unsigned r5 = _mesa_roundevenf(CLAMP(color->f[0], 0.0, 1.0) * 31.0);
- unsigned g6 = _mesa_roundevenf(CLAMP(color->f[1], 0.0, 1.0) * 63.0);
- unsigned b5 = _mesa_roundevenf(CLAMP(color->f[2], 0.0, 1.0) * 31.0);
+ unsigned r5 = _mesa_roundevenf(SATURATE(color->f[0]) * 31.0);
+ unsigned g6 = _mesa_roundevenf(SATURATE(color->f[1]) * 63.0);
+ unsigned b5 = _mesa_roundevenf(SATURATE(color->f[2]) * 31.0);
/* Then we pack into a sparse u32. TODO: Why these shifts? */
pan_pack_color_32(packed, (b5 << 25) | (g6 << 14) | (r5 << 5));
} else if (format == PIPE_FORMAT_B4G4R4A4_UNORM) {
/* Convert to 4-bits */
- unsigned r4 = _mesa_roundevenf(CLAMP(color->f[0], 0.0, 1.0) * 15.0);
- unsigned g4 = _mesa_roundevenf(CLAMP(color->f[1], 0.0, 1.0) * 15.0);
- unsigned b4 = _mesa_roundevenf(CLAMP(color->f[2], 0.0, 1.0) * 15.0);
- unsigned a4 = _mesa_roundevenf(CLAMP(clear_alpha, 0.0, 1.0) * 15.0);
+ unsigned r4 = _mesa_roundevenf(SATURATE(color->f[0]) * 15.0);
+ unsigned g4 = _mesa_roundevenf(SATURATE(color->f[1]) * 15.0);
+ unsigned b4 = _mesa_roundevenf(SATURATE(color->f[2]) * 15.0);
+ unsigned a4 = _mesa_roundevenf(SATURATE(clear_alpha) * 15.0);
/* Pack on *byte* intervals */
pan_pack_color_32(packed, (a4 << 28) | (b4 << 20) | (g4 << 12) | (r4 << 4));
} else if (format == PIPE_FORMAT_B5G5R5A1_UNORM) {
/* Scale as expected but shift oddly */
- unsigned r5 = _mesa_roundevenf(CLAMP(color->f[0], 0.0, 1.0) * 31.0);
- unsigned g5 = _mesa_roundevenf(CLAMP(color->f[1], 0.0, 1.0) * 31.0);
- unsigned b5 = _mesa_roundevenf(CLAMP(color->f[2], 0.0, 1.0) * 31.0);
- unsigned a1 = _mesa_roundevenf(CLAMP(clear_alpha, 0.0, 1.0) * 1.0);
+ unsigned r5 = _mesa_roundevenf(SATURATE(color->f[0]) * 31.0);
+ unsigned g5 = _mesa_roundevenf(SATURATE(color->f[1]) * 31.0);
+ unsigned b5 = _mesa_roundevenf(SATURATE(color->f[2]) * 31.0);
+ unsigned a1 = _mesa_roundevenf(SATURATE(clear_alpha) * 1.0);
pan_pack_color_32(packed, (a1 << 31) | (b5 << 25) | (g5 << 15) | (r5 << 5));
} else {
diff --git a/src/panfrost/bifrost/test/bi_interpret.c b/src/panfrost/bifrost/test/bi_interpret.c
index adb718bfabf..7f18fbc5554 100644
--- a/src/panfrost/bifrost/test/bi_interpret.c
+++ b/src/panfrost/bifrost/test/bi_interpret.c
@@ -215,7 +215,7 @@ bit_outmod(float raw, enum bifrost_outmod mod)
case BIFROST_SAT_SIGNED:
return CLAMP(raw, -1.0, 1.0);
case BIFROST_SAT:
- return CLAMP(raw, 0.0, 1.0);
+ return SATURATE(raw);
default:
return raw;
}
More information about the mesa-commit
mailing list