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

Author: Alyssa Rosenzweig <aly...@rosenzweig.io>
Date:   Sat May 18 20:36:00 2019 +0000

panfrost: Hoist blend constant into Midgard-specific struct

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 <aly...@rosenzweig.io>
Reviewed-by: Ryan Houdek <sonicadvan...@gmail.com>

---

 src/gallium/drivers/panfrost/include/panfrost-job.h | 12 +++++-------
 src/gallium/drivers/panfrost/pan_blending.c         |  9 ++++++---
 src/gallium/drivers/panfrost/pan_blending.h         |  4 +++-
 src/gallium/drivers/panfrost/pan_context.c          |  9 ++++++---
 src/gallium/drivers/panfrost/pan_context.h          |  1 +
 src/gallium/drivers/panfrost/pan_pretty_print.c     |  2 --
 6 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/panfrost/include/panfrost-job.h 
b/src/gallium/drivers/panfrost/include/panfrost-job.h
index 96c2d07ef4d..fb4a12fe156 100644
--- a/src/gallium/drivers/panfrost/include/panfrost-job.h
+++ b/src/gallium/drivers/panfrost/include/panfrost-job.h
@@ -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
diff --git a/src/gallium/drivers/panfrost/pan_blending.c 
b/src/gallium/drivers/panfrost/pan_blending.c
index cecdd780ce1..54e232b0a44 100644
--- a/src/gallium/drivers/panfrost/pan_blending.c
+++ b/src/gallium/drivers/panfrost/pan_blending.c
@@ -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;
diff --git a/src/gallium/drivers/panfrost/pan_blending.h 
b/src/gallium/drivers/panfrost/pan_blending.h
index 926b41e298e..8ddd81147eb 100644
--- a/src/gallium/drivers/panfrost/pan_blending.h
+++ b/src/gallium/drivers/panfrost/pan_blending.h
@@ -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
diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 18cd6fe2c04..5cae386f070 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -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 */
diff --git a/src/gallium/drivers/panfrost/pan_context.h 
b/src/gallium/drivers/panfrost/pan_context.h
index d4b9c1e9bcf..7f08d471511 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -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;
diff --git a/src/gallium/drivers/panfrost/pan_pretty_print.c 
b/src/gallium/drivers/panfrost/pan_pretty_print.c
index d590f267d1c..504bd9af744 100644
--- a/src/gallium/drivers/panfrost/pan_pretty_print.c
+++ b/src/gallium/drivers/panfrost/pan_pretty_print.c
@@ -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);
 }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to