[PATCH] etnaviv: fix blend color for RB swapped rendertargets
Wladimir J. van der Laan
laanwj at gmail.com
Tue Jun 20 14:06:20 UTC 2017
On Mon, Jun 05, 2017 at 09:11:02PM +0200, Lucas Stach wrote:
> Same as with the colormasks, the blend color needs to be swizzled according
> to the rendertarget format.
Yes, indeed.
Reviewed-by: Wladimir J. van der Laan
> Signed-off-by: Lucas Stach <dev at lynxeye.de>
> ---
> src/gallium/drivers/etnaviv/etnaviv_blend.c | 35 ++++++++++++++++++++++++++
> src/gallium/drivers/etnaviv/etnaviv_blend.h | 6 +++++
> src/gallium/drivers/etnaviv/etnaviv_internal.h | 1 +
> src/gallium/drivers/etnaviv/etnaviv_state.c | 17 +++----------
> 4 files changed, 45 insertions(+), 14 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> index 8ea09a3..6ed0e0f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_blend.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> @@ -129,3 +129,38 @@ etna_update_blend(struct etna_context *ctx)
>
> return true;
> }
> +
> +void
> +etna_set_blend_color(struct pipe_context *pctx, const struct pipe_blend_color *bc)
> +{
> + struct etna_context *ctx = etna_context(pctx);
> + struct compiled_blend_color *cs = &ctx->blend_color;
> +
> + memcpy(cs->color, bc->color, sizeof(float) * 4);
> +
> + ctx->dirty |= ETNA_DIRTY_BLEND_COLOR;
> +}
> +
> +bool
> +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]->texture->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]));
> + }
Looks ok to me - though I wish we just had a swizzle[4] for the
rendertarget-color mapping instead of having to special casing rb-swap.
> +
> + return true;
> +}
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.h b/src/gallium/drivers/etnaviv/etnaviv_blend.h
> index e26864d..c219396 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_blend.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.h
> @@ -56,4 +56,10 @@ etna_blend_state_create(struct pipe_context *pctx,
> bool
> etna_update_blend(struct etna_context *ctx);
>
> +void
> +etna_set_blend_color(struct pipe_context *pctx, const struct pipe_blend_color *bc);
> +
> +bool
> +etna_update_blend_color(struct etna_context *ctx);
> +
> #endif
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> index 2f8dacb..1212fdf 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> @@ -126,6 +126,7 @@ struct etna_specs {
>
> /* Compiled pipe_blend_color */
> struct compiled_blend_color {
> + float color[4];
> uint32_t PE_ALPHA_BLEND_COLOR;
> };
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c
> index fb7bb0f..fc3d9f1 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_state.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
> @@ -43,20 +43,6 @@
> #include "util/u_memory.h"
>
> static void
> -etna_set_blend_color(struct pipe_context *pctx, const struct pipe_blend_color *bc)
> -{
> - struct etna_context *ctx = etna_context(pctx);
> - struct compiled_blend_color *cs = &ctx->blend_color;
> -
> - cs->PE_ALPHA_BLEND_COLOR =
> - VIVS_PE_ALPHA_BLEND_COLOR_R(etna_cfloat_to_uint8(bc->color[0])) |
> - VIVS_PE_ALPHA_BLEND_COLOR_G(etna_cfloat_to_uint8(bc->color[1])) |
> - VIVS_PE_ALPHA_BLEND_COLOR_B(etna_cfloat_to_uint8(bc->color[2])) |
> - VIVS_PE_ALPHA_BLEND_COLOR_A(etna_cfloat_to_uint8(bc->color[3]));
> - ctx->dirty |= ETNA_DIRTY_BLEND_COLOR;
> -}
> -
> -static void
> etna_set_stencil_ref(struct pipe_context *pctx, const struct pipe_stencil_ref *sr)
> {
> struct etna_context *ctx = etna_context(pctx);
> @@ -600,6 +586,9 @@ static const struct etna_state_updater etna_state_updates[] = {
> },
> {
> etna_update_blend, ETNA_DIRTY_BLEND | ETNA_DIRTY_FRAMEBUFFER
> + },
> + {
> + etna_update_blend_color, ETNA_DIRTY_BLEND_COLOR | ETNA_DIRTY_FRAMEBUFFER,
> }
> };
>
> --
> 2.9.4
>
> _______________________________________________
> etnaviv mailing list
> etnaviv at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
More information about the etnaviv
mailing list