[Mesa-dev] [PATCH 16/22] mesa: Implement VertexArrayBindingDivisor
Fredrik Höglund
fredrik at kde.org
Wed Mar 18 16:18:42 PDT 2015
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 +++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
src/mesa/main/varray.c | 65 +++++++++++++++++++-------
src/mesa/main/varray.h | 2 +
4 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 4d36657..5ab30f2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -449,5 +449,11 @@
<param name="bindingindex" type="GLuint" />
</function>
+ <function name="VertexArrayBindingDivisor" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="bindingindex" type="GLuint" />
+ <param name="divisor" type="GLuint" />
+ </function>
+
</category>
</OpenGLAPI>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index b545175..b805fe6 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -980,6 +980,7 @@ const struct function gl_core_functions_possible[] = {
{ "glVertexArrayAttribIFormat", 45, -1 },
{ "glVertexArrayAttribLFormat", 45, -1 },
{ "glVertexArrayAttribBinding", 45, -1 },
+ { "glVertexArrayBindingDivisor", 45, -1 },
/* GL_EXT_polygon_offset_clamp */
{ "glPolygonOffsetClampEXT", 11, -1 },
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c9a328b..0faf158 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1996,19 +1996,43 @@ _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingI
}
-void GLAPIENTRY
-_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
+static void
+vertex_array_binding_divisor(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint bindingIndex, GLuint divisor,
+ const char *func)
{
- GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (!ctx->Extensions.ARB_instanced_arrays) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexBindingDivisor()");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s()", func);
return;
}
/* The ARB_vertex_attrib_binding spec says:
*
+ * "An INVALID_VALUE error is generated if <bindingindex> is greater
+ * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
+ */
+ if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(bindingindex=%u > "
+ "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
+ func, bindingIndex);
+ return;
+ }
+
+ vertex_binding_divisor(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex), divisor);
+}
+
+
+void GLAPIENTRY
+_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* The ARB_vertex_attrib_binding spec says:
+ *
* "An INVALID_OPERATION error is generated if no vertex array object
* is bound."
*/
@@ -2019,21 +2043,30 @@ _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
return;
}
- /* The ARB_vertex_attrib_binding spec says:
+ vertex_array_binding_divisor(ctx, ctx->Array.VAO,
+ bindingIndex, divisor,
+ "glVertexBindingDivisor");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor)
+{
+ struct gl_vertex_array_object *vao;
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* The ARB_direct_state_access specification says:
*
- * "An INVALID_VALUE error is generated if <bindingindex> is greater
- * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
+ * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
*/
- if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexBindingDivisor(bindingindex=%u > "
- "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
- bindingIndex);
- return;
- }
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayBindingDivisor");
+ if (!vao)
+ return;
- vertex_binding_divisor(ctx, ctx->Array.VAO,
- VERT_ATTRIB_GENERIC(bindingIndex), divisor);
+ vertex_array_binding_divisor(ctx, vao, bindingIndex, divisor,
+ "glVertexArrayBindingDivisor");
}
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 6eeb571..67823b7 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -335,6 +335,8 @@ _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
extern void GLAPIENTRY
_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
+extern void GLAPIENTRY
+_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor);
extern void
_mesa_copy_client_array(struct gl_context *ctx,
--
1.8.5.3
More information about the mesa-dev
mailing list