diff options
author | Ian Romanick <[email protected]> | 2005-07-18 12:31:24 +0000 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2005-07-18 12:31:24 +0000 |
commit | 9bdfee3a470a535ebe31074651fbacf680bcea6a (patch) | |
tree | fba4d709fc92d1afafdf77f0e9db9a82e1d52831 /src/mesa/tnl/t_save_api.c | |
parent | e0e993c5ff090058037875642dcd34727a3d8760 (diff) |
Wrap every place that accesses a dispatch table with a macro. A new script-
generated file, called src/mesa/glapi/dispatch.h, is added. This file
contains three macros for each API function. It contains a GET, a SET, and
a CALL. Each of the macros take a pointer to the context and a pointer to
the dispatch table.
In several threads on mesa3d-dev we discussed replacing _glapi_add_entrypoint
with a new function called _glapi_add_dispatch. For this discussion, the
important difference between the two is that the caller of _glapi_add_dispatch
does *not* know what the dispatch offset will be at compile time. Because of
this callers need to track the dispatch offset returned by
_glapi_add_dispatch.
http://marc.theaimsgroup.com/?t=111947074700001&r=1&w=2
The downside is that driver code then has to access the dispatch table two
different ways. It accesses it using structure tags (e.g., exec->Begin) for
functions with fixed offsets and via a remap table (e.g., exec[
remap->NewExtensionFunction ]) for functions without fixed offsets. Yuck!
Using the macros allows both types of functions to be accessed
identically. If a driver needs to set a pointer for Begin, it does
'SET_Begin(ctx, exec, my_begin_function)'. If it needs to set a pointer
for NewExtensionFunction, it does 'SET_NewExtensionFunction(ctx, exec,
my_NewExtensionFunction_function)'. Furthermore, if at some point in
the future a static offset is assigned for NewExtensionFunction, only
the macros need to change (instead of every single place that accesses a
table for that function).
This code differs slightly from the originally posted patches in that the
CALL, GET, and SET marcos no longer take a context pointer as a parameter.
Brian Paul had suggested that the remap table could be stored as a global
since it would be set at CreateScreen time and would be constant for all
contexts. This change reflects that feedback.
http://marc.theaimsgroup.com/?t=112087194700001&r=1&w=2
Diffstat (limited to 'src/mesa/tnl/t_save_api.c')
-rw-r--r-- | src/mesa/tnl/t_save_api.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c index dcc8850bec0..b3637cf8d9b 100644 --- a/src/mesa/tnl/t_save_api.c +++ b/src/mesa/tnl/t_save_api.c @@ -77,6 +77,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "api_arrayelt.h" #include "vtxfmt.h" #include "t_save_api.h" +#include "dispatch.h" /* * NOTE: Old 'parity' issue is gone, but copying can still be @@ -1212,56 +1213,56 @@ static void GLAPIENTRY _save_EvalCoord1f( GLfloat u ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalCoord1f( u ); + CALL_EvalCoord1f(ctx->Save, ( u )); } static void GLAPIENTRY _save_EvalCoord1fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalCoord1fv( v ); + CALL_EvalCoord1fv(ctx->Save, ( v )); } static void GLAPIENTRY _save_EvalCoord2f( GLfloat u, GLfloat v ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalCoord2f( u, v ); + CALL_EvalCoord2f(ctx->Save, ( u, v )); } static void GLAPIENTRY _save_EvalCoord2fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalCoord2fv( v ); + CALL_EvalCoord2fv(ctx->Save, ( v )); } static void GLAPIENTRY _save_EvalPoint1( GLint i ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalPoint1( i ); + CALL_EvalPoint1(ctx->Save, ( i )); } static void GLAPIENTRY _save_EvalPoint2( GLint i, GLint j ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->EvalPoint2( i, j ); + CALL_EvalPoint2(ctx->Save, ( i, j )); } static void GLAPIENTRY _save_CallList( GLuint l ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->CallList( l ); + CALL_CallList(ctx->Save, ( l )); } static void GLAPIENTRY _save_CallLists( GLsizei n, GLenum type, const GLvoid *v ) { GET_CURRENT_CONTEXT(ctx); FALLBACK(ctx); - ctx->Save->CallLists( n, type, v ); + CALL_CallLists(ctx->Save, ( n, type, v )); } @@ -1383,11 +1384,11 @@ static void GLAPIENTRY _save_OBE_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfl { GET_CURRENT_CONTEXT(ctx); _save_NotifyBegin( ctx, GL_QUADS | PRIM_WEAK ); - GL_CALL(Vertex2f)( x1, y1 ); - GL_CALL(Vertex2f)( x2, y1 ); - GL_CALL(Vertex2f)( x2, y2 ); - GL_CALL(Vertex2f)( x1, y2 ); - GL_CALL(End)(); + CALL_Vertex2f(GET_DISPATCH(), ( x1, y1 )); + CALL_Vertex2f(GET_DISPATCH(), ( x2, y1 )); + CALL_Vertex2f(GET_DISPATCH(), ( x2, y2 )); + CALL_Vertex2f(GET_DISPATCH(), ( x1, y2 )); + CALL_End(GET_DISPATCH(), ()); } @@ -1401,8 +1402,8 @@ static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei co _save_NotifyBegin( ctx, mode | PRIM_WEAK ); for (i = 0; i < count; i++) - GL_CALL(ArrayElement)(start + i); - GL_CALL(End)(); + CALL_ArrayElement(GET_DISPATCH(), (start + i)); + CALL_End(GET_DISPATCH(), ()); } @@ -1420,22 +1421,22 @@ static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum switch (type) { case GL_UNSIGNED_BYTE: for (i = 0 ; i < count ; i++) - GL_CALL(ArrayElement)( ((GLubyte *)indices)[i] ); + CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] )); break; case GL_UNSIGNED_SHORT: for (i = 0 ; i < count ; i++) - GL_CALL(ArrayElement)( ((GLushort *)indices)[i] ); + CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] )); break; case GL_UNSIGNED_INT: for (i = 0 ; i < count ; i++) - GL_CALL(ArrayElement)( ((GLuint *)indices)[i] ); + CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] )); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); break; } - GL_CALL(End)(); + CALL_End(GET_DISPATCH(), ()); } static void GLAPIENTRY _save_OBE_DrawRangeElements(GLenum mode, |