summaryrefslogtreecommitdiff
path: root/src/mesa/main/vtxfmt.c
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2005-07-18 12:31:24 +0000
committerIan Romanick <idr@us.ibm.com>2005-07-18 12:31:24 +0000
commit9bdfee3a470a535ebe31074651fbacf680bcea6a (patch)
treefba4d709fc92d1afafdf77f0e9db9a82e1d52831 /src/mesa/main/vtxfmt.c
parente0e993c5ff090058037875642dcd34727a3d8760 (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/main/vtxfmt.c')
-rw-r--r--src/mesa/main/vtxfmt.c144
1 files changed, 72 insertions, 72 deletions
diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c
index 1496fd1c00..0d285cb26c 100644
--- a/src/mesa/main/vtxfmt.c
+++ b/src/mesa/main/vtxfmt.c
@@ -56,7 +56,7 @@
\
/* Save the swapped function's dispatch entry so it can be */ \
/* restored later. */ \
- tnl->Swapped[tnl->SwapCount][0] = (void *)&(ctx->Exec->FUNC); \
+ tnl->Swapped[tnl->SwapCount][0] = (void *)&(GET_ ## FUNC (ctx->Exec)); \
*(func_ptr_t *)(tnl->Swapped[tnl->SwapCount]+1) = (func_ptr_t)TAG(FUNC); \
tnl->SwapCount++; \
\
@@ -64,7 +64,7 @@
_mesa_debug(ctx, " swapping gl" #FUNC"...\n" ); \
\
/* Install the tnl function pointer. */ \
- ctx->Exec->FUNC = tnl->Current->FUNC; \
+ SET_ ## FUNC(ctx->Exec, tnl->Current->FUNC); \
}
#define TAG(x) neutral_##x
@@ -75,76 +75,76 @@
static void
install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
{
- tab->ArrayElement = vfmt->ArrayElement;
- tab->Color3f = vfmt->Color3f;
- tab->Color3fv = vfmt->Color3fv;
- tab->Color4f = vfmt->Color4f;
- tab->Color4fv = vfmt->Color4fv;
- tab->EdgeFlag = vfmt->EdgeFlag;
- tab->EdgeFlagv = vfmt->EdgeFlagv;
- tab->EvalCoord1f = vfmt->EvalCoord1f;
- tab->EvalCoord1fv = vfmt->EvalCoord1fv;
- tab->EvalCoord2f = vfmt->EvalCoord2f;
- tab->EvalCoord2fv = vfmt->EvalCoord2fv;
- tab->EvalPoint1 = vfmt->EvalPoint1;
- tab->EvalPoint2 = vfmt->EvalPoint2;
- tab->FogCoordfEXT = vfmt->FogCoordfEXT;
- tab->FogCoordfvEXT = vfmt->FogCoordfvEXT;
- tab->Indexf = vfmt->Indexf;
- tab->Indexfv = vfmt->Indexfv;
- tab->Materialfv = vfmt->Materialfv;
- tab->MultiTexCoord1fARB = vfmt->MultiTexCoord1fARB;
- tab->MultiTexCoord1fvARB = vfmt->MultiTexCoord1fvARB;
- tab->MultiTexCoord2fARB = vfmt->MultiTexCoord2fARB;
- tab->MultiTexCoord2fvARB = vfmt->MultiTexCoord2fvARB;
- tab->MultiTexCoord3fARB = vfmt->MultiTexCoord3fARB;
- tab->MultiTexCoord3fvARB = vfmt->MultiTexCoord3fvARB;
- tab->MultiTexCoord4fARB = vfmt->MultiTexCoord4fARB;
- tab->MultiTexCoord4fvARB = vfmt->MultiTexCoord4fvARB;
- tab->Normal3f = vfmt->Normal3f;
- tab->Normal3fv = vfmt->Normal3fv;
- tab->SecondaryColor3fEXT = vfmt->SecondaryColor3fEXT;
- tab->SecondaryColor3fvEXT = vfmt->SecondaryColor3fvEXT;
- tab->TexCoord1f = vfmt->TexCoord1f;
- tab->TexCoord1fv = vfmt->TexCoord1fv;
- tab->TexCoord2f = vfmt->TexCoord2f;
- tab->TexCoord2fv = vfmt->TexCoord2fv;
- tab->TexCoord3f = vfmt->TexCoord3f;
- tab->TexCoord3fv = vfmt->TexCoord3fv;
- tab->TexCoord4f = vfmt->TexCoord4f;
- tab->TexCoord4fv = vfmt->TexCoord4fv;
- tab->Vertex2f = vfmt->Vertex2f;
- tab->Vertex2fv = vfmt->Vertex2fv;
- tab->Vertex3f = vfmt->Vertex3f;
- tab->Vertex3fv = vfmt->Vertex3fv;
- tab->Vertex4f = vfmt->Vertex4f;
- tab->Vertex4fv = vfmt->Vertex4fv;
- tab->CallList = vfmt->CallList;
- tab->CallLists = vfmt->CallLists;
- tab->Begin = vfmt->Begin;
- tab->End = vfmt->End;
- tab->VertexAttrib1fNV = vfmt->VertexAttrib1fNV;
- tab->VertexAttrib1fvNV = vfmt->VertexAttrib1fvNV;
- tab->VertexAttrib2fNV = vfmt->VertexAttrib2fNV;
- tab->VertexAttrib2fvNV = vfmt->VertexAttrib2fvNV;
- tab->VertexAttrib3fNV = vfmt->VertexAttrib3fNV;
- tab->VertexAttrib3fvNV = vfmt->VertexAttrib3fvNV;
- tab->VertexAttrib4fNV = vfmt->VertexAttrib4fNV;
- tab->VertexAttrib4fvNV = vfmt->VertexAttrib4fvNV;
- tab->VertexAttrib1fARB = vfmt->VertexAttrib1fARB;
- tab->VertexAttrib1fvARB = vfmt->VertexAttrib1fvARB;
- tab->VertexAttrib2fARB = vfmt->VertexAttrib2fARB;
- tab->VertexAttrib2fvARB = vfmt->VertexAttrib2fvARB;
- tab->VertexAttrib3fARB = vfmt->VertexAttrib3fARB;
- tab->VertexAttrib3fvARB = vfmt->VertexAttrib3fvARB;
- tab->VertexAttrib4fARB = vfmt->VertexAttrib4fARB;
- tab->VertexAttrib4fvARB = vfmt->VertexAttrib4fvARB;
- tab->Rectf = vfmt->Rectf;
- tab->DrawArrays = vfmt->DrawArrays;
- tab->DrawElements = vfmt->DrawElements;
- tab->DrawRangeElements = vfmt->DrawRangeElements;
- tab->EvalMesh1 = vfmt->EvalMesh1;
- tab->EvalMesh2 = vfmt->EvalMesh2;
+ SET_ArrayElement(tab, vfmt->ArrayElement);
+ SET_Color3f(tab, vfmt->Color3f);
+ SET_Color3fv(tab, vfmt->Color3fv);
+ SET_Color4f(tab, vfmt->Color4f);
+ SET_Color4fv(tab, vfmt->Color4fv);
+ SET_EdgeFlag(tab, vfmt->EdgeFlag);
+ SET_EdgeFlagv(tab, vfmt->EdgeFlagv);
+ SET_EvalCoord1f(tab, vfmt->EvalCoord1f);
+ SET_EvalCoord1fv(tab, vfmt->EvalCoord1fv);
+ SET_EvalCoord2f(tab, vfmt->EvalCoord2f);
+ SET_EvalCoord2fv(tab, vfmt->EvalCoord2fv);
+ SET_EvalPoint1(tab, vfmt->EvalPoint1);
+ SET_EvalPoint2(tab, vfmt->EvalPoint2);
+ SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT);
+ SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT);
+ SET_Indexf(tab, vfmt->Indexf);
+ SET_Indexfv(tab, vfmt->Indexfv);
+ SET_Materialfv(tab, vfmt->Materialfv);
+ SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB);
+ SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB);
+ SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB);
+ SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB);
+ SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB);
+ SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB);
+ SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB);
+ SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB);
+ SET_Normal3f(tab, vfmt->Normal3f);
+ SET_Normal3fv(tab, vfmt->Normal3fv);
+ SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT);
+ SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT);
+ SET_TexCoord1f(tab, vfmt->TexCoord1f);
+ SET_TexCoord1fv(tab, vfmt->TexCoord1fv);
+ SET_TexCoord2f(tab, vfmt->TexCoord2f);
+ SET_TexCoord2fv(tab, vfmt->TexCoord2fv);
+ SET_TexCoord3f(tab, vfmt->TexCoord3f);
+ SET_TexCoord3fv(tab, vfmt->TexCoord3fv);
+ SET_TexCoord4f(tab, vfmt->TexCoord4f);
+ SET_TexCoord4fv(tab, vfmt->TexCoord4fv);
+ SET_Vertex2f(tab, vfmt->Vertex2f);
+ SET_Vertex2fv(tab, vfmt->Vertex2fv);
+ SET_Vertex3f(tab, vfmt->Vertex3f);
+ SET_Vertex3fv(tab, vfmt->Vertex3fv);
+ SET_Vertex4f(tab, vfmt->Vertex4f);
+ SET_Vertex4fv(tab, vfmt->Vertex4fv);
+ SET_CallList(tab, vfmt->CallList);
+ SET_CallLists(tab, vfmt->CallLists);
+ SET_Begin(tab, vfmt->Begin);
+ SET_End(tab, vfmt->End);
+ SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
+ SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV);
+ SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV);
+ SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV);
+ SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV);
+ SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV);
+ SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV);
+ SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV);
+ SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB);
+ SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB);
+ SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB);
+ SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB);
+ SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB);
+ SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB);
+ SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB);
+ SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB);
+ SET_Rectf(tab, vfmt->Rectf);
+ SET_DrawArrays(tab, vfmt->DrawArrays);
+ SET_DrawElements(tab, vfmt->DrawElements);
+ SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
+ SET_EvalMesh1(tab, vfmt->EvalMesh1);
+ SET_EvalMesh2(tab, vfmt->EvalMesh2);
ASSERT(tab->EvalMesh2);
}