r600g: add initial relative support to assembler
authorDave Airlie <airlied@redhat.com>
Mon, 30 Aug 2010 05:19:20 +0000 (15:19 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 30 Aug 2010 05:47:49 +0000 (15:47 +1000)
passes another ~20 piglits.

/me starts to run out low hanging fruit around now.

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/r600_sq.h

index d3a9c6ca1f1a5bae812ca47d299391b927308bf4..1a354a6293bc0bff263954e846a696b8f0be2e8c 100644 (file)
@@ -341,9 +341,11 @@ static int r600_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsign
 
        /* don't replace gpr by pv or ps for destination register */
        bc->bytecode[id++] = S_SQ_ALU_WORD0_SRC0_SEL(alu->src[0].sel) |
+                               S_SQ_ALU_WORD0_SRC0_REL(alu->src[0].rel) |
                                S_SQ_ALU_WORD0_SRC0_CHAN(alu->src[0].chan) |
                                S_SQ_ALU_WORD0_SRC0_NEG(alu->src[0].neg) |
                                S_SQ_ALU_WORD0_SRC1_SEL(alu->src[1].sel) |
+                               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_LAST(alu->last);
@@ -351,8 +353,10 @@ static int r600_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsign
        if (alu->is_op3) {
                bc->bytecode[id++] = S_SQ_ALU_WORD1_DST_GPR(alu->dst.sel) |
                                        S_SQ_ALU_WORD1_DST_CHAN(alu->dst.chan) |
+                                       S_SQ_ALU_WORD1_DST_REL(alu->dst.rel) |
                                        S_SQ_ALU_WORD1_CLAMP(alu->dst.clamp) |
                                        S_SQ_ALU_WORD1_OP3_SRC2_SEL(alu->src[2].sel) |
+                                       S_SQ_ALU_WORD1_OP3_SRC2_REL(alu->src[2].rel) |
                                        S_SQ_ALU_WORD1_OP3_SRC2_CHAN(alu->src[2].chan) |
                                        S_SQ_ALU_WORD1_OP3_SRC2_NEG(alu->src[2].neg) |
                                        S_SQ_ALU_WORD1_OP3_ALU_INST(alu->inst) |
@@ -360,6 +364,7 @@ static int r600_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsign
        } else {
                bc->bytecode[id++] = S_SQ_ALU_WORD1_DST_GPR(alu->dst.sel) |
                                        S_SQ_ALU_WORD1_DST_CHAN(alu->dst.chan) |
+                                       S_SQ_ALU_WORD1_DST_REL(alu->dst.rel) |
                                        S_SQ_ALU_WORD1_CLAMP(alu->dst.clamp) |
                                        S_SQ_ALU_WORD1_OP2_SRC0_ABS(alu->src[0].abs) |
                                        S_SQ_ALU_WORD1_OP2_SRC1_ABS(alu->src[1].abs) |
index bb4f4b77b3343a15086ec24ffc781ed1ee386709..9e65fcdd4fa14b83be1c85eebe1df59becd2decd 100644 (file)
@@ -31,6 +31,7 @@ struct r600_bc_alu_src {
        unsigned                        chan;
        unsigned                        neg;
        unsigned                        abs;
+       unsigned                        rel;
 };
 
 struct r600_bc_alu_dst {
@@ -38,6 +39,7 @@ struct r600_bc_alu_dst {
        unsigned                        chan;
        unsigned                        clamp;
        unsigned                        write;
+       unsigned                        rel;
 };
 
 struct r600_bc_alu {
index 514288bc8cdf6e2aae0cfda33e1c434ebf5e08a4..bda829af2b079b5521b6f734901a096192e08a2f 100644 (file)
@@ -284,16 +284,18 @@ static int tgsi_is_supported(struct r600_shader_ctx *ctx)
        }
 #endif
        for (j = 0; j < i->Instruction.NumSrcRegs; j++) {
-               if (i->Src[j].Register.Indirect ||
-                       i->Src[j].Register.Dimension ||
+               if (i->Src[j].Register.Dimension ||
                        i->Src[j].Register.Absolute) {
-                       R600_ERR("unsupported src (indirect|dimension|absolute)\n");
+                       R600_ERR("unsupported src %d (dimension %d|absolute %d)\n", j,
+                                i->Src[j].Register.Indirect,
+                                i->Src[j].Register.Dimension,
+                                i->Src[j].Register.Absolute);
                        return -EINVAL;
                }
        }
        for (j = 0; j < i->Instruction.NumDstRegs; j++) {
-               if (i->Dst[j].Register.Indirect || i->Dst[j].Register.Dimension) {
-                       R600_ERR("unsupported dst (indirect|dimension)\n");
+               if (i->Dst[j].Register.Dimension) {
+                       R600_ERR("unsupported dst (dimension)\n");
                        return -EINVAL;
                }
        }
@@ -344,6 +346,7 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
        case TGSI_FILE_CONSTANT:
        case TGSI_FILE_TEMPORARY:
        case TGSI_FILE_SAMPLER:
+       case TGSI_FILE_ADDRESS:
                break;
        default:
                R600_ERR("unsupported file %d declaration\n", d->Declaration.File);
@@ -586,6 +589,8 @@ static int tgsi_src(struct r600_shader_ctx *ctx,
                ctx->value[2] = ctx->literals[index * 4 + 2];
                ctx->value[3] = ctx->literals[index * 4 + 3];
        }
+       if (tgsi_src->Register.Indirect)
+               r600_src->rel = V_SQ_REL_RELATIVE;
        r600_src->neg = tgsi_src->Register.Negate;
        r600_src->sel += ctx->file_offset[tgsi_src->Register.File];
        return 0;
@@ -602,6 +607,8 @@ static int tgsi_dst(struct r600_shader_ctx *ctx,
        r600_dst->sel += ctx->file_offset[tgsi_dst->Register.File];
        r600_dst->chan = swizzle;
        r600_dst->write = 1;
+       if (tgsi_dst->Register.Indirect)
+               r600_dst->rel = V_SQ_REL_RELATIVE;
        if (inst->Instruction.Saturate) {
                r600_dst->clamp = 1;
        }
@@ -1769,6 +1776,29 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
        return tgsi_helper_copy(ctx, inst);
 }
 
+static int tgsi_arl(struct r600_shader_ctx *ctx)
+{
+       /* TODO from r600c, ar values don't persist between clauses */
+       struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
+       struct r600_bc_alu alu;
+       int r;
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+
+       alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR;
+
+       r = tgsi_src(ctx, &inst->Src[0], &alu.src[0]);
+       if (r)
+               return r;
+       alu.src[0].chan = tgsi_chan(&inst->Src[0], 0);
+
+       alu.last = 1;
+
+       r = r600_bc_add_alu_type(ctx->bc, &alu, V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU);
+       if (r)
+               return r;
+       return 0;
+}
+
 static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode)
 {
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
@@ -2047,7 +2077,7 @@ static int tgsi_loop_brk_cont(struct r600_shader_ctx *ctx)
 }
 
 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
-       {TGSI_OPCODE_ARL,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
+       {TGSI_OPCODE_ARL,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_arl},
        {TGSI_OPCODE_MOV,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV, tgsi_op2},
        {TGSI_OPCODE_LIT,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_lit},
        {TGSI_OPCODE_RCP,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE, tgsi_trans_srcx_replicate},
index b4ed435e91f77d8dfb782ef0edae17d9561e7168..fa7a31742af440706f024ff2444cda0a60c38ce8 100644 (file)
 #define V_SQ_CF_COND_BOOL                               0x02
 #define V_SQ_CF_COND_NOT_BOOL                           0x03
 
+#define V_SQ_REL_ABSOLUTE 0
+#define V_SQ_REL_RELATIVE 1
 #endif