panfrost: Fix the reads_dest prototype
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 14 May 2021 13:47:37 +0000 (09:47 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 May 2021 22:51:56 +0000 (22:51 +0000)
Takes too much state, only pass what we need.

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/panfrost/lib/pan_blend.c
src/panfrost/lib/pan_blend.h

index f23860e..9f30f67 100644 (file)
@@ -146,7 +146,7 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc
         /* First, we'll try fixed function, matching equation and constant */
         if (pan_blend_can_fixed_function(dev, &pan_blend, rti)) {
                 struct panfrost_blend_final final = {
-                        .load_dest = pan_blend_reads_dest(&pan_blend, rti),
+                        .load_dest = pan_blend_reads_dest(pan_blend.rts[rti].equation),
                         .equation.constant = pan_blend_get_constant(dev, &pan_blend, rti),
                         .opaque = pan_blend_is_opaque(&pan_blend, rti),
                         .no_colour = pan_blend.rts[rti].equation.color_mask == 0,
@@ -196,7 +196,8 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc
                         .first_tag = shader->first_tag,
                         .gpu = (*bo)->ptr.gpu + *shader_offset,
                 },
-                .load_dest = pan_blend_reads_dest(&pan_blend, rti),
+                .load_dest = pan_blend.logicop_enable ||
+                        pan_blend_reads_dest(pan_blend.rts[rti].equation),
         };
 
         *shader_offset += shader->binary.size;
index 78a93b1..07fbad1 100644 (file)
@@ -304,25 +304,20 @@ is_dest_factor(enum blend_factor factor, bool alpha)
              (factor == BLEND_FACTOR_SRC_ALPHA_SATURATE && !alpha);
 }
 
+/* Determines if a blend equation reads back the destination. This can occur by
+ * explicitly referencing the destination in the blend equation, or by using a
+ * partial writemask. */
+
 bool
-pan_blend_reads_dest(const struct pan_blend_state *state, unsigned rt)
+pan_blend_reads_dest(const struct pan_blend_equation equation)
 {
-        const struct pan_blend_rt_state *rt_state = &state->rts[rt];
-
-        if (state->logicop_enable ||
-            (rt_state->equation.color_mask &&
-             rt_state->equation.color_mask != 0xF))
-                return true;
-
-        if (is_dest_factor(rt_state->equation.rgb_src_factor, false) ||
-            is_dest_factor(rt_state->equation.alpha_src_factor, true) ||
-            rt_state->equation.rgb_dst_factor != BLEND_FACTOR_ZERO ||
-            rt_state->equation.rgb_invert_dst_factor ||
-            rt_state->equation.alpha_dst_factor != BLEND_FACTOR_ZERO ||
-            rt_state->equation.alpha_invert_dst_factor)
-                return true;
-
-        return false;
+        return (equation.color_mask && equation.color_mask != 0xF) ||
+                is_dest_factor(equation.rgb_src_factor, false) ||
+                is_dest_factor(equation.alpha_src_factor, true) ||
+                equation.rgb_dst_factor != BLEND_FACTOR_ZERO ||
+                equation.rgb_invert_dst_factor ||
+                equation.alpha_dst_factor != BLEND_FACTOR_ZERO ||
+                equation.alpha_invert_dst_factor;
 }
 
 /* Create the descriptor for a fixed blend mode given the corresponding Gallium
index 0f00cba..09c69f3 100644 (file)
@@ -97,7 +97,7 @@ struct pan_blend_shader {
 };
 
 bool
-pan_blend_reads_dest(const struct pan_blend_state *state, unsigned rt);
+pan_blend_reads_dest(const struct pan_blend_equation eq);
 
 bool
 pan_blend_can_fixed_function(const struct panfrost_device *dev,