panfrost: Translate fixed-function blend at CSO create
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 14 May 2021 17:22:47 +0000 (13:22 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 May 2021 22:51:56 +0000 (22:51 +0000)
Fixes: 93824b6451a ("panfrost: Move the blend logic out of the gallium driver")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>

src/gallium/drivers/panfrost/pan_blend_cso.c
src/gallium/drivers/panfrost/pan_blend_cso.h
src/gallium/drivers/panfrost/pan_cmdstream.c

index a4c996b..de5aa4f 100644 (file)
@@ -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;
         }
 
index 95c03c6..4aa8751 100644 (file)
@@ -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
index cf587a3..5b9a0ad 100644 (file)
@@ -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) {