mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-26 04:40:39 +02:00
etnaviv: Compute blend color registers directly in etna_set_blend_color(..)
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Reviewed-by: Daniel Lang <dalang@gmx.at> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38710>
This commit is contained in:
parent
3b99a0aca3
commit
f5bbbea9aa
4 changed files with 19 additions and 42 deletions
|
|
@ -198,43 +198,27 @@ void
|
|||
etna_set_blend_color(struct pipe_context *pctx, const struct pipe_blend_color *bc)
|
||||
{
|
||||
struct etna_context *ctx = etna_context(pctx);
|
||||
struct etna_screen *screen = etna_screen(pctx->screen);
|
||||
struct compiled_blend_color *cs = &ctx->blend_color;
|
||||
const unsigned num_rts = screen->specs.num_rts;
|
||||
|
||||
memcpy(cs->color, bc->color, sizeof(float) * 4);
|
||||
cs->PE_ALPHA_BLEND_COLOR =
|
||||
VIVS_PE_ALPHA_BLEND_COLOR_R(float_to_ubyte(bc->color[0])) |
|
||||
VIVS_PE_ALPHA_BLEND_COLOR_G(float_to_ubyte(bc->color[1])) |
|
||||
VIVS_PE_ALPHA_BLEND_COLOR_B(float_to_ubyte(bc->color[2])) |
|
||||
VIVS_PE_ALPHA_BLEND_COLOR_A(float_to_ubyte(bc->color[3]));
|
||||
|
||||
const uint32_t ext0 =
|
||||
VIVS_PE_ALPHA_COLOR_EXT0_B(_mesa_float_to_half(bc->color[0])) |
|
||||
VIVS_PE_ALPHA_COLOR_EXT0_G(_mesa_float_to_half(bc->color[1]));
|
||||
const uint32_t ext1 =
|
||||
VIVS_PE_ALPHA_COLOR_EXT1_R(_mesa_float_to_half(bc->color[2])) |
|
||||
VIVS_PE_ALPHA_COLOR_EXT1_A(_mesa_float_to_half(bc->color[3]));
|
||||
|
||||
for (unsigned i = 0; i < num_rts; i++) {
|
||||
cs->rt[i].PE_ALPHA_COLOR_EXT0 = ext0;
|
||||
cs->rt[i].PE_ALPHA_COLOR_EXT1 = ext1;
|
||||
}
|
||||
|
||||
ctx->dirty |= ETNA_DIRTY_BLEND_COLOR;
|
||||
}
|
||||
|
||||
bool
|
||||
etna_update_blend_color(struct etna_context *ctx)
|
||||
{
|
||||
struct pipe_framebuffer_state *fb = &ctx->framebuffer_s;
|
||||
struct compiled_blend_color *cs = &ctx->blend_color;
|
||||
unsigned rt = 0;
|
||||
|
||||
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
|
||||
if (!fb->cbufs[i].texture)
|
||||
continue;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,4 @@ 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
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ struct etna_specs {
|
|||
|
||||
/* Compiled pipe_blend_color */
|
||||
struct compiled_blend_color {
|
||||
float color[4];
|
||||
uint32_t PE_ALPHA_BLEND_COLOR;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -1138,9 +1138,6 @@ 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,
|
||||
},
|
||||
{
|
||||
etna_update_ts_config, ETNA_DIRTY_DERIVE_TS,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue