be consistent in populating NegateBase field
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 8 Sep 2005 18:35:48 +0000 (18:35 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Thu, 8 Sep 2005 18:35:48 +0000 (18:35 +0000)
src/mesa/shader/arbfragparse.c
src/mesa/shader/arbprogparse.c
src/mesa/shader/nvfragparse.c

index 725ae54..51aa342 100644 (file)
@@ -124,8 +124,7 @@ _mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
         _mesa_printf("_SAT");
 
       if (fp[a].DstReg.File != 0xf) {
-        if (fp[a].DstReg.WriteMask != 0xf ||
-            fp[a].SrcReg[0].NegateBase)
+        if (fp[a].DstReg.WriteMask != 0xf)
            _mesa_printf(" %s[%d].%s%s%s%s ", file_string[fp[a].DstReg.File], fp[a].DstReg.Index,
                         GET_BIT(fp[a].DstReg.WriteMask, 0) ? "x" : "",
                         GET_BIT(fp[a].DstReg.WriteMask, 1) ? "y" : "",
@@ -135,14 +134,19 @@ _mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
            _mesa_printf(" %s[%d] ", file_string[fp[a].DstReg.File], fp[a].DstReg.Index);
       }
 
+      /* Examine each bit of negatebase here as this may be a SWZ instruction
+       */
       if (fp[a].SrcReg[0].File != 0xf) {
         if (fp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
             fp[a].SrcReg[0].NegateBase)
-           _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[fp[a].SrcReg[0].File], fp[a].SrcReg[0].Index,
-                        fp[a].SrcReg[0].NegateBase ? "-" : "",
+           _mesa_printf("%s[%d].%s%c%s%c%s%c%s%c ", file_string[fp[a].SrcReg[0].File], fp[a].SrcReg[0].Index,
+                        GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
                         swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 0)],
+                        GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
                         swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 1)],
+                        GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
                         swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 2)],
+                        GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
                         swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 3)]);
         else
            _mesa_printf("%s[%d] ", file_string[fp[a].SrcReg[0].File], fp[a].SrcReg[0].Index);
index e671c3f..3c62a1f 100644 (file)
@@ -2444,15 +2444,15 @@ parse_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLint len)
 /**
  */
 static GLuint
-parse_extended_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLboolean * Negate)
+parse_extended_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLubyte * Negate)
 {
    GLint a;
    GLubyte swz;
 
-   *Negate = GL_FALSE;
+   *Negate = 0x0;
    for (a = 0; a < 4; a++) {
       if (parse_sign (inst) == -1)
-         *Negate = GL_TRUE;
+         *Negate |= 1<<a;
 
       swz = *(*inst)++;
 
@@ -3036,19 +3036,16 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
             return 1;
 
         {
-           GLubyte Swizzle[4]; /* FP's swizzle mask is a GLubyte, while VP's is GLuint */
-           GLubyte Negate[4];
+           GLubyte Swizzle[4];
+           GLubyte NegateMask;
            GLint File, Index;
 
            if (parse_src_reg(ctx, inst, vc_head, Program, &File, &Index, &rel))
               return 1;
-           parse_extended_swizzle_mask (inst, Swizzle, Negate);
+           parse_extended_swizzle_mask (inst, Swizzle, &NegateMask);
            fp->SrcReg[0].File = File;
            fp->SrcReg[0].Index = Index;
-           fp->SrcReg[0].NegateBase = (Negate[0] << 0 |
-                                       Negate[1] << 1 |
-                                       Negate[2] << 2 |
-                                       Negate[3] << 3);
+           fp->SrcReg[0].NegateBase = NegateMask;
            fp->SrcReg[0].Swizzle = (Swizzle[0] << 0 |
                                     Swizzle[1] << 3 |
                                     Swizzle[2] << 6 |
@@ -3423,8 +3420,8 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
                break;
          }
         {
-           GLubyte Swizzle[4]; /* FP's swizzle mask is a GLubyte, while VP's is GLuint */
-           GLubyte Negate[4];
+           GLubyte Swizzle[4]; 
+           GLubyte NegateMask;
            GLboolean RelAddr;
            GLint File, Index;
 
@@ -3433,13 +3430,10 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
 
            if (parse_src_reg(ctx, inst, vc_head, Program, &File, &Index, &RelAddr))
               return 1;
-           parse_extended_swizzle_mask (inst, Swizzle, Negate);
+           parse_extended_swizzle_mask (inst, Swizzle, &NegateMask);
            vp->SrcReg[0].File = File;
            vp->SrcReg[0].Index = Index;
-           vp->SrcReg[0].Negate = (Negate[0] << 0 |
-                                   Negate[1] << 1 |
-                                   Negate[2] << 2 |
-                                   Negate[3] << 3);
+           vp->SrcReg[0].Negate = NegateMask;
            vp->SrcReg[0].Swizzle = (Swizzle[0] << 0 |
                                     Swizzle[1] << 3 |
                                     Swizzle[2] << 6 |
index c967b81..17dd42b 100644 (file)
@@ -983,16 +983,16 @@ Parse_VectorSrc(struct parse_state *parseState,
       srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
 
       if (Parse_String(parseState, "-"))
-         srcReg->NegateBase = GL_TRUE;
+         srcReg->NegateBase = 0xf;
       else if (Parse_String(parseState, "+"))
-         srcReg->NegateBase = GL_FALSE;
+         srcReg->NegateBase = 0;
       else
-         srcReg->NegateBase = GL_FALSE;
+         srcReg->NegateBase = 0;
    }
    else {
       srcReg->Abs = GL_FALSE;
       srcReg->NegateAbs = GL_FALSE;
-      srcReg->NegateBase = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+      srcReg->NegateBase = (sign < 0.0F) ? 0xf : 0x0;
    }
 
    /* This should be the real src vector/register name */
@@ -1107,16 +1107,16 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
       srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
 
       if (Parse_String(parseState, "-"))
-         srcReg->NegateBase = GL_TRUE;
+         srcReg->NegateBase = 0xf;
       else if (Parse_String(parseState, "+"))
-         srcReg->NegateBase = GL_FALSE;
+         srcReg->NegateBase = 0x0;
       else
-         srcReg->NegateBase = GL_FALSE;
+         srcReg->NegateBase = 0x0;
    }
    else {
       srcReg->Abs = GL_FALSE;
       srcReg->NegateAbs = GL_FALSE;
-      srcReg->NegateBase = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+      srcReg->NegateBase = (sign < 0.0F) ? 0xf : 0x0;
    }
 
    if (!Peek_Token(parseState, token))
@@ -1241,7 +1241,7 @@ Parse_PrintInstruction(struct parse_state *parseState,
    }
 
    inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
-   inst->SrcReg[0].NegateBase = GL_FALSE;
+   inst->SrcReg[0].NegateBase = 0x0;
    inst->SrcReg[0].Abs = GL_FALSE;
    inst->SrcReg[0].NegateAbs = GL_FALSE;