glsl: lower mediump partial derivatives
[mesa.git] / src / mesa / main / texparam.c
index a8147786fa82be869f7fe1e319ddc7279415a06d..e0dbdbbb1a23e84912623b350d87af713c330316 100644 (file)
@@ -45,6 +45,7 @@
 #include "main/teximage.h"
 #include "main/texstate.h"
 #include "program/prog_instruction.h"
+#include "util/u_math.h"
 
 
 /**
@@ -114,38 +115,27 @@ validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap)
 }
 
 
-/**
- * Get current texture object for given target.
- * Return NULL if any error (and record the error).
- * Note that this is different from _mesa_get_current_tex_object() in that
- * proxy targets are not accepted.
- * Only the glGetTexLevelParameter() functions accept proxy targets.
- */
-static struct gl_texture_object *
-get_texobj_by_target(struct gl_context *ctx, GLenum target, GLboolean get)
+static bool
+is_texparameteri_target_valid(GLenum target)
 {
-   struct gl_texture_unit *texUnit;
-   int targetIndex;
-
-   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "gl%sTexParameter(current unit)", get ? "Get" : "");
-      return NULL;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
-   targetIndex = _mesa_tex_target_to_index(ctx, target);
-   if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) {
-      _mesa_error(ctx, GL_INVALID_ENUM,
-                  "gl%sTexParameter(target)", get ? "Get" : "");
-      return NULL;
+   switch (target) {
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_1D_ARRAY:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_2D_ARRAY:
+   case GL_TEXTURE_2D_MULTISAMPLE:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+   case GL_TEXTURE_3D:
+   case GL_TEXTURE_CUBE_MAP:
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+   case GL_TEXTURE_RECTANGLE:
+      return true;
+   default:
+      return false;
    }
-   assert(targetIndex < NUM_TEXTURE_TARGETS);
-
-   return texUnit->CurrentTex[targetIndex];
 }
 
+
 /**
  * Get current texture object for given name.
  * Return NULL if any error (and record the error).
@@ -153,37 +143,20 @@ get_texobj_by_target(struct gl_context *ctx, GLenum target, GLboolean get)
  * Only the glGetTexLevelParameter() functions accept proxy targets.
  */
 static struct gl_texture_object *
-get_texobj_by_name(struct gl_context *ctx, GLuint texture, GLboolean get)
+get_texobj_by_name(struct gl_context *ctx, GLuint texture, const char *name)
 {
    struct gl_texture_object *texObj;
 
-   texObj = _mesa_lookup_texture(ctx, texture);
-   if (!texObj) {
-      /*
-       * User passed a non-generated name.
-       * Throw the error in the caller.
-       */
+   texObj = _mesa_lookup_texture_err(ctx, texture, name);
+   if (!texObj)
       return NULL;
-   }
 
-   switch (texObj->Target) {
-   case GL_TEXTURE_1D:
-   case GL_TEXTURE_1D_ARRAY:
-   case GL_TEXTURE_2D:
-   case GL_TEXTURE_2D_ARRAY:
-   case GL_TEXTURE_2D_MULTISAMPLE:
-   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-   case GL_TEXTURE_3D:
-   case GL_TEXTURE_CUBE_MAP:
-   case GL_TEXTURE_CUBE_MAP_ARRAY:
-   case GL_TEXTURE_RECTANGLE:
-      return texObj;
-   default:
-      _mesa_error(ctx, GL_INVALID_ENUM,
-                  "gl%sTextureParameter(target)", get ? "Get" : "");
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(target)", name);
       return NULL;
    }
 
+   return texObj;
 }
 
 
@@ -214,7 +187,7 @@ comp_to_swizzle(GLenum comp)
 
 
 static void
-set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
+set_swizzle_component(GLushort *swizzle, GLuint comp, GLuint swz)
 {
    assert(comp < 4);
    assert(swz <= SWIZZLE_NIL);
@@ -233,21 +206,21 @@ set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
 static inline void
 flush(struct gl_context *ctx)
 {
-   FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+   FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
 }
 
 
 /**
  * This is called just prior to changing any texture object state which
  * could affect texture completeness (texture base level, max level).
- * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
+ * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE_OBJECT
  * state flag and then mark the texture object as 'incomplete' so that any
  * per-texture derived state gets recomputed.
  */
 static inline void
 incomplete(struct gl_context *ctx, struct gl_texture_object *texObj)
 {
-   FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+   FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
    _mesa_dirty_texobj(ctx, texObj);
 }
 
@@ -277,6 +250,19 @@ set_tex_parameteri(struct gl_context *ctx,
 {
    const char *suffix = dsa ? "ture" : "";
 
+   if (texObj->HandleAllocated) {
+      /* The ARB_bindless_texture spec says:
+       *
+       * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+       * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+       * functions defined in terms of these, if the texture object to be
+       * modified is referenced by one or more texture or image handles."
+       */
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glTex%sParameter(immutable texture)", suffix);
+      return GL_FALSE;
+   }
+
    switch (pname) {
    case GL_TEXTURE_MIN_FILTER:
       if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
@@ -369,8 +355,26 @@ set_tex_parameteri(struct gl_context *ctx,
       if (texObj->BaseLevel == params[0])
          return GL_FALSE;
 
+      /* Section 8.10 (Texture Parameters) of the OpenGL 4.5 Core Profile spec
+       * says:
+       *
+       *    An INVALID_OPERATION error is generated if the effective target is
+       *    TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, or
+       *    TEXTURE_RECTANGLE, and pname TEXTURE_BASE_LEVEL is set to a value
+       *    other than zero.
+       *
+       * Note that section 3.8.8 (Texture Parameters) of the OpenGL 3.3 Core
+       * Profile spec said:
+       *
+       *    The error INVALID_VALUE is generated if TEXTURE_BASE_LEVEL is set
+       *    to any value other than zero.
+       *
+       * We take the 4.5 language as a correction to 3.3, and we implement
+       * that on all GL versions.
+       */
       if ((texObj->Target == GL_TEXTURE_2D_MULTISAMPLE ||
-           texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) && params[0] != 0)
+           texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY ||
+           texObj->Target == GL_TEXTURE_RECTANGLE) && params[0] != 0)
          goto invalid_operation;
 
       if (params[0] < 0) {
@@ -378,12 +382,6 @@ set_tex_parameteri(struct gl_context *ctx,
                      "glTex%sParameter(param=%d)", suffix, params[0]);
          return GL_FALSE;
       }
-      if (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glTex%sParameter(target=%s, param=%d)", suffix,
-                     _mesa_enum_to_string(texObj->Target), params[0]);
-         return GL_FALSE;
-      }
       incomplete(ctx, texObj);
 
       /** See note about ARB_texture_storage below */
@@ -603,6 +601,14 @@ set_tex_parameteri(struct gl_context *ctx,
       }
       goto invalid_pname;
 
+   case GL_TEXTURE_TILING_EXT:
+      if (ctx->Extensions.EXT_memory_object) {
+         texObj->TextureTiling = params[0];
+
+         return GL_TRUE;
+      }
+      goto invalid_pname;
+
    default:
       goto invalid_pname;
    }
@@ -640,6 +646,19 @@ set_tex_parameterf(struct gl_context *ctx,
 {
    const char *suffix = dsa ? "ture" : "";
 
+   if (texObj->HandleAllocated) {
+      /* The ARB_bindless_texture spec says:
+       *
+       * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+       * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+       * functions defined in terms of these, if the texture object to be
+       * modified is referenced by one or more texture or image handles."
+       */
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glTex%sParameter(immutable texture)", suffix);
+      return GL_FALSE;
+   }
+
    switch (pname) {
    case GL_TEXTURE_MIN_LOD:
       if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@@ -716,8 +735,16 @@ set_tex_parameterf(struct gl_context *ctx,
       break;
 
    case GL_TEXTURE_BORDER_COLOR:
+      /* Border color exists in desktop OpenGL since 1.0 for GL_CLAMP.  In
+       * OpenGL ES 2.0+, it only exists in when GL_OES_texture_border_clamp is
+       * enabled.  It is never available in OpenGL ES 1.x.
+       *
+       * FIXME: Every driver that supports GLES2 has this extension.  Elide
+       * the check?
+       */
       if (ctx->API == API_OPENGLES ||
-          !ctx->Extensions.ARB_texture_border_clamp)
+          (ctx->API == API_OPENGLES2 &&
+           !ctx->Extensions.ARB_texture_border_clamp))
          goto invalid_pname;
 
       if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
@@ -738,6 +765,13 @@ set_tex_parameterf(struct gl_context *ctx,
       }
       return GL_TRUE;
 
+   case GL_TEXTURE_TILING_EXT:
+      if (ctx->Extensions.EXT_memory_object) {
+         texObj->TextureTiling = params[0];
+         return GL_TRUE;
+      }
+      goto invalid_pname;
+
    default:
       goto invalid_pname;
    }
@@ -807,7 +841,7 @@ _mesa_texture_parameterf(struct gl_context *ctx,
    }
 
    if (ctx->Driver.TexParameter && need_update) {
-      ctx->Driver.TexParameter(ctx, texObj, pname, &param);
+      ctx->Driver.TexParameter(ctx, texObj, pname);
    }
 }
 
@@ -874,7 +908,7 @@ _mesa_texture_parameterfv(struct gl_context *ctx,
    }
 
    if (ctx->Driver.TexParameter && need_update) {
-      ctx->Driver.TexParameter(ctx, texObj, pname, params);
+      ctx->Driver.TexParameter(ctx, texObj, pname);
    }
 }
 
@@ -891,7 +925,6 @@ _mesa_texture_parameteri(struct gl_context *ctx,
    case GL_TEXTURE_PRIORITY:
    case GL_TEXTURE_MAX_ANISOTROPY_EXT:
    case GL_TEXTURE_LOD_BIAS:
-   case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
       {
          GLfloat fparam[4];
          fparam[0] = (GLfloat) param;
@@ -919,8 +952,7 @@ _mesa_texture_parameteri(struct gl_context *ctx,
    }
 
    if (ctx->Driver.TexParameter && need_update) {
-      GLfloat fparam = (GLfloat) param;
-      ctx->Driver.TexParameter(ctx, texObj, pname, &fparam);
+      ctx->Driver.TexParameter(ctx, texObj, pname);
    }
 }
 
@@ -949,7 +981,6 @@ _mesa_texture_parameteriv(struct gl_context *ctx,
    case GL_TEXTURE_PRIORITY:
    case GL_TEXTURE_MAX_ANISOTROPY_EXT:
    case GL_TEXTURE_LOD_BIAS:
-   case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
       {
          /* convert int param to float */
          GLfloat fparams[4];
@@ -964,15 +995,7 @@ _mesa_texture_parameteriv(struct gl_context *ctx,
    }
 
    if (ctx->Driver.TexParameter && need_update) {
-      GLfloat fparams[4];
-      fparams[0] = INT_TO_FLOAT(params[0]);
-      if (pname == GL_TEXTURE_BORDER_COLOR ||
-          pname == GL_TEXTURE_CROP_RECT_OES) {
-         fparams[1] = INT_TO_FLOAT(params[1]);
-         fparams[2] = INT_TO_FLOAT(params[2]);
-         fparams[3] = INT_TO_FLOAT(params[3]);
-      }
-      ctx->Driver.TexParameter(ctx, texObj, pname, fparams);
+      ctx->Driver.TexParameter(ctx, texObj, pname);
    }
 }
 
@@ -983,7 +1006,17 @@ _mesa_texture_parameterIiv(struct gl_context *ctx,
 {
    switch (pname) {
    case GL_TEXTURE_BORDER_COLOR:
-      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      if (texObj->HandleAllocated) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glTextureParameterIiv(immutable texture)");
+         return;
+      }
+
+      if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIiv(texture)");
+         return;
+      }
+      FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
       /* set the integer-valued border color */
       COPY_4V(texObj->Sampler.BorderColor.i, params);
       break;
@@ -1001,7 +1034,17 @@ _mesa_texture_parameterIuiv(struct gl_context *ctx,
 {
    switch (pname) {
    case GL_TEXTURE_BORDER_COLOR:
-      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      if (texObj->HandleAllocated) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glTextureParameterIuiv(immutable texture)");
+         return;
+      }
+
+      if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIuiv(texture)");
+         return;
+      }
+      FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
       /* set the unsigned integer-valued border color */
       COPY_4V(texObj->Sampler.BorderColor.ui, params);
       break;
@@ -1019,7 +1062,10 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameterf");
    if (!texObj)
       return;
 
@@ -1032,7 +1078,10 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameterfv");
    if (!texObj)
       return;
 
@@ -1045,7 +1094,10 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameteri");
    if (!texObj)
       return;
 
@@ -1058,7 +1110,10 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameteriv");
    if (!texObj)
       return;
 
@@ -1076,7 +1131,10 @@ _mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameterIiv");
    if (!texObj)
       return;
 
@@ -1094,13 +1152,34 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   ctx->Texture.CurrentUnit,
+                                                   false,
+                                                   "glTexParameterIuiv");
    if (!texObj)
       return;
 
    _mesa_texture_parameterIuiv(ctx, texObj, pname, params, false);
 }
 
+void GLAPIENTRY
+_mesa_TextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname, const GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterfvEXT");
+      return;
+   }
+
+   _mesa_texture_parameterfv(ctx, texObj, pname, params, true);
+}
 
 void GLAPIENTRY
 _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
@@ -1108,10 +1187,28 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterfv(texture)");
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameterfv");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterfv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_MultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glMultiTexParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMultiTexParameterifvEXT(target)");
       return;
    }
 
@@ -1119,15 +1216,18 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
 }
 
 void GLAPIENTRY
-_mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
+_mesa_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterf(texture)");
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameterfEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterfEXT");
       return;
    }
 
@@ -1135,15 +1235,53 @@ _mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
 }
 
 void GLAPIENTRY
-_mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
+_mesa_MultiTexParameterfEXT(GLenum texunit, GLenum target, GLenum pname,
+                            GLfloat param)
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteri(texture)");
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glMultiTexParameterfEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMultiTexParameterfEXT");
+      return;
+   }
+
+   _mesa_texture_parameterf(ctx, texObj, pname, param, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameterf");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterf(ctx, texObj, pname, param, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameteriEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteriEXT(target)");
       return;
    }
 
@@ -1151,22 +1289,96 @@ _mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
 }
 
 void GLAPIENTRY
-_mesa_TextureParameteriv(GLuint texture, GLenum pname,
+_mesa_MultiTexParameteriEXT(GLenum texunit, GLenum target, GLenum pname,
+                            GLint param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glMultiTexParameteriEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMultiTexParameteriEXT(target)");
+      return;
+   }
+
+   _mesa_texture_parameteri(ctx, texObj, pname, param, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameteri");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameteri(ctx, texObj, pname, param, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameterivEXT(GLuint texture, GLenum target, GLenum pname,
                          const GLint *params)
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteriv(texture)");
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterivEXT(target)");
       return;
    }
 
    _mesa_texture_parameteriv(ctx, texObj, pname, params, true);
 }
 
+void GLAPIENTRY
+_mesa_MultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname,
+                             const GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glMultiTexParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMultiTexParameterivEXT(target)");
+      return;
+   }
+
+   _mesa_texture_parameteriv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameteriv(GLuint texture, GLenum pname,
+                         const GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameteriv");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameteriv(ctx, texObj, pname, params, true);
+}
+
 
 void GLAPIENTRY
 _mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
@@ -1174,13 +1386,41 @@ _mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureParameterIiv(texture)");
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameterIiv");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname,
+                             const GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameterIivEXT");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_MultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname,
+                              const GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glMultiTexParameterIivEXT");
+   if (!texObj)
       return;
-   }
 
    _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
 }
@@ -1191,13 +1431,41 @@ _mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureParameterIuiv(texture)");
+   texObj = get_texobj_by_name(ctx, texture, "glTextureParameterIuiv");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
+                              const GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glTextureParameterIuivEXT");
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_MultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname,
+                               const GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glMultiTexParameterIuivEXT");
+   if (!texObj)
       return;
-   }
 
    _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
 }
@@ -1241,8 +1509,8 @@ _mesa_legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target
        * From the OpenGL 3.1 spec:
        * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
        */
-      return (ctx->API == API_OPENGL_CORE && ctx->Version >= 31) ||
-         _mesa_has_OES_texture_buffer(ctx);
+      return (_mesa_is_desktop_gl(ctx) && ctx->Version >= 31) ||
+             _mesa_has_OES_texture_buffer(ctx);
    case GL_TEXTURE_CUBE_MAP_ARRAY:
       return _mesa_has_texture_cube_map_array(ctx);
    }
@@ -1380,6 +1648,11 @@ get_tex_level_parameter_image(struct gl_context *ctx,
                               _mesa_get_format_bits(texFormat,
                                                     GL_TEXTURE_GREEN_SIZE));
             }
+            if (*params == 0 && pname == GL_TEXTURE_INTENSITY_SIZE) {
+               /* Gallium may store intensity as LA */
+               *params = _mesa_get_format_bits(texFormat,
+                                               GL_TEXTURE_ALPHA_SIZE);
+            }
          }
          else {
             *params = 0;
@@ -1402,16 +1675,15 @@ get_tex_level_parameter_image(struct gl_context *ctx,
 
       /* GL_ARB_texture_compression */
       case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
-        if (_mesa_is_format_compressed(texFormat) &&
+         if (_mesa_is_format_compressed(texFormat) &&
              !_mesa_is_proxy_texture(target)) {
             *params = _mesa_format_image_size(texFormat, img->Width,
                                               img->Height, img->Depth);
-    }
-    else {
-       _mesa_error(ctx, GL_INVALID_OPERATION,
-                   "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
-                   _mesa_enum_to_string(pname));
-    }
+         } else {
+            _mesa_error(ctx, GL_INVALID_OPERATION,
+                        "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+                        _mesa_enum_to_string(pname));
+         }
          break;
       case GL_TEXTURE_COMPRESSED:
          *params = (GLint) _mesa_is_format_compressed(texFormat);
@@ -1746,6 +2018,52 @@ _mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
    *params = (GLfloat) iparam;
 }
 
+void GLAPIENTRY
+_mesa_GetTextureLevelParameterfvEXT(GLuint texture, GLenum target, GLint level,
+                                    GLenum pname, GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GLint iparam;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureLevelParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+      return;
+
+   get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+                             pname, &iparam, true);
+
+   *params = (GLfloat) iparam;
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexLevelParameterfvEXT(GLenum texunit, GLenum target, GLint level,
+                                     GLenum pname, GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GLint iparam;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glGetMultiTexLevelParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+      return;
+
+   get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+                             pname, &iparam, true);
+
+   *params = (GLfloat) iparam;
+}
+
 void GLAPIENTRY
 _mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
                                  GLenum pname, GLint *params)
@@ -1765,6 +2083,47 @@ _mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
                              pname, params, true);
 }
 
+void GLAPIENTRY
+_mesa_GetTextureLevelParameterivEXT(GLuint texture, GLenum target, GLint level,
+                                    GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureLevelParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+      return;
+
+   get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+                             pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexLevelParameterivEXT(GLenum texunit, GLenum target, GLint level,
+                                     GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glGetMultiTexLevelParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+      return;
+
+   get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+                             pname, params, true);
+}
+
+
 /**
  * This isn't exposed to the rest of the driver because it is a part of the
  * OpenGL API that is rarely used.
@@ -1796,8 +2155,6 @@ get_tex_parameterfv(struct gl_context *ctx,
              !ctx->Extensions.ARB_texture_border_clamp)
             goto invalid_pname;
 
-         if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
-            _mesa_update_state_locked(ctx);
          if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
             params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
             params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
@@ -1934,33 +2291,32 @@ get_tex_parameterfv(struct gl_context *ctx,
          break;
 
       case GL_TEXTURE_IMMUTABLE_LEVELS:
-         if (_mesa_is_gles3(ctx) ||
-             (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_view))
+         if (_mesa_is_gles3(ctx) || _mesa_has_texture_view(ctx))
             *params = (GLfloat) obj->ImmutableLevels;
          else
             goto invalid_pname;
          break;
 
       case GL_TEXTURE_VIEW_MIN_LEVEL:
-         if (!ctx->Extensions.ARB_texture_view)
+         if (!_mesa_has_texture_view(ctx))
             goto invalid_pname;
          *params = (GLfloat) obj->MinLevel;
          break;
 
       case GL_TEXTURE_VIEW_NUM_LEVELS:
-         if (!ctx->Extensions.ARB_texture_view)
+         if (!_mesa_has_texture_view(ctx))
             goto invalid_pname;
          *params = (GLfloat) obj->NumLevels;
          break;
 
       case GL_TEXTURE_VIEW_MIN_LAYER:
-         if (!ctx->Extensions.ARB_texture_view)
+         if (!_mesa_has_texture_view(ctx))
             goto invalid_pname;
          *params = (GLfloat) obj->MinLayer;
          break;
 
       case GL_TEXTURE_VIEW_NUM_LAYERS:
-         if (!ctx->Extensions.ARB_texture_view)
+         if (!_mesa_has_texture_view(ctx))
             goto invalid_pname;
          *params = (GLfloat) obj->NumLayers;
          break;
@@ -1989,6 +2345,12 @@ get_tex_parameterfv(struct gl_context *ctx,
          *params = ENUM_TO_FLOAT(obj->Target);
          break;
 
+      case GL_TEXTURE_TILING_EXT:
+         if (!ctx->Extensions.EXT_memory_object)
+            goto invalid_pname;
+         *params = ENUM_TO_FLOAT(obj->TextureTiling);
+         break;
+
       default:
          goto invalid_pname;
    }
@@ -2060,16 +2422,30 @@ get_tex_parameteriv(struct gl_context *ctx,
             goto invalid_pname;
          /* GL spec 'Data Conversions' section specifies that floating-point
           * value in integer Get function is rounded to nearest integer
+          *
+          * Section 2.2.2 (Data Conversions For State Query Commands) of the
+          * OpenGL 4.5 spec says:
+          *
+          *   Following these steps, if a value is so large in magnitude that
+          *   it cannot be represented by the returned data type, then the
+          *   nearest value representable using that type is returned.
           */
-         *params = IROUND(obj->Sampler.MinLod);
+         *params = CLAMP(lroundf(obj->Sampler.MinLod), INT_MIN, INT_MAX);
          break;
       case GL_TEXTURE_MAX_LOD:
          if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
             goto invalid_pname;
          /* GL spec 'Data Conversions' section specifies that floating-point
           * value in integer Get function is rounded to nearest integer
+          *
+          * Section 2.2.2 (Data Conversions For State Query Commands) of the
+          * OpenGL 4.5 spec says:
+          *
+          *   Following these steps, if a value is so large in magnitude that
+          *   it cannot be represented by the returned data type, then the
+          *   nearest value representable using that type is returned.
           */
-         *params = IROUND(obj->Sampler.MaxLod);
+         *params = CLAMP(lroundf(obj->Sampler.MaxLod), INT_MIN, INT_MAX);
          break;
       case GL_TEXTURE_BASE_LEVEL:
          if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@@ -2085,8 +2461,15 @@ get_tex_parameteriv(struct gl_context *ctx,
             goto invalid_pname;
          /* GL spec 'Data Conversions' section specifies that floating-point
           * value in integer Get function is rounded to nearest integer
+          *
+          * Section 2.2.2 (Data Conversions For State Query Commands) of the
+          * OpenGL 4.5 spec says:
+          *
+          *   Following these steps, if a value is so large in magnitude that
+          *   it cannot be represented by the returned data type, then the
+          *   nearest value representable using that type is returned.
           */
-         *params = IROUND(obj->Sampler.MaxAnisotropy);
+         *params = CLAMP(lroundf(obj->Sampler.MaxAnisotropy), INT_MIN, INT_MAX);
          break;
       case GL_GENERATE_MIPMAP_SGIS:
          if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
@@ -2123,8 +2506,15 @@ get_tex_parameteriv(struct gl_context *ctx,
 
          /* GL spec 'Data Conversions' section specifies that floating-point
           * value in integer Get function is rounded to nearest integer
+          *
+          * Section 2.2.2 (Data Conversions For State Query Commands) of the
+          * OpenGL 4.5 spec says:
+          *
+          *   Following these steps, if a value is so large in magnitude that
+          *   it cannot be represented by the returned data type, then the
+          *   nearest value representable using that type is returned.
           */
-         *params = IROUND(obj->Sampler.LodBias);
+         *params = CLAMP(lroundf(obj->Sampler.LodBias), INT_MIN, INT_MAX);
          break;
       case GL_TEXTURE_CROP_RECT_OES:
          if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
@@ -2221,6 +2611,12 @@ get_tex_parameteriv(struct gl_context *ctx,
          *params = (GLint) obj->Target;
          break;
 
+      case GL_TEXTURE_TILING_EXT:
+         if (!ctx->Extensions.EXT_memory_object)
+            goto invalid_pname;
+         *params = (GLint) obj->TextureTiling;
+         break;
+
       default:
          goto invalid_pname;
    }
@@ -2249,37 +2645,16 @@ get_tex_parameterIiv(struct gl_context *ctx,
    }
 }
 
-static void
-get_tex_parameterIuiv(struct gl_context *ctx,
-                      struct gl_texture_object *obj,
-                      GLenum pname, GLuint *params, bool dsa)
-{
-   switch (pname) {
-   case GL_TEXTURE_BORDER_COLOR:
-      COPY_4V(params, obj->Sampler.BorderColor.i);
-      break;
-   default:
-      {
-         GLint ip[4];
-         get_tex_parameteriv(ctx, obj, pname, ip, dsa);
-         params[0] = ip[0];
-         if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
-             pname == GL_TEXTURE_CROP_RECT_OES) {
-            params[1] = ip[1];
-            params[2] = ip[2];
-            params[3] = ip[3];
-         }
-      }
-   }
-}
-
 void GLAPIENTRY
 _mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
 {
    struct gl_texture_object *obj;
    GET_CURRENT_CONTEXT(ctx);
 
-   obj = get_texobj_by_target(ctx, target, GL_TRUE);
+   obj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                ctx->Texture.CurrentUnit,
+                                                false,
+                                                "glGetTexParameterfv");
    if (!obj)
       return;
 
@@ -2292,7 +2667,10 @@ _mesa_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
    struct gl_texture_object *obj;
    GET_CURRENT_CONTEXT(ctx);
 
-   obj = get_texobj_by_target(ctx, target, GL_TRUE);
+   obj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                ctx->Texture.CurrentUnit,
+                                                false,
+                                                "glGetTexParameteriv");
    if (!obj)
       return;
 
@@ -2306,7 +2684,10 @@ _mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_TRUE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                ctx->Texture.CurrentUnit,
+                                                false,
+                                                "glGetTexParameterIiv");
    if (!texObj)
       return;
 
@@ -2321,13 +2702,54 @@ _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_target(ctx, target, GL_TRUE);
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                ctx->Texture.CurrentUnit,
+                                                false,
+                                                "glGetTexParameterIuiv");
    if (!texObj)
       return;
 
-   get_tex_parameterIuiv(ctx, texObj, pname, params, false);
+   get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, false);
 }
 
+void GLAPIENTRY
+_mesa_GetTextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname, GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTextureParameterfvEXT");
+      return;
+   }
+
+   get_tex_parameterfv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glGetMultiTexParameterfvEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMultiTexParameterfvEXT");
+      return;
+   }
+   get_tex_parameterfv(ctx, texObj, pname, params, true);
+}
 
 void GLAPIENTRY
 _mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
@@ -2335,30 +2757,60 @@ _mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
    struct gl_texture_object *obj;
    GET_CURRENT_CONTEXT(ctx);
 
-   obj = get_texobj_by_name(ctx, texture, GL_TRUE);
-   if (!obj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTextureParameterfv(texture)");
+   obj = get_texobj_by_name(ctx, texture, "glGetTextureParameterfv");
+   if (!obj)
       return;
-   }
 
    get_tex_parameterfv(ctx, obj, pname, params, true);
 }
 
+void GLAPIENTRY
+_mesa_GetTextureParameterivEXT(GLuint texture, GLenum target, GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTextureParameterivEXT");
+      return;
+   }
+   get_tex_parameteriv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   false,
+                                                   "glGetMultiTexParameterivEXT");
+   if (!texObj)
+      return;
+
+   if (!is_texparameteri_target_valid(texObj->Target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMultiTexParameterivEXT");
+      return;
+   }
+   get_tex_parameteriv(ctx, texObj, pname, params, true);
+}
+
 void GLAPIENTRY
 _mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
 {
    struct gl_texture_object *obj;
    GET_CURRENT_CONTEXT(ctx);
 
-   obj = get_texobj_by_name(ctx, texture, GL_TRUE);
-   if (!obj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTextureParameteriv(texture)");
+   obj = get_texobj_by_name(ctx, texture, "glGetTextureParameteriv");
+   if (!obj)
       return;
-   }
 
    get_tex_parameteriv(ctx, obj, pname, params, true);
 }
@@ -2369,17 +2821,44 @@ _mesa_GetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTextureParameterIiv(texture)");
+   texObj = get_texobj_by_name(ctx, texture, "glGetTextureParameterIiv");
+   if (!texObj)
       return;
-   }
 
    get_tex_parameterIiv(ctx, texObj, pname, params, true);
 }
 
+void GLAPIENTRY
+_mesa_GetTextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureParameterIivEXT");
+   if (!texObj)
+      return;
+
+
+   get_tex_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname,
+                                 GLint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glGetMultiTexParameterIiv");
+   if (!texObj)
+      return;
+
+   get_tex_parameterIiv(ctx, texObj, pname, params, true);
+}
 
 void GLAPIENTRY
 _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
@@ -2387,13 +2866,41 @@ _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
-   if (!texObj) {
-      /* User passed a non-generated name. */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTextureParameterIuiv(texture)");
+   texObj = get_texobj_by_name(ctx, texture, "glGetTextureParameterIuiv");
+   if (!texObj)
+      return;
+
+   get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetTextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
+                                 GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+                                           "glGetTextureParameterIuvEXT");
+   if (!texObj)
+      return;
+
+   get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname,
+                               GLuint *params)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glGetMultiTexParameterIuiv");
+   if (!texObj)
       return;
-   }
 
-   get_tex_parameterIuiv(ctx, texObj, pname, params, true);
+   get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
 }