retval = _mesa_parse_arb_program(ctx, str, len, &ap);
+ /* copy the relvant contents of the arb_program struct into the
+ * fragment_program struct
+ */
+ program->Base.NumInstructions = ap.Base.NumInstructions;
+ program->Base.NumTemporaries = ap.Base.NumTemporaries;
+ program->Base.NumParameters = ap.Base.NumParameters;
+ program->Base.NumAttributes = ap.Base.NumAttributes;
+ program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
+
+ program->InputsRead = ap.InputsRead;
+ program->OutputsWritten = ap.OutputsWritten;
+ for (retval=0; retval<MAX_TEXTURE_IMAGE_UNITS; retval++)
+ program->TexturesUsed[retval] = ap.TexturesUsed[retval];
+ program->NumAluInstructions = ap.NumAluInstructions;
+ program->NumTexInstructions = ap.NumTexInstructions;
+ program->NumTexIndirections = ap.NumTexIndirections;
+ program->Parameters = ap.Parameters;
+
/* XXX: Parse error. Cleanup things and return */
if (retval)
{
+ program->Instructions = (struct fp_instruction *) _mesa_malloc (
+ sizeof(struct fp_instruction) );
+ program->Instructions[0].Opcode = FP_OPCODE_END;
return;
}
/* XXX: Eh.. we parsed something that wasn't a fragment program. doh! */
if (ap.type != GL_FRAGMENT_PROGRAM_ARB)
{
+ program->Instructions = (struct fp_instruction *) _mesa_malloc (
+ sizeof(struct fp_instruction) );
+ program->Instructions[0].Opcode = FP_OPCODE_END;
+
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Parsed a non-fragment program as a fragment program");
return;
}
(void) debug_fp_inst;
#endif
- /* copy the relvant contents of the arb_program struct into the
- * fragment_program struct
- */
- program->Base.NumInstructions = ap.Base.NumInstructions;
- program->Base.NumTemporaries = ap.Base.NumTemporaries;
- program->Base.NumParameters = ap.Base.NumParameters;
- program->Base.NumAttributes = ap.Base.NumAttributes;
- program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
-
program->Instructions = ap.FPInstructions;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
- for (retval=0; retval<MAX_TEXTURE_IMAGE_UNITS; retval++)
- program->TexturesUsed[retval] = ap.TexturesUsed[retval];
- program->NumAluInstructions = ap.NumAluInstructions;
- program->NumTexInstructions = ap.NumTexInstructions;
- program->NumTexIndirections = ap.NumTexIndirections;
- program->Parameters = ap.Parameters;
}
*
* Cosmetic Stuff
* -----------------------------------------------------
- * - fix compiler warnings
+ * - fix compiler warnings
* - remove any leftover unused grammer.c stuff (dict_ ?)
* - fix grammer.c error handling so its not static
* - #ifdef around stuff pertaining to extentions
* " exponent .or .true .emit '1' .emit 0x00 .emit $;\n"
*
* - XXX: need to recognize "1" as a valid float ?
+ * - XXX: this fails:
+ * "MUL result.color.xyz, R0, program.local[35] ;"
+ * but this works:
+ * "MUL result.color.primary.xyz, R0, program.local[35] ;"
+ * -> see progs/tests/arbvptorus.c
+ *
+ * - changed "progLocalParam\n" changed from:
+ * " \"local\" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum
+ * .and rbracket;\n"
+ * to:
+ * " \"local\" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum
+ * .and rbracket .emit 0x00;\n"
+ * so we can distinguish between the progLocalParam and progLocalParams rules
+ *
+ * - made the same change as above to the progEnvParam rule
*/
typedef GLubyte *production;
case PROGRAM_PARAM_ENV:
state_tokens[1] = STATE_ENV;
state_tokens[2] = parse_integer (inst, Program);
+
/* Check state_tokens[2] against the number of ENV parameters available */
if (((Program->type == GL_FRAGMENT_PROGRAM_ARB) &&
(state_tokens[2] >= ctx->Const.MaxFragmentProgramEnvParams))
case PROGRAM_PARAM_LOCAL:
state_tokens[1] = STATE_LOCAL;
state_tokens[2] = parse_integer (inst, Program);
+
/* Check state_tokens[2] against the number of LOCAL parameters available */
if (((Program->type == GL_FRAGMENT_PROGRAM_ARB) &&
(state_tokens[2] >= ctx->Const.MaxFragmentProgramLocalParams))
switch (*(*inst)++) {
case PARAM_STATE_ELEMENT:
+
if (parse_state_single_item (ctx, inst, Program, state_tokens))
return 1;
break;
case PARAM_PROGRAM_ELEMENT:
+
if (parse_program_single_item (ctx, inst, Program, state_tokens))
return 1;
idx = _mesa_add_state_reference (Program->Parameters, state_tokens);
Program->Base.NumParameters++;
}
}
+ else
+ {
+ (*(*inst)++);
+ }
break;
case PARAM_CONSTANT:
*/
param_var->param_binding_type = PROGRAM_STATE_VAR;
-
var_cache_append (vc_head, param_var);
/* Then fill it with juicy parameter goodness */
/* If the name has never been added to our symbol table, we're hosed */
if (!result) {
_mesa_set_program_error (ctx, Program->Position,
- "Undefined variable");
- _mesa_error (ctx, GL_INVALID_OPERATION, "Undefined variable: %s",
+ "0: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "0: Undefined variable: %s",
dst->name);
return 1;
}
dst = parse_string (inst, vc_head, Program, &result);
Program->Position = parse_position (inst);
- /* If the name has never been added to our symbol table, we're hosed */
+ /* If the name has never been added to our symbol table, we're hosed */
if (!result) {
- _mesa_set_program_error (ctx, Program->Position, "Undefined variable");
- _mesa_error (ctx, GL_INVALID_OPERATION, "Undefined variable: %s",
+ _mesa_set_program_error (ctx, Program->Position, "1: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "1: Undefined variable: %s",
dst->name);
return 1;
}
break;
case REGISTER_PARAM:
-
switch (**inst) {
case PARAM_ARRAY_ELEMENT:
*(*inst)++;
if (!found) {
_mesa_set_program_error (ctx, Program->Position,
- "Undefined variable");
+ "2: Undefined variable");
_mesa_error (ctx, GL_INVALID_OPERATION,
- "Undefined variable: %s", src->name);
+ "2: Undefined variable: %s", src->name);
return 1;
}
break;
default:
+
if (parse_param_use (ctx, inst, vc_head, Program, &src))
return 1;
break;
case REGISTER_ESTABLISHED_NAME:
+
src = parse_string (inst, vc_head, Program, &found);
Program->Position = parse_position (inst);
/* If the name has never been added to our symbol table, we're hosed */
if (!found) {
_mesa_set_program_error (ctx, Program->Position,
- "Undefined variable");
- _mesa_error (ctx, GL_INVALID_OPERATION, "Undefined variable: %s",
+ "3: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "3: Undefined variable: %s",
src->name);
return 1;
}
/* finally, the swizzle */
parse_swizzle_mask (inst, Swizzle, 4);
-
+
return 0;
}
retval = _mesa_parse_arb_program(ctx, str, len, &ap);
- /* XXX: Parse error. Cleanup things and return */
+ /* copy the relvant contents of the arb_program struct into the
+ * fragment_program struct
+ */
+ program->Base.NumInstructions = ap.Base.NumInstructions;
+ program->Base.NumTemporaries = ap.Base.NumTemporaries;
+ program->Base.NumParameters = ap.Base.NumParameters;
+ program->Base.NumAttributes = ap.Base.NumAttributes;
+ program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
+
+ program->IsPositionInvariant = ap.HintPositionInvariant;
+ program->InputsRead = ap.InputsRead;
+ program->OutputsWritten = ap.OutputsWritten;
+ program->Parameters = ap.Parameters;
+
+ /* Parse error. Allocate a dummy program and return */
if (retval)
{
+ program->Instructions = (struct vp_instruction *) _mesa_malloc (
+ sizeof(struct vp_instruction) );
+ program->Instructions[0].Opcode = VP_OPCODE_END;
return;
}
- /* XXX: Eh.. we parsed something that wasn't a vertex program. doh! */
+ /* Eh.. we parsed something that wasn't a vertex program. doh! */
if (ap.type != GL_VERTEX_PROGRAM_ARB)
{
+ program->Instructions = (struct vp_instruction *) _mesa_malloc (
+ sizeof(struct vp_instruction) );
+ program->Instructions[0].Opcode = VP_OPCODE_END;
+
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Parsed a non-vertex program as a vertex program");
return;
}
-
+
+ program->Instructions = ap.VPInstructions;
+
#if DEBUG_VP
debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
#else
(void) debug_vp_inst;
#endif
- /* copy the relvant contents of the arb_program struct into the
- * fragment_program struct
- */
- program->Base.NumInstructions = ap.Base.NumInstructions;
- program->Base.NumTemporaries = ap.Base.NumTemporaries;
- program->Base.NumParameters = ap.Base.NumParameters;
- program->Base.NumAttributes = ap.Base.NumAttributes;
- program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
-
- program->Instructions = ap.VPInstructions;
- program->IsPositionInvariant = ap.HintPositionInvariant;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
- program->Parameters = ap.Parameters;
}