#include "glheader.h"
#include "context.h"
+#include "arbvertparse.h"
#include "hash.h"
#include "imports.h"
#include "macros.h"
GLuint retval;
struct arb_program ap;
- retval = _mesa_parse_arb_program(ctx, str, len, &ap);
-
- /* XXX: Parse error. Cleanup things and return */
- if (retval)
- {
- return;
- }
-
- /* XXX: Eh.. we parsed something that wasn't a vertex program. doh! */
- if (ap.type != GL_VERTEX_PROGRAM_ARB)
- {
- return;
- }
-
-#if DEBUG_VP
- debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
-#endif
+ 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.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;
+
+ /* 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;
+ }
+
+ /* 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
+
}