summaryrefslogtreecommitdiff
path: root/src/mesa/shader/arbprogparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/arbprogparse.c')
-rw-r--r--src/mesa/shader/arbprogparse.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 4d89d057c7..2e0fc3694a 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -53,23 +53,17 @@ having three separate program parameter arrays.
#include "main/glheader.h"
#include "main/imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
#include "shader/grammar/grammar_mesa.h"
#include "arbprogparse.h"
#include "program.h"
#include "programopt.h"
#include "prog_parameter.h"
#include "prog_statevars.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
#include "prog_instruction.h"
-
-/* For ARB programs, use the NV instruction limits */
-#define MAX_INSTRUCTIONS MAX2(MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS, \
- MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS)
-
-
/**
* This is basically a union of the vertex_program and fragment_program
* structs that we can use to parse the program into
@@ -985,6 +979,8 @@ parse_output_color_num (GLcontext * ctx, const GLubyte ** inst,
/**
+ * Validate the index of a texture coordinate
+ *
* \param coord The texture unit index
* \return 0 on sucess, 1 on error
*/
@@ -994,8 +990,8 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst,
{
GLint i = parse_integer (inst, Program);
- if ((i < 0) || (i >= (int)ctx->Const.MaxTextureUnits)) {
- program_error(ctx, Program->Position, "Invalid texture unit index");
+ if ((i < 0) || (i >= (int)ctx->Const.MaxTextureCoordUnits)) {
+ program_error(ctx, Program->Position, "Invalid texture coordinate index");
return 1;
}
@@ -1003,6 +999,29 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst,
return 0;
}
+
+/**
+ * Validate the index of a texture image unit
+ *
+ * \param coord The texture unit index
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_teximage_num (GLcontext * ctx, const GLubyte ** inst,
+ struct arb_program *Program, GLuint * coord)
+{
+ GLint i = parse_integer (inst, Program);
+
+ if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) {
+ program_error(ctx, Program->Position, "Invalid texture image index");
+ return 1;
+ }
+
+ *coord = (GLuint) i;
+ return 0;
+}
+
+
/**
* \param coord The weight index
* \return 0 on sucess, 1 on error
@@ -3041,7 +3060,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst,
return 1;
/* texImageUnit */
- if (parse_texcoord_num (ctx, inst, Program, &texcoord))
+ if (parse_teximage_num (ctx, inst, Program, &texcoord))
return 1;
fp->TexSrcUnit = texcoord;
@@ -3443,6 +3462,8 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst,
: ctx->Const.VertexProgram.MaxInstructions;
GLint err = 0;
+ ASSERT(MAX_PROGRAM_INSTRUCTIONS >= maxInst);
+
Program->MajorVersion = (GLuint) * inst++;
Program->MinorVersion = (GLuint) * inst++;
@@ -3627,8 +3648,7 @@ enable_parser_extensions(GLcontext *ctx, grammar id)
if (ctx->Extensions.NV_texture_rectangle
&& !enable_ext(ctx, id, "texture_rectangle"))
return GL_FALSE;
- if (ctx->Extensions.ARB_draw_buffers
- && !enable_ext(ctx, id, "draw_buffers"))
+ if (!enable_ext(ctx, id, "draw_buffers"))
return GL_FALSE;
if (ctx->Extensions.MESA_texture_array
&& !enable_ext(ctx, id, "texture_array"))
@@ -3796,7 +3816,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target,
/* Initialize the arb_program struct */
program->Base.String = strz;
- program->Base.Instructions = _mesa_alloc_instructions(MAX_INSTRUCTIONS);
+ program->Base.Instructions = _mesa_alloc_instructions(MAX_PROGRAM_INSTRUCTIONS);
program->Base.NumInstructions =
program->Base.NumTemporaries =
program->Base.NumParameters =
@@ -3841,12 +3861,12 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target,
_mesa_free (parsed);
- /* Reallocate the instruction array from size [MAX_INSTRUCTIONS]
+ /* Reallocate the instruction array from size [MAX_PROGRAM_INSTRUCTIONS]
* to size [ap.Base.NumInstructions].
*/
program->Base.Instructions
= _mesa_realloc_instructions(program->Base.Instructions,
- MAX_INSTRUCTIONS,
+ MAX_PROGRAM_INSTRUCTIONS,
program->Base.NumInstructions);
return !err;
@@ -3899,6 +3919,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
program->FogOption = ap.FogOption;
program->UsesKill = ap.UsesKill;
+ if (program->FogOption)
+ program->Base.InputsRead |= FRAG_BIT_FOGC;
+
if (program->Base.Instructions)
_mesa_free(program->Base.Instructions);
program->Base.Instructions = ap.Base.Instructions;