panfrost: Simplify make_fixed_blend_mode prototype
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 18 Aug 2020 21:50:39 +0000 (17:50 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:33 +0000 (17:05 +0200)
blend_rt is a bitfield so in practice it will be quite small, let's save
the indirection.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>

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

index ffda1196d046dedbfc6fc4b23aeb4e62ead7d9c3..1d0b2bad5c9ecdaf151c083cfaf57b6cc5a48f71 100644 (file)
@@ -110,24 +110,22 @@ panfrost_create_blend_state(struct pipe_context *pipe,
         assert(!blend->alpha_to_one);
 
         for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
-                struct panfrost_blend_rt *rt = &so->rt[c];
-
-                /* There are two paths. First, we would like to try a
-                 * fixed-function if we can */
+                unsigned g = blend->independent_blend_enable ? c : 0;
+                struct pipe_rt_blend_state pipe = blend->rt[g];
 
-                /* Without indep blending, the first RT settings replicate */
+                struct panfrost_blend_rt *rt = &so->rt[c];
+                rt->shaders = _mesa_hash_table_u64_create(so);
 
-                if (!blend->logicop_enable) {
-                        unsigned g =
-                                blend->independent_blend_enable ? c : 0;
+                /* Logic ops are always shader */
+                if (blend->logicop_enable) {
+                        continue;
+                }
 
-                        rt->has_fixed_function =
+                rt->has_fixed_function =
                                 panfrost_make_fixed_blend_mode(
-                                        &blend->rt[g],
+                                        pipe,
                                         &rt->equation,
-                                        &rt->constant_mask,
-                                        blend->rt[g].colormask);
-                }
+                                        &rt->constant_mask);
 
                 /* Regardless if that works, we also need to initialize
                  * the blend shaders */
index 458ab51a4e916ac27d3dd5041985637019e351e8..e1122880594b548ab720eda4ab167ab817e813cb 100644 (file)
@@ -341,19 +341,18 @@ panfrost_constant_mask(unsigned *factors, unsigned num_factors)
 
 bool
 panfrost_make_fixed_blend_mode(
-        const struct pipe_rt_blend_state *blend,
+        struct pipe_rt_blend_state blend,
         struct mali_blend_equation *out,
-        unsigned *constant_mask,
-        unsigned colormask)
+        unsigned *constant_mask)
 {
         /* Gallium and Mali represent colour masks identically. XXX: Static
          * assert for future proof */
 
-        out->color_mask = colormask;
+        out->color_mask = blend.colormask;
 
         /* If no blending is enabled, default back on `replace` mode */
 
-        if (!blend->blend_enable) {
+        if (!blend.blend_enable) {
                 out->rgb_mode = 0x122;
                 out->alpha_mode = 0x122;
                 return true;
@@ -364,8 +363,8 @@ panfrost_make_fixed_blend_mode(
          * fixed-function blending */
 
         unsigned factors[] = {
-                blend->rgb_src_factor, blend->rgb_dst_factor,
-                blend->alpha_src_factor, blend->alpha_dst_factor,
+                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));
@@ -376,12 +375,12 @@ panfrost_make_fixed_blend_mode(
         unsigned alpha_mode = 0;
 
         if (!panfrost_make_fixed_blend_part(
-                    blend->rgb_func, blend->rgb_src_factor, blend->rgb_dst_factor,
+                    blend.rgb_func, blend.rgb_src_factor, blend.rgb_dst_factor,
                     &rgb_mode))
                 return false;
 
         if (!panfrost_make_fixed_blend_part(
-                    blend->alpha_func, blend->alpha_src_factor, blend->alpha_dst_factor,
+                    blend.alpha_func, blend.alpha_src_factor, blend.alpha_dst_factor,
                     &alpha_mode))
                 return false;
 
index 4ceaf16f1de7f3b6588ce70f9268d8b308e83caf..123b1d13bf45c8352493986e796128b942fe48f8 100644 (file)
@@ -33,10 +33,9 @@ struct panfrost_blend_state;
 
 bool
 panfrost_make_fixed_blend_mode(
-        const struct pipe_rt_blend_state *blend,
+        const struct pipe_rt_blend_state blend,
         struct mali_blend_equation *out,
-        unsigned *constant_mask,
-        unsigned colormask);
+        unsigned *constant_mask);
 
 bool
 panfrost_can_fixed_blend(enum pipe_format format);