Mesa (main): panfrost: Add blend helper packing the equation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 18:32:47 UTC 2021


Module: Mesa
Branch: main
Commit: b7af56f2ad10c137e6425f4e36b920aec210bc68
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7af56f2ad10c137e6425f4e36b920aec210bc68

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri Jul 30 17:46:21 2021 -0400

panfrost: Add blend helper packing the equation

This is more convenient for the Gallium driver and easier to test.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12152>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c |  3 +--
 src/panfrost/lib/pan_blend.c                 | 14 ++++++++++++++
 src/panfrost/lib/pan_blend.h                 |  3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 450dcaf7aaf..cfc1413fa53 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -3461,8 +3461,7 @@ panfrost_create_blend_state(struct pipe_context *pipe,
                 /* Converting equations to Mali style is expensive, do it at
                  * CSO create time instead of draw-time */
                 if (so->info[c].fixed_function) {
-                        pan_pack(&so->equation[c], BLEND_EQUATION, cfg)
-                                pan_blend_to_fixed_function_equation(equation, &cfg);
+                        so->equation[c] = pan_pack_blend(equation);
                 }
         }
 
diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c
index 1f55d09177e..4dd5fc00956 100644
--- a/src/panfrost/lib/pan_blend.c
+++ b/src/panfrost/lib/pan_blend.c
@@ -312,6 +312,20 @@ pan_blend_to_fixed_function_equation(const struct pan_blend_equation equation,
         out->color_mask = equation.color_mask;
 }
 
+uint32_t
+pan_pack_blend(const struct pan_blend_equation equation)
+{
+        STATIC_ASSERT(sizeof(uint32_t) == MALI_BLEND_EQUATION_LENGTH);
+
+        uint32_t out = 0;
+
+        pan_pack(&out, BLEND_EQUATION, cfg) {
+                pan_blend_to_fixed_function_equation(equation, &cfg);
+        }
+
+        return out;
+}
+
 static const char *
 logicop_str(enum pipe_logicop logicop)
 {
diff --git a/src/panfrost/lib/pan_blend.h b/src/panfrost/lib/pan_blend.h
index 2a95503262a..397022c7c6d 100644
--- a/src/panfrost/lib/pan_blend.h
+++ b/src/panfrost/lib/pan_blend.h
@@ -134,6 +134,9 @@ void
 pan_blend_to_fixed_function_equation(const struct pan_blend_equation eq,
                                      struct MALI_BLEND_EQUATION *equation);
 
+uint32_t
+pan_pack_blend(const struct pan_blend_equation equation);
+
 nir_shader *
 pan_blend_create_shader(const struct panfrost_device *dev,
                         const struct pan_blend_state *state,



More information about the mesa-commit mailing list