mesa: merge gallium-0.2 into gallium-master-merge
[mesa.git] / src / mesa / shader / arbprogparse.c
index 536404bf978463fe49ae0e2f2c7aa45b4d0d244f..2e0fc3694a4f709377ff9968227553868d2553f3 100644 (file)
@@ -979,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
  */
@@ -988,8 +990,30 @@ 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;
+   }
+
+   *coord = (GLuint) i;
+   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;
    }
 
@@ -997,6 +1021,7 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst,
    return 0;
 }
 
+
 /**
  * \param coord The weight index
  * \return 0 on sucess, 1 on error
@@ -3035,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;
 
@@ -3623,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"))