From ffeeda341451dd6cb7b6bd10e4990b0c260498d5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 14 May 2021 13:22:47 -0400 Subject: [PATCH] panfrost: Translate fixed-function blend at CSO create Fixes: 93824b6451a ("panfrost: Move the blend logic out of the gallium driver") Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_blend_cso.c | 9 +++++++-- src/gallium/drivers/panfrost/pan_blend_cso.h | 2 +- src/gallium/drivers/panfrost/pan_cmdstream.c | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c index a4c996b..de5aa4f 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.c +++ b/src/gallium/drivers/panfrost/pan_blend_cso.c @@ -115,6 +115,13 @@ panfrost_create_blend_state(struct pipe_context *pipe, }; so->pan.rts[c].equation = equation; + + /* Converting equations to Mali style is expensive, do it at + * CSO create time instead of draw-time */ + if (so->info[c].fixed_function) { + pan_blend_to_fixed_function_equation(equation, + &so->equation[c]); + } } return so; @@ -165,7 +172,6 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc sizeof(pan_blend.constants)); /* First, we'll try fixed function, matching equation and constant */ - const struct pan_blend_equation eq = pan_blend.rts[rti].equation; bool ff = blend->info[rti].fixed_function; /* Not all formats are blendable, check if this one is */ @@ -182,7 +188,6 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc ctx->blend_color.color), }; - pan_blend_to_fixed_function_equation(eq, &final.equation.equation); return final; } diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.h b/src/gallium/drivers/panfrost/pan_blend_cso.h index 95c03c6..4aa87513 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.h +++ b/src/gallium/drivers/panfrost/pan_blend_cso.h @@ -65,7 +65,6 @@ struct panfrost_blend_shader_final { }; struct panfrost_blend_equation_final { - struct MALI_BLEND_EQUATION equation; float constant; }; @@ -81,6 +80,7 @@ struct panfrost_blend_state { struct pipe_blend_state base; struct pan_blend_state pan; struct pan_blend_info info[PIPE_MAX_COLOR_BUFS]; + struct MALI_BLEND_EQUATION equation[PIPE_MAX_COLOR_BUFS]; }; /* Container for a final blend state, specialized to constants and a diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index cf587a3..5b9a0ad 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -364,7 +364,7 @@ panfrost_emit_bifrost_blend(struct panfrost_batch *batch, for (unsigned i = 0; i < format_desc->nr_channels; i++) chan_size = MAX2(format_desc->channel[0].size, chan_size); - cfg.bifrost.equation = blend[i].equation.equation; + cfg.bifrost.equation = so->equation[i]; /* Fixed point constant */ u16 constant = blend[i].equation.constant * ((1 << chan_size) - 1); @@ -431,7 +431,7 @@ panfrost_emit_midgard_blend(struct panfrost_batch *batch, if (blend[i].is_shader) { cfg.midgard.shader_pc = blend[i].shader.gpu | blend[i].shader.first_tag; } else { - cfg.midgard.equation = blend[i].equation.equation; + cfg.midgard.equation = ctx->blend->equation[i]; cfg.midgard.constant = blend[i].equation.constant; } } @@ -569,7 +569,7 @@ panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx, state->sfbd_blend_shader = blend[0].shader.gpu | blend[0].shader.first_tag; } else { - state->sfbd_blend_equation = blend[0].equation.equation; + state->sfbd_blend_equation = so->equation[0]; state->sfbd_blend_constant = blend[0].equation.constant; } } else if (dev->quirks & MIDGARD_SFBD) { -- 2.7.4