summaryrefslogtreecommitdiff
path: root/lib/mesa/src/mapi
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:34:57 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:34:57 +0000
commit32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (patch)
treefc5893a490729ebf6b87b83eebf5d4ebfdfccf27 /lib/mesa/src/mapi
parent286ec9d289bada8abb84753c461cfa3432866e98 (diff)
Import Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/mapi')
-rw-r--r--lib/mesa/src/mapi/es1api/gles1-symbols.txt2
-rw-r--r--lib/mesa/src/mapi/es1api/meson.build2
-rw-r--r--lib/mesa/src/mapi/es2api/meson.build2
-rw-r--r--lib/mesa/src/mapi/glapi/gen/ARB_draw_indirect.xml14
-rw-r--r--lib/mesa/src/mapi/glapi/gen/ARB_indirect_parameters.xml6
-rw-r--r--lib/mesa/src/mapi/glapi/gen/ARB_instanced_arrays.xml11
-rw-r--r--lib/mesa/src/mapi/glapi/gen/EXT_direct_state_access.xml24
-rw-r--r--lib/mesa/src/mapi/glapi/gen/api_beginend_init_h.py4
-rw-r--r--lib/mesa/src/mapi/glapi/gen/api_exec_decl_h.py6
-rw-r--r--lib/mesa/src/mapi/glapi/gen/api_exec_init.py2
-rw-r--r--lib/mesa/src/mapi/glapi/gen/api_save_h.py2
-rw-r--r--lib/mesa/src/mapi/glapi/glapi_dispatch.c72
-rw-r--r--lib/mesa/src/mapi/glapi/tests/check_table.cpp5
-rw-r--r--lib/mesa/src/mapi/meson.build7
-rwxr-xr-xlib/mesa/src/mapi/new/gen_gldispatch_mapi.py13
-rw-r--r--lib/mesa/src/mapi/shared-glapi/glapi.c252
-rw-r--r--lib/mesa/src/mapi/shared-glapi/meson.build24
-rw-r--r--lib/mesa/src/mapi/shared-glapi/stub.c221
-rw-r--r--lib/mesa/src/mapi/shared-glapi/stub.h59
-rw-r--r--lib/mesa/src/mapi/shared-glapi/table.c80
-rw-r--r--lib/mesa/src/mapi/shared-glapi/table.h80
-rw-r--r--lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp1
22 files changed, 751 insertions, 138 deletions
diff --git a/lib/mesa/src/mapi/es1api/gles1-symbols.txt b/lib/mesa/src/mapi/es1api/gles1-symbols.txt
index 935b9d583..37db6df35 100644
--- a/lib/mesa/src/mapi/es1api/gles1-symbols.txt
+++ b/lib/mesa/src/mapi/es1api/gles1-symbols.txt
@@ -1,6 +1,6 @@
# gl.* functions in GL ES 1.1
# or in extensions that are part of the ES 1.1 extension pack.
-# (see http://www.khronos.org/registry/gles/specs/1.1/opengles_spec_1_1_extension_pack.pdf)
+# (see https://registry.khronos.org/OpenGL/specs/es/1.1/opengles_spec_1_1_extension_pack.pdf)
glActiveTexture
glAlphaFunc
diff --git a/lib/mesa/src/mapi/es1api/meson.build b/lib/mesa/src/mapi/es1api/meson.build
index d0d89b464..9ee093dd3 100644
--- a/lib/mesa/src/mapi/es1api/meson.build
+++ b/lib/mesa/src/mapi/es1api/meson.build
@@ -58,7 +58,7 @@ libglesv1_cm = shared_library(
soversion : host_machine.system() == 'windows' ? '' : '1',
version : '1.1.0',
darwin_versions : '3.0.0',
- name_prefix : 'lib',
+ name_prefix : host_machine.system() == 'windows' ? 'lib' : [], # always use lib, but avoid warnings on !windows
install : true,
)
diff --git a/lib/mesa/src/mapi/es2api/meson.build b/lib/mesa/src/mapi/es2api/meson.build
index 1156ee92e..7bce74198 100644
--- a/lib/mesa/src/mapi/es2api/meson.build
+++ b/lib/mesa/src/mapi/es2api/meson.build
@@ -58,7 +58,7 @@ libgles2 = shared_library(
soversion : host_machine.system() == 'windows' ? '' : '2',
version : '2.0.0',
darwin_versions : '3.0.0',
- name_prefix : 'lib',
+ name_prefix : host_machine.system() == 'windows' ? 'lib' : [], # always use lib, but avoid warnings on !windows
install : true,
)
diff --git a/lib/mesa/src/mapi/glapi/gen/ARB_draw_indirect.xml b/lib/mesa/src/mapi/glapi/gen/ARB_draw_indirect.xml
index feb6588de..398720e0b 100644
--- a/lib/mesa/src/mapi/glapi/gen/ARB_draw_indirect.xml
+++ b/lib/mesa/src/mapi/glapi/gen/ARB_draw_indirect.xml
@@ -8,16 +8,12 @@
<enum name="DRAW_INDIRECT_BUFFER" value="0x8F3F"/>
<enum name="DRAW_INDIRECT_BUFFER_BINDING" value="0x8F43"/>
- <function name="DrawArraysIndirect" es2="3.1" exec="dlist"
- marshal="async"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices_or_indirect(ctx)">
+ <function name="DrawArraysIndirect" es2="3.1" exec="dlist" marshal="custom">
<param name="mode" type="GLenum"/>
<param name="indirect" type="const GLvoid *"/>
</function>
- <function name="DrawElementsIndirect" es2="3.1" exec="dlist"
- marshal="async"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices_or_indices_or_indirect(ctx)">
+ <function name="DrawElementsIndirect" es2="3.1" exec="dlist" marshal="custom">
<param name="mode" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="indirect" type="const GLvoid *"/>
@@ -28,16 +24,14 @@
<category name="GL_ARB_multi_draw_indirect" number="133">
- <function name="MultiDrawArraysIndirect" marshal="async" exec="dlist"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices_or_indirect(ctx)">
+ <function name="MultiDrawArraysIndirect" marshal="custom" exec="dlist">
<param name="mode" type="GLenum"/>
<param name="indirect" type="const GLvoid *"/>
<param name="primcount" type="GLsizei"/>
<param name="stride" type="GLsizei"/>
</function>
- <function name="MultiDrawElementsIndirect" marshal="async" exec="dlist"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices_or_indices_or_indirect(ctx)">
+ <function name="MultiDrawElementsIndirect" marshal="custom" exec="dlist">
<param name="mode" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="indirect" type="const GLvoid *"/>
diff --git a/lib/mesa/src/mapi/glapi/gen/ARB_indirect_parameters.xml b/lib/mesa/src/mapi/glapi/gen/ARB_indirect_parameters.xml
index f08201d4a..89250abab 100644
--- a/lib/mesa/src/mapi/glapi/gen/ARB_indirect_parameters.xml
+++ b/lib/mesa/src/mapi/glapi/gen/ARB_indirect_parameters.xml
@@ -8,8 +8,7 @@
<enum name="PARAMETER_BUFFER_ARB" value="0x80EE"/>
<enum name="PARAMETER_BUFFER_BINDING_ARB" value="0x80EF"/>
- <function name="MultiDrawArraysIndirectCountARB"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices(ctx)">
+ <function name="MultiDrawArraysIndirectCountARB" marshal="custom">
<param name="mode" type="GLenum"/>
<param name="indirect" type="GLintptr"/>
<param name="drawcount" type="GLintptr"/>
@@ -18,8 +17,7 @@
</function>
<!-- Use "...has_non_vbo_vertices", because indices always come from a buffer object. -->
- <function name="MultiDrawElementsIndirectCountARB"
- marshal_sync="_mesa_glthread_has_non_vbo_vertices(ctx)">
+ <function name="MultiDrawElementsIndirectCountARB" marshal="custom">
<param name="mode" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="indirect" type="GLintptr"/>
diff --git a/lib/mesa/src/mapi/glapi/gen/ARB_instanced_arrays.xml b/lib/mesa/src/mapi/glapi/gen/ARB_instanced_arrays.xml
index 49f92cfe8..6f68a71b0 100644
--- a/lib/mesa/src/mapi/glapi/gen/ARB_instanced_arrays.xml
+++ b/lib/mesa/src/mapi/glapi/gen/ARB_instanced_arrays.xml
@@ -24,5 +24,16 @@
</category>
+<category name="GL_EXT_instanced_arrays" number="156">
+
+ <enum name="VERTEX_ATTRIB_ARRAY_DIVISOR_EXT" value="0x88FE"/>
+
+ <function name="VertexAttribDivisorEXT" alias="VertexAttribDivisor" es2="2.0">
+ <param name="index" type="GLuint"/>
+ <param name="divisor" type="GLuint"/>
+ </function>
+ <!-- The rest of the bits for this is already in ARB_draw_instanced.xml. -->
+
+</category>
</OpenGLAPI>
diff --git a/lib/mesa/src/mapi/glapi/gen/EXT_direct_state_access.xml b/lib/mesa/src/mapi/glapi/gen/EXT_direct_state_access.xml
index a450846c2..620a09b96 100644
--- a/lib/mesa/src/mapi/glapi/gen/EXT_direct_state_access.xml
+++ b/lib/mesa/src/mapi/glapi/gen/EXT_direct_state_access.xml
@@ -676,7 +676,7 @@
</function>
<function name="MultiTexCoordPointerEXT" marshal="async"
- marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_TEX(texunit - GL_TEXTURE0), size, type, stride, pointer);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_TEX(texunit - GL_TEXTURE0), MESA_PACK_VFORMAT(type, size, 0, 0, 0), stride, pointer);">
<param name="texunit" type="GLenum" />
<param name="size" type="GLint" />
<param name="type" type="GLenum" />
@@ -1088,7 +1088,7 @@
</function>
<function name="VertexArrayVertexOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_POS, size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_POS, MESA_PACK_VFORMAT(type, size, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="size" type="GLint" />
@@ -1098,7 +1098,7 @@
</function>
<function name="VertexArrayColorOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR0, size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR0, MESA_PACK_VFORMAT(type, size, 1, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="size" type="GLint" />
@@ -1108,7 +1108,7 @@
</function>
<function name="VertexArrayEdgeFlagOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_EDGEFLAG, 1, GL_UNSIGNED_BYTE, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_EDGEFLAG, MESA_PACK_VFORMAT(GL_UNSIGNED_BYTE, 1, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="stride" type="GLsizei" />
@@ -1116,7 +1116,7 @@
</function>
<function name="VertexArrayIndexOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR_INDEX, 1, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR_INDEX, MESA_PACK_VFORMAT(type, 1, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="type" type="GLenum" />
@@ -1125,7 +1125,7 @@
</function>
<function name="VertexArrayNormalOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_NORMAL, 3, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_NORMAL, MESA_PACK_VFORMAT(type, 3, 1, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="type" type="GLenum" />
@@ -1134,7 +1134,7 @@
</function>
<function name="VertexArrayTexCoordOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture), size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture), MESA_PACK_VFORMAT(type, size, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="size" type="GLint" />
@@ -1144,7 +1144,7 @@
</function>
<function name="VertexArrayMultiTexCoordOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_TEX(texunit - GL_TEXTURE0), size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_TEX(texunit - GL_TEXTURE0), MESA_PACK_VFORMAT(type, size, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="texunit" type="GLenum" />
@@ -1155,7 +1155,7 @@
</function>
<function name="VertexArrayFogCoordOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_FOG, 1, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_FOG, MESA_PACK_VFORMAT(type, 1, 0, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="type" type="GLenum" />
@@ -1164,7 +1164,7 @@
</function>
<function name="VertexArraySecondaryColorOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR1, size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_COLOR1, MESA_PACK_VFORMAT(type, size, 1, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="size" type="GLint" />
@@ -1174,7 +1174,7 @@
</function>
<function name="VertexArrayVertexAttribOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_GENERIC(index), size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_GENERIC(index), MESA_PACK_VFORMAT(type, size, normalized, 0, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="index" type="GLuint" />
@@ -1186,7 +1186,7 @@
</function>
<function name="VertexArrayVertexAttribIOffsetEXT"
- marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_GENERIC(index), size, type, stride, offset);">
+ marshal_call_after="if (COMPAT) _mesa_glthread_DSAAttribPointer(ctx, vaobj, buffer, VERT_ATTRIB_GENERIC(index), MESA_PACK_VFORMAT(type, size, 0, 1, 0), stride, offset);">
<param name="vaobj" type="GLuint" />
<param name="buffer" type="GLuint" />
<param name="index" type="GLuint" />
diff --git a/lib/mesa/src/mapi/glapi/gen/api_beginend_init_h.py b/lib/mesa/src/mapi/glapi/gen/api_beginend_init_h.py
index b0aab7b5f..f0a22e363 100644
--- a/lib/mesa/src/mapi/glapi/gen/api_beginend_init_h.py
+++ b/lib/mesa/src/mapi/glapi/gen/api_beginend_init_h.py
@@ -54,12 +54,12 @@ class PrintCode(gl_XML.gl_print_base):
if not condition:
continue
- if (condition == '_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2' and
+ if (condition == '_mesa_is_desktop_gl(ctx) || _mesa_is_gles2(ctx)' and
re.match('VertexAttrib[1-4].*ARB', f.name)):
# These functions should map to an *ES callback for GLES2.
settings_by_condition['_mesa_is_desktop_gl(ctx)'].append(
'SET_{0}(tab, NAME({0}));'.format(f.name))
- settings_by_condition['ctx->API == API_OPENGLES2'].append(
+ settings_by_condition['_mesa_is_gles2(ctx)'].append(
'SET_{0}(tab, NAME_ES({0}));'.format(f.name))
else:
macro = ('NAME_CALLLIST' if f.name[0:8] == 'CallList' else
diff --git a/lib/mesa/src/mapi/glapi/gen/api_exec_decl_h.py b/lib/mesa/src/mapi/glapi/gen/api_exec_decl_h.py
index d6e396738..12f134c68 100644
--- a/lib/mesa/src/mapi/glapi/gen/api_exec_decl_h.py
+++ b/lib/mesa/src/mapi/glapi/gen/api_exec_decl_h.py
@@ -47,11 +47,7 @@ class PrintCode(gl_XML.gl_print_base):
#ifndef API_EXEC_DECL_H
#define API_EXEC_DECL_H
- #include "GL/gl.h"
-
- #define GL_API GLAPI
- #define GL_APIENTRY GLAPIENTRY
- #include "GLES/gl.h"
+ #include "util/glheader.h"
#ifdef __cplusplus
extern "C" {
diff --git a/lib/mesa/src/mapi/glapi/gen/api_exec_init.py b/lib/mesa/src/mapi/glapi/gen/api_exec_init.py
index 3f8622877..9c3af5e9e 100644
--- a/lib/mesa/src/mapi/glapi/gen/api_exec_init.py
+++ b/lib/mesa/src/mapi/glapi/gen/api_exec_init.py
@@ -63,7 +63,7 @@ header = """/**
void
_mesa_init_dispatch(struct gl_context *ctx)
{
- struct _glapi_table *table = ctx->OutsideBeginEnd;
+ struct _glapi_table *table = ctx->Dispatch.OutsideBeginEnd;
assert(table != NULL);
assert(ctx->Version > 0);
diff --git a/lib/mesa/src/mapi/glapi/gen/api_save_h.py b/lib/mesa/src/mapi/glapi/gen/api_save_h.py
index d2838f5fb..71d0b19cf 100644
--- a/lib/mesa/src/mapi/glapi/gen/api_save_h.py
+++ b/lib/mesa/src/mapi/glapi/gen/api_save_h.py
@@ -46,7 +46,7 @@ class PrintCode(gl_XML.gl_print_base):
#ifndef API_SAVE_H
#define API_SAVE_H
- #include "GL/gl.h"
+ #include "util/glheader.h"
"""))
for f in api.functionIterateAll():
diff --git a/lib/mesa/src/mapi/glapi/glapi_dispatch.c b/lib/mesa/src/mapi/glapi/glapi_dispatch.c
index b462c4af9..43209b597 100644
--- a/lib/mesa/src/mapi/glapi/glapi_dispatch.c
+++ b/lib/mesa/src/mapi/glapi/glapi_dispatch.c
@@ -74,83 +74,13 @@
#endif /* logging */
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY
-#endif
-
#ifdef GLX_INDIRECT_RENDERING
/* those link to libglapi.a should provide the entry points */
#define _GLAPI_SKIP_PROTO_ENTRY_POINTS
#endif
-/* These prototypes are necessary because GLES1 library builds will create
- * dispatch functions for them. We can't directly include GLES/gl.h because
- * it would conflict the previously-included GL/gl.h. Since GLES1 ABI is not
- * expected to every add more functions, the path of least resistance is to
- * just duplicate the prototypes for the functions that aren't already in
- * desktop OpenGL.
- */
-#include <GLES/glplatform.h>
-
-
-/* Redefine GL_API to avoid MSVC/MinGW warnings about different dllimport
- * attributes for these prototypes vs those in the GLES/gl.h header.
- */
-#undef GL_API
-#define GL_API KEYWORD1
-
-GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
-GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
-GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat *equation);
-GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-
-GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
-GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
-GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
-GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
-GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed *equation);
-GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
-GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
-GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
-GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
-GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
-GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glPointSizex (GLfixed size);
-GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
-GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
-GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
-GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
-GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
-GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
-GL_API void GL_APIENTRY glBlendBarrier (void);
-GL_API void GL_APIENTRY glPrimitiveBoundingBox (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
-
/* Enable frame pointer elimination on Windows, otherwise forgetting to add
- * APIENTRY to _mesa_* entrypoints will not cause crashes on debug builds, as
+ * GLAPIENTRY to _mesa_* entrypoints will not cause crashes on debug builds, as
* the initial ESP value is saved in the EBP in the function prologue, then
* restored on the epilogue, clobbering any corruption in the ESP pointer due
* to mismatch in the callee calling convention.
diff --git a/lib/mesa/src/mapi/glapi/tests/check_table.cpp b/lib/mesa/src/mapi/glapi/tests/check_table.cpp
index 6dad1bbcd..5b9d1e7c4 100644
--- a/lib/mesa/src/mapi/glapi/tests/check_table.cpp
+++ b/lib/mesa/src/mapi/glapi/tests/check_table.cpp
@@ -22,7 +22,6 @@
*/
#include <gtest/gtest.h>
-#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glapitable.h"
@@ -1131,8 +1130,8 @@ const struct name_offset known_dispatch[] = {
{ "glGetAttribLocation", _O(GetAttribLocation) },
{ "glDrawBuffers", _O(DrawBuffers) },
{ "glClampColor", _O(ClampColor) },
- { "glDrawArraysInstancedARB", _O(DrawArraysInstancedARB) },
- { "glDrawElementsInstancedARB", _O(DrawElementsInstancedARB) },
+ { "glDrawArraysInstanced", _O(DrawArraysInstanced) },
+ { "glDrawElementsInstanced", _O(DrawElementsInstanced) },
{ "glRenderbufferStorageMultisample", _O(RenderbufferStorageMultisample) },
{ "glFramebufferTexture", _O(FramebufferTexture) },
{ "glProgramParameteri", _O(ProgramParameteri) },
diff --git a/lib/mesa/src/mapi/meson.build b/lib/mesa/src/mapi/meson.build
index 2c79a04f1..71331aaa6 100644
--- a/lib/mesa/src/mapi/meson.build
+++ b/lib/mesa/src/mapi/meson.build
@@ -18,13 +18,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-files_mapi_util = files(
- 'u_current.c',
- 'u_current.h',
- 'u_execmem.c',
- 'u_execmem.h',
-)
-
genCommon_py = files('new/genCommon.py')
glapi_gen_mapi_py = files('new/gen_gldispatch_mapi.py')
mapi_abi_py = files('mapi_abi.py')
diff --git a/lib/mesa/src/mapi/new/gen_gldispatch_mapi.py b/lib/mesa/src/mapi/new/gen_gldispatch_mapi.py
index e5678867d..19fabf9b0 100755
--- a/lib/mesa/src/mapi/new/gen_gldispatch_mapi.py
+++ b/lib/mesa/src/mapi/new/gen_gldispatch_mapi.py
@@ -57,7 +57,6 @@ def _main():
#ifndef _GLAPI_TMP_H_
#define _GLAPI_TMP_H_
-typedef int GLclampx;
#endif /* _GLAPI_TMP_H_ */
""".lstrip("\n"))
@@ -75,13 +74,11 @@ typedef int GLclampx;
def generate_defines(functions):
text = r"""
#ifdef MAPI_TMP_DEFINES
-#define GL_GLEXT_PROTOTYPES
-#include "GL/gl.h"
-#include "GL/glext.h"
+#include "util/glheader.h"
""".lstrip("\n")
for func in functions:
- text += "GLAPI {f.rt} APIENTRY {f.name}({f.decArgs});\n".format(f=func)
+ text += "GLAPI {f.rt} GLAPIENTRY {f.name}({f.decArgs});\n".format(f=func)
text += "#undef MAPI_TMP_DEFINES\n"
text += "#endif /* MAPI_TMP_DEFINES */\n"
return text
@@ -99,7 +96,7 @@ def generate_noop_array(functions):
text += "#ifdef DEBUG\n\n"
for func in functions:
- text += "static {f.rt} APIENTRY noop{f.basename}({f.decArgs})\n".format(f=func)
+ text += "static {f.rt} GLAPIENTRY noop{f.basename}({f.decArgs})\n".format(f=func)
text += "{\n"
if (len(func.args) > 0):
text += " "
@@ -147,11 +144,11 @@ def generate_public_entries(functions):
for func in functions:
retStr = ("return " if func.hasReturn() else "")
text += r"""
-GLAPI {f.rt} APIENTRY {f.name}({f.decArgs})
+GLAPI {f.rt} GLAPIENTRY {f.name}({f.decArgs})
{{
const struct _glapi_table *_tbl = entry_current_get();
mapi_func _func = ((const mapi_func *) _tbl)[{f.slot}];
- {retStr}(({f.rt} (APIENTRY *)({f.decArgs})) _func)({f.callArgs});
+ {retStr}(({f.rt} (GLAPIENTRY *)({f.decArgs})) _func)({f.callArgs});
}}
""".lstrip("\n").format(f=func, retStr=retStr)
diff --git a/lib/mesa/src/mapi/shared-glapi/glapi.c b/lib/mesa/src/mapi/shared-glapi/glapi.c
new file mode 100644
index 000000000..216a69870
--- /dev/null
+++ b/lib/mesa/src/mapi/shared-glapi/glapi.c
@@ -0,0 +1,252 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include "glapi/glapi.h"
+#include "u_current.h"
+#include "table.h" /* for MAPI_TABLE_NUM_SLOTS */
+#include "stub.h"
+
+/*
+ * _glapi_Dispatch, _glapi_Context
+ * _glapi_tls_Dispatch, _glapi_tls_Context,
+ * _glapi_set_context, _glapi_get_context,
+ * _glapi_destroy_multithread, _glapi_check_multithread
+ * _glapi_set_dispatch, and _glapi_get_dispatch
+ * are defined in u_current.c.
+ */
+
+/**
+ * Return size of dispatch table struct as number of functions (or
+ * slots).
+ */
+unsigned int
+_glapi_get_dispatch_table_size(void)
+{
+ return MAPI_TABLE_NUM_SLOTS;
+}
+
+/**
+ * Fill-in the dispatch stub for the named function.
+ *
+ * This function is intended to be called by a hardware driver. When called,
+ * a dispatch stub may be created created for the function. A pointer to this
+ * dispatch function will be returned by glXGetProcAddress.
+ *
+ * \param function_names Array of pointers to function names that should
+ * share a common dispatch offset.
+ * \param parameter_signature String representing the types of the parameters
+ * passed to the named function. Parameter types
+ * are converted to characters using the following
+ * rules:
+ * - 'i' for \c GLint, \c GLuint, and \c GLenum
+ * - 'p' for any pointer type
+ * - 'f' for \c GLfloat and \c GLclampf
+ * - 'd' for \c GLdouble and \c GLclampd
+ *
+ * \returns
+ * The offset in the dispatch table of the named function. A pointer to the
+ * driver's implementation of the named function should be stored at
+ * \c dispatch_table[\c offset]. Return -1 if error/problem.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \warning
+ * This function can only handle up to 8 names at a time. As far as I know,
+ * the maximum number of names ever associated with an existing GL function is
+ * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
+ * \c glPointParameterfARB, and \c glPointParameterf), so this should not be
+ * too painful of a limitation.
+ *
+ * \todo
+ * Check parameter_signature.
+ */
+int
+_glapi_add_dispatch( const char * const * function_names,
+ const char * parameter_signature )
+{
+ const struct mapi_stub *function_stubs[8];
+ const struct mapi_stub *alias = NULL;
+ unsigned i;
+
+ (void) memset((void*)function_stubs, 0, sizeof(function_stubs));
+
+ /* find the missing stubs, and decide the alias */
+ for (i = 0; function_names[i] != NULL && i < 8; i++) {
+ const char * funcName = function_names[i];
+ const struct mapi_stub *stub;
+ int slot;
+
+ if (!funcName || funcName[0] != 'g' || funcName[1] != 'l')
+ return -1;
+ funcName += 2;
+
+ stub = stub_find_public(funcName);
+ if (!stub)
+ stub = stub_find_dynamic(funcName, 0);
+
+ slot = (stub) ? stub_get_slot(stub) : -1;
+ if (slot >= 0) {
+ if (alias && stub_get_slot(alias) != slot)
+ return -1;
+ /* use the first existing stub as the alias */
+ if (!alias)
+ alias = stub;
+
+ function_stubs[i] = stub;
+ }
+ }
+
+ /* generate missing stubs */
+ for (i = 0; function_names[i] != NULL && i < 8; i++) {
+ const char * funcName = function_names[i] + 2;
+ struct mapi_stub *stub;
+
+ if (function_stubs[i])
+ continue;
+
+ stub = stub_find_dynamic(funcName, 1);
+ if (!stub)
+ return -1;
+
+ stub_fix_dynamic(stub, alias);
+ if (!alias)
+ alias = stub;
+ }
+
+ return (alias) ? stub_get_slot(alias) : -1;
+}
+
+#if defined(ANDROID) && ANDROID_API_LEVEL <= 30
+static int is_debug_marker_func(const char *name)
+{
+ return (!strcmp(name, "InsertEventMarkerEXT") ||
+ !strcmp(name, "PushGroupMarkerEXT") ||
+ !strcmp(name, "PopGroupMarkerEXT"));
+}
+#endif
+
+static const struct mapi_stub *
+_glapi_get_stub(const char *name, int generate)
+{
+ const struct mapi_stub *stub;
+
+ if (!name || name[0] != 'g' || name[1] != 'l')
+ return NULL;
+ name += 2;
+
+ stub = stub_find_public(name);
+#if defined(ANDROID) && ANDROID_API_LEVEL <= 30
+ /* Android framework till API Level 30 uses function pointers from
+ * eglGetProcAddress without checking GL_EXT_debug_marker.
+ * Make sure we don't return stub function pointers if we don't
+ * support GL_EXT_debug_marker */
+ if (!stub && !is_debug_marker_func(name))
+#else
+ if (!stub)
+#endif
+ stub = stub_find_dynamic(name, generate);
+
+ return stub;
+}
+
+/**
+ * Return offset of entrypoint for named function within dispatch table.
+ */
+int
+_glapi_get_proc_offset(const char *funcName)
+{
+ const struct mapi_stub *stub = _glapi_get_stub(funcName, 0);
+ return (stub) ? stub_get_slot(stub) : -1;
+}
+
+/**
+ * Return pointer to the named function. If the function name isn't found
+ * in the name of static functions, try generating a new API entrypoint on
+ * the fly with assembly language.
+ */
+_glapi_proc
+_glapi_get_proc_address(const char *funcName)
+{
+ const struct mapi_stub *stub = _glapi_get_stub(funcName, 1);
+ return (stub) ? (_glapi_proc) stub_get_addr(stub) : NULL;
+}
+
+/**
+ * Return the name of the function at the given dispatch offset.
+ * This is only intended for debugging.
+ */
+const char *
+_glapi_get_proc_name(unsigned int offset)
+{
+ const struct mapi_stub *stub = stub_find_by_slot(offset);
+ return stub ? stub_get_name(stub) : NULL;
+}
+
+/** Return pointer to new dispatch table filled with no-op functions */
+struct _glapi_table *
+_glapi_new_nop_table(unsigned num_entries)
+{
+ struct _glapi_table *table;
+
+ if (num_entries > MAPI_TABLE_NUM_SLOTS)
+ num_entries = MAPI_TABLE_NUM_SLOTS;
+
+ table = malloc(num_entries * sizeof(mapi_func));
+ if (table) {
+ memcpy(table, table_noop_array, num_entries * sizeof(mapi_func));
+ }
+ return table;
+}
+
+void
+_glapi_set_nop_handler(_glapi_nop_handler_proc func)
+{
+ table_set_noop_handler(func);
+}
+
+/**
+ * This is a deprecated function which should not be used anymore.
+ * It's only present to satisfy linking with older versions of libGL.
+ */
+unsigned long
+_glthread_GetID(void)
+{
+ return 0;
+}
+
+void
+_glapi_noop_enable_warnings(unsigned char enable)
+{
+}
+
+void
+_glapi_set_warning_func(_glapi_proc func)
+{
+}
diff --git a/lib/mesa/src/mapi/shared-glapi/meson.build b/lib/mesa/src/mapi/shared-glapi/meson.build
index 3db5646c7..bf84745d1 100644
--- a/lib/mesa/src/mapi/shared-glapi/meson.build
+++ b/lib/mesa/src/mapi/shared-glapi/meson.build
@@ -18,13 +18,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-files_mapi_glapi = files(
+files_shared_glapi = files(
'../entry.c',
- '../mapi_glapi.c',
- '../stub.c',
- '../stub.h',
- '../table.c',
- '../table.h',
+ '../u_current.c',
+ '../u_current.h',
+ '../u_execmem.c',
+ '../u_execmem.h',
+ 'glapi.c',
+ 'stub.c',
+ 'stub.h',
+ 'table.c',
+ 'table.h',
)
shared_glapi_mapi_tmp_h = custom_target(
@@ -43,7 +47,7 @@ endif
libglapi = shared_library(
'glapi',
- [files_mapi_glapi, files_mapi_util, shared_glapi_mapi_tmp_h],
+ [files_shared_glapi, shared_glapi_mapi_tmp_h],
c_args : [
_glapi_c_args,
c_msvc_compat_args,
@@ -54,10 +58,10 @@ libglapi = shared_library(
gnu_symbol_visibility : 'hidden',
link_args : [ld_args_gc_sections],
include_directories : [inc_src, inc_include, inc_mapi],
- dependencies : [dep_thread, dep_selinux, idep_mesautilc11, idep_mesautil],
+ dependencies : [dep_thread, dep_selinux, idep_mesautil],
soversion : host_machine.system() == 'windows' ? '' : '0',
version : '0.0.0',
- name_prefix : 'lib',
+ name_prefix : host_machine.system() == 'windows' ? 'lib' : [], # always use lib, but avoid warnings on !windows
install : true,
)
libglapi_build_dir = meson.current_build_dir()
@@ -74,7 +78,7 @@ if with_any_opengl and with_tests
dependencies : [dep_thread, idep_gtest, idep_mesautilc11],
),
suite : ['mapi'],
- protocol : gtest_test_protocol,
+ protocol : 'gtest',
)
if with_symbols_check
test(
diff --git a/lib/mesa/src/mapi/shared-glapi/stub.c b/lib/mesa/src/mapi/shared-glapi/stub.c
new file mode 100644
index 000000000..1836e330c
--- /dev/null
+++ b/lib/mesa/src/mapi/shared-glapi/stub.c
@@ -0,0 +1,221 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "c11/threads.h"
+
+#include "util/macros.h"
+#include "util/simple_mtx.h"
+#include "u_current.h"
+#include "entry.h"
+#include "stub.h"
+#include "table.h"
+
+
+struct mapi_stub {
+ const void *name;
+ int slot;
+ mapi_func addr;
+};
+
+/* define public_string_pool and public_stubs */
+#define MAPI_TMP_PUBLIC_STUBS
+#include "mapi_tmp.h"
+
+static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC];
+static int num_dynamic_stubs;
+static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC;
+
+void
+stub_init_once(void)
+{
+ static once_flag flag = ONCE_FLAG_INIT;
+ call_once(&flag, entry_patch_public);
+}
+
+static int
+stub_compare(const void *key, const void *elem)
+{
+ const char *name = (const char *) key;
+ const struct mapi_stub *stub = (const struct mapi_stub *) elem;
+ const char *stub_name;
+
+ stub_name = &public_string_pool[(size_t) stub->name];
+
+ return strcmp(name, stub_name);
+}
+
+/**
+ * Return the public stub with the given name.
+ */
+const struct mapi_stub *
+stub_find_public(const char *name)
+{
+ return (const struct mapi_stub *) bsearch(name, public_stubs,
+ ARRAY_SIZE(public_stubs), sizeof(public_stubs[0]), stub_compare);
+}
+
+/**
+ * Add a dynamic stub.
+ */
+static struct mapi_stub *
+stub_add_dynamic(const char *name)
+{
+ struct mapi_stub *stub;
+ int idx;
+
+ idx = num_dynamic_stubs;
+ /* minus 1 to make sure we can never reach the last slot */
+ if (idx >= MAPI_TABLE_NUM_DYNAMIC - 1)
+ return NULL;
+
+ stub = &dynamic_stubs[idx];
+
+ /* dispatch to the last slot, which is reserved for no-op */
+ stub->addr = entry_generate(
+ MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC - 1);
+ if (!stub->addr)
+ return NULL;
+
+ stub->name = (const void *) strdup(name);
+ /* to be fixed later */
+ stub->slot = -1;
+
+ num_dynamic_stubs = idx + 1;
+
+ return stub;
+}
+
+/**
+ * Return the dynamic stub with the given name. If no such stub exists and
+ * generate is true, a new stub is generated.
+ */
+struct mapi_stub *
+stub_find_dynamic(const char *name, int generate)
+{
+ static simple_mtx_t dynamic_mutex = SIMPLE_MTX_INITIALIZER;
+ struct mapi_stub *stub = NULL;
+ int count, i;
+
+ simple_mtx_lock(&dynamic_mutex);
+
+ if (generate)
+ assert(!stub_find_public(name));
+
+ count = num_dynamic_stubs;
+ for (i = 0; i < count; i++) {
+ if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) {
+ stub = &dynamic_stubs[i];
+ break;
+ }
+ }
+
+ /* generate a dynamic stub */
+ if (generate && !stub)
+ stub = stub_add_dynamic(name);
+
+ simple_mtx_unlock(&dynamic_mutex);
+
+ return stub;
+}
+
+static const struct mapi_stub *
+search_table_by_slot(const struct mapi_stub *table, size_t num_entries,
+ int slot)
+{
+ size_t i;
+ for (i = 0; i < num_entries; ++i) {
+ if (table[i].slot == slot)
+ return &table[i];
+ }
+ return NULL;
+}
+
+const struct mapi_stub *
+stub_find_by_slot(int slot)
+{
+ const struct mapi_stub *stub =
+ search_table_by_slot(public_stubs, ARRAY_SIZE(public_stubs), slot);
+ if (stub)
+ return stub;
+ return search_table_by_slot(dynamic_stubs, num_dynamic_stubs, slot);
+}
+
+void
+stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias)
+{
+ int slot;
+
+ if (stub->slot >= 0)
+ return;
+
+ if (alias)
+ slot = alias->slot;
+ else
+ slot = next_dynamic_slot++;
+
+ entry_patch(stub->addr, slot);
+ stub->slot = slot;
+}
+
+/**
+ * Return the name of a stub.
+ */
+const char *
+stub_get_name(const struct mapi_stub *stub)
+{
+ const char *name;
+
+ if (stub >= public_stubs &&
+ stub < public_stubs + ARRAY_SIZE(public_stubs))
+ name = &public_string_pool[(size_t) stub->name];
+ else
+ name = (const char *) stub->name;
+
+ return name;
+}
+
+/**
+ * Return the slot of a stub.
+ */
+int
+stub_get_slot(const struct mapi_stub *stub)
+{
+ return stub->slot;
+}
+
+/**
+ * Return the address of a stub.
+ */
+mapi_func
+stub_get_addr(const struct mapi_stub *stub)
+{
+ assert(stub->addr || (unsigned int) stub->slot < MAPI_TABLE_NUM_STATIC);
+ return (stub->addr) ? stub->addr : entry_get_public(stub->slot);
+}
diff --git a/lib/mesa/src/mapi/shared-glapi/stub.h b/lib/mesa/src/mapi/shared-glapi/stub.h
new file mode 100644
index 000000000..953a0fae5
--- /dev/null
+++ b/lib/mesa/src/mapi/shared-glapi/stub.h
@@ -0,0 +1,59 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#ifndef _STUB_H_
+#define _STUB_H_
+
+#include "entry.h"
+
+struct mapi_stub;
+
+void
+stub_init_once(void);
+
+const struct mapi_stub *
+stub_find_public(const char *name);
+
+struct mapi_stub *
+stub_find_dynamic(const char *name, int generate);
+
+const struct mapi_stub *
+stub_find_by_slot(int slot);
+
+void
+stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias);
+
+const char *
+stub_get_name(const struct mapi_stub *stub);
+
+int
+stub_get_slot(const struct mapi_stub *stub);
+
+mapi_func
+stub_get_addr(const struct mapi_stub *stub);
+
+#endif /* _STUB_H_ */
diff --git a/lib/mesa/src/mapi/shared-glapi/table.c b/lib/mesa/src/mapi/shared-glapi/table.c
new file mode 100644
index 000000000..b0dd51f86
--- /dev/null
+++ b/lib/mesa/src/mapi/shared-glapi/table.c
@@ -0,0 +1,80 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "c11/threads.h"
+#include "table.h"
+
+static nop_handler_proc nop_handler = NULL;
+
+void
+table_set_noop_handler(nop_handler_proc func)
+{
+ nop_handler = func;
+}
+
+static bool log_noop;
+
+static void check_debug_env(void)
+{
+ const char *debug = getenv("MESA_DEBUG");
+ if (!debug)
+ debug = getenv("LIBGL_DEBUG");
+ if (debug && strcmp(debug, "silent") != 0)
+ log_noop = true;
+}
+
+static void
+noop_warn(const char *name)
+{
+ if (nop_handler) {
+ nop_handler(name);
+ }
+ else {
+ static once_flag flag = ONCE_FLAG_INIT;
+ call_once(&flag, check_debug_env);
+
+ if (log_noop)
+ fprintf(stderr, "%s is no-op\n", name);
+ }
+}
+
+static int
+noop_generic(void)
+{
+ noop_warn("function");
+ return 0;
+}
+
+/* define noop_array */
+#define MAPI_TMP_DEFINES
+#define MAPI_TMP_NOOP_ARRAY
+#include "mapi_tmp.h"
diff --git a/lib/mesa/src/mapi/shared-glapi/table.h b/lib/mesa/src/mapi/shared-glapi/table.h
new file mode 100644
index 000000000..fd70cc410
--- /dev/null
+++ b/lib/mesa/src/mapi/shared-glapi/table.h
@@ -0,0 +1,80 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#ifndef _TABLE_H_
+#define _TABLE_H_
+
+#include "entry.h"
+
+#define MAPI_TMP_TABLE
+#include "mapi_tmp.h"
+
+#define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC)
+#define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func))
+
+struct _glapi_table;
+
+extern const mapi_func table_noop_array[];
+
+
+typedef void (*nop_handler_proc)(const char *name);
+
+
+void
+table_set_noop_handler(nop_handler_proc func);
+
+
+/**
+ * Get the no-op dispatch table.
+ */
+static inline const struct _glapi_table *
+table_get_noop(void)
+{
+ return (const struct _glapi_table *) table_noop_array;
+}
+
+/**
+ * Set the function of a slot.
+ */
+static inline void
+table_set_func(struct _glapi_table *tbl, int slot, mapi_func func)
+{
+ mapi_func *funcs = (mapi_func *) tbl;
+ funcs[slot] = func;
+}
+
+/**
+ * Return the function of a slot.
+ */
+static inline mapi_func
+table_get_func(const struct _glapi_table *tbl, int slot)
+{
+ const mapi_func *funcs = (const mapi_func *) tbl;
+ return funcs[slot];
+}
+
+#endif /* _TABLE_H_ */
diff --git a/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp b/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp
index 314e6769b..fdc9f7543 100644
--- a/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp
+++ b/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp
@@ -22,7 +22,6 @@
*/
#include <gtest/gtest.h>
-#include "../../../mesa/main/glheader.h"
#include "glapi/glapi.h"
#include "glapitable.h"