summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arbfragparse.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/arbfragparse.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/arbfragparse.c')
-rw-r--r--src/mesa/main/arbfragparse.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/mesa/main/arbfragparse.c b/src/mesa/main/arbfragparse.c
index ca4b68d8e24..a12fd93cf37 100644
--- a/src/mesa/main/arbfragparse.c
+++ b/src/mesa/main/arbfragparse.c
@@ -189,15 +189,41 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
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;
}
@@ -207,22 +233,5 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
(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;
}