etnaviv: Extend etna_update_blend_color(..) for MRTs

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/26565>
This commit is contained in:
Christian Gmeiner 2023-11-30 09:17:45 +01:00 committed by Marge Bot
parent 5598a449f1
commit 64b78ef9c2
3 changed files with 33 additions and 17 deletions

View file

@ -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;
}

View file

@ -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]);

View file

@ -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 */