diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c b/src/gallium/drivers/etnaviv/etnaviv_blend.c index 7cb56e463cc..46ebe3bfaaf 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_blend.c +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c @@ -170,22 +170,33 @@ etna_set_blend_color(struct pipe_context *pctx, const struct pipe_blend_color *b bool etna_update_blend_color(struct etna_context *ctx) { - struct pipe_framebuffer_state *pfb = &ctx->framebuffer_s; + struct pipe_framebuffer_state *fb = &ctx->framebuffer_s; struct compiled_blend_color *cs = &ctx->blend_color; - bool rb_swap = (pfb->cbufs[0] && translate_pe_format_rb_swap(pfb->cbufs[0]->format)); + unsigned rt = 0; - cs->PE_ALPHA_BLEND_COLOR = - 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])); + for (unsigned i = 0; i < fb->nr_cbufs; i++) { + if (!fb->cbufs[i]) + continue; - cs->PE_ALPHA_COLOR_EXT0 = - VIVS_PE_ALPHA_COLOR_EXT0_B(_mesa_float_to_half(cs->color[rb_swap ? 2 : 0])) | - VIVS_PE_ALPHA_COLOR_EXT0_G(_mesa_float_to_half(cs->color[1])); - cs->PE_ALPHA_COLOR_EXT1 = - VIVS_PE_ALPHA_COLOR_EXT1_R(_mesa_float_to_half(cs->color[rb_swap ? 0 : 2])) | - VIVS_PE_ALPHA_COLOR_EXT1_A(_mesa_float_to_half(cs->color[3])); + bool rb_swap = translate_pe_format_rb_swap(fb->cbufs[i]->format); + + if (rt == 0) { + cs->PE_ALPHA_BLEND_COLOR = + 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->rt[rt].PE_ALPHA_COLOR_EXT0 = + VIVS_PE_ALPHA_COLOR_EXT0_B(_mesa_float_to_half(cs->color[rb_swap ? 2 : 0])) | + VIVS_PE_ALPHA_COLOR_EXT0_G(_mesa_float_to_half(cs->color[1])); + cs->rt[rt].PE_ALPHA_COLOR_EXT1 = + VIVS_PE_ALPHA_COLOR_EXT1_R(_mesa_float_to_half(cs->color[rb_swap ? 0 : 2])) | + VIVS_PE_ALPHA_COLOR_EXT1_A(_mesa_float_to_half(cs->color[3])); + + rt++; + } return true; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c b/src/gallium/drivers/etnaviv/etnaviv_emit.c index 27dbdce2194..4e9c358d897 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c @@ -519,8 +519,8 @@ etna_emit_state(struct etna_context *ctx) } if (unlikely(dirty & (ETNA_DIRTY_BLEND_COLOR)) && VIV_FEATURE(screen, ETNA_FEATURE_HALF_FLOAT)) { - /*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); + /*014B0*/ EMIT_STATE(PE_ALPHA_COLOR_EXT0, ctx->blend_color.rt[0].PE_ALPHA_COLOR_EXT0); + /*014B4*/ EMIT_STATE(PE_ALPHA_COLOR_EXT1, ctx->blend_color.rt[0].PE_ALPHA_COLOR_EXT1); } if (unlikely(dirty & (ETNA_DIRTY_ZSA | ETNA_DIRTY_RASTERIZER))) { /*014B8*/ EMIT_STATE(PE_STENCIL_CONFIG_EXT2, etna_zsa_state(ctx->zsa)->PE_STENCIL_CONFIG_EXT2[ccw]); diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h index 667d4622ee4..d24a4d11f73 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h @@ -35,6 +35,8 @@ #include "drm/etnaviv_drmif.h" +#include "pipe/p_state.h" + #define ETNA_NUM_INPUTS (16) #define ETNA_NUM_VARYINGS 16 #define ETNA_NUM_LOD (14) @@ -137,8 +139,11 @@ 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; + + struct { + uint32_t PE_ALPHA_COLOR_EXT0; + uint32_t PE_ALPHA_COLOR_EXT1; + } rt[PIPE_MAX_COLOR_BUFS]; }; /* Compiled pipe_stencil_ref */