r600g: implement output modifiers and use them to further optimize LRP
authorChristian König <deathsimple@vodafone.de>
Thu, 16 Dec 2010 15:42:14 +0000 (16:42 +0100)
committerChristian König <deathsimple@vodafone.de>
Thu, 16 Dec 2010 15:42:14 +0000 (16:42 +0100)
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_asm.h
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r700_asm.c

index 4476f432b98227a09bffff25ab9f740e20b831fa..2a62b06cc6041429508afe1e3df8a6b68a00de2d 100644 (file)
@@ -707,6 +707,7 @@ static int r600_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsign
                                        S_SQ_ALU_WORD1_OP2_SRC0_ABS(alu->src[0].abs) |
                                        S_SQ_ALU_WORD1_OP2_SRC1_ABS(alu->src[1].abs) |
                                        S_SQ_ALU_WORD1_OP2_WRITE_MASK(alu->dst.write) |
+                                       S_SQ_ALU_WORD1_OP2_OMOD(alu->omod) |
                                        S_SQ_ALU_WORD1_OP2_ALU_INST(alu->inst) |
                                        S_SQ_ALU_WORD1_BANK_SWIZZLE(alu->bank_swizzle) |
                                        S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu->predicate) |
index b147f0f5c88d47d50b056844185050a7d62e578d..ac3ed3c8520b3b5f20d563151b55d2ae951ae1ef 100644 (file)
@@ -62,6 +62,7 @@ struct r600_bc_alu {
        unsigned                        bank_swizzle_force;
        u32                             value[4];
        int                             hw_gpr[NUM_OF_CYCLES][NUM_OF_COMPONENTS];
+       unsigned                        omod;
 };
 
 struct r600_bc_tex {
index 9de088472631faba03e481f68e06e0422f1f74a0..80579b8d8719de011241822b54183ed9b5e80b67 100644 (file)
@@ -1975,6 +1975,35 @@ static int tgsi_lrp(struct r600_shader_ctx *ctx)
        r = tgsi_split_literal_constant(ctx, r600_src);
        if (r)
                return r;
+
+       /* optimize if it's just an equal balance */
+       if(r600_src[0].sel == V_SQ_ALU_SRC_0_5) {
+               for (i = 0; i < lasti + 1; i++) {
+                       if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
+                               continue;
+
+                       memset(&alu, 0, sizeof(struct r600_bc_alu));
+                       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD);
+                       alu.src[0] = r600_src[1];
+                       alu.src[0].chan = tgsi_chan(&inst->Src[1], i);
+                       alu.src[1] = r600_src[2];
+                       alu.src[1].chan = tgsi_chan(&inst->Src[2], i);
+                       alu.omod = 3;
+                       r = tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
+                       if (r)
+                               return r;
+
+                       alu.dst.chan = i;
+                       if (i == lasti) {
+                               alu.last = 1;
+                       }
+                       r = r600_bc_add_alu(ctx->bc, &alu);
+                       if (r)
+                               return r;
+               }
+               return 0;
+       }
+
        /* 1 - src0 */
        for (i = 0; i < lasti + 1; i++) {
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
index 892dee86baf38c023c6a278971853c728938dc45..3eb6fb50ca721671a909508e215305dd56b76638 100644 (file)
@@ -61,6 +61,7 @@ int r700_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsigned id)
                                        S_SQ_ALU_WORD1_OP2_SRC0_ABS(alu->src[0].abs) |
                                        S_SQ_ALU_WORD1_OP2_SRC1_ABS(alu->src[1].abs) |
                                        S_SQ_ALU_WORD1_OP2_WRITE_MASK(alu->dst.write) |
+                                       S_SQ_ALU_WORD1_OP2_OMOD(alu->omod) |
                                        S_SQ_ALU_WORD1_OP2_ALU_INST(alu->inst) |
                                        S_SQ_ALU_WORD1_BANK_SWIZZLE(alu->bank_swizzle) |
                                        S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu->predicate) |