mesa: add support for glBindMultiTextureEXT

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml b/src/mapi/glapi/gen/EXT_direct_state_access.xml
index 7619674..73d8d97 100644
--- a/src/mapi/glapi/gen/EXT_direct_state_access.xml
+++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml
@@ -100,6 +100,14 @@
       <param name="matrixMode" type="GLenum" />
    </function>
 
+   <!-- OpenGL 1.2.1 -->
+
+  <function name="BindMultiTextureEXT">
+      <param name="texunit" type="GLenum" />
+      <param name="target" type="GLenum" />
+      <param name="texture" type="GLuint" />
+   </function>
+
    <!-- OpenGL 1.3 -->
 
    <function name="MatrixLoadTransposefEXT" offset="assign">
@@ -122,5 +130,5 @@
       <param name="m" type="const GLdouble *" />
    </function>
 </category>
-
+</category>
 </OpenGLAPI>
diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py
index 5351bc1..e189eb3 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -1473,6 +1473,7 @@
     "MatrixLoadTransposedEXT": 1437,
     "MatrixMultTransposefEXT": 1438,
     "MatrixMultTransposedEXT": 1439,
+    "BindMultiTextureEXT": 1440,
 }
 
 functions = [
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 44f5374..eb0f217 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -1056,7 +1056,7 @@
    //{ "glTextureSubImage3DEXT", 12, -1 },
    //{ "glCopyTextureSubImage3DEXT", 12, -1 },
    /* GL_EXT_direct_state_access - GL 1.2.1 */
-   //{ "glBindMultiTextureEXT", 12, -1 },
+   { "glBindMultiTextureEXT", 12, -1 },
    //{ "glMultiTexCoordPointerEXT", 12, -1 },
    //{ "glMultiTexEnvfEXT", 12, -1 },
    //{ "glMultiTexEnvfvEXT", 12, -1 },
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index ef6458e..fa8a4d8 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1709,17 +1709,18 @@
  *
  * \param target texture target.
  * \param texName texture name.
+ * \param texunit texture unit.
  */
 static ALWAYS_INLINE void
 bind_texture(struct gl_context *ctx, GLenum target, GLuint texName,
-             bool no_error)
+             GLenum texunit, bool no_error, const char *caller)
 {
    struct gl_texture_object *newTexObj = NULL;
    int targetIndex;
 
    targetIndex = _mesa_tex_target_to_index(ctx, target);
    if (!no_error && targetIndex < 0) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target = %s)",
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target = %s)", caller,
                   _mesa_enum_to_string(target));
       return;
    }
@@ -1741,8 +1742,8 @@
             /* The named texture object's target doesn't match the
              * given target
              */
-            _mesa_error( ctx, GL_INVALID_OPERATION,
-                         "glBindTexture(target mismatch)" );
+            _mesa_error(ctx, GL_INVALID_OPERATION,
+                        "%s(target mismatch)", caller);
             return;
          }
          if (newTexObj->Target == 0) {
@@ -1752,14 +1753,14 @@
       else {
          if (!no_error && ctx->API == API_OPENGL_CORE) {
             _mesa_error(ctx, GL_INVALID_OPERATION,
-                        "glBindTexture(non-gen name)");
+                        "%s(non-gen name)", caller);
             return;
          }
 
          /* if this is a new texture id, allocate a texture object now */
          newTexObj = ctx->Driver.NewTextureObject(ctx, texName, target);
          if (!newTexObj) {
-            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
+            _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
             return;
          }
 
@@ -1771,14 +1772,15 @@
    assert(newTexObj->Target == target);
    assert(newTexObj->TargetIndex == targetIndex);
 
-   bind_texture_object(ctx, ctx->Texture.CurrentUnit, newTexObj);
+   bind_texture_object(ctx, texunit, newTexObj);
 }
 
 void GLAPIENTRY
 _mesa_BindTexture_no_error(GLenum target, GLuint texName)
 {
    GET_CURRENT_CONTEXT(ctx);
-   bind_texture(ctx, target, texName, true);
+   bind_texture(ctx, target, texName, ctx->Texture.CurrentUnit, true,
+                "glBindTexture");
 }
 
 
@@ -1791,7 +1793,29 @@
       _mesa_debug(ctx, "glBindTexture %s %d\n",
                   _mesa_enum_to_string(target), (GLint) texName);
 
-   bind_texture(ctx, target, texName, false);
+   bind_texture(ctx, target, texName, ctx->Texture.CurrentUnit, false,
+                "glBindTexture");
+}
+
+
+void GLAPIENTRY
+_mesa_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   unsigned unit = texunit - GL_TEXTURE0;
+
+   if (texunit < GL_TEXTURE0 || unit >= _mesa_max_tex_unit(ctx)) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBindMultiTextureEXT(texunit=%s)",
+                  _mesa_enum_to_string(texunit));
+      return;
+   }
+
+   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+      _mesa_debug(ctx, "glBindMultiTextureEXT %s %d\n",
+                  _mesa_enum_to_string(texunit), (GLint) texture);
+
+   bind_texture(ctx, target, texture, unit, false, "glBindMultiTextureEXT");
 }
 
 
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 743e6b7..80e95d1 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -209,6 +209,9 @@
 _mesa_BindTexture( GLenum target, GLuint texture );
 
 void GLAPIENTRY
+_mesa_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture);
+
+void GLAPIENTRY
 _mesa_BindTextureUnit_no_error(GLuint unit, GLuint texture);
 
 extern void GLAPIENTRY