summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/t_dd_vertex.h54
-rw-r--r--src/mesa/main/colormac.h7
-rw-r--r--src/mesa/main/context.c6
-rw-r--r--src/mesa/main/dd.h111
-rw-r--r--src/mesa/main/mtypes.h26
-rw-r--r--src/mesa/main/vtxfmt.c98
-rw-r--r--src/mesa/main/vtxfmt.h31
-rw-r--r--src/mesa/main/vtxfmt_tmp.h4
-rw-r--r--src/mesa/tnl/t_context.c18
9 files changed, 260 insertions, 95 deletions
diff --git a/src/mesa/drivers/common/t_dd_vertex.h b/src/mesa/drivers/common/t_dd_vertex.h
index 7bc10e9457..61c69b8719 100644
--- a/src/mesa/drivers/common/t_dd_vertex.h
+++ b/src/mesa/drivers/common/t_dd_vertex.h
@@ -1,19 +1,19 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
- *
+ *
* Copyright (C) 1999 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -27,44 +27,44 @@
#ifdef COLOR_IS_RGBA
typedef struct {
- GLubyte red;
- GLubyte green;
- GLubyte blue;
- GLubyte alpha;
+ GLubyte red;
+ GLubyte green;
+ GLubyte blue;
+ GLubyte alpha;
} TAG(_color);
-#else
+#else
typedef struct {
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
+ GLubyte blue;
+ GLubyte green;
+ GLubyte red;
+ GLubyte alpha;
} TAG(_color);
#endif
typedef union {
struct {
- float x, y, z, w;
+ GLfloat x, y, z, w;
TAG(_color) color;
TAG(_color) specular;
- float u0, v0;
- float u1, v1;
- float u2, v2;
- float u3, v3;
+ GLfloat u0, v0;
+ GLfloat u1, v1;
+ GLfloat u2, v2;
+ GLfloat u3, v3;
} v;
struct {
- float x, y, z, w;
+ GLfloat x, y, z, w;
TAG(_color) color;
TAG(_color) specular;
- float u0, v0, q0;
- float u1, v1, q1;
- float u2, v2, q2;
- float u3, v3, q3;
+ GLfloat u0, v0, q0;
+ GLfloat u1, v1, q1;
+ GLfloat u2, v2, q2;
+ GLfloat u3, v3, q3;
} pv;
struct {
- float x, y, z;
+ GLfloat x, y, z;
TAG(_color) color;
} tv;
- float f[16];
- unsigned int ui[16];
- unsigned char ub4[16][4];
+ GLfloat f[24];
+ GLuint ui[24];
+ GLubyte ub4[24][4];
} TAG(Vertex), *TAG(VertexPtr);
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index c5c129eaa4..0812a51704 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,4 +1,4 @@
-/* $Id: colormac.h,v 1.8 2001/03/08 15:23:46 brianp Exp $ */
+/* $Id: colormac.h,v 1.9 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -51,6 +51,7 @@
#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
+#define CHAN_TO_UBYTE(c) (c)
#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
@@ -70,6 +71,7 @@
#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15))
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
+#define CHAN_TO_UBYTE(c) ((c) >> 8)
#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))
#define CLAMPED_FLOAT_TO_CHAN(c, f) \
@@ -92,6 +94,7 @@
#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F)))
#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
+#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c)
#define CHAN_TO_FLOAT(c) (c)
#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
@@ -101,7 +104,7 @@
#define CHAN_PRODUCT(a, b) ((a) * (b))
-#else
+#else
#error unexpected CHAN_BITS size
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 85a437947a..cfd0fcb927 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.125 2001/03/03 20:33:27 brianp Exp $ */
+/* $Id: context.c,v 1.126 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -1435,6 +1435,10 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->ExecPrefersFloat = GL_FALSE;
ctx->SavePrefersFloat = GL_FALSE;
+ /* Neutral tnl module stuff */
+ ctx->TnlModule.Current = NULL;
+ ctx->TnlModule.SwapCount = 0;
+
/* Z buffer stuff */
if (ctx->Visual.depthBits == 0) {
/* Special case. Even if we don't have a depth buffer we need
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 35f122415f..4f4cff7556 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,21 +1,21 @@
-/* $Id: dd.h,v 1.56 2001/03/07 00:21:32 brianp Exp $ */
+/* $Id: dd.h,v 1.57 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -75,7 +75,7 @@ struct gl_pixelstore_attrib;
*
* Look below in the dd_function_table struct definition for descriptions
* of each device driver function.
- *
+ *
* More function pointers may be added as required.
*
*
@@ -130,7 +130,7 @@ typedef void (*triangle_func)( GLcontext *ctx,
typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
GLuint v3, GLuint v4 );
-typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
+typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
GLuint flags );
typedef void (*interp_func)( GLcontext *ctx,
@@ -167,7 +167,7 @@ struct dd_function_table {
GLint x, GLint y, GLint width, GLint height );
/* Clear the color/depth/stencil/accum buffer(s).
* 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
- * which buffers need to be cleared.
+ * which buffers need to be cleared.
* If 'all' is true then the clear the whole buffer, else clear only the
* region defined by (x,y,width,height).
* This function must obey the glColorMask, glIndexMask and glStencilMask
@@ -390,7 +390,7 @@ struct dd_function_table {
GLstencil stencil[] );
/* Read an array of stencil values from the stencil buffer.
*/
-
+
/***
*** For hardware accumulation buffer:
@@ -509,7 +509,7 @@ struct dd_function_table {
* width, height, border and internalFormat information.
* The driver should use a fallback routine from texstore.c if needed.
*/
-
+
void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
GLenum internalFormat, GLint x, GLint y,
GLsizei width, GLint border );
@@ -688,7 +688,7 @@ struct dd_function_table {
* should free anything attached to the DriverData pointers.
*/
- GLboolean (*IsTextureResident)( GLcontext *ctx,
+ GLboolean (*IsTextureResident)( GLcontext *ctx,
struct gl_texture_object *t );
/* Called by glAreTextureResident().
*/
@@ -757,7 +757,7 @@ struct dd_function_table {
void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
void (*StencilMask)(GLcontext *ctx, GLuint mask);
void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
- void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
+ void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
const GLfloat *params);
void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
const GLfloat *param);
@@ -784,19 +784,19 @@ struct dd_function_table {
***
*** Called by the corresponding OpenGL functions.
***/
- void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
+ void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*NormalPointer)(GLcontext *ctx, GLenum type,
+ void (*NormalPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
+ void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*IndexPointer)(GLcontext *ctx, GLenum type,
+ void (*IndexPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
- void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
+ void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
@@ -857,8 +857,8 @@ struct dd_function_table {
void (*ResetLineStipple)( GLcontext *ctx );
/* Reset the hardware's line stipple counter.
*/
-
- void (*BuildProjectedVertices)( GLcontext *ctx,
+
+ void (*BuildProjectedVertices)( GLcontext *ctx,
GLuint start, GLuint end,
GLuint new_inputs);
/* This function is called whenever new vertices are required for
@@ -867,7 +867,7 @@ struct dd_function_table {
* the vertex which need to be updated, if only a partial repair of
* the vertex is required.
*
- * This function is called only from _tnl_render_stage in tnl/t_render.c.
+ * This function is called only from _tnl_render_stage in tnl/t_render.c.
*/
@@ -876,8 +876,8 @@ struct dd_function_table {
* when this function is called. This function will be called
* after the first pass, and passes will be made until the function
* returns GL_FALSE. If no function is registered, only one pass
- * is made.
- *
+ * is made.
+ *
* This function will be first invoked with passno == 1.
*/
@@ -885,13 +885,31 @@ struct dd_function_table {
/***
*** Support for multiple t&l engines
***/
+
+ GLuint NeedValidate;
+ /* Bitmask of state changes that require the current tnl module to be
+ * validated, using ValidateTnlModule() below.
+ */
+
+ void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state );
+ /* Validate the current tnl module. This is called directly after
+ * UpdateState() when a state change that has occured matches the
+ * NeedValidate bitmask above. This ensures all computed values are
+ * up to date, thus allowing the driver to decide if the current tnl
+ * module needs to be swapped out.
+ *
+ * This must be non-NULL if a driver installs a custom tnl module and
+ * sets the NeedValidate bitmask, but may be NULL otherwise.
+ */
+
+
#define PRIM_OUTSIDE_BEGIN_END GL_POLYGON+1
#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
#define PRIM_UNKNOWN GL_POLYGON+3
-
+
GLuint CurrentExecPrimitive;
/* Set by the driver-supplied t&l engine. Set to
- * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
+ * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
*/
GLuint CurrentSavePrimitive;
@@ -899,7 +917,6 @@ struct dd_function_table {
* the additional values defined above.
*/
-
#define FLUSH_STORED_VERTICES 0x1
#define FLUSH_UPDATE_CURRENT 0x2
@@ -907,15 +924,15 @@ struct dd_function_table {
/* Set by the driver-supplied t&l engine whenever vertices are
* buffered between begin/end objects or ctx->Current is not uptodate.
*
- * The FlushVertices() call below may be used to resolve
- * these conditions.
+ * The FlushVertices() call below may be used to resolve
+ * these conditions.
*/
void (*FlushVertices)( GLcontext *ctx, GLuint flags );
- /* If inside begin/end, ASSERT(0).
- * Otherwise,
+ /* If inside begin/end, ASSERT(0).
+ * Otherwise,
* if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
- * if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
+ * if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
* and ctx->Light.Material
*
* Note that the default t&l engine never clears the
@@ -924,7 +941,7 @@ struct dd_function_table {
void (*LightingSpaceChange)( GLcontext *ctx );
/* Notify driver that the special derived value _NeedEyeCoords has
- * changed.
+ * changed.
*/
void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
@@ -940,7 +957,7 @@ struct dd_function_table {
* Called by glCallList(s), but not recursively.
*/
- void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
+ void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer );
/* Let the t&l component know when the context becomes current.
*/
@@ -980,7 +997,7 @@ typedef struct {
void (*FogCoordfvEXT)( const GLfloat * );
void (*Indexi)( GLint );
void (*Indexiv)( const GLint * );
- void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
+ void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
void (*MultiTexCoord1fARB)( GLenum, GLfloat );
void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * );
void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
@@ -1014,7 +1031,7 @@ typedef struct {
void (*End)( void );
/* Drivers present a reduced set of the functions possible in
* begin/end objects. Core mesa provides translation stubs for the
- * remaining functions to map down to these entrypoints.
+ * remaining functions to map down to these entrypoints.
*
* These are the initial values to be installed into dispatch by
* mesa. If the t&l driver wants to modify the dispatch table
@@ -1025,20 +1042,19 @@ typedef struct {
*
* If the driver wants to hook in entrypoints other than those
* listed above, it must restore them to their original values in
- * the disable() callback, below.
+ * the disable() callback, below.
*/
void (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
- /*
+ /*
*/
-
void (*DrawArrays)( GLenum mode, GLint start, GLsizei count );
- void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
+ void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices );
- void (*DrawRangeElements)(GLenum mode, GLuint start,
- GLuint end, GLsizei count,
- GLenum type, const GLvoid *indices);
+ void (*DrawRangeElements)( GLenum mode, GLuint start,
+ GLuint end, GLsizei count,
+ GLenum type, const GLvoid *indices );
/* These may or may not belong here. Heuristic: If an array is
* enabled, the installed vertex format should support that array and
* it's current size natively.
@@ -1051,17 +1067,14 @@ typedef struct {
* provide partial t&l acceleration.
*
* Mesa will provide a set of helper functions to do eval within
- * accelerated vertex formats, eventually...
+ * accelerated vertex formats, eventually...
*/
GLboolean prefer_float_colors;
/* Should core try to send colors to glColor4f or glColor4chan,
- * where it has a choice?
+ * where it has a choice?
*/
-
-
} GLvertexformat;
-#endif
-
+#endif /* DD_INCLUDED */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c40049d462..1ee63f89ad 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.23 2001/03/03 20:33:27 brianp Exp $ */
+/* $Id: mtypes.h,v 1.24 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -1399,11 +1399,30 @@ typedef union node Node;
-
/* This has to be included here. */
#include "dd.h"
+
+
+/*
+ * Core Mesa's support for tnl modules:
+ */
+#define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
+
+struct gl_tnl_module {
+ /* Vertex format to be lazily swapped into current dispatch.
+ */
+ GLvertexformat *Current;
+
+ /* Record of functions swapped out. On restore, only need to swap
+ * these functions back in.
+ */
+ void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
+ GLuint SwapCount;
+};
+
+
/*
* The library context:
*/
@@ -1574,6 +1593,9 @@ struct __GLcontextRec {
void *TraceCtx;
#endif
+ /* Core tnl module support */
+ struct gl_tnl_module TnlModule;
+
/* Hooks for module contexts. These will eventually live
* in the driver or elsewhere.
*/
diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c
index 860a9011fe..22685e0f37 100644
--- a/src/mesa/main/vtxfmt.c
+++ b/src/mesa/main/vtxfmt.c
@@ -1,9 +1,86 @@
+/* $Id: vtxfmt.c,v 1.2 2001/03/11 18:49:11 gareth Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <keithw@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
#include "glheader.h"
#include "api_loopback.h"
+#include "context.h"
#include "mtypes.h"
#include "vtxfmt.h"
+/* The neutral vertex format. This wraps all tnl module functions,
+ * verifying that the currently-installed module is valid and then
+ * installing the function pointers in a lazy fashion. It records the
+ * function pointers that have been swapped out, which allows a fast
+ * restoration of the neutral module in almost all cases -- a typical
+ * app might only require 4-6 functions to be modified from the neutral
+ * baseline, and only restoring these is certainly preferable to doing
+ * the entire module's 60 or so function pointers.
+ */
+
+#define PRE_LOOPBACK( FUNC ) \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ struct gl_tnl_module *tnl = &(ctx->TnlModule); \
+ const GLuint new_state = ctx->NewState; \
+ \
+ if ( new_state ) \
+ _mesa_update_state( ctx ); \
+ \
+ /* Validate the current tnl module. \
+ */ \
+ if ( new_state & ctx->Driver.NeedValidate ) \
+ ctx->Driver.ValidateTnlModule( ctx, new_state ); \
+ \
+ ASSERT( tnl->Current ); \
+ ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \
+ \
+ /* 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][1] = (void *)TAG(FUNC); \
+ tnl->SwapCount++; \
+ \
+ if ( 0 ) \
+ fprintf( stderr, " swapping gl" #FUNC"...\n" ); \
+ \
+ /* Install the tnl function pointer. \
+ */ \
+ ctx->Exec->FUNC = tnl->Current->FUNC; \
+}
+
+#define TAG(x) neutral_##x
+#include "vtxfmt_tmp.h"
+
+
static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt )
{
@@ -59,7 +136,7 @@ static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt )
tab->Vertex4fv = vfmt->Vertex4fv;
tab->Begin = vfmt->Begin;
tab->End = vfmt->End;
-
+
/* tab->NewList = vfmt->NewList; */
tab->CallList = vfmt->CallList;
@@ -74,12 +151,12 @@ static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt )
void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt )
{
- install_vtxfmt( ctx->Exec, vfmt );
+ ctx->TnlModule.Current = vfmt;
+ install_vtxfmt( ctx->Exec, &neutral_vtxfmt );
if (ctx->ExecPrefersFloat != vfmt->prefer_float_colors)
_mesa_loopback_prefer_float( ctx->Exec, vfmt->prefer_float_colors );
}
-
void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt )
{
install_vtxfmt( ctx->Save, vfmt );
@@ -87,3 +164,18 @@ void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt )
_mesa_loopback_prefer_float( ctx->Save, vfmt->prefer_float_colors );
}
+void _mesa_restore_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt )
+{
+ struct gl_tnl_module *tnl = &(ctx->TnlModule);
+ GLuint i;
+
+ tnl->Current = vfmt;
+
+ /* Restore the neutral tnl module wrapper.
+ */
+ for ( i = 0 ; i < tnl->SwapCount ; i++ ) {
+ *(void **)tnl->Swapped[i][0] = tnl->Swapped[i][1];
+ }
+
+ tnl->SwapCount = 0;
+}
diff --git a/src/mesa/main/vtxfmt.h b/src/mesa/main/vtxfmt.h
index 6abeadfcde..af80ada7a4 100644
--- a/src/mesa/main/vtxfmt.h
+++ b/src/mesa/main/vtxfmt.h
@@ -1,8 +1,39 @@
+/* $Id: vtxfmt.h,v 1.2 2001/03/11 18:49:11 gareth Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <keithw@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
#ifndef _VTXFMT_H_
#define _VTXFMT_H_
extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt );
extern void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt );
+extern void _mesa_restore_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt );
#endif
diff --git a/src/mesa/main/vtxfmt_tmp.h b/src/mesa/main/vtxfmt_tmp.h
index 1f6c7671e3..faea1d48c6 100644
--- a/src/mesa/main/vtxfmt_tmp.h
+++ b/src/mesa/main/vtxfmt_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: vtxfmt_tmp.h,v 1.2 2001/03/10 02:50:42 gareth Exp $ */
+/* $Id: vtxfmt_tmp.h,v 1.3 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -136,7 +136,7 @@ static void TAG(EvalPoint2)( GLint a, GLint b )
static void TAG(FogCoordfEXT)( GLfloat a )
{
PRE_LOOPBACK( FogCoordfEXT );
- glFogCordfEXT( a );
+ glFogCoordfEXT( a );
}
static void TAG(FogCoordfvEXT)( const GLfloat *v )
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 71bbfd64f9..7e359bfd20 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,4 +1,4 @@
-/* $Id: t_context.c,v 1.12 2001/03/07 05:06:13 brianp Exp $ */
+/* $Id: t_context.c,v 1.13 2001/03/11 18:49:11 gareth Exp $ */
/*
* Mesa 3-D graphics library
@@ -51,8 +51,8 @@ struct immediate *_tnl_CurrentInput = NULL;
void
-_tnl_MakeCurrent( GLcontext *ctx,
- GLframebuffer *drawBuffer,
+_tnl_MakeCurrent( GLcontext *ctx,
+ GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
#ifndef THREADS
@@ -92,7 +92,7 @@ _tnl_CreateContext( GLcontext *ctx )
/* Initialize the VB.
*/
- tnl->vb.Size = MAX2( IMM_SIZE,
+ tnl->vb.Size = MAX2( IMM_SIZE,
ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES);
@@ -106,7 +106,7 @@ _tnl_CreateContext( GLcontext *ctx )
tnl->NeedProjCoords = GL_TRUE;
-
+
/* Hook our functions into exec and compile dispatch tables.
*/
_mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
@@ -157,7 +157,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
}
tnl->pipeline.run_state_changes |= new_state;
- tnl->pipeline.build_state_changes |= (new_state &
+ tnl->pipeline.build_state_changes |= (new_state &
tnl->pipeline.build_state_trigger);
tnl->eval.EvalNewState |= new_state;
@@ -168,13 +168,13 @@ void
_tnl_wakeup_exec( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
-
+
install_driver_callbacks(ctx);
ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
/* Hook our functions into exec and compile dispatch tables.
*/
- _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
+ _mesa_restore_exec_vtxfmt( ctx, &tnl->vtxfmt );
/* Call all appropriate driver callbacks to revive state.
*/
@@ -182,7 +182,7 @@ _tnl_wakeup_exec( GLcontext *ctx )
/* Assume we haven't been getting state updates either:
*/
- _tnl_InvalidateState( ctx, ~0 );
+ _tnl_InvalidateState( ctx, ~0 );
tnl->pipeline.run_input_changes = ~0;
}