From 9bdfee3a470a535ebe31074651fbacf680bcea6a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 18 Jul 2005 12:31:24 +0000 Subject: 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 --- src/mesa/tnl/t_array_api.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/mesa/tnl/t_array_api.c') diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index c8cd22f0c6..1ad77c5a99 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -43,6 +43,7 @@ #include "t_save_api.h" #include "t_context.h" #include "t_pipeline.h" +#include "dispatch.h" static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, GLsizei count ) @@ -52,10 +53,10 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, assert(!ctx->CompileFlag); assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1); - GL_CALL(Begin)(mode); + CALL_Begin(GET_DISPATCH(), (mode)); for (i = 0; i < count; i++) - GL_CALL(ArrayElement)( start + i ); - GL_CALL(End)(); + CALL_ArrayElement(GET_DISPATCH(), ( start + i )); + CALL_End(GET_DISPATCH(), ()); } @@ -69,11 +70,11 @@ static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count, /* Here, indices will already reflect the buffer object if active */ - GL_CALL(Begin)(mode); + CALL_Begin(GET_DISPATCH(), (mode)); for (i = 0 ; i < count ; i++) { - GL_CALL(ArrayElement)( indices[i] ); + CALL_ArrayElement(GET_DISPATCH(), ( indices[i] )); } - GL_CALL(End)(); + CALL_End(GET_DISPATCH(), ()); } -- cgit v1.2.3