code tweaks, remove old comments
[mesa.git] / src / mesa / shader / nvfragparse.c
index 364c7061ee16ba44ad97e3578d804f91227d4255..5f3a30b74164d84c097caaa4e487ef9486e41a37 100644 (file)
@@ -1009,14 +1009,14 @@ Parse_VectorSrc(struct parse_state *parseState,
       srcReg->Index = idx;
    }
    else if (token[0] == 'f') {
-      /* XXX this might be an identier! */
+      /* XXX this might be an identifier! */
       srcReg->File = PROGRAM_INPUT;
       if (!Parse_FragReg(parseState, &idx))
          RETURN_ERROR;
       srcReg->Index = idx;
    }
    else if (token[0] == 'p') {
-      /* XXX this might be an identier! */
+      /* XXX this might be an identifier! */
       srcReg->File = PROGRAM_LOCAL_PARAM;
       if (!Parse_ProgramParamReg(parseState, &idx))
          RETURN_ERROR;
@@ -1146,6 +1146,20 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
       srcReg->File = PROGRAM_NAMED_PARAM;
       srcReg->Index = paramIndex;      
    }
+   else if (IsLetter(token[0])){
+      /* named param/constant */
+      GLubyte ident[100];
+      GLint paramIndex;
+      if (!Parse_Identifier(parseState, ident))
+         RETURN_ERROR;
+      paramIndex = _mesa_lookup_parameter_index(parseState->parameters,
+                                                -1, (const char *) ident);
+      if (paramIndex < 0) {
+         RETURN_ERROR2("Undefined constant or parameter: ", ident);
+      }
+      srcReg->File = PROGRAM_NAMED_PARAM;
+      srcReg->Index = paramIndex;      
+   }
    else if (IsDigit(token[0])) {
       /* scalar literal */
       GLfloat values[4];
@@ -1259,7 +1273,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
       GLubyte token[100];
 
       /* Initialize the instruction */
-      _mesa_init_instruction(inst);
+      _mesa_init_instructions(inst, 1);
 
       /* special instructions */
       if (Parse_String(parseState, "DEFINE")) {
@@ -1520,14 +1534,13 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
 
       /* copy the compiled instructions */
       assert(parseState.numInst <= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS);
-      newInst = (struct prog_instruction *)
-         MALLOC(parseState.numInst * sizeof(struct prog_instruction));
+      newInst = _mesa_alloc_instructions(parseState.numInst);
       if (!newInst) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
          return;  /* out of memory */
       }
-      MEMCPY(newInst, instBuffer,
-             parseState.numInst * sizeof(struct prog_instruction));
+      _mesa_memcpy(newInst, instBuffer,
+                   parseState.numInst * sizeof(struct prog_instruction));
 
       /* install the program */
       program->Base.Target = target;