The 8888 splats the first component to all the channels, so later channels
packing from it can be skipped.

total instructions in shared programs: 98170 -> 98168 (-0.00%)
instructions in affected programs:     257 -> 255 (-0.78%)
---
 src/gallium/drivers/vc4/vc4_program.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 13c4721..ab2f885 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -840,13 +840,17 @@ ntq_emit_alu(struct vc4_compile *c, nir_alu_instr *instr)
 
         if (instr->op == nir_op_pack_unorm_4x8) {
                 struct qreg result;
+                struct qreg src0;
                 for (int i = 0; i < 4; i++) {
                         struct qreg src = ntq_get_src(c, instr->src[0].src,
                                                       
instr->src[0].swizzle[i]);
-                        if (i == 0)
+                        if (i == 0) {
+                                src0 = src;
                                 result = qir_PACK_8888_F(c, src);
-                        else
-                                result = qir_PACK_8_F(c, result, src, i);
+                        } else {
+                                if (memcmp(&src, &src0, sizeof(src)) != 0)
+                                        result = qir_PACK_8_F(c, result, src, 
i);
+                        }
                 }
                 struct qreg *dest = ntq_get_dest(c, &instr->dest.dest);
                 *dest = result;
-- 
2.1.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to