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>
This commit is contained in:
committed by
Marge Bot
parent
98eecece9b
commit
e13bdbbd5b
@@ -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])) |
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user