summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-05-10 04:36:11 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-05-10 04:36:11 +0000
commit3fdb8fbfc5eb82822ac8b5f3e2376249ae7c73ca (patch)
treec585b3cbeae28cfa23473fc9267eac5d9a6d6b33
parentea31ca47200d96b7cc687989ee7f9953819fddbb (diff)
fix scalar literal parsing glitches
-rw-r--r--src/mesa/main/nvfragparse.c18
-rw-r--r--src/mesa/main/nvfragprog.h6
2 files changed, 20 insertions, 4 deletions
diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c
index 5846452b16..f9d66f4a25 100644
--- a/src/mesa/main/nvfragparse.c
+++ b/src/mesa/main/nvfragparse.c
@@ -136,7 +136,7 @@ struct parse_state {
GLuint numInst; /* number of instructions parsed */
GLuint inputsRead; /* bitmask of input registers used */
- GLuint outputsWritten; /* 2 = depth register */
+ GLuint outputsWritten; /* bitmask of 1 << FRAG_OUTPUT_* bits */
GLuint texturesUsed[MAX_TEXTURE_IMAGE_UNITS];
};
@@ -545,6 +545,7 @@ Parse_Identifier(struct parse_state *parseState, GLubyte *ident)
/**
* Parse a floating point constant, or a defined symbol name.
* [+/-]N[.N[eN]]
+ * Output: number[0 .. 3] will get the value.
*/
static GLboolean
Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
@@ -556,6 +557,9 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
if (end && end > (char *) parseState->pos) {
/* got a number */
parseState->pos = (GLubyte *) end;
+ number[1] = *number;
+ number[2] = *number;
+ number[3] = *number;
return GL_TRUE;
}
else {
@@ -925,9 +929,10 @@ Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
/* try to match an output register name */
for (j = 0; OutputRegisters[j]; j++) {
if (_mesa_strcmp((const char *) token, OutputRegisters[j]) == 0) {
+ static GLuint bothColors = (1 << FRAG_OUTPUT_COLR) | (1 << FRAG_OUTPUT_COLH);
*outputRegNum = FP_OUTPUT_REG_START + j;
parseState->outputsWritten |= (1 << j);
- if ((parseState->outputsWritten & 0x3) == 0x3) {
+ if ((parseState->outputsWritten & bothColors) == bothColors) {
RETURN_ERROR1("Illegal to write to both o[COLR] and o[COLH]");
}
break;
@@ -1110,12 +1115,19 @@ Parse_VectorSrc(struct parse_state *parseState,
srcReg->IsParameter = GL_TRUE;
srcReg->Register = paramIndex;
}
- else if (IsDigit(token[0]) || token[0] == '-' || token[0] == '+'){
+ else if (IsDigit(token[0]) || token[0] == '-' || token[0] == '+' || token[0] == '.'){
/* literal scalar constant */
GLfloat values[4];
+ GLuint paramIndex;
if (!Parse_ScalarConstant(parseState, values))
RETURN_ERROR;
+#if 0
srcReg->Register = 0; /* XXX fix */
+#else
+ paramIndex = add_unnamed_constant(parseState, values);
+ srcReg->IsParameter = GL_TRUE;
+ srcReg->Register = paramIndex;
+#endif
}
else if (token[0] == '{'){
/* literal vector constant */
diff --git a/src/mesa/main/nvfragprog.h b/src/mesa/main/nvfragprog.h
index 2e9d82975c..5505582eb1 100644
--- a/src/mesa/main/nvfragprog.h
+++ b/src/mesa/main/nvfragprog.h
@@ -1,4 +1,4 @@
-/* $Id: nvfragprog.h,v 1.6 2003/04/05 00:38:09 brianp Exp $ */
+/* $Id: nvfragprog.h,v 1.7 2003/05/10 04:36:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,6 +50,10 @@
#define FRAG_ATTRIB_TEX6 10
#define FRAG_ATTRIB_TEX7 11
+#define FRAG_OUTPUT_COLR 0
+#define FRAG_OUTPUT_COLH 1
+#define FRAG_OUTPUT_DEPR 2
+
/* Location of register sets within the whole register file */
#define FP_INPUT_REG_START 0