mesa: add ARB_instanced_arrays EXT_dsa function
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 6 Nov 2019 11:16:30 +0000 (12:16 +0100)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 19 Nov 2019 07:49:45 +0000 (08:49 +0100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
docs/features.txt
src/mapi/glapi/gen/ARB_instanced_arrays.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/varray.c
src/mesa/main/varray.h

index 49ed0fdb7e6e7f475644d8a8b10a39e107156f56..7ccc097c9dbe7a5ddb14ce49cb284c4411331f9a 100644 (file)
@@ -380,7 +380,7 @@ GL_EXT_direct_state_access additions from other extensions (complete list):
   GL_ARB_clear_buffer_object                            DONE
   GL_ARB_framebuffer_no_attachments                     DONE
   GL_ARB_gpu_shader_fp64                                DONE
-  GL_ARB_instanced_arrays                               not started
+  GL_ARB_instanced_arrays                               DONE
   GL_ARB_internalformat_query2                          DONE
   GL_ARB_sparse_texture                                 n/a
   GL_ARB_sparse_buffer                                  not started
index 907a9d4b8f3cf4de790b37f9b6bc9e934e263b9e..8ecf7951af81ee72f7a4b193320608d7dcf115e8 100644 (file)
     <param name="divisor" type="GLuint"/>
   </function>
 
+  <function name="VertexArrayVertexAttribDivisorEXT">
+       <param name="vaobj" type="GLuint"/>
+    <param name="index" type="GLuint"/>
+    <param name="divisor" type="GLuint"/>
+  </function>
+
 </category>
 
 
index c9d9b2cb2d651dac95a7603e5d688e71ce804d5b..3326ffdf3787f2f988bac3b2e840f2141f4f61f5 100644 (file)
@@ -1621,6 +1621,7 @@ offsets = {
     "NamedFramebufferParameteriEXT": 1585,
     "GetNamedFramebufferParameterivEXT": 1586,
     "VertexArrayVertexAttribLOffsetEXT": 1587,
+    "VertexArrayVertexAttribDivisorEXT": 1588,
 }
 
 functions = [
index a34879ff17e86c941089774733713b1d91cb866f..02ed63743177f71f72df31f75d953aa1bb2d6d94 100644 (file)
@@ -546,6 +546,7 @@ const struct function common_desktop_functions_possible[] = {
 
    /* GL_ARB_instanced_arrays */
    { "glVertexAttribDivisorARB", 31, -1 },
+   { "glVertexArrayVertexAttribDivisorEXT", 31, -1 },
 
    /* GL_NV_texture_barrier */
    { "glTextureBarrierNV", 31, -1 },
index 8db6f13a3199a8024e6d88f88d02735d2a630561..d046d5af3020769f5774bf9cfa6e765f09ef9825 100644 (file)
@@ -2558,6 +2558,55 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
 }
 
 
+void GLAPIENTRY
+_mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   const gl_vert_attrib genericIndex = VERT_ATTRIB_GENERIC(index);
+   struct gl_vertex_array_object * vao;
+   /* The ARB_instanced_arrays spec says:
+    *
+    *     "The vertex array object named by vaobj must
+    *     be generated by GenVertexArrays (and not since deleted);
+    *     otherwise an INVALID_OPERATION error is generated."
+    */
+   vao = _mesa_lookup_vao_err(ctx, vaobj,
+                              false,
+                              "glVertexArrayVertexAttribDivisorEXT");
+   if (!vao)
+      return;
+
+   if (!ctx->Extensions.ARB_instanced_arrays) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexArrayVertexAttribDivisorEXT()");
+      return;
+   }
+
+   if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glVertexArrayVertexAttribDivisorEXT(index = %u)", index);
+      return;
+   }
+
+   assert(genericIndex < ARRAY_SIZE(vao->VertexAttrib));
+
+   /* The ARB_vertex_attrib_binding spec says:
+    *
+    *    "The command
+    *
+    *       void VertexAttribDivisor(uint index, uint divisor);
+    *
+    *     is equivalent to (assuming no errors are generated):
+    *
+    *       VertexAttribBinding(index, index);
+    *       VertexBindingDivisor(index, divisor);"
+    */
+   _mesa_vertex_attrib_binding(ctx, vao, genericIndex, genericIndex);
+   vertex_binding_divisor(ctx, vao, genericIndex, divisor);
+}
+
+
+
 static ALWAYS_INLINE void
 vertex_array_vertex_buffer(struct gl_context *ctx,
                            struct gl_vertex_array_object *vao,
index fb490f1a586469855dd8cf6523269becdbb9b872..9c1ed9efeac60f4d3f594b323b2b993e4f742167 100644 (file)
@@ -317,6 +317,8 @@ extern void GLAPIENTRY
 _mesa_VertexAttribDivisor_no_error(GLuint index, GLuint divisor);
 extern void GLAPIENTRY
 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
+extern void GLAPIENTRY
+_mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor);
 
 static inline unsigned
 _mesa_primitive_restart_index(const struct gl_context *ctx,