From: Brian Paul Date: Tue, 30 May 2006 22:17:35 +0000 (+0000) Subject: Define new NEGATE_* tokens for setting the src register's NegateBase field. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8c4242395b1bce0eac2a20243e5289414a9f511;p=mesa.git Define new NEGATE_* tokens for setting the src register's NegateBase field. Before, we were using GL_TRUE/GL_FALSE in a few places. Note: only the SWZ instruction can negate individual components. --- diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index e5a34205fbd..14de7cdd52b 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -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 = 0xf; + srcReg->NegateBase = NEGATE_XYZW; else if (Parse_String(parseState, "+")) - srcReg->NegateBase = 0; + srcReg->NegateBase = NEGATE_NONE; else - srcReg->NegateBase = 0; + srcReg->NegateBase = NEGATE_NONE; } else { srcReg->Abs = GL_FALSE; srcReg->NegateAbs = GL_FALSE; - srcReg->NegateBase = (sign < 0.0F) ? 0xf : 0x0; + srcReg->NegateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; } /* 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 = 0xf; + srcReg->NegateBase = NEGATE_XYZW; else if (Parse_String(parseState, "+")) - srcReg->NegateBase = 0x0; + srcReg->NegateBase = NEGATE_NONE; else - srcReg->NegateBase = 0x0; + srcReg->NegateBase = NEGATE_NONE; } else { srcReg->Abs = GL_FALSE; srcReg->NegateAbs = GL_FALSE; - srcReg->NegateBase = (sign < 0.0F) ? 0xf : 0x0; + srcReg->NegateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; } 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 = 0x0; + inst->SrcReg[0].NegateBase = NEGATE_NONE; inst->SrcReg[0].Abs = GL_FALSE; inst->SrcReg[0].NegateAbs = GL_FALSE; diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index a7e062c61cb..ebfe1fdeefd 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -642,12 +642,12 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *sr RETURN_ERROR; if (token[0] == '-') { (void) Parse_String(parseState, "-"); - srcReg->NegateBase = GL_TRUE; + srcReg->NegateBase = NEGATE_XYZW; if (!Peek_Token(parseState, token)) RETURN_ERROR; } else { - srcReg->NegateBase = GL_FALSE; + srcReg->NegateBase = NEGATE_NONE; } /* Src reg can be R, c[n], c[n +/- offset], or a named vertex attrib */ @@ -735,13 +735,13 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *src if (!Peek_Token(parseState, token)) RETURN_ERROR; if (token[0] == '-') { - srcReg->NegateBase = GL_TRUE; + srcReg->NegateBase = NEGATE_XYZW; (void) Parse_String(parseState, "-"); /* consume '-' */ if (!Peek_Token(parseState, token)) RETURN_ERROR; } else { - srcReg->NegateBase = GL_FALSE; + srcReg->NegateBase = NEGATE_NONE; } /* Src reg can be R, c[n], c[n +/- offset], or a named vertex attrib */ @@ -1070,7 +1070,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction * RETURN_ERROR; srcReg->RelAddr = GL_FALSE; - srcReg->NegateBase = GL_FALSE; + srcReg->NegateBase = NEGATE_NONE; srcReg->Swizzle = SWIZZLE_NOOP; /* Register can be R, c[n], c[n +/- offset], a named vertex attrib, diff --git a/src/mesa/shader/program_instruction.h b/src/mesa/shader/program_instruction.h index 20886d9f021..93bcfc240a9 100644 --- a/src/mesa/shader/program_instruction.h +++ b/src/mesa/shader/program_instruction.h @@ -74,6 +74,19 @@ /*@}*/ +/** + * Per-component negation masks + */ +/*@{*/ +#define NEGATE_X 0x1 +#define NEGATE_Y 0x2 +#define NEGATE_Z 0x4 +#define NEGATE_W 0x8 +#define NEGATE_XYZW 0xf +#define NEGATE_NONE 0x0 +/*@}*/ + + /** * Program instruction opcodes, for both vertex and fragment programs. * \note changes to this opcode list must be reflected in t_vb_arbprogram.c @@ -173,7 +186,8 @@ struct prog_src_register */ /*@{*/ /** - * Per-component negation for the SWZ instruction. + * Per-component negation for the SWZ instruction. For non-SWZ + * instructions the only possible values are NEGATE_XYZW and NEGATE_NONE. * * \since * ARB_vertex_program, ARB_fragment_program @@ -190,8 +204,7 @@ struct prog_src_register GLuint Abs:1; /** - * Take the component-wise negation. The negation occurs \b after the - * (optional) absolute value operation. + * Post-absolute value negation (all components). */ GLuint NegateAbs:1; /*@}*/