Module: Mesa
Branch: master
Commit: abe74a9820bc5b512ab24518622368db20187637
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=abe74a9820bc5b512ab24518622368db20187637

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Mon Jun 20 11:42:23 2011 +0200

r600g: reorder LIT instructions to support src == dst

the attached patch should be an improvement over Vadim Girlin's patch
fixing LIT instruction for r600g (commit
2fe39b46e73aea37152777fe11d489e0b1bc3f92).

Instructions used in tgsi_lit have been reordered to always write to a
dst channel after the same channel in src has been read (so if src ==
dst, input values are not overwritten before being used).

Signed-off-by: Dave Airlie <[email protected]>

---

 src/gallium/drivers/r600/r600_shader.c |   71 ++++++++++++++++----------------
 1 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 0268108..86fdfbc 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1303,41 +1303,6 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
        struct r600_bc_alu alu;
        int r;
 
-       /* dst.x, <- 1.0  */
-       memset(&alu, 0, sizeof(struct r600_bc_alu));
-       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
-       alu.src[0].sel  = V_SQ_ALU_SRC_1; /*1.0*/
-       alu.src[0].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 0) & 1;
-       r = r600_bc_add_alu(ctx->bc, &alu);
-       if (r)
-               return r;
-
-       /* dst.y = max(src.x, 0.0) */
-       memset(&alu, 0, sizeof(struct r600_bc_alu));
-       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
-       r600_bc_src(&alu.src[0], &ctx->src[0], 0);
-       alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
-       alu.src[1].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 1) & 1;
-       r = r600_bc_add_alu(ctx->bc, &alu);
-       if (r)
-               return r;
-
-       /* dst.w, <- 1.0  */
-       memset(&alu, 0, sizeof(struct r600_bc_alu));
-       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
-       alu.src[0].sel  = V_SQ_ALU_SRC_1;
-       alu.src[0].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 3) & 1;
-       alu.last = 1;
-       r = r600_bc_add_alu(ctx->bc, &alu);
-       if (r)
-               return r;
-
        if (inst->Dst[0].Register.WriteMask & (1 << 2))
        {
                int chan;
@@ -1425,6 +1390,42 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                                return r;
                }
        }
+
+       /* dst.y = max(src.x, 0.0) */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
+       r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+       alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
+       alu.src[1].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 1) & 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
+       /* dst.x, <- 1.0  */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+       alu.src[0].sel  = V_SQ_ALU_SRC_1; /*1.0*/
+       alu.src[0].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 0) & 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
+       /* dst.w, <- 1.0  */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+       alu.src[0].sel  = V_SQ_ALU_SRC_1;
+       alu.src[0].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 3) & 1;
+       alu.last = 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
        return 0;
 }
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to