aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arbvertparse.c
diff options
context:
space:
mode:
authorKarl Rasche <[email protected]>2003-11-23 17:54:39 +0000
committerKarl Rasche <[email protected]>2003-11-23 17:54:39 +0000
commit4eebfa14e72c7c1f2572dbbc3bc7e85cf71f5926 (patch)
treeeb4cf0003f6798752906a2a23df6f4e7115ac49b /src/mesa/main/arbvertparse.c
parent15955f1c5e040dc56ad874177577f88f0e86d77b (diff)
- Create a dummy program to keep from segfaulting when parsing
fails - Change to grammar .emit to fix single LOCAL/ENV param usage
Diffstat (limited to 'src/mesa/main/arbvertparse.c')
-rw-r--r--src/mesa/main/arbvertparse.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/mesa/main/arbvertparse.c b/src/mesa/main/arbvertparse.c
index 7a6fc6e7dbb..0bc2a2d04ce 100644
--- a/src/mesa/main/arbvertparse.c
+++ b/src/mesa/main/arbvertparse.c
@@ -178,36 +178,46 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
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;
}