r5xx: Fragprog shader now handles TEX/TXP correctly.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 2 May 2008 17:15:10 +0000 (10:15 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 2 May 2008 19:06:21 +0000 (12:06 -0700)
src/mesa/drivers/dri/r300/r500_fragprog.c

index b751a2a..f94b244 100644 (file)
@@ -110,7 +110,7 @@ static inline GLuint make_strq_swizzle(struct prog_src_register src) {
        GLuint swiz = 0x0;
        GLuint temp = src.Swizzle;
        for (int i = 0; i < 4; i++) {
-               swiz = (temp & 0x3) << i*2;
+               swiz += (temp & 0x3) << i*2;
                temp >>= 3;
        }
        return swiz;
@@ -147,7 +147,7 @@ static GLuint make_src(struct r500_fragment_program *fp, struct prog_src_registe
        GLuint reg;
        switch (src.File) {
                case PROGRAM_TEMPORARY:
-                       reg = src.Index + 1;
+                       reg = (src.Index << 0x1) | 0x1;
                        break;
                case PROGRAM_INPUT:
                        /* Ugly hack needed to work around Mesa;
@@ -170,7 +170,7 @@ static GLuint make_dest(struct r500_fragment_program *fp, struct prog_dst_regist
        GLuint reg;
        switch (dest.File) {
                case PROGRAM_TEMPORARY:
-                       reg = dest.Index + 1;
+                       reg = (dest.Index << 0x1) | 0x1;
                        break;
                case PROGRAM_OUTPUT:
                        /* Eventually we may need to handle multiple
@@ -496,11 +496,30 @@ static GLboolean parse_program(struct r500_fragment_program *fp)
                                break;
                        case OPCODE_TEX:
                                src[0] = make_src(fp, fpi->SrcReg[0]);
+                               fp->inst[counter].inst0 = R500_INST_TYPE_TEX | mask
+                                       | R500_INST_TEX_SEM_WAIT;
+                               fp->inst[counter].inst1 = fpi->TexSrcUnit
+                                       | R500_TEX_INST_LD | R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED;
+                               fp->inst[counter].inst2 = R500_TEX_SRC_ADDR(src[0])
+                                       /* | MAKE_SWIZ_TEX_STRQ(make_strq_swizzle(fpi->SrcReg[0])) */
+                                       | R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G
+                                       | R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A
+                                       | R500_TEX_DST_ADDR(dest)
+                                       | R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G
+                                       | R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;
+                               fp->inst[counter].inst3 = 0x0;
+                               fp->inst[counter].inst4 = 0x0;
+                               fp->inst[counter].inst5 = 0x0;
+                               break;
+                       case OPCODE_TXP:
+                               src[0] = make_src(fp, fpi->SrcReg[0]);
                                fp->inst[counter].inst0 = R500_INST_TYPE_TEX | mask;
                                fp->inst[counter].inst1 = fpi->TexSrcUnit
-                                       | R500_TEX_INST_LD | R500_TEX_SEM_ACQUIRE;
+                                       | R500_TEX_INST_PROJ | R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED;
                                fp->inst[counter].inst2 = R500_TEX_SRC_ADDR(src[0])
-                                       | MAKE_SWIZ_TEX_STRQ(make_strq_swizzle(fpi->SrcReg[0]))
+                                       /* | MAKE_SWIZ_TEX_STRQ(make_strq_swizzle(fpi->SrcReg[0])) */
+                                       | R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G
+                                       | R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A
                                        | R500_TEX_DST_ADDR(dest)
                                        | R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G
                                        | R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;