Mesa (master): vc4: Take advantage of the 8888 pack function in pack_unorm_4x8.

Eric Anholt anholt at kemper.freedesktop.org
Sun Oct 25 01:54:34 UTC 2015


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

Author: Eric Anholt <eric at anholt.net>
Date:   Sat Oct 24 17:04:49 2015 -0700

vc4: Take advantage of the 8888 pack function in pack_unorm_4x8.

One instruction instead of four, and it turns out you do this a lot for
the Over operator.

total uniforms in shared programs: 32168 -> 32087 (-0.25%)
uniforms in affected programs:     318 -> 237 (-25.47%)
total instructions in shared programs: 89830 -> 89472 (-0.40%)
instructions in affected programs:     6434 -> 6076 (-5.56%)

---

 src/gallium/drivers/vc4/vc4_program.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 5d7564b..a48dad8 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -738,6 +738,20 @@ ntq_emit_pack_unorm_4x8(struct vc4_compile *c, nir_alu_instr *instr)
                 vec4 = nir_instr_as_alu(instr->src[0].src.ssa->parent_instr);
         }
 
+        /* If the pack is replicating the same channel 4 times, use the 8888
+         * pack flag.  This is common for blending using the alpha
+         * channel.
+         */
+        if (instr->src[0].swizzle[0] == instr->src[0].swizzle[1] &&
+            instr->src[0].swizzle[0] == instr->src[0].swizzle[2] &&
+            instr->src[0].swizzle[0] == instr->src[0].swizzle[3]) {
+                struct qreg *dest = ntq_get_dest(c, &instr->dest.dest);
+                *dest = qir_PACK_8888_F(c,
+                                        ntq_get_src(c, instr->src[0].src,
+                                                    instr->src[0].swizzle[0]));
+                return;
+        }
+
         for (int i = 0; i < 4; i++) {
                 int swiz = instr->src[0].swizzle[i];
                 struct qreg src;




More information about the mesa-commit mailing list