r600g: Add support for predicates
authorVincent Lejeune <vljn@ovi.com>
Wed, 1 Aug 2012 20:52:52 +0000 (22:52 +0200)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 15 Aug 2012 21:07:13 +0000 (21:07 +0000)
Signed-off-by: Tom Stellard <thomas.stellard@amd.com>
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 2341bec44126cfacc1739aa5d9ead67694c7074d..0cca829f2cafe26c0f60f0383222053d10a2f90c 100644 (file)
@@ -1424,7 +1424,7 @@ int r600_bytecode_add_alu_type(struct r600_bytecode *bc, const struct r600_bytec
                if (bc->cf_last->inst == BC_INST(bc, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU) &&
                        type == BC_INST(bc, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE)) {
                        LIST_FOR_EACH_ENTRY(lalu, &bc->cf_last->alu, list) {
-                               if (lalu->predicate) {
+                               if (lalu->execute_mask) {
                                        bc->force_add_cf = 1;
                                        break;
                                }
@@ -1755,6 +1755,7 @@ static int r600_bytecode_alu_build(struct r600_bytecode *bc, struct r600_bytecod
                                S_SQ_ALU_WORD0_SRC1_CHAN(alu->src[1].chan) |
                                S_SQ_ALU_WORD0_SRC1_NEG(alu->src[1].neg) |
                                S_SQ_ALU_WORD0_INDEX_MODE(alu->index_mode) |
+                               S_SQ_ALU_WORD0_PRED_SEL(alu->pred_sel) |
                                S_SQ_ALU_WORD0_LAST(alu->last);
 
        if (alu->is_op3) {
@@ -1779,8 +1780,8 @@ static int r600_bytecode_alu_build(struct r600_bytecode *bc, struct r600_bytecod
                                        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) |
-                                       S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu->predicate);
+                                       S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu->execute_mask) |
+                                       S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu->update_pred);
        }
        return 0;
 }
@@ -2467,6 +2468,7 @@ void r600_bytecode_dump(struct r600_bytecode *bc)
                        fprintf(stderr, "CHAN:%d ", alu->src[1].chan);
                        fprintf(stderr, "NEG:%d ", alu->src[1].neg);
                        fprintf(stderr, "IM:%d) ", alu->index_mode);
+                       fprintf(stderr, "PRED_SEL:%d ", alu->pred_sel);
                        fprintf(stderr, "LAST:%d)\n", alu->last);
                        id++;
                        fprintf(stderr, "%04d %08X %c ", id, bc->bytecode[id], alu->last ? '*' : ' ');
@@ -2486,8 +2488,8 @@ void r600_bytecode_dump(struct r600_bytecode *bc)
                                fprintf(stderr, "SRC1_ABS:%d ", alu->src[1].abs);
                                fprintf(stderr, "WRITE_MASK:%d ", alu->dst.write);
                                fprintf(stderr, "OMOD:%d ", alu->omod);
-                               fprintf(stderr, "EXECUTE_MASK:%d ", alu->predicate);
-                               fprintf(stderr, "UPDATE_PRED:%d\n", alu->predicate);
+                               fprintf(stderr, "EXECUTE_MASK:%d ", alu->execute_mask);
+                               fprintf(stderr, "UPDATE_PRED:%d\n", alu->update_pred);
                        }
 
                        id++;
index a8a157b79e4d74de4142d25d117fb5a75fa2a2ff..87e751adc78737080aae7de27059617a398e5a8e 100644 (file)
@@ -53,7 +53,9 @@ struct r600_bytecode_alu {
        unsigned                        inst;
        unsigned                        last;
        unsigned                        is_op3;
-       unsigned                        predicate;
+       unsigned                        execute_mask;
+       unsigned                        update_pred;
+       unsigned                        pred_sel;
        unsigned                        bank_swizzle;
        unsigned                        bank_swizzle_force;
        unsigned                        omod;
index ed95f4cdff324d569ca15148b8ac1d1ece788a5c..dfaff832e764f7cec7f288b103b0602550aa934f 100644 (file)
@@ -310,7 +310,7 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
        alu.inst = inst0 | (inst1 << 8);
        alu.last = bytes[bytes_read++];
        alu.is_op3 = bytes[bytes_read++];
-       alu.predicate = bytes[bytes_read++];
+       alu.pred_sel = bytes[bytes_read++];
        alu.bank_swizzle = bytes[bytes_read++];
        alu.bank_swizzle_force = bytes[bytes_read++];
        alu.omod = bytes[bytes_read++];
@@ -330,7 +330,8 @@ static void llvm_if(struct r600_shader_ctx *ctx, struct r600_bytecode_alu * alu,
        unsigned pred_inst)
 {
        alu->inst = pred_inst; 
-       alu->predicate = 1;
+       alu->execute_mask = 1;
+       alu->update_pred = 1;
        alu->dst.write = 0;
        alu->src[1].sel = V_SQ_ALU_SRC_0;
        alu->src[1].chan = 0;
@@ -4854,7 +4855,8 @@ static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode)
 
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
        alu.inst = opcode;
-       alu.predicate = 1;
+       alu.execute_mask = 1;
+       alu.update_pred = 1;
 
        alu.dst.sel = ctx->temp_reg;
        alu.dst.write = 1;
index ffa179fbf828216b79c1885cec70c3a58cff272e..ea37c63525f748c3352d81e99180894e260e00e8 100644 (file)
@@ -43,6 +43,7 @@ int r700_bytecode_alu_build(struct r600_bytecode *bc, struct r600_bytecode_alu *
                S_SQ_ALU_WORD0_SRC1_REL(alu->src[1].rel) |
                S_SQ_ALU_WORD0_SRC1_CHAN(alu->src[1].chan) |
                S_SQ_ALU_WORD0_SRC1_NEG(alu->src[1].neg) |
+               S_SQ_ALU_WORD0_PRED_SEL(alu->pred_sel) |
                S_SQ_ALU_WORD0_LAST(alu->last);
 
        /* don't replace gpr by pv or ps for destination register */
@@ -68,8 +69,8 @@ int r700_bytecode_alu_build(struct r600_bytecode *bc, struct r600_bytecode_alu *
                                        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) |
-                                       S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu->predicate);
+                                       S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(alu->execute_mask) |
+                                       S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu->update_pred);
        }
        return 0;
 }