[Mesa-dev] [PATCH 4/7] mesa: implement glBindVertexBuffers()

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


---
 src/mesa/main/varray.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/varray.h |  3 +++
 2 files changed, 56 insertions(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 0f38270..cf21770 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1681,6 +1681,59 @@ _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
 
 
 /**
+ * See GL_ARB_multi_bind spec
+ */
+
+void GLAPIENTRY
+_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
+                        const GLintptr *offsets, const GLsizei *strides)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   int i = 0;
+
+   if (first + count > ctx->Const.MaxVertexAttribBindings) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glBindVertexBuffers(first+count=%u > "
+                  "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
+                  first+count);
+      return;
+   }
+
+   for(i = 0 ; i < count ; i++) {
+      GLuint buffer;
+      GLintptr offset;
+      GLsizei stride;
+      struct gl_buffer_object *bufferObj;
+
+      if(buffers == NULL)
+        buffer = 0;
+      else {
+        buffer = buffers[i];
+        offset = offsets[i];
+        stride = strides[i];
+      }
+
+      if(buffer != 0) {
+        bufferObj = _mesa_lookup_bufferobj(ctx, buffer);
+        if(bufferObj) {
+          if(!offset < 0 || !stride < 0) {
+            _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffers"
+                        "(offsets[%i] < 0 || stride[%i] < 0)", i, i);
+          }
+          else
+            _mesa_BindVertexBuffer(first+i, buffer, offset, stride);
+        }
+        else
+          _mesa_error(ctx, GL_INVALID_OPERATION,
+                      "glBindVertexBuffer(buffer[i] is not valid)", i);
+      }
+      else
+        _mesa_BindVertexBuffer(first + i, 0, 0, 16);
+   }
+}
+
+
+/**
  * Copy one client vertex array to another.
  */
 void
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index bc820ed..5411a9c 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -308,6 +308,9 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
 extern void GLAPIENTRY
 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
 
+extern void GLAPIENTRY
+_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
+                        const GLintptr *offsets, const GLsizei *strides);
 
 extern void
 _mesa_copy_client_array(struct gl_context *ctx,
-- 
1.8.5.2



More information about the mesa-dev mailing list