Remove all the glDraw* functions from the GLvertexformat structure.
The point of that dispatch struct is to handle all the functions which
dispatch differently depending on whether we're inside glBegin/End.
glDraw* are never allowed inside glBegin/End so we can remove those
entries.
This simplifies the code paths and gets rid of quite a bit of code.
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
#include "main/syncobj.h"
#include "main/formatquery.h"
#include "main/dispatch.h"
+#include "vbo/vbo.h"
/**
assert(exec != NULL);
assert(ctx->Version > 0);
+
+ vbo_initialize_exec_dispatch(ctx, exec);
"""
void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
- /**
- * \name Array
- */
- /*@{*/
- void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count );
- void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices );
- void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start,
- GLuint end, GLsizei count,
- GLenum type, const GLvoid *indices );
- void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count,
- GLenum type,
- const GLvoid **indices,
- GLsizei primcount);
- void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count,
- GLenum type,
- const GLvoid *indices,
- GLint basevertex );
- void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start,
- GLuint end, GLsizei count,
- GLenum type,
- const GLvoid *indices,
- GLint basevertex);
- void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode,
- const GLsizei *count,
- GLenum type,
- const GLvoid * const *indices,
- GLsizei primcount,
- const GLint *basevertex);
- void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first,
- GLsizei count, GLsizei primcount);
- void (GLAPIENTRYP DrawArraysInstancedBaseInstance)(GLenum mode, GLint first,
- GLsizei count, GLsizei primcount,
- GLuint baseinstance);
- void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices,
- GLsizei primcount);
- void (GLAPIENTRYP DrawElementsInstancedBaseInstance)(GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices,
- GLsizei primcount, GLuint baseinstance);
- void (GLAPIENTRYP DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices,
- GLsizei primcount, GLint basevertex);
- void (GLAPIENTRYP DrawElementsInstancedBaseVertexBaseInstance)(GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices,
- GLsizei primcount, GLint basevertex,
- GLuint baseinstance);
- void (GLAPIENTRYP DrawTransformFeedback)(GLenum mode, GLuint name);
- void (GLAPIENTRYP DrawTransformFeedbackStream)(GLenum mode, GLuint name,
- GLuint stream);
- void (GLAPIENTRYP DrawTransformFeedbackInstanced)(GLenum mode, GLuint name,
- GLsizei primcount);
- void (GLAPIENTRYP DrawTransformFeedbackStreamInstanced)(GLenum mode,
- GLuint name,
- GLuint stream,
- GLsizei primcount);
- /*@}*/
-
/**
* \name Eval
*
#include "main/dispatch.h"
+#include "vbo/vbo.h"
+
/**
_mesa_loopback_init_api_table(ctx, table);
+ /* VBO functions */
+ vbo_initialize_save_dispatch(ctx, table);
+
/* GL 1.0 */
SET_Accum(table, save_Accum);
SET_AlphaFunc(table, save_AlphaFunc);
/* GL_ARB_uniform_buffer_object */
SET_UniformBlockBinding(table, save_UniformBlockBinding);
+
+ /* GL_ARB_draw_instanced */
+ SET_DrawArraysInstancedARB(table, save_DrawArraysInstancedARB);
+ SET_DrawElementsInstancedARB(table, save_DrawElementsInstancedARB);
+
+ /* GL_ARB_draw_elements_base_vertex */
+ SET_DrawElementsInstancedBaseVertex(table, save_DrawElementsInstancedBaseVertexARB);
+
+ /* GL_ARB_base_instance */
+ SET_DrawArraysInstancedBaseInstance(table, save_DrawArraysInstancedBaseInstance);
+ SET_DrawElementsInstancedBaseInstance(table, save_DrawElementsInstancedBaseInstance);
+ SET_DrawElementsInstancedBaseVertexBaseInstance(table, save_DrawElementsInstancedBaseVertexBaseInstance);
}
vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
vfmt->Rectf = save_Rectf;
-
- /* GL_ARB_draw_instanced */
- vfmt->DrawArraysInstanced = save_DrawArraysInstancedARB;
- vfmt->DrawElementsInstanced = save_DrawElementsInstancedARB;
-
- /* GL_ARB_draw_elements_base_vertex */
- vfmt->DrawElementsInstancedBaseVertex = save_DrawElementsInstancedBaseVertexARB;
-
- /* GL_ARB_base_instance */
- vfmt->DrawArraysInstancedBaseInstance = save_DrawArraysInstancedBaseInstance;
- vfmt->DrawElementsInstancedBaseInstance = save_DrawElementsInstancedBaseInstance;
- vfmt->DrawElementsInstancedBaseVertexBaseInstance = save_DrawElementsInstancedBaseVertexBaseInstance;
-
- /* The driver is required to implement these as
- * 1) They can probably do a better job.
- * 2) A lot of new mechanisms would have to be added to this module
- * to support it. That code would probably never get used,
- * because of (1).
- */
-#if 0
- vfmt->DrawArrays = 0;
- vfmt->DrawElements = 0;
- vfmt->DrawRangeElements = 0;
- vfmt->MultiDrawElemementsEXT = 0;
- vfmt->DrawElementsBaseVertex = 0;
- vfmt->DrawRangeElementsBaseVertex = 0;
- vfmt->MultiDrawElemementsBaseVertex = 0;
-#endif
}
SET_Rectf(tab, vfmt->Rectf);
}
- if (!beginend) {
- /* These functions are only valid outside glBegin/glEnd */
- SET_DrawArrays(tab, vfmt->DrawArrays);
- SET_DrawElements(tab, vfmt->DrawElements);
-
- if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
- SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
- }
-
- SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT);
-
- if (_mesa_is_desktop_gl(ctx)) {
- SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex);
- SET_DrawRangeElementsBaseVertex(tab,
- vfmt->DrawRangeElementsBaseVertex);
- SET_MultiDrawElementsBaseVertex(tab,
- vfmt->MultiDrawElementsBaseVertex);
- SET_DrawArraysInstancedBaseInstance(tab,
- vfmt->DrawArraysInstancedBaseInstance);
- SET_DrawElementsInstancedBaseInstance(tab,
- vfmt->DrawElementsInstancedBaseInstance);
- SET_DrawElementsInstancedBaseVertex(tab,
- vfmt->DrawElementsInstancedBaseVertex);
- SET_DrawElementsInstancedBaseVertexBaseInstance(tab,
- vfmt->DrawElementsInstancedBaseVertexBaseInstance);
- }
-
- if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
- SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced);
- SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced);
- }
-
- if (_mesa_is_desktop_gl(ctx)) {
- SET_DrawTransformFeedback(tab, vfmt->DrawTransformFeedback);
- SET_DrawTransformFeedbackStream(tab,
- vfmt->DrawTransformFeedbackStream);
- SET_DrawTransformFeedbackInstanced(tab,
- vfmt->DrawTransformFeedbackInstanced);
- SET_DrawTransformFeedbackStreamInstanced(tab,
- vfmt->DrawTransformFeedbackStreamInstanced);
- }
- }
-
/* Originally for GL_NV_vertex_program, this is also used by dlist.c */
if (ctx->API == API_OPENGL_COMPAT) {
SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
return;
vbo_exec_vtx_init( exec );
- vbo_exec_array_init( exec );
ctx->Driver.NeedFlush = 0;
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
}
vbo_exec_vtx_destroy( exec );
- vbo_exec_array_destroy( exec );
}
/* Internal functions:
*/
-void vbo_exec_array_init( struct vbo_exec_context *exec );
-void vbo_exec_array_destroy( struct vbo_exec_context *exec );
-
void vbo_exec_vtx_init( struct vbo_exec_context *exec );
void vbo_exec_vtx_destroy( struct vbo_exec_context *exec );
vbo_draw_transform_feedback(ctx, mode, obj, stream, primcount);
}
-/**
- * Plug in the immediate-mode vertex array drawing commands into the
- * givven vbo_exec_context object.
- */
-void
-vbo_exec_array_init( struct vbo_exec_context *exec )
-{
- exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays;
- exec->vtxfmt.DrawElements = vbo_exec_DrawElements;
- exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements;
- exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements;
- exec->vtxfmt.DrawElementsBaseVertex = vbo_exec_DrawElementsBaseVertex;
- exec->vtxfmt.DrawRangeElementsBaseVertex = vbo_exec_DrawRangeElementsBaseVertex;
- exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex;
- exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced;
- exec->vtxfmt.DrawArraysInstancedBaseInstance = vbo_exec_DrawArraysInstancedBaseInstance;
- exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced;
- exec->vtxfmt.DrawElementsInstancedBaseInstance = vbo_exec_DrawElementsInstancedBaseInstance;
- exec->vtxfmt.DrawElementsInstancedBaseVertex = vbo_exec_DrawElementsInstancedBaseVertex;
- exec->vtxfmt.DrawElementsInstancedBaseVertexBaseInstance = vbo_exec_DrawElementsInstancedBaseVertexBaseInstance;
- exec->vtxfmt.DrawTransformFeedback = vbo_exec_DrawTransformFeedback;
- exec->vtxfmt.DrawTransformFeedbackStream =
- vbo_exec_DrawTransformFeedbackStream;
- exec->vtxfmt.DrawTransformFeedbackInstanced =
- vbo_exec_DrawTransformFeedbackInstanced;
- exec->vtxfmt.DrawTransformFeedbackStreamInstanced =
- vbo_exec_DrawTransformFeedbackStreamInstanced;
-}
-
-
-void
-vbo_exec_array_destroy( struct vbo_exec_context *exec )
-{
- /* nothing to do */
-}
-
/**
* Initialize the dispatch table with the VBO functions for drawing.
}
-static void GLAPIENTRY
-_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
-}
-
-static void GLAPIENTRY
-_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid * indices)
-{
-}
-
-static void GLAPIENTRY
-_mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
- const GLvoid * indices, GLint basevertex)
-{
-}
-
-
-static void GLAPIENTRY
-_mesa_noop_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid * indices)
-{
-}
-
-static void GLAPIENTRY
-_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei * count, GLenum type,
- const GLvoid ** indices, GLsizei primcount)
-{
-}
-
-static void GLAPIENTRY
-_mesa_noop_DrawRangeElementsBaseVertex(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid * indices,
- GLint basevertex)
-{
-}
-
-static void GLAPIENTRY
-_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei * count,
- GLenum type,
- const GLvoid * const *indices,
- GLsizei primcount,
- const GLint * basevertex)
-{
-}
-
static void GLAPIENTRY
_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2)
{
vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB;
vfmt->Rectf = _mesa_noop_Rectf;
-
- vfmt->DrawArrays = _mesa_noop_DrawArrays;
- vfmt->DrawElements = _mesa_noop_DrawElements;
- vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
- vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements;
- vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex;
- vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex;
- vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex;
}
}
-/* These are all errors as this vtxfmt is only installed inside
- * begin/end pairs.
- */
-static void GLAPIENTRY
-_save_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid * indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) count;
- (void) type;
- (void) indices;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawElements");
-}
-
-
-static void GLAPIENTRY
-_save_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
- GLsizei count, GLenum type, const GLvoid * indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) start;
- (void) end;
- (void) count;
- (void) type;
- (void) indices;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawRangeElements");
-}
-
-
-static void GLAPIENTRY
-_save_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
- const GLvoid * indices, GLint basevertex)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) count;
- (void) type;
- (void) indices;
- (void) basevertex;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawElements");
-}
-
-
-static void GLAPIENTRY
-_save_DrawRangeElementsBaseVertex(GLenum mode,
- GLuint start,
- GLuint end,
- GLsizei count,
- GLenum type,
- const GLvoid * indices, GLint basevertex)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) start;
- (void) end;
- (void) count;
- (void) type;
- (void) indices;
- (void) basevertex;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawRangeElements");
-}
-
-
-static void GLAPIENTRY
-_save_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) start;
- (void) count;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawArrays");
-}
-
-
-static void GLAPIENTRY
-_save_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
- const GLvoid **indices, GLsizei primcount)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) count;
- (void) type;
- (void) indices;
- (void) primcount;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glMultiDrawElements");
-}
-
-
-static void GLAPIENTRY
-_save_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
- GLenum type, const GLvoid * const *indices,
- GLsizei primcount, const GLint *basevertex)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) count;
- (void) type;
- (void) indices;
- (void) primcount;
- (void) basevertex;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION,
- "glMultiDrawElementsBaseVertex");
-}
-
-
-static void GLAPIENTRY
-_save_DrawTransformFeedback(GLenum mode, GLuint name)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) name;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback");
-}
-
-
-static void GLAPIENTRY
-_save_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) name;
- (void) stream;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION,
- "glDrawTransformFeedbackStream");
-}
-
-
-static void GLAPIENTRY
-_save_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
- GLsizei primcount)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) name;
- (void) primcount;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION,
- "glDrawTransformFeedbackInstanced");
-}
-
-
-static void GLAPIENTRY
-_save_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
- GLuint stream, GLsizei primcount)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode;
- (void) name;
- (void) stream;
- (void) primcount;
- _mesa_compile_error(ctx, GL_INVALID_OPERATION,
- "glDrawTransformFeedbackStreamInstanced");
-}
-
-
static void GLAPIENTRY
_save_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
*/
vfmt->Begin = _save_Begin;
vfmt->Rectf = _save_Rectf;
- vfmt->DrawArrays = _save_DrawArrays;
- vfmt->DrawElements = _save_DrawElements;
- vfmt->DrawRangeElements = _save_DrawRangeElements;
- vfmt->DrawElementsBaseVertex = _save_DrawElementsBaseVertex;
- vfmt->DrawRangeElementsBaseVertex = _save_DrawRangeElementsBaseVertex;
- vfmt->MultiDrawElementsEXT = _save_MultiDrawElements;
- vfmt->MultiDrawElementsBaseVertex = _save_MultiDrawElementsBaseVertex;
- vfmt->DrawTransformFeedback = _save_DrawTransformFeedback;
- vfmt->DrawTransformFeedbackStream = _save_DrawTransformFeedbackStream;
- vfmt->DrawTransformFeedbackInstanced = _save_DrawTransformFeedbackInstanced;
- vfmt->DrawTransformFeedbackStreamInstanced =
- _save_DrawTransformFeedbackStreamInstanced;
}
* ctx->ListState.
*/
ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf;
- ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays;
- ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements;
- ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements;
- ctx->ListState.ListVtxfmt.MultiDrawElementsEXT = _save_OBE_MultiDrawElements;
- ctx->ListState.ListVtxfmt.MultiDrawElementsBaseVertex = _save_OBE_MultiDrawElementsBaseVertex;
}