summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/arbfragparse.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-10-29 15:52:31 +0000
committerBrian Paul <[email protected]>2005-10-29 15:52:31 +0000
commit4570364097eb27266eefaa4b2ffdd5dd22325805 (patch)
tree9443cbfcab28af62f78929beddcb9a22f290f8ee /src/mesa/shader/arbfragparse.c
parentaba878d8c2d0d75b0762f7d8ae191fa438fc7d6a (diff)
If parsing a program fails, don't change the vertex/fragment program object.
Specifically, don't attach a dummy program. This change also fixes an occasional segfault. Some code clean-ups. Use GLboolean instead of GLuint to return pass/fail.
Diffstat (limited to 'src/mesa/shader/arbfragparse.c')
-rw-r--r--src/mesa/shader/arbfragparse.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/mesa/shader/arbfragparse.c b/src/mesa/shader/arbfragparse.c
index 51aa3426ac4..3ef6f8b137a 100644
--- a/src/mesa/shader/arbfragparse.c
+++ b/src/mesa/shader/arbfragparse.c
@@ -182,31 +182,26 @@ _mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
}
}
+
void
_mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
const GLubyte * str, GLsizei len,
struct fragment_program *program)
{
- GLuint a, retval;
+ GLuint i;
struct arb_program ap;
(void) target;
/* set the program target before parsing */
ap.Base.Target = GL_FRAGMENT_PROGRAM_ARB;
- retval = _mesa_parse_arb_program(ctx, str, len, &ap);
-
- /* 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;
+ if (!_mesa_parse_arb_program(ctx, str, len, &ap)) {
+ /* Error in the program. Just return. */
return;
}
- /* copy the relvant contents of the arb_program struct into the
- * fragment_program struct
+ /* Copy the relevant contents of the arb_program struct into the
+ * fragment_program struct.
*/
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
@@ -217,8 +212,8 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
program->InputsRead = ap.InputsRead;
program->OutputsWritten = ap.OutputsWritten;
- for (a=0; a<MAX_TEXTURE_IMAGE_UNITS; a++)
- program->TexturesUsed[a] = ap.TexturesUsed[a];
+ for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
+ program->TexturesUsed[i] = ap.TexturesUsed[i];
program->NumAluInstructions = ap.NumAluInstructions;
program->NumTexInstructions = ap.NumTexInstructions;
program->NumTexIndirections = ap.NumTexIndirections;