#include "glheader.h"
#include "context.h"
-#include "hash.h"
#include "imports.h"
#include "macros.h"
-#include "mtypes.h"
-#include "program_instruction.h"
+#include "prog_parameter.h"
+#include "prog_instruction.h"
#include "nvfragparse.h"
-#include "nvprogram.h"
#include "program.h"
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;
GLuint paramIndex;
if (!Parse_ScalarConstant(parseState, values))
RETURN_ERROR;
- paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
+ values, 4, NULL);
srcReg->File = PROGRAM_NAMED_PARAM;
srcReg->Index = paramIndex;
}
(void) Parse_String(parseState, "{");
if (!Parse_VectorConstant(parseState, values))
RETURN_ERROR;
- paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
+ values, 4, NULL);
srcReg->File = PROGRAM_NAMED_PARAM;
srcReg->Index = paramIndex;
}
(void) Parse_String(parseState, "{");
if (!Parse_VectorConstant(parseState, values))
RETURN_ERROR;
- paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
+ values, 4, NULL);
+ 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;
}
GLuint paramIndex;
if (!Parse_ScalarConstant(parseState, values))
RETURN_ERROR;
- paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
+ values, 4, NULL);
srcReg->Index = paramIndex;
srcReg->File = PROGRAM_NAMED_PARAM;
needSuffix = GL_FALSE;
GLubyte token[100];
/* Initialize the instruction */
- _mesa_init_instruction(inst);
+ _mesa_init_instructions(inst, 1);
/* special instructions */
if (Parse_String(parseState, "DEFINE")) {
/* 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_copy_instructions(newInst, instBuffer, parseState.numInst);
/* install the program */
program->Base.Target = target;
program->Base.InputsRead = parseState.inputsRead;
program->Base.OutputsWritten = parseState.outputsWritten;
for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++)
- program->TexturesUsed[u] = parseState.texturesUsed[u];
+ program->Base.TexturesUsed[u] = parseState.texturesUsed[u];
/* save program parameters */
program->Base.Parameters = parseState.parameters;