[Mesa-dev] [PATCH 3/7] mesa: implement glBindTextures()

Maxence Le Doré maxence.ledore at gmail.com
Thu Jan 2 16:27:33 PST 2014


---
 src/mesa/main/texobj.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/texobj.h |  3 +++
 2 files changed, 55 insertions(+)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index bddbc50..66e2fb0 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1686,4 +1686,56 @@ _mesa_InvalidateTexImage(GLuint texture, GLint level)
    return;
 }
 
+/** ARB_multi_bind / OpenGL 4.4 */
+
+void GLAPIENTRY
+_mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct GLuint currentTexUnit = 0;
+   int i = 0;
+
+   currentTexUnit = ctx->Texture.CurrentUnit;
+ 
+   if(first + count > ctx->Const.MaxCombinedTextureImageUnits) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBindTextures(first+count)");
+      return;
+   }
+
+   for(i = 0 ; i < count ; i++) {
+      GLuint texture;
+      struct gl_texture_object *texObj;
+      GLenum texTarget;
+      int j = 0;
+
+      if(textures == NULL)
+        texture = 0;
+      else
+        texture = textures[i];
+
+      _mesa_ActiveTexture(GL_TEXTURE0 + first + i);
+      if(texture != 0) {
+        texObj = _mesa_lookup_texture(ctx, texture);
+        if(texObj) {
+          texTarget = texObj->Target;
+          _mesa_BindTexture(texTarget, texture);
+        }
+        else
+          _mesa_error(ctx, GL_INVALID_OPERATION,
+                      "glBindTextures(textures[%i])", i);
+      }
+      else
+        for(j = 0 ; j < NUM_TEXTURE_TARGETS ; j++) {
+          GLint index = target_enum_to_index(ctx, j);
+          if(index >= 0) {
+            texTarget = index_to_target_enum(index);
+            _mesa_BindTexture(texTarget, 0);
+          }
+          else
+            continue;
+        }
+     }
+   _mesa_ActiveTexture(GL_TEXTURE0 + currentTexUnit);
+}
+
 /*@}*/
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 55091a6..bbf1e9b 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -179,6 +179,9 @@ _mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
 extern void GLAPIENTRY
 _mesa_InvalidateTexImage(GLuint texture, GLint level);
 
+extern void GLAPIENTRY
+_mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures);
+
 /*@}*/
 
 
-- 
1.8.5.2



More information about the mesa-dev mailing list