mesa: add implementation of glDrawElementsInstancedBaseVertex
authorPierre-Eric Pelloux-Prayer <pelloux@gmail.com>
Tue, 31 May 2011 11:33:54 +0000 (13:33 +0200)
committerBrian Paul <brianp@vmware.com>
Thu, 2 Jun 2011 23:55:48 +0000 (17:55 -0600)
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/main/api_validate.c
src/mesa/main/api_validate.h
src/mesa/main/dd.h
src/mesa/main/vtxfmt.c
src/mesa/vbo/vbo_exec_array.c

index 993519f61b25a7c55da72ff861e7231cf4ffd757..2981d42297a80f87e5c876d26f9087a9b7603c8b 100644 (file)
@@ -396,7 +396,8 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
 GLboolean
 _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
                                      GLenum mode, GLsizei count, GLenum type,
-                                     const GLvoid *indices, GLsizei numInstances)
+                                     const GLvoid *indices, GLsizei numInstances,
+                                     GLint basevertex)
 {
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
@@ -447,7 +448,7 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
          return GL_FALSE;
    }
 
-   if (!check_index_bounds(ctx, count, type, indices, 0))
+   if (!check_index_bounds(ctx, count, type, indices, basevertex))
       return GL_FALSE;
 
    return GL_TRUE;
index 16b9c2b26473965d4f74e349a3d8db1f1ba1283d..09e9522d20ec384be302c6c471490acc7bb04776 100644 (file)
@@ -62,7 +62,8 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
 extern GLboolean
 _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
                                      GLenum mode, GLsizei count, GLenum type,
-                                     const GLvoid *indices, GLsizei primcount);
+                                     const GLvoid *indices, GLsizei primcount,
+                                     GLint basevertex);
 
 
 #endif
index d749b245e13d9ff1991f10bc19037d78caa75d41..9fe6d527f926ce343e574a2d01b3b74aacad2eac 100644 (file)
@@ -1177,6 +1177,9 @@ typedef struct {
    void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count,
                                             GLenum type, const GLvoid *indices,
                                             GLsizei primcount);
+   void (GLAPIENTRYP DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count,
+                                            GLenum type, const GLvoid *indices,
+                                            GLsizei primcount, GLint basevertex);
    /*@}*/
 
    /**
index 692ce080c9f83c07eea74336afc0e18e3688ad7c..d0941477d61aa6f28abce1044b067ea12a3a84e1 100644 (file)
@@ -106,6 +106,7 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex);
    SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced);
    SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced);
+   SET_DrawElementsInstancedBaseVertex(tab, vfmt->DrawElementsInstancedBaseVertex);
 
    /* GL_NV_vertex_program */
    SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
index a49cd5017a3cb36a23f861aa68539f6b9e9511ee..5e9b2798c43448845e35e6924553411186d8728e 100644 (file)
@@ -1045,13 +1045,37 @@ vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
                   _mesa_lookup_enum_by_nr(type), indices, numInstances);
 
    if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
-                                             numInstances))
+                                             numInstances, 0))
       return;
 
    vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
                                   count, type, indices, 0, numInstances);
 }
 
+/**
+ * Called by glDrawElementsInstancedBaseVertex() in immediate mode.
+ */
+static void GLAPIENTRY
+vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type,
+                               const GLvoid *indices, GLsizei numInstances,
+                               GLint basevertex)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_DRAW)
+      _mesa_debug(ctx, "glDrawElementsInstancedBaseVertex(%s, %d, %s, %p, %d; %d)\n",
+                  _mesa_lookup_enum_by_nr(mode), count,
+                  _mesa_lookup_enum_by_nr(type), indices,
+                  numInstances, basevertex);
+
+   if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
+                                             numInstances, basevertex))
+      return;
+
+   vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
+                                  count, type, indices, basevertex, numInstances);
+}
+
 
 /**
  * Inner support for both _mesa_MultiDrawElements() and
@@ -1260,6 +1284,7 @@ vbo_exec_array_init( struct vbo_exec_context *exec )
    exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex;
    exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced;
    exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced;
+   exec->vtxfmt.DrawElementsInstancedBaseVertex = vbo_exec_DrawElementsInstancedBaseVertex;
 }