nv50: create emit_pow() - emit_lit() will need to use it
authorBen Skeggs <skeggsb@gmail.com>
Sat, 7 Jun 2008 07:36:10 +0000 (17:36 +1000)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 29 Jun 2008 05:46:15 +0000 (15:46 +1000)
src/gallium/drivers/nv50/nv50_program.c

index b013435..bc0a834 100644 (file)
@@ -627,6 +627,7 @@ emit_preex2(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 
        emit(pc, inst);
 }
+
 /*XXX: inaccurate results.. why? */
 #define ALLOW_SET_SWAP 0
 
@@ -694,6 +695,20 @@ emit_flr(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        emit(pc, inst);
 }
 
+static void
+emit_pow(struct nv50_pc *pc, struct nv50_reg *dst,
+        struct nv50_reg *v, struct nv50_reg *e)
+{
+       struct nv50_reg *temp = alloc_temp(pc, NULL);
+
+       emit_flop(pc, 3, temp, v);
+       emit_mul(pc, temp, temp, e);
+       emit_preex2(pc, temp, temp);
+       emit_flop(pc, 6, dst, temp);
+
+       free_temp(pc, temp);
+}
+
 static boolean
 nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
 {
@@ -875,10 +890,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                break;
        case TGSI_OPCODE_POW:
                temp = alloc_temp(pc, NULL);
-               emit_flop(pc, 3, temp, src[0][0]);
-               emit_mul(pc, temp, temp, src[1][0]);
-               emit_preex2(pc, temp, temp);
-               emit_flop(pc, 6, temp, temp);
+               emit_pow(pc, temp, src[0][0], src[1][0]);
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;