summaryrefslogtreecommitdiff
path: root/src/mesa/shader/arbfragparse.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-11-03 03:30:34 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-11-03 03:30:34 +0000
commit72030e0d91cc505db1eb7d39d5240b2f562cf710 (patch)
tree75f2085ad159184a033423f022e242ebf81862e6 /src/mesa/shader/arbfragparse.c
parentccfe3d4683bb6c97ffacd67267aa002dcb060433 (diff)
Streamline code generation by using a fixed size instruction buffer in
arb_program struct.
Diffstat (limited to 'src/mesa/shader/arbfragparse.c')
-rw-r--r--src/mesa/shader/arbfragparse.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mesa/shader/arbfragparse.c b/src/mesa/shader/arbfragparse.c
index 7b9abec1c9..75c7b35e40 100644
--- a/src/mesa/shader/arbfragparse.c
+++ b/src/mesa/shader/arbfragparse.c
@@ -190,6 +190,7 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
{
GLuint i;
struct arb_program ap;
+ struct fp_instruction *newInstructions;
(void) target;
/* set the program target before parsing */
@@ -203,6 +204,18 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
/* Copy the relevant contents of the arb_program struct into the
* fragment_program struct.
*/
+ /* copy instruction buffer */
+ newInstructions = (struct fp_instruction *)
+ _mesa_malloc(ap.Base.NumInstructions * sizeof(struct fp_instruction));
+ if (!newInstructions) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
+ return;
+ }
+ _mesa_memcpy(newInstructions, ap.FPInstructions,
+ ap.Base.NumInstructions * sizeof(struct fp_instruction));
+ if (program->Instructions)
+ _mesa_free(program->Instructions);
+ program->Instructions = newInstructions;
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
program->Base.NumTemporaries = ap.Base.NumTemporaries;
@@ -212,7 +225,6 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
program->NumAluInstructions = ap.NumAluInstructions;
program->NumTexInstructions = ap.NumTexInstructions;
program->NumTexIndirections = ap.NumTexIndirections;
-
program->InputsRead = ap.InputsRead;
program->OutputsWritten = ap.OutputsWritten;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
@@ -228,6 +240,4 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
#if DEBUG_FP
_mesa_debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
#endif
-
- program->Instructions = ap.FPInstructions;
}