mesa: remove _mesa_initialize_exec_dispatch from draw.c by autogenerating it
authorMarek Olšák <marek.olsak@amd.com>
Wed, 23 Dec 2020 12:10:06 +0000 (07:10 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 21 Jan 2021 00:12:35 +0000 (00:12 +0000)
The glapi scripts are fully capable of generating this correctly for all
GL APIs if we don't set exec="dynamic".

exec="dynamic" should only be used for glBegin, glEnd, and all functions
that are legal inside Begin/End.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8297>

src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
src/mapi/glapi/gen/es_EXT.xml
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/gl_genexec.py
src/mesa/main/draw.c
src/mesa/main/draw.h
src/mesa/main/tests/dispatch_sanity.cpp

index 0350dd7..08ea7a3 100644 (file)
@@ -8,7 +8,7 @@
 
 <category name="GL_ARB_draw_elements_base_vertex" number="62">
 
-    <function name="DrawElementsBaseVertex" es2="3.2" exec="dynamic" marshal="custom">
+    <function name="DrawElementsBaseVertex" es2="3.2" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
@@ -16,7 +16,7 @@
         <param name="basevertex" type="GLint"/>
     </function>
 
-    <function name="DrawRangeElementsBaseVertex" es2="3.2" exec="dynamic" marshal="custom">
+    <function name="DrawRangeElementsBaseVertex" es2="3.2" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
@@ -26,7 +26,7 @@
         <param name="basevertex" type="GLint"/>
     </function>
 
-    <function name="MultiDrawElementsBaseVertex" exec="dynamic" marshal="custom">
+    <function name="MultiDrawElementsBaseVertex" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
         <param name="type" type="GLenum"/>
index 4386375..929b40b 100644 (file)
 <category name="GL_EXT_draw_elements_base_vertex" number="204">
 
     <function name="DrawElementsBaseVertexEXT" alias="DrawElementsBaseVertex"
-              es2="2.0" exec="dynamic">
+              es2="2.0">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
     </function>
 
     <function name="DrawRangeElementsBaseVertexEXT" alias="DrawRangeElementsBaseVertex"
-              es2="3.0" exec="dynamic">
+              es2="3.0">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
     </function>
 
     <function name="MultiDrawElementsBaseVertexEXT" alias="MultiDrawElementsBaseVertex"
-              es2="2.0" exec="dynamic">
+              es2="2.0">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *"/>
         <param name="type" type="GLenum"/>
 <category name="GL_OES_draw_elements_base_vertex" number="219">
 
     <function name="DrawElementsBaseVertexOES" alias="DrawElementsBaseVertex"
-              es2="2.0" exec="dynamic">
+              es2="2.0">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
     </function>
 
     <function name="DrawRangeElementsBaseVertexOES" alias="DrawRangeElementsBaseVertex"
-              es2="3.0" exec="dynamic">
+              es2="3.0">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
index 9abc045..f97aea7 100644 (file)
         <glx rop="44"/>
     </function>
 
-    <function name="Rectd" vectorequiv="Rectdv" deprecated="3.1" exec="dynamic">
+    <function name="Rectd" vectorequiv="Rectdv" deprecated="3.1">
         <param name="x1" type="GLdouble"/>
         <param name="y1" type="GLdouble"/>
         <param name="x2" type="GLdouble"/>
         <param name="y2" type="GLdouble"/>
     </function>
 
-    <function name="Rectdv" deprecated="3.1" exec="dynamic">
+    <function name="Rectdv" deprecated="3.1">
         <param name="v1" type="const GLdouble *" count="2"/>
         <param name="v2" type="const GLdouble *" count="2"/>
         <glx rop="45"/>
     </function>
 
-    <function name="Rectf" vectorequiv="Rectfv" deprecated="3.1" exec="dynamic">
+    <function name="Rectf" vectorequiv="Rectfv" deprecated="3.1">
         <param name="x1" type="GLfloat"/>
         <param name="y1" type="GLfloat"/>
         <param name="x2" type="GLfloat"/>
         <param name="y2" type="GLfloat"/>
     </function>
 
-    <function name="Rectfv" deprecated="3.1" exec="dynamic">
+    <function name="Rectfv" deprecated="3.1">
         <param name="v1" type="const GLfloat *" count="2"/>
         <param name="v2" type="const GLfloat *" count="2"/>
         <glx rop="46"/>
     </function>
 
-    <function name="Recti" vectorequiv="Rectiv" deprecated="3.1" exec="dynamic">
+    <function name="Recti" vectorequiv="Rectiv" deprecated="3.1">
         <param name="x1" type="GLint"/>
         <param name="y1" type="GLint"/>
         <param name="x2" type="GLint"/>
         <param name="y2" type="GLint"/>
     </function>
 
-    <function name="Rectiv" deprecated="3.1" exec="dynamic">
+    <function name="Rectiv" deprecated="3.1">
         <param name="v1" type="const GLint *" count="2"/>
         <param name="v2" type="const GLint *" count="2"/>
         <glx rop="47"/>
     </function>
 
-    <function name="Rects" vectorequiv="Rectsv" deprecated="3.1" exec="dynamic">
+    <function name="Rects" vectorequiv="Rectsv" deprecated="3.1">
         <param name="x1" type="GLshort"/>
         <param name="y1" type="GLshort"/>
         <param name="x2" type="GLshort"/>
         <param name="y2" type="GLshort"/>
     </function>
 
-    <function name="Rectsv" deprecated="3.1" exec="dynamic">
+    <function name="Rectsv" deprecated="3.1">
         <param name="v1" type="const GLshort *" count="2"/>
         <param name="v2" type="const GLshort *" count="2"/>
         <glx rop="48"/>
         <glx handcode="true"/>
     </function>
 
-    <function name="DrawArrays" es1="1.0" es2="2.0" exec="dynamic" marshal="custom">
+    <function name="DrawArrays" es1="1.0" es2="2.0" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="first" type="GLint"/>
         <param name="count" type="GLsizei"/>
         <glx rop="193" handcode="true"/>
     </function>
 
-    <function name="DrawElements" es1="1.0" es2="2.0" exec="dynamic" marshal="custom">
+    <function name="DrawElements" es1="1.0" es2="2.0" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
         <glx rop="4097"/>
     </function>
 
-    <function name="DrawRangeElements" es2="3.0" exec="dynamic" marshal="custom">
+    <function name="DrawRangeElements" es2="3.0" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
 </category>
 
 <category name="GL_EXT_multi_draw_arrays" number="148">
-    <function name="MultiDrawArraysEXT" es1="1.0" es2="2.0" exec="dynamic" alias="MultiDrawArrays">
+    <function name="MultiDrawArraysEXT" es1="1.0" es2="2.0" alias="MultiDrawArrays">
         <param name="mode" type="GLenum"/>
         <param name="first" type="const GLint *"/>
         <param name="count" type="const GLsizei *"/>
         <param name="primcount" type="GLsizei"/>
     </function>
 
-    <function name="MultiDrawElementsEXT" es1="1.0" es2="2.0" exec="dynamic" marshal="custom">
+    <function name="MultiDrawElementsEXT" es1="1.0" es2="2.0" marshal="custom">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
         <param name="type" type="GLenum"/>
index 9f7c8ca..8bca9ed 100644 (file)
@@ -149,8 +149,6 @@ _mesa_initialize_exec_table(struct gl_context *ctx)
    assert(exec != NULL);
 
    assert(ctx->Version > 0);
-
-   _mesa_initialize_exec_dispatch(ctx, exec);
 """
 
 
index 669f0c5..2438091 100644 (file)
@@ -600,8 +600,8 @@ _mesa_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
 /**
  * Execute a glRectf() function.
  */
-static void GLAPIENTRY
-_mesa_exec_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+void GLAPIENTRY
+_mesa_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -617,46 +617,46 @@ _mesa_exec_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
 }
 
 
-static void GLAPIENTRY
-_mesa_exec_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
+void GLAPIENTRY
+_mesa_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
 {
-   _mesa_exec_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+   _mesa_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Rectdv(const GLdouble *v1, const GLdouble *v2)
+void GLAPIENTRY
+_mesa_Rectdv(const GLdouble *v1, const GLdouble *v2)
 {
-   _mesa_exec_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+   _mesa_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Rectfv(const GLfloat *v1, const GLfloat *v2)
+void GLAPIENTRY
+_mesa_Rectfv(const GLfloat *v1, const GLfloat *v2)
 {
-   _mesa_exec_Rectf(v1[0], v1[1], v2[0], v2[1]);
+   _mesa_Rectf(v1[0], v1[1], v2[0], v2[1]);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
+void GLAPIENTRY
+_mesa_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
 {
-   _mesa_exec_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+   _mesa_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Rectiv(const GLint *v1, const GLint *v2)
+void GLAPIENTRY
+_mesa_Rectiv(const GLint *v1, const GLint *v2)
 {
-   _mesa_exec_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+   _mesa_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
+void GLAPIENTRY
+_mesa_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
 {
-   _mesa_exec_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+   _mesa_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
 }
 
-static void GLAPIENTRY
-_mesa_exec_Rectsv(const GLshort *v1, const GLshort *v2)
+void GLAPIENTRY
+_mesa_Rectsv(const GLshort *v1, const GLshort *v2)
 {
-   _mesa_exec_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+   _mesa_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
 }
 
 
@@ -889,9 +889,9 @@ _mesa_DrawArraysInstancedBaseInstance(GLenum mode, GLint first,
 /**
  * Called from glMultiDrawArrays when in immediate mode.
  */
-static void GLAPIENTRY
-_mesa_exec_MultiDrawArrays(GLenum mode, const GLint *first,
-                           const GLsizei *count, GLsizei primcount)
+void GLAPIENTRY
+_mesa_MultiDrawArrays(GLenum mode, const GLint *first,
+                      const GLsizei *count, GLsizei primcount)
 {
    GET_CURRENT_CONTEXT(ctx);
    GLint i;
@@ -1598,8 +1598,8 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
 
 
 void GLAPIENTRY
-_mesa_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
-                        const GLvoid * const *indices, GLsizei primcount)
+_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
+                           const GLvoid * const *indices, GLsizei primcount)
 {
    GET_CURRENT_CONTEXT(ctx);
 
@@ -2171,49 +2171,6 @@ _mesa_MultiDrawElementsIndirectCountARB(GLenum mode, GLenum type,
 }
 
 
-/**
- * Initialize the dispatch table with the VBO functions for drawing.
- */
-void
-_mesa_initialize_exec_dispatch(const struct gl_context *ctx,
-                               struct _glapi_table *exec)
-{
-   SET_DrawArrays(exec, _mesa_DrawArrays);
-   SET_DrawElements(exec, _mesa_DrawElements);
-
-   if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
-      SET_DrawRangeElements(exec, _mesa_DrawRangeElements);
-   }
-
-   SET_MultiDrawArrays(exec, _mesa_exec_MultiDrawArrays);
-   SET_MultiDrawElementsEXT(exec, _mesa_MultiDrawElements);
-
-   if (ctx->API == API_OPENGL_COMPAT) {
-      SET_Rectf(exec, _mesa_exec_Rectf);
-      SET_Rectd(exec, _mesa_exec_Rectd);
-      SET_Rectdv(exec, _mesa_exec_Rectdv);
-      SET_Rectfv(exec, _mesa_exec_Rectfv);
-      SET_Recti(exec, _mesa_exec_Recti);
-      SET_Rectiv(exec, _mesa_exec_Rectiv);
-      SET_Rects(exec, _mesa_exec_Rects);
-      SET_Rectsv(exec, _mesa_exec_Rectsv);
-   }
-
-   if (ctx->API != API_OPENGLES &&
-       ctx->Extensions.ARB_draw_elements_base_vertex) {
-      SET_DrawElementsBaseVertex(exec, _mesa_DrawElementsBaseVertex);
-      SET_MultiDrawElementsBaseVertex(exec,
-                                      _mesa_MultiDrawElementsBaseVertex);
-
-      if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
-         SET_DrawRangeElementsBaseVertex(exec,
-                                         _mesa_DrawRangeElementsBaseVertex);
-      }
-   }
-}
-
-
-
 /* GL_IBM_multimode_draw_arrays */
 void GLAPIENTRY
 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
index 2e2773e..f8dc1a4 100644 (file)
@@ -78,10 +78,6 @@ struct _mesa_index_buffer
 
 
 void
-_mesa_initialize_exec_dispatch(const struct gl_context *ctx,
-                               struct _glapi_table *exec);
-
-void
 _mesa_draw_gallium_fallback(struct gl_context *ctx,
                             struct pipe_draw_info *info,
                             const struct pipe_draw_start_count *draws,
@@ -211,8 +207,8 @@ _mesa_MultiDrawArrays(GLenum mode, const GLint *first,
 
 
 void GLAPIENTRY
-_mesa_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
-                        const GLvoid *const *indices, GLsizei primcount);
+_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
+                           const GLvoid *const *indices, GLsizei primcount);
 
 
 void GLAPIENTRY
@@ -233,6 +229,29 @@ _mesa_MultiModeDrawElementsIBM(const GLenum * mode, const GLsizei * count,
                                GLenum type, const GLvoid * const * indices,
                                GLsizei primcount, GLint modestride);
 
+void GLAPIENTRY
+_mesa_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
+
+void GLAPIENTRY
+_mesa_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
+
+void GLAPIENTRY
+_mesa_Rectdv(const GLdouble *v1, const GLdouble *v2);
+
+void GLAPIENTRY
+_mesa_Rectfv(const GLfloat *v1, const GLfloat *v2);
+
+void GLAPIENTRY
+_mesa_Recti(GLint x1, GLint y1, GLint x2, GLint y2);
+
+void GLAPIENTRY
+_mesa_Rectiv(const GLint *v1, const GLint *v2);
+
+void GLAPIENTRY
+_mesa_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
+
+void GLAPIENTRY
+_mesa_Rectsv(const GLshort *v1, const GLshort *v2);
 
 #ifdef __cplusplus
 } // extern "C"
index bbb3ee0..e499ea2 100644 (file)
@@ -2264,6 +2264,7 @@ const struct function gles2_functions_possible[] = {
    { "glDrawArrays", 20, _gloffset_DrawArrays },
    { "glDrawBuffersNV", 20, -1 },
    { "glDrawElements", 20, _gloffset_DrawElements },
+   { "glDrawElementsBaseVertex", 20, -1 },
    { "glEGLImageTargetRenderbufferStorageOES", 20, -1 },
    { "glEGLImageTargetTexture2DOES", 20, -1 },
    { "glEnable", 20, _gloffset_Enable },
@@ -2323,6 +2324,7 @@ const struct function gles2_functions_possible[] = {
    { "glMapBufferRangeEXT", 20, -1 },
    { "glMultiDrawArraysEXT", 20, -1 },
    { "glMultiDrawElementsEXT", 20, -1 },
+   { "glMultiDrawElementsBaseVertex", 20, -1 },
    { "glPixelStorei", 20, _gloffset_PixelStorei },
    { "glPolygonOffset", 20, _gloffset_PolygonOffset },
    { "glReadBufferNV", 20, _gloffset_ReadBuffer },
@@ -2556,6 +2558,7 @@ const struct function gles3_functions_possible[] = {
    // { "glDrawBuffers", 30, -1 },
    { "glDrawElementsInstanced", 30, -1 },
    { "glDrawRangeElements", 30, -1 },
+   { "glDrawRangeElementsBaseVertex", 30, -1 },
    // We check for the aliased -EXT version in GLES 2
    // { "glEndQuery", 30, -1 },
    { "glEndTransformFeedback", 30, -1 },