diff options
author | Jonathan Marek <[email protected]> | 2019-07-03 14:06:17 -0400 |
---|---|---|
committer | Jonathan Marek <[email protected]> | 2019-07-17 23:07:50 -0400 |
commit | 76adf041f25defad204abea1ed49b82fd9c264d1 (patch) | |
tree | c72613c2a7d81b035efa5340485c2e6f8d7fc44e /src/gallium/drivers/etnaviv | |
parent | 5f73726013fabaa2b1bda595a2b2192a4db25760 (diff) |
etnaviv: fix blend color on newer GPUs
Newer GPUs use the half float ALPHA_COLOR_EXT register.
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Diffstat (limited to 'src/gallium/drivers/etnaviv')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_blend.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_emit.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_internal.h | 2 |
4 files changed, 21 insertions, 19 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c b/src/gallium/drivers/etnaviv/etnaviv_blend.c index 2e5538e3577..637586aee72 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_blend.c +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c @@ -32,6 +32,7 @@ #include "hw/common.xml.h" #include "pipe/p_defines.h" #include "util/u_memory.h" +#include "util/u_half.h" void * etna_blend_state_create(struct pipe_context *pctx, @@ -162,21 +163,20 @@ etna_update_blend_color(struct etna_context *ctx) { struct pipe_framebuffer_state *pfb = &ctx->framebuffer_s; struct compiled_blend_color *cs = &ctx->blend_color; - - if (pfb->cbufs[0] && - translate_rs_format_rb_swap(pfb->cbufs[0]->format)) { - cs->PE_ALPHA_BLEND_COLOR = - VIVS_PE_ALPHA_BLEND_COLOR_R(etna_cfloat_to_uint8(cs->color[2])) | - 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[0])) | - VIVS_PE_ALPHA_BLEND_COLOR_A(etna_cfloat_to_uint8(cs->color[3])); - } else { - cs->PE_ALPHA_BLEND_COLOR = - VIVS_PE_ALPHA_BLEND_COLOR_R(etna_cfloat_to_uint8(cs->color[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[2])) | - VIVS_PE_ALPHA_BLEND_COLOR_A(etna_cfloat_to_uint8(cs->color[3])); - } + bool rb_swap = (pfb->cbufs[0] && translate_rs_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])); + + cs->PE_ALPHA_COLOR_EXT0 = + VIVS_PE_ALPHA_COLOR_EXT0_B(util_float_to_half(cs->color[rb_swap ? 2 : 0])) | + VIVS_PE_ALPHA_COLOR_EXT0_G(util_float_to_half(cs->color[1])); + cs->PE_ALPHA_COLOR_EXT1 = + VIVS_PE_ALPHA_COLOR_EXT1_R(util_float_to_half(cs->color[rb_swap ? 0 : 2])) | + VIVS_PE_ALPHA_COLOR_EXT1_A(util_float_to_half(cs->color[3])); return true; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 8aabbe6e944..47eeeecfc74 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -342,8 +342,6 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream *stream, void *priv) etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404); etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0)); etna_set_state(stream, VIVS_PA_ZFARCLIPPING, 0x00000000); - etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT0, 0x00000000); - etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT1, 0x00000000); etna_set_state(stream, VIVS_RA_HDEPTH_CONTROL, 0x00007000); etna_set_state(stream, VIVS_PE_STENCIL_CONFIG_EXT2, 0x00000000); etna_set_state(stream, VIVS_PS_CONTROL_EXT, 0x00000000); diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c b/src/gallium/drivers/etnaviv/etnaviv_emit.c index 7c954732368..05223ff2062 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c @@ -531,10 +531,12 @@ etna_emit_state(struct etna_context *ctx) /*014A8*/ EMIT_STATE(PE_DITHER(x), blend->PE_DITHER[x]); } } - + if (unlikely(dirty & (ETNA_DIRTY_BLEND_COLOR))) { + /*014B0*/ EMIT_STATE(PE_ALPHA_COLOR_EXT0, ctx->blend_color.PE_ALPHA_COLOR_EXT0); + /*014B4*/ EMIT_STATE(PE_ALPHA_COLOR_EXT1, ctx->blend_color.PE_ALPHA_COLOR_EXT1); + } if (unlikely(dirty & (ETNA_DIRTY_FRAMEBUFFER)) && ctx->specs.halti >= 3) /*014BC*/ EMIT_STATE(PE_MEM_CONFIG, ctx->framebuffer.PE_MEM_CONFIG); - if (unlikely(dirty & (ETNA_DIRTY_FRAMEBUFFER | ETNA_DIRTY_TS))) { /*01654*/ EMIT_STATE(TS_MEM_CONFIG, ctx->framebuffer.TS_MEM_CONFIG); /*01658*/ EMIT_STATE_RELOC(TS_COLOR_STATUS_BASE, &ctx->framebuffer.TS_COLOR_STATUS_BASE); diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h index 27b6c3b28e7..c5b2dc14b1a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h @@ -146,6 +146,8 @@ struct etna_specs { struct compiled_blend_color { float color[4]; uint32_t PE_ALPHA_BLEND_COLOR; + uint32_t PE_ALPHA_COLOR_EXT0; + uint32_t PE_ALPHA_COLOR_EXT1; }; /* Compiled pipe_stencil_ref */ |