panfrost: Add blend helper packing the equation
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 30 Jul 2021 21:46:21 +0000 (17:46 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Aug 2021 18:15:52 +0000 (18:15 +0000)
This is more convenient for the Gallium driver and easier to test.

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

src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/lib/pan_blend.c
src/panfrost/lib/pan_blend.h

index 450dcaf..cfc1413 100644 (file)
@@ -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);
                 }
         }
 
index 1f55d09..4dd5fc0 100644 (file)
@@ -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)
 {
index 2a95503..397022c 100644 (file)
@@ -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,