summaryrefslogtreecommitdiff
path: root/src/mesa/main/api_noop.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/api_noop.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/api_noop.c')
-rw-r--r--src/mesa/main/api_noop.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c
index d3496ff59f..f42f166ae3 100644
--- a/src/mesa/main/api_noop.c
+++ b/src/mesa/main/api_noop.c
@@ -33,6 +33,7 @@
#include "macros.h"
#include "mtypes.h"
#include "dlist.h"
+#include "dispatch.h"
/* In states where certain vertex components are required for t&l or
@@ -685,12 +686,12 @@ void GLAPIENTRY _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2
ASSERT_OUTSIDE_BEGIN_END(ctx);
}
- GL_CALL(Begin)( GL_QUADS );
- GL_CALL(Vertex2f)( x1, y1 );
- GL_CALL(Vertex2f)( x2, y1 );
- GL_CALL(Vertex2f)( x2, y2 );
- GL_CALL(Vertex2f)( x1, y2 );
- GL_CALL(End)();
+ CALL_Begin(GET_DISPATCH(), (GL_QUADS));
+ 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(), ());
}
@@ -706,10 +707,10 @@ void GLAPIENTRY _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
return;
- 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(), ());
}
@@ -722,27 +723,27 @@ void GLAPIENTRY _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
return;
- GL_CALL(Begin)(mode);
+ CALL_Begin(GET_DISPATCH(), (mode));
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(), ());
}
void GLAPIENTRY _mesa_noop_DrawRangeElements(GLenum mode,
@@ -755,7 +756,7 @@ void GLAPIENTRY _mesa_noop_DrawRangeElements(GLenum mode,
if (_mesa_validate_DrawRangeElements( ctx, mode,
start, end,
count, type, indices ))
- GL_CALL(DrawElements)( mode, count, type, indices );
+ CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices));
}
/*
@@ -800,11 +801,11 @@ void GLAPIENTRY _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
du = ctx->Eval.MapGrid1du;
u = ctx->Eval.MapGrid1u1 + i1 * du;
- GL_CALL(Begin)( prim );
+ CALL_Begin(GET_DISPATCH(), (prim));
for (i=i1;i<=i2;i++,u+=du) {
- GL_CALL(EvalCoord1f)( u );
+ CALL_EvalCoord1f(GET_DISPATCH(), (u));
}
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
}
@@ -839,38 +840,38 @@ void GLAPIENTRY _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1,
switch (mode) {
case GL_POINT:
- GL_CALL(Begin)( GL_POINTS );
+ CALL_Begin(GET_DISPATCH(), (GL_POINTS));
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
for (u=u1,i=i1;i<=i2;i++,u+=du) {
- GL_CALL(EvalCoord2f)(u, v );
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
}
}
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
break;
case GL_LINE:
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- GL_CALL(Begin)( GL_LINE_STRIP );
+ CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
for (u=u1,i=i1;i<=i2;i++,u+=du) {
- GL_CALL(EvalCoord2f)(u, v );
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
}
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
}
for (u=u1,i=i1;i<=i2;i++,u+=du) {
- GL_CALL(Begin)( GL_LINE_STRIP );
+ CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- GL_CALL(EvalCoord2f)(u, v );
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
}
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
}
break;
case GL_FILL:
for (v=v1,j=j1;j<j2;j++,v+=dv) {
- GL_CALL(Begin)( GL_TRIANGLE_STRIP );
+ CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP));
for (u=u1,i=i1;i<=i2;i++,u+=du) {
- GL_CALL(EvalCoord2f)(u, v );
- GL_CALL(EvalCoord2f)(u, v+dv );
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv));
}
- GL_CALL(End)();
+ CALL_End(GET_DISPATCH(), ());
}
break;
default: