summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <cgmeiner@igalia.com>2023-08-14 13:30:29 +0200
committerMarge Bot <emma+marge@anholt.net>2023-08-17 09:42:20 +0000
commite13bdbbd5bfc1cef00cf504b0567238ae8f45524 (patch)
tree22fcbb6543b4fee7585d94623fdf893b6363f2b9
parent98eecece9bb4e82a964edfaf3840887e7adeee06 (diff)
etnaviv: switch to float_to_ubyte(..)
The blob generates following values for e.g. this call. glBlendColor(0.002000f, 0.018000f, 0.030000f, 1.0) 0xff010508, /* [01424] PE.ALPHA_BLEND_COLOR := B=0x8,G=0x5,R=0x1,A=0xff */ etnaviv's etna_cfloat_to_uint8(..) creates different values. 0.002000: 0x0 0.018000: 0x4 0.030000: 0x7 The same applies for the alpha reference value. Lets drop this hand-rolled conversion helper to get the same values as blob. Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24727>
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_blend.c8
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_util.h13
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_zsa.c2
3 files changed, 5 insertions, 18 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c b/src/gallium/drivers/etnaviv/etnaviv_blend.c
index 9927664bb13..b8b9592f26c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_blend.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c
@@ -176,10 +176,10 @@ etna_update_blend_color(struct etna_context *ctx)
bool rb_swap = (pfb->cbufs[0] && translate_pe_format_rb_swap(pfb->cbufs[0]->format));
cs->PE_ALPHA_BLEND_COLOR =
- VIVS_PE_ALPHA_BLEND_COLOR_R(etna_cfloat_to_uint8(cs->color[rb_swap ? 2 : 0])) |
- VIVS_PE_ALPHA_BLEND_COLOR_G(etna_cfloat_to_uint8(cs->color[1])) |
- VIVS_PE_ALPHA_BLEND_COLOR_B(etna_cfloat_to_uint8(cs->color[rb_swap ? 0 : 2])) |
- VIVS_PE_ALPHA_BLEND_COLOR_A(etna_cfloat_to_uint8(cs->color[3]));
+ VIVS_PE_ALPHA_BLEND_COLOR_R(float_to_ubyte(cs->color[rb_swap ? 2 : 0])) |
+ VIVS_PE_ALPHA_BLEND_COLOR_G(float_to_ubyte(cs->color[1])) |
+ VIVS_PE_ALPHA_BLEND_COLOR_B(float_to_ubyte(cs->color[rb_swap ? 0 : 2])) |
+ VIVS_PE_ALPHA_BLEND_COLOR_A(float_to_ubyte(cs->color[3]));
cs->PE_ALPHA_COLOR_EXT0 =
VIVS_PE_ALPHA_COLOR_EXT0_B(_mesa_float_to_half(cs->color[rb_swap ? 2 : 0])) |
diff --git a/src/gallium/drivers/etnaviv/etnaviv_util.h b/src/gallium/drivers/etnaviv/etnaviv_util.h
index c2ecb020c49..4f3061f2d2e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_util.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_util.h
@@ -31,19 +31,6 @@
/* for conditionally setting boolean flag(s): */
#define COND(bool, val) ((bool) ? (val) : 0)
-/* clamped float [0.0 .. 1.0] -> [0 .. 255] */
-static inline uint8_t
-etna_cfloat_to_uint8(float f)
-{
- if (f <= 0.0f)
- return 0;
-
- if (f >= (1.0f - 1.0f / 256.0f))
- return 255;
-
- return f * 256.0f;
-}
-
/* float to fixp 5.5 */
static inline uint32_t
etna_float_to_fixp55(float f)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_zsa.c b/src/gallium/drivers/etnaviv/etnaviv_zsa.c
index 530a38cbcc3..38971e72916 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_zsa.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_zsa.c
@@ -101,7 +101,7 @@ etna_zsa_state_create(struct pipe_context *pctx,
cs->PE_ALPHA_OP =
COND(so->alpha_enabled, VIVS_PE_ALPHA_OP_ALPHA_TEST) |
VIVS_PE_ALPHA_OP_ALPHA_FUNC(so->alpha_func) |
- VIVS_PE_ALPHA_OP_ALPHA_REF(etna_cfloat_to_uint8(so->alpha_ref_value));
+ VIVS_PE_ALPHA_OP_ALPHA_REF(float_to_ubyte(so->alpha_ref_value));
for (unsigned i = 0; i < 2; i++) {
const struct pipe_stencil_state *stencil_front = (so->stencil[1].enabled && so->stencil[1].valuemask) ? &so->stencil[i] : &so->stencil[0];