Module: Mesa
Branch: master
Commit: 78ec5225c2a069955e6304ef26f3b474aaa7885d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=78ec5225c2a069955e6304ef26f3b474aaa7885d

Author: Boris Brezillon <[email protected]>
Date:   Thu Oct  8 10:25:13 2020 +0200

panfrost: Move the blend constant mask extraction out of make_fixed_blend_mode()

This way we can get a constant mask for the blend shader case too.

Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7066>

---

 src/gallium/drivers/panfrost/pan_blend_cso.c |  6 ++---
 src/gallium/drivers/panfrost/pan_blending.c  | 38 ++++++++++++----------------
 src/gallium/drivers/panfrost/pan_blending.h  |  6 +++--
 3 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c 
b/src/gallium/drivers/panfrost/pan_blend_cso.c
index 4378b4d00e8..4b724e2cc32 100644
--- a/src/gallium/drivers/panfrost/pan_blend_cso.c
+++ b/src/gallium/drivers/panfrost/pan_blend_cso.c
@@ -125,11 +125,9 @@ panfrost_create_blend_state(struct pipe_context *pipe,
                         continue;
                 }
 
+                rt->constant_mask = panfrost_blend_constant_mask(&pipe);
                 rt->has_fixed_function =
-                                panfrost_make_fixed_blend_mode(
-                                        pipe,
-                                        &rt->equation,
-                                        &rt->constant_mask);
+                        panfrost_make_fixed_blend_mode(pipe, &rt->equation);
 
                 /* v6 doesn't support blend constants in FF blend equations. */
                 if (rt->has_fixed_function && version == 6 && 
rt->constant_mask)
diff --git a/src/gallium/drivers/panfrost/pan_blending.c 
b/src/gallium/drivers/panfrost/pan_blending.c
index fda516c8089..e1b6a7ba7f6 100644
--- a/src/gallium/drivers/panfrost/pan_blending.c
+++ b/src/gallium/drivers/panfrost/pan_blending.c
@@ -256,22 +256,28 @@ to_panfrost_function(unsigned blend_func,
  * the factors for constants used to create a mask to check later. */
 
 static unsigned
-panfrost_constant_mask(unsigned *factors, unsigned num_factors)
+panfrost_blend_factor_constant_mask(enum pipe_blendfactor factor)
 {
         unsigned mask = 0;
 
-        for (unsigned i = 0; i < num_factors; ++i) {
-                unsigned factor = uncomplement_factor(factors[i]);
-
-                if (factor == PIPE_BLENDFACTOR_CONST_COLOR)
-                        mask |= 0b0111; /* RGB */
-                else if (factor == PIPE_BLENDFACTOR_CONST_ALPHA)
-                        mask |= 0b1000; /* A */
-        }
+        factor = uncomplement_factor(factor);
+        if (factor == PIPE_BLENDFACTOR_CONST_COLOR)
+                mask |= 0b0111; /* RGB */
+        else if (factor == PIPE_BLENDFACTOR_CONST_ALPHA)
+                mask |= 0b1000; /* A */
 
         return mask;
 }
 
+unsigned
+panfrost_blend_constant_mask(const struct pipe_rt_blend_state *blend)
+{
+        return panfrost_blend_factor_constant_mask(blend->rgb_src_factor) |
+               panfrost_blend_factor_constant_mask(blend->rgb_dst_factor) |
+               panfrost_blend_factor_constant_mask(blend->alpha_src_factor) |
+               panfrost_blend_factor_constant_mask(blend->alpha_dst_factor);
+}
+
 /* Create the descriptor for a fixed blend mode given the corresponding Gallium
  * state, if possible. Return true and write out the blend descriptor into
  * blend_equation. If it is not possible with the fixed function
@@ -280,8 +286,7 @@ panfrost_constant_mask(unsigned *factors, unsigned 
num_factors)
 
 bool
 panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state blend,
-                               struct MALI_BLEND_EQUATION *equation,
-                               unsigned *constant_mask)
+                               struct MALI_BLEND_EQUATION *equation)
 {
         /* If no blending is enabled, default back on `replace` mode */
 
@@ -296,17 +301,6 @@ panfrost_make_fixed_blend_mode(const struct 
pipe_rt_blend_state blend,
                 return true;
         }
 
-        /* At draw-time, we'll need to analyze the blend constant, so
-         * precompute a mask for it -- even if we don't end up able to use
-         * fixed-function blending */
-
-        unsigned factors[] = {
-                blend.rgb_src_factor, blend.rgb_dst_factor,
-                blend.alpha_src_factor, blend.alpha_dst_factor,
-        };
-
-        *constant_mask = panfrost_constant_mask(factors, ARRAY_SIZE(factors));
-
         /* Try to compile the actual fixed-function blend */
         if (!to_panfrost_function(blend.rgb_func, blend.rgb_src_factor,
                                   blend.rgb_dst_factor,
diff --git a/src/gallium/drivers/panfrost/pan_blending.h 
b/src/gallium/drivers/panfrost/pan_blending.h
index d34e472de50..e1870747d82 100644
--- a/src/gallium/drivers/panfrost/pan_blending.h
+++ b/src/gallium/drivers/panfrost/pan_blending.h
@@ -32,10 +32,12 @@
 
 struct panfrost_blend_state;
 
+unsigned
+panfrost_blend_constant_mask(const struct pipe_rt_blend_state *blend);
+
 bool
 panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state blend,
-                               struct MALI_BLEND_EQUATION *equation,
-                               unsigned *constant_mask);
+                               struct MALI_BLEND_EQUATION *equation);
 
 bool
 panfrost_can_fixed_blend(enum pipe_format format);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to