panfrost: Hoist blend constant into Midgard-specific struct
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 18 May 2019 20:36:00 +0000 (20:36 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 19 May 2019 17:41:21 +0000 (17:41 +0000)
This eliminates one major source of #ifdef parity between Midgard and
Bifrost, better representing how the struct acts on Midgard and allowing
proper decodes on Bifrost.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Ryan Houdek <Sonicadvance1@gmail.com>
src/gallium/drivers/panfrost/include/panfrost-job.h
src/gallium/drivers/panfrost/pan_blending.c
src/gallium/drivers/panfrost/pan_blending.h
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_pretty_print.c

index 96c2d07ef4dc2b435fa47cbd2b7b3d66ca75f2a7..fb4a12fe1563aab17fc2688a5f296c640a87b91b 100644 (file)
@@ -228,12 +228,6 @@ struct mali_blend_equation {
         /* Corresponds to MALI_MASK_* above and glColorMask arguments */
 
         unsigned color_mask : 4;
-
-        /* Attached constant for CONSTANT_ALPHA, etc */
-
-#ifndef BIFROST
-        float constant;
-#endif
 } __attribute__((packed));
 
 /* Used with channel swizzling */
@@ -420,7 +414,11 @@ enum mali_format {
 
 union midgard_blend {
         mali_ptr shader;
-        struct mali_blend_equation equation;
+
+        struct {
+                struct mali_blend_equation equation;
+                float constant;
+        };
 };
 
 /* On MRT Midgard systems (using an MFBD), each render target gets its own
index cecdd780ce11156f9b28c3d2c3cdccd6f7a90d3f..54e232b0a4482334fe61c38ffe95a2565f1ae78c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include "pan_blending.h"
+#include "pan_context.h"
 
 /*
  * Implements fixed-function blending on Midgard.
@@ -360,12 +361,14 @@ static const struct pipe_rt_blend_state default_blend = {
 };
 
 bool
-panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct mali_blend_equation *out, unsigned colormask, const struct pipe_blend_color *blend_color)
+panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct panfrost_blend_state *so, unsigned colormask, const struct pipe_blend_color *blend_color)
 {
+        struct mali_blend_equation *out = &so->equation;
+
         /* If no blending is enabled, default back on `replace` mode */
 
         if (!blend->blend_enable)
-                return panfrost_make_fixed_blend_mode(&default_blend, out, colormask, blend_color);
+                return panfrost_make_fixed_blend_mode(&default_blend, so, colormask, blend_color);
 
         /* We have room only for a single float32 constant between the four
          * components. If we need more, spill to the programmable pipeline. */
@@ -375,7 +378,7 @@ panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct m
                 blend->alpha_src_factor, blend->alpha_dst_factor,
         };
 
-        if (!panfrost_make_constant(factors, ARRAY_SIZE(factors), blend_color, &out->constant))
+        if (!panfrost_make_constant(factors, ARRAY_SIZE(factors), blend_color, &so->constant))
                 return false;
 
         unsigned rgb_mode = 0;
index 926b41e298e6dd13d100ed01617fb4306a9759f5..8ddd81147ebfd65538b9b3b7d3b96d68e38802c9 100644 (file)
@@ -29,6 +29,8 @@
 #include "pipe/p_defines.h"
 #include <panfrost-job.h>
 
-bool panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct mali_blend_equation *out, unsigned colormask, const struct pipe_blend_color *blend_color);
+struct panfrost_blend_state;
+
+bool panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct panfrost_blend_state *so, unsigned colormask, const struct pipe_blend_color *blend_color);
 
 #endif
index 18cd6fe2c04e3dd3cbc45e37d3fd4d981a7f92d0..5cae386f070eb39213cde3325b5142171a5d0a29 100644 (file)
@@ -1009,6 +1009,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
 
                         if (!ctx->blend->has_blend_shader) {
                                 ctx->fragment_shader_core.blend.equation = ctx->blend->equation;
+                                ctx->fragment_shader_core.blend.constant = ctx->blend->constant;
                         }
 
                         if (!no_blending) {
@@ -1050,10 +1051,12 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                         for (unsigned i = 0; i < 1; ++i) {
                                 rts[i].flags = blend_count;
 
-                                if (ctx->blend->has_blend_shader)
+                                if (ctx->blend->has_blend_shader) {
                                         rts[i].blend.shader = ctx->blend->blend_shader;
-                                else
+                                } else {
                                         rts[i].blend.equation = ctx->blend->equation;
+                                        rts[i].blend.constant = ctx->blend->constant;
+                                }
                         }
 
                         memcpy(transfer.cpu + sizeof(struct mali_shader_meta), rts, sizeof(rts[0]) * 1);
@@ -2160,7 +2163,7 @@ panfrost_create_blend_state(struct pipe_context *pipe,
 
         /* Compile the blend state, first as fixed-function if we can */
 
-        if (panfrost_make_fixed_blend_mode(&blend->rt[0], &so->equation, blend->rt[0].colormask, &ctx->blend_color))
+        if (panfrost_make_fixed_blend_mode(&blend->rt[0], so, blend->rt[0].colormask, &ctx->blend_color))
                 return so;
 
         /* If we can't, compile a blend shader instead */
index d4b9c1e9bcf670c2edee5cdeb1a1137ff13e74a3..7f08d47151181aa77368e9761b92b6ae71527935 100644 (file)
@@ -240,6 +240,7 @@ struct panfrost_blend_state {
 
         /* Compiled fixed function command */
         struct mali_blend_equation equation;
+        float constant;
 
         /* Compiled blend shader */
         mali_ptr blend_shader;
index d590f267d1c1456cad39510a70e61fe6095faa81..504bd9af74423a0c01c14b0d0fb985ef49421a11 100644 (file)
@@ -222,6 +222,4 @@ panfrost_print_blend_equation(struct mali_blend_equation eq)
                (eq.color_mask & MALI_MASK_G) ? "G" : "",
                (eq.color_mask & MALI_MASK_B) ? "B" : "",
                (eq.color_mask & MALI_MASK_A) ? "A" : "");
-
-        printf("Constant: %f\n", eq.constant);
 }