Mesa (master): panfrost: Dual-source blending on Bifrost

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 12 21:26:49 UTC 2021


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

Author: Icecream95 <ixn at disroot.org>
Date:   Wed Jan 13 02:18:10 2021 +1300

panfrost: Dual-source blending on Bifrost

Tested with the arb_blend_func_extended Piglit tests and Alacritty.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8455>

---

 src/gallium/drivers/panfrost/pan_screen.c |  2 +-
 src/panfrost/bifrost/bifrost_compile.c    | 27 ++++++++++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index 1bf78f39518..4aea02e3566 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -123,7 +123,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
                 return has_mrt ? 8 : 1;
 
         case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
-                return is_bifrost ? 0 : 1;
+                return 1;
 
         case PIPE_CAP_SAMPLE_SHADING:
                 /* WIP */
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 7aa5caba16c..40034ae5d79 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -302,15 +302,20 @@ bi_emit_load_blend_input(bi_builder *b, nir_intrinsic_instr *instr)
 {
         ASSERTED nir_io_semantics sem = nir_intrinsic_io_semantics(instr);
 
-        /* We don't support dual-source blending yet. */
-        assert(sem.location == VARYING_SLOT_COL0);
-
-        /* Source color is passed through r0-r3.  TODO: Precolour instead */
+        /* Source color is passed through r0-r3, or r4-r7 for the second
+         * source when dual-source blending.  TODO: Precolour instead */
         bi_index srcs[] = {
                 bi_register(0), bi_register(1), bi_register(2), bi_register(3)
         };
+        bi_index srcs2[] = {
+                bi_register(4), bi_register(5), bi_register(6), bi_register(7)
+        };
 
-        bi_make_vec_to(b, bi_dest_index(&instr->dest), srcs, NULL, 4, 32);
+        bool second_source = (sem.location == VARYING_SLOT_VAR0);
+
+        bi_make_vec_to(b, bi_dest_index(&instr->dest),
+                       second_source ? srcs2 : srcs,
+                       NULL, 4, 32);
 }
 
 static void
@@ -355,6 +360,18 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr)
                                 nir_var_shader_out, nir_intrinsic_base(instr));
         assert(var);
 
+        /* Dual-source blending is implemented by putting the color in
+         * registers r4-r7. */
+        if (var->data.index) {
+                bi_index color = bi_src_index(&instr->src[0]);
+                unsigned count = nir_src_num_components(instr->src[0]);
+
+                for (unsigned i = 0; i < count; ++i)
+                        bi_mov_i32_to(b, bi_register(4 + i),
+                                      bi_word(color, i));
+                return;
+        }
+
         /* Emit ATEST if we have to, note ATEST requires a floating-point alpha
          * value, but render target #0 might not be floating point. However the
          * alpha value is only used for alpha-to-coverage, a stage which is



More information about the mesa-commit mailing list