diff options
Diffstat (limited to 'src/mesa/shader/arbprogparse.c')
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 87 |
1 files changed, 52 insertions, 35 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index b9ff08de5f..480fdf512c 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,10 +35,12 @@ #include "arbprogparse.h" #include "grammar_mesa.h" #include "program.h" +#include "prog_parameter.h" +#include "prog_statevars.h" #include "context.h" #include "macros.h" #include "mtypes.h" -#include "program_instruction.h" +#include "prog_instruction.h" /* For ARB programs, use the NV instruction limits */ @@ -1008,7 +1010,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra switch (mat) { case MATRIX_MODELVIEW: - *matrix = STATE_MODELVIEW; + *matrix = STATE_MODELVIEW_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx > 0) { program_error(ctx, Program->Position, @@ -1018,15 +1020,15 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra break; case MATRIX_PROJECTION: - *matrix = STATE_PROJECTION; + *matrix = STATE_PROJECTION_MATRIX; break; case MATRIX_MVP: - *matrix = STATE_MVP; + *matrix = STATE_MVP_MATRIX; break; case MATRIX_TEXTURE: - *matrix = STATE_TEXTURE; + *matrix = STATE_TEXTURE_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) { program_error(ctx, Program->Position, "Invalid Texture Unit"); @@ -1044,7 +1046,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra break; case MATRIX_PROGRAM: - *matrix = STATE_PROGRAM; + *matrix = STATE_PROGRAM_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) { program_error(ctx, Program->Position, "Invalid Program Matrix"); @@ -1136,7 +1138,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, state_tokens[2] = STATE_ATTENUATION; break; case LIGHT_HALF: - state_tokens[2] = STATE_HALF; + state_tokens[2] = STATE_HALF_VECTOR; break; case LIGHT_SPOT_DIRECTION: state_tokens[2] = STATE_SPOT_DIRECTION; @@ -1185,10 +1187,12 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case STATE_FOG: switch (*(*inst)++) { case FOG_COLOR: - state_tokens[0] = STATE_FOG_COLOR; + state_tokens[0] = STATE_FOG; + state_tokens[1] = STATE_FOG_COLOR; break; case FOG_PARAMS: - state_tokens[0] = STATE_FOG_PARAMS; + state_tokens[0] = STATE_FOG; + state_tokens[1] = STATE_FOG_PARAMS; break; } break; @@ -1272,28 +1276,29 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case STATE_POINT: switch (*(*inst++)) { case POINT_SIZE: - state_tokens[0] = STATE_POINT_SIZE; + state_tokens[0] = STATE_POINT; + state_tokens[1] = STATE_POINT_SIZE; break; case POINT_ATTENUATION: - state_tokens[0] = STATE_POINT_ATTENUATION; + state_tokens[0] = STATE_POINT; + state_tokens[1] = STATE_POINT_ATTENUATION; break; } break; /* XXX: I think this is the correct format for a matrix row */ case STATE_MATRIX_ROWS: - state_tokens[0] = STATE_MATRIX; if (parse_matrix - (ctx, inst, Program, &state_tokens[1], &state_tokens[2], - &state_tokens[5])) + (ctx, inst, Program, &state_tokens[0], &state_tokens[1], + &state_tokens[4])) return 1; - state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */ + state_tokens[2] = parse_integer (inst, Program); /* The first row to grab */ if ((**inst) != 0) { /* Either the last row, 0 */ - state_tokens[4] = parse_integer (inst, Program); - if (state_tokens[4] < state_tokens[3]) { + state_tokens[3] = parse_integer (inst, Program); + if (state_tokens[3] < state_tokens[2]) { program_error(ctx, Program->Position, "Second matrix index less than the first"); /* state_tokens[4] vs. state_tokens[3] */ @@ -1301,7 +1306,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, } } else { - state_tokens[4] = state_tokens[3]; + state_tokens[3] = state_tokens[2]; (*inst)++; } break; @@ -1459,7 +1464,7 @@ parse_attrib_binding(GLcontext * ctx, const GLubyte ** inst, break; case FRAGMENT_ATTRIB_TEXCOORD: { - GLuint texcoord; + GLuint texcoord = 0; err = parse_texcoord_num (ctx, inst, Program, &texcoord); *inputReg = FRAG_ATTRIB_TEX0 + texcoord; } @@ -1520,7 +1525,7 @@ parse_attrib_binding(GLcontext * ctx, const GLubyte ** inst, case VERTEX_ATTRIB_TEXCOORD: { - GLuint unit; + GLuint unit = 0; err = parse_texcoord_num (ctx, inst, Program, &unit); *inputReg = VERT_ATTRIB_TEX0 + unit; } @@ -1717,7 +1722,7 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst, { GLint idx; GLuint err = 0; - GLint state_tokens[6]; + GLint state_tokens[STATE_LENGTH]; GLfloat const_values[4]; switch (*(*inst)++) { @@ -1728,14 +1733,18 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst, /* If we adding STATE_MATRIX that has multiple rows, we need to * unroll it and call _mesa_add_state_reference() for each row */ - if ((state_tokens[0] == STATE_MATRIX) - && (state_tokens[3] != state_tokens[4])) { + if ((state_tokens[0] == STATE_MODELVIEW_MATRIX || + state_tokens[0] == STATE_PROJECTION_MATRIX || + state_tokens[0] == STATE_MVP_MATRIX || + state_tokens[0] == STATE_TEXTURE_MATRIX || + state_tokens[0] == STATE_PROGRAM_MATRIX) + && (state_tokens[2] != state_tokens[3])) { GLint row; - GLint first_row = state_tokens[3]; - GLint last_row = state_tokens[4]; + const GLint first_row = state_tokens[2]; + const GLint last_row = state_tokens[3]; for (row = first_row; row <= last_row; row++) { - state_tokens[3] = state_tokens[4] = row; + state_tokens[2] = state_tokens[3] = row; idx = _mesa_add_state_reference(Program->Base.Parameters, state_tokens); @@ -3355,6 +3364,10 @@ print_state_token (GLint token) fprintf (stderr, "STATE_TEXGEN "); break; + case STATE_FOG: + fprintf (stderr, "STATE_FOG "); + break; + case STATE_FOG_COLOR: fprintf (stderr, "STATE_FOG_COLOR "); break; @@ -3367,6 +3380,10 @@ print_state_token (GLint token) fprintf (stderr, "STATE_CLIPPLANE "); break; + case STATE_POINT: + fprintf (stderr, "STATE_POINT "); + break; + case STATE_POINT_SIZE: fprintf (stderr, "STATE_POINT_SIZE "); break; @@ -4027,16 +4044,16 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, program->Base.NumNativeParameters = ap.Base.NumNativeParameters; program->Base.NumNativeAttributes = ap.Base.NumNativeAttributes; program->Base.NumNativeAddressRegs = ap.Base.NumNativeAddressRegs; - program->NumAluInstructions = ap.NumAluInstructions; - program->NumTexInstructions = ap.NumTexInstructions; - program->NumTexIndirections = ap.NumTexIndirections; - program->NumNativeAluInstructions = ap.NumAluInstructions; - program->NumNativeTexInstructions = ap.NumTexInstructions; - program->NumNativeTexIndirections = ap.NumTexIndirections; + program->Base.NumAluInstructions = ap.Base.NumAluInstructions; + program->Base.NumTexInstructions = ap.Base.NumTexInstructions; + program->Base.NumTexIndirections = ap.Base.NumTexIndirections; + program->Base.NumNativeAluInstructions = ap.Base.NumAluInstructions; + program->Base.NumNativeTexInstructions = ap.Base.NumTexInstructions; + program->Base.NumNativeTexIndirections = ap.Base.NumTexIndirections; program->Base.InputsRead = ap.Base.InputsRead; program->Base.OutputsWritten = ap.Base.OutputsWritten; for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) - program->TexturesUsed[i] = ap.TexturesUsed[i]; + program->Base.TexturesUsed[i] = ap.TexturesUsed[i]; program->FogOption = ap.FogOption; if (program->Base.Instructions) |