summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_save_loopback.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2005-07-18 12:31:24 +0000
committerIan Romanick <[email protected]>2005-07-18 12:31:24 +0000
commit9bdfee3a470a535ebe31074651fbacf680bcea6a (patch)
treefba4d709fc92d1afafdf77f0e9db9a82e1d52831 /src/mesa/tnl/t_save_loopback.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/tnl/t_save_loopback.c')
-rw-r--r--src/mesa/tnl/t_save_loopback.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/mesa/tnl/t_save_loopback.c b/src/mesa/tnl/t_save_loopback.c
index 2dae9c60932..7b2e4a43203 100644
--- a/src/mesa/tnl/t_save_loopback.c
+++ b/src/mesa/tnl/t_save_loopback.c
@@ -35,6 +35,7 @@
#include "mtypes.h"
#include "t_context.h"
#include "t_save_api.h"
+#include "dispatch.h"
/* If someone compiles a display list like:
* glBegin(Triangles)
@@ -70,22 +71,22 @@ typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * );
/* Wrapper functions in case glVertexAttrib*fvNV doesn't exist */
static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib1fvNV(target, v);
+ CALL_VertexAttrib1fvNV(ctx->Exec, (target, v));
}
static void VertexAttrib2fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib2fvNV(target, v);
+ CALL_VertexAttrib2fvNV(ctx->Exec, (target, v));
}
static void VertexAttrib3fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib3fvNV(target, v);
+ CALL_VertexAttrib3fvNV(ctx->Exec, (target, v));
}
static void VertexAttrib4fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib4fvNV(target, v);
+ CALL_VertexAttrib4fvNV(ctx->Exec, (target, v));
}
static attr_func vert_attrfunc[4] = {
@@ -98,22 +99,22 @@ static attr_func vert_attrfunc[4] = {
static void VertexAttrib1fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib1fvARB(target, v);
+ CALL_VertexAttrib1fvARB(ctx->Exec, (target, v));
}
static void VertexAttrib2fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib2fvARB(target, v);
+ CALL_VertexAttrib2fvARB(ctx->Exec, (target, v));
}
static void VertexAttrib3fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib3fvARB(target, v);
+ CALL_VertexAttrib3fvARB(ctx->Exec, (target, v));
}
static void VertexAttrib4fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
{
- ctx->Exec->VertexAttrib4fvARB(target, v);
+ CALL_VertexAttrib4fvARB(ctx->Exec, (target, v));
}
static attr_func vert_attrfunc_arb[4] = {
@@ -133,10 +134,10 @@ static void mat_attr1fv( GLcontext *ctx, GLint target, const GLfloat *v )
{
switch (target) {
case _TNL_ATTRIB_MAT_FRONT_SHININESS:
- ctx->Exec->Materialfv( GL_FRONT, GL_SHININESS, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SHININESS, v ));
break;
case _TNL_ATTRIB_MAT_BACK_SHININESS:
- ctx->Exec->Materialfv( GL_BACK, GL_SHININESS, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SHININESS, v ));
break;
}
}
@@ -146,10 +147,10 @@ static void mat_attr3fv( GLcontext *ctx, GLint target, const GLfloat *v )
{
switch (target) {
case _TNL_ATTRIB_MAT_FRONT_INDEXES:
- ctx->Exec->Materialfv( GL_FRONT, GL_COLOR_INDEXES, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_COLOR_INDEXES, v ));
break;
case _TNL_ATTRIB_MAT_BACK_INDEXES:
- ctx->Exec->Materialfv( GL_BACK, GL_COLOR_INDEXES, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_COLOR_INDEXES, v ));
break;
}
}
@@ -159,28 +160,28 @@ static void mat_attr4fv( GLcontext *ctx, GLint target, const GLfloat *v )
{
switch (target) {
case _TNL_ATTRIB_MAT_FRONT_EMISSION:
- ctx->Exec->Materialfv( GL_FRONT, GL_EMISSION, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_EMISSION, v ));
break;
case _TNL_ATTRIB_MAT_BACK_EMISSION:
- ctx->Exec->Materialfv( GL_BACK, GL_EMISSION, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_EMISSION, v ));
break;
case _TNL_ATTRIB_MAT_FRONT_AMBIENT:
- ctx->Exec->Materialfv( GL_FRONT, GL_AMBIENT, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_AMBIENT, v ));
break;
case _TNL_ATTRIB_MAT_BACK_AMBIENT:
- ctx->Exec->Materialfv( GL_BACK, GL_AMBIENT, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_AMBIENT, v ));
break;
case _TNL_ATTRIB_MAT_FRONT_DIFFUSE:
- ctx->Exec->Materialfv( GL_FRONT, GL_DIFFUSE, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_DIFFUSE, v ));
break;
case _TNL_ATTRIB_MAT_BACK_DIFFUSE:
- ctx->Exec->Materialfv( GL_BACK, GL_DIFFUSE, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_DIFFUSE, v ));
break;
case _TNL_ATTRIB_MAT_FRONT_SPECULAR:
- ctx->Exec->Materialfv( GL_FRONT, GL_SPECULAR, v );
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SPECULAR, v ));
break;
case _TNL_ATTRIB_MAT_BACK_SPECULAR:
- ctx->Exec->Materialfv( GL_BACK, GL_SPECULAR, v );
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SPECULAR, v ));
break;
}
}
@@ -197,13 +198,13 @@ static attr_func mat_attrfunc[4] = {
static void index_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
{
(void) target;
- ctx->Exec->Indexf(v[0]);
+ CALL_Indexf(ctx->Exec, (v[0]));
}
static void edgeflag_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
{
(void) target;
- ctx->Exec->EdgeFlag((GLboolean)(v[0] == 1.0));
+ CALL_EdgeFlag(ctx->Exec, ((GLboolean)(v[0] == 1.0)));
}
struct loopback_attr {
@@ -228,7 +229,7 @@ static void loopback_prim( GLcontext *ctx,
GLuint k;
if (prim->mode & PRIM_BEGIN) {
- GL_CALL(Begin)( prim->mode & PRIM_MODE_MASK );
+ CALL_Begin(GET_DISPATCH(), ( prim->mode & PRIM_MODE_MASK ));
}
else {
assert(i == 0);
@@ -253,7 +254,7 @@ static void loopback_prim( GLcontext *ctx,
}
if (prim->mode & PRIM_END) {
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
}
else {
assert (i == list->prim_count-1);