Browse Source

Support for swappable tnl modules.

Core Mesa provides a neutral tnl module that verifies the currently
module before installing the tnl function pointers in a lazy fashion.
It also records which tnl functions have been swapped out, and only
restores these when tnl modules themselves are swapped.

Fallback strategies:

Drivers set a bitmask of dangerous stage changes.  When such a state
change occurs, the driver should restore the neutral tnl module via
_mesa_restore_exec_vtxfmt().  The neutral tnl module will call
_mesa_update_state(), followed by ctx->Driver.ValidateTnlModule() if the
validation bitmask matches the new state bitmask.  The driver should
call _tnl_wakeup_exec() if it can no longer handle the current state,
which will revert to the default tnl module.  In this case, previous
vertices should be replayed as required (depending on the current
primitive) after the new tnl module is installed.

If the driver uses chooser functions for any part of the tnl module,
these should generally be reinstalled as part of the fallback to the
neutral tnl module.  For example, if the lighting state changes, a
driver might fall back to the neutral tnl module, verify that the
current lighting state can be handled, and use the chooser function to
pick the most efficient implementation of the current lighting state.

It is up to the drivers to detect and handle fallback cases caused by
tnl function calls themselves (such as glTexCoord4f* if the current tnl
module can't handle projected textures, for example).
tags/mesa_3_5
Gareth Hughes 24 years ago
parent
commit
d8aa0269cd

+ 27
- 27
src/mesa/drivers/common/t_dd_vertex.h View File

/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 3.5 * Version: 3.5
*
*
* Copyright (C) 1999 Brian Paul All Rights Reserved. * Copyright (C) 1999 Brian Paul All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL


#ifdef COLOR_IS_RGBA #ifdef COLOR_IS_RGBA
typedef struct { typedef struct {
GLubyte red;
GLubyte green;
GLubyte blue;
GLubyte alpha;
GLubyte red;
GLubyte green;
GLubyte blue;
GLubyte alpha;
} TAG(_color); } TAG(_color);
#else
#else
typedef struct { typedef struct {
GLubyte blue;
GLubyte green;
GLubyte red;
GLubyte alpha;
GLubyte blue;
GLubyte green;
GLubyte red;
GLubyte alpha;
} TAG(_color); } TAG(_color);
#endif #endif


typedef union { typedef union {
struct { struct {
float x, y, z, w;
GLfloat x, y, z, w;
TAG(_color) color; TAG(_color) color;
TAG(_color) specular; 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; } v;
struct { struct {
float x, y, z, w;
GLfloat x, y, z, w;
TAG(_color) color; TAG(_color) color;
TAG(_color) specular; 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; } pv;
struct { struct {
float x, y, z;
GLfloat x, y, z;
TAG(_color) color; TAG(_color) color;
} tv; } 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); } TAG(Vertex), *TAG(VertexPtr);

+ 5
- 2
src/mesa/main/colormac.h View File

/* $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 * Mesa 3-D graphics library
#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23)) #define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24)) #define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))


#define CHAN_TO_UBYTE(c) (c)
#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) #define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)


#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) #define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15)) #define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15))
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16)) #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 CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))


#define CLAMPED_FLOAT_TO_CHAN(c, f) \ #define CLAMPED_FLOAT_TO_CHAN(c, f) \
#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F))) #define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F)))
#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.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 CHAN_TO_FLOAT(c) (c)


#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) #define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)


#define CHAN_PRODUCT(a, b) ((a) * (b)) #define CHAN_PRODUCT(a, b) ((a) * (b))


#else
#else


#error unexpected CHAN_BITS size #error unexpected CHAN_BITS size



+ 5
- 1
src/mesa/main/context.c View File

/* $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 * Mesa 3-D graphics library
ctx->ExecPrefersFloat = GL_FALSE; ctx->ExecPrefersFloat = GL_FALSE;
ctx->SavePrefersFloat = GL_FALSE; ctx->SavePrefersFloat = GL_FALSE;


/* Neutral tnl module stuff */
ctx->TnlModule.Current = NULL;
ctx->TnlModule.SwapCount = 0;

/* Z buffer stuff */ /* Z buffer stuff */
if (ctx->Visual.depthBits == 0) { if (ctx->Visual.depthBits == 0) {
/* Special case. Even if we don't have a depth buffer we need /* Special case. Even if we don't have a depth buffer we need

+ 62
- 49
src/mesa/main/dd.h View File

/* $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 * Mesa 3-D graphics library
* Version: 3.5 * Version: 3.5
*
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* *
* Look below in the dd_function_table struct definition for descriptions * Look below in the dd_function_table struct definition for descriptions
* of each device driver function. * of each device driver function.
*
*
* More function pointers may be added as required. * More function pointers may be added as required.
* *
* *
typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2, typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
GLuint v3, GLuint v4 ); 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 ); GLuint flags );


typedef void (*interp_func)( GLcontext *ctx, typedef void (*interp_func)( GLcontext *ctx,
GLint x, GLint y, GLint width, GLint height ); GLint x, GLint y, GLint width, GLint height );
/* Clear the color/depth/stencil/accum buffer(s). /* Clear the color/depth/stencil/accum buffer(s).
* 'mask' is a bitmask of the DD_*_BIT values defined above that indicates * '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 * If 'all' is true then the clear the whole buffer, else clear only the
* region defined by (x,y,width,height). * region defined by (x,y,width,height).
* This function must obey the glColorMask, glIndexMask and glStencilMask * This function must obey the glColorMask, glIndexMask and glStencilMask
GLstencil stencil[] ); GLstencil stencil[] );
/* Read an array of stencil values from the stencil buffer. /* Read an array of stencil values from the stencil buffer.
*/ */


/*** /***
*** For hardware accumulation buffer: *** For hardware accumulation buffer:
* width, height, border and internalFormat information. * width, height, border and internalFormat information.
* The driver should use a fallback routine from texstore.c if needed. * The driver should use a fallback routine from texstore.c if needed.
*/ */
void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level, void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
GLenum internalFormat, GLint x, GLint y, GLenum internalFormat, GLint x, GLint y,
GLsizei width, GLint border ); GLsizei width, GLint border );
* should free anything attached to the DriverData pointers. * should free anything attached to the DriverData pointers.
*/ */


GLboolean (*IsTextureResident)( GLcontext *ctx,
GLboolean (*IsTextureResident)( GLcontext *ctx,
struct gl_texture_object *t ); struct gl_texture_object *t );
/* Called by glAreTextureResident(). /* Called by glAreTextureResident().
*/ */
void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask); void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
void (*StencilMask)(GLcontext *ctx, GLuint mask); void (*StencilMask)(GLcontext *ctx, GLuint mask);
void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass); 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); const GLfloat *params);
void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname, void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
const GLfloat *param); const GLfloat *param);
*** ***
*** Called by the corresponding OpenGL functions. *** 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); GLsizei stride, const GLvoid *ptr);
void (*NormalPointer)(GLcontext *ctx, GLenum type,
void (*NormalPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr); 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); GLsizei stride, const GLvoid *ptr);
void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr); GLsizei stride, const GLvoid *ptr);
void (*IndexPointer)(GLcontext *ctx, GLenum type,
void (*IndexPointer)(GLcontext *ctx, GLenum type,
GLsizei stride, const GLvoid *ptr); 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); 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); GLsizei stride, const GLvoid *ptr);
void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr); void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);


void (*ResetLineStipple)( GLcontext *ctx ); void (*ResetLineStipple)( GLcontext *ctx );
/* Reset the hardware's line stipple counter. /* Reset the hardware's line stipple counter.
*/ */
void (*BuildProjectedVertices)( GLcontext *ctx,
void (*BuildProjectedVertices)( GLcontext *ctx,
GLuint start, GLuint end, GLuint start, GLuint end,
GLuint new_inputs); GLuint new_inputs);
/* This function is called whenever new vertices are required for /* This function is called whenever new vertices are required for
* the vertex which need to be updated, if only a partial repair of * the vertex which need to be updated, if only a partial repair of
* the vertex is required. * 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.
*/ */




* when this function is called. This function will be called * when this function is called. This function will be called
* after the first pass, and passes will be made until the function * after the first pass, and passes will be made until the function
* returns GL_FALSE. If no function is registered, only one pass * returns GL_FALSE. If no function is registered, only one pass
* is made.
*
* is made.
*
* This function will be first invoked with passno == 1. * This function will be first invoked with passno == 1.
*/ */


/*** /***
*** Support for multiple t&l engines *** 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_OUTSIDE_BEGIN_END GL_POLYGON+1
#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2 #define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
#define PRIM_UNKNOWN GL_POLYGON+3 #define PRIM_UNKNOWN GL_POLYGON+3
GLuint CurrentExecPrimitive; GLuint CurrentExecPrimitive;
/* Set by the driver-supplied t&l engine. Set to /* 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; GLuint CurrentSavePrimitive;
* the additional values defined above. * the additional values defined above.
*/ */




#define FLUSH_STORED_VERTICES 0x1 #define FLUSH_STORED_VERTICES 0x1
#define FLUSH_UPDATE_CURRENT 0x2 #define FLUSH_UPDATE_CURRENT 0x2
/* Set by the driver-supplied t&l engine whenever vertices are /* Set by the driver-supplied t&l engine whenever vertices are
* buffered between begin/end objects or ctx->Current is not uptodate. * 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 ); 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_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 * and ctx->Light.Material
* *
* Note that the default t&l engine never clears the * Note that the default t&l engine never clears the


void (*LightingSpaceChange)( GLcontext *ctx ); void (*LightingSpaceChange)( GLcontext *ctx );
/* Notify driver that the special derived value _NeedEyeCoords has /* Notify driver that the special derived value _NeedEyeCoords has
* changed.
* changed.
*/ */


void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode ); void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
* Called by glCallList(s), but not recursively. * Called by glCallList(s), but not recursively.
*/ */


void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer ); GLframebuffer *readBuffer );
/* Let the t&l component know when the context becomes current. /* Let the t&l component know when the context becomes current.
*/ */
void (*FogCoordfvEXT)( const GLfloat * ); void (*FogCoordfvEXT)( const GLfloat * );
void (*Indexi)( GLint ); void (*Indexi)( GLint );
void (*Indexiv)( const 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 (*MultiTexCoord1fARB)( GLenum, GLfloat );
void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * ); void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * );
void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
void (*End)( void ); void (*End)( void );
/* Drivers present a reduced set of the functions possible in /* Drivers present a reduced set of the functions possible in
* begin/end objects. Core mesa provides translation stubs for the * 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 * These are the initial values to be installed into dispatch by
* mesa. If the t&l driver wants to modify the dispatch table * mesa. If the t&l driver wants to modify the dispatch table
* *
* If the driver wants to hook in entrypoints other than those * If the driver wants to hook in entrypoints other than those
* listed above, it must restore them to their original values in * 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 (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
/*
/*
*/ */



void (*DrawArrays)( GLenum mode, GLint start, GLsizei count ); 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 ); 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 /* These may or may not belong here. Heuristic: If an array is
* enabled, the installed vertex format should support that array and * enabled, the installed vertex format should support that array and
* it's current size natively. * it's current size natively.
* provide partial t&l acceleration. * provide partial t&l acceleration.
* *
* Mesa will provide a set of helper functions to do eval within * Mesa will provide a set of helper functions to do eval within
* accelerated vertex formats, eventually...
* accelerated vertex formats, eventually...
*/ */


GLboolean prefer_float_colors; GLboolean prefer_float_colors;
/* Should core try to send colors to glColor4f or glColor4chan, /* Should core try to send colors to glColor4f or glColor4chan,
* where it has a choice?
* where it has a choice?
*/ */


} GLvertexformat; } GLvertexformat;




#endif

#endif /* DD_INCLUDED */

+ 24
- 2
src/mesa/main/mtypes.h View File

/* $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 * Mesa 3-D graphics library







/* This has to be included here. */ /* This has to be included here. */
#include "dd.h" #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: * The library context:
*/ */
void *TraceCtx; void *TraceCtx;
#endif #endif


/* Core tnl module support */
struct gl_tnl_module TnlModule;

/* Hooks for module contexts. These will eventually live /* Hooks for module contexts. These will eventually live
* in the driver or elsewhere. * in the driver or elsewhere.
*/ */

+ 95
- 3
src/mesa/main/vtxfmt.c View File

/* $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 "glheader.h"
#include "api_loopback.h" #include "api_loopback.h"
#include "context.h"
#include "mtypes.h" #include "mtypes.h"
#include "vtxfmt.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 ) static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt )
{ {
tab->Vertex4fv = vfmt->Vertex4fv; tab->Vertex4fv = vfmt->Vertex4fv;
tab->Begin = vfmt->Begin; tab->Begin = vfmt->Begin;
tab->End = vfmt->End; tab->End = vfmt->End;
/* tab->NewList = vfmt->NewList; */ /* tab->NewList = vfmt->NewList; */
tab->CallList = vfmt->CallList; tab->CallList = vfmt->CallList;




void _mesa_install_exec_vtxfmt( GLcontext *ctx, 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) if (ctx->ExecPrefersFloat != vfmt->prefer_float_colors)
_mesa_loopback_prefer_float( ctx->Exec, vfmt->prefer_float_colors ); _mesa_loopback_prefer_float( ctx->Exec, vfmt->prefer_float_colors );
} }



void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ) void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt )
{ {
install_vtxfmt( ctx->Save, vfmt ); install_vtxfmt( ctx->Save, vfmt );
_mesa_loopback_prefer_float( ctx->Save, vfmt->prefer_float_colors ); _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;
}

+ 31
- 0
src/mesa/main/vtxfmt.h View File

/* $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_ #ifndef _VTXFMT_H_
#define _VTXFMT_H_ #define _VTXFMT_H_


extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ); extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt );
extern void _mesa_install_save_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 #endif

+ 2
- 2
src/mesa/main/vtxfmt_tmp.h View File

/* $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 * Mesa 3-D graphics library
static void TAG(FogCoordfEXT)( GLfloat a ) static void TAG(FogCoordfEXT)( GLfloat a )
{ {
PRE_LOOPBACK( FogCoordfEXT ); PRE_LOOPBACK( FogCoordfEXT );
glFogCordfEXT( a );
glFogCoordfEXT( a );
} }


static void TAG(FogCoordfvEXT)( const GLfloat *v ) static void TAG(FogCoordfvEXT)( const GLfloat *v )

+ 9
- 9
src/mesa/tnl/t_context.c View File

/* $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 * Mesa 3-D graphics library




void void
_tnl_MakeCurrent( GLcontext *ctx,
GLframebuffer *drawBuffer,
_tnl_MakeCurrent( GLcontext *ctx,
GLframebuffer *drawBuffer,
GLframebuffer *readBuffer ) GLframebuffer *readBuffer )
{ {
#ifndef THREADS #ifndef THREADS


/* Initialize the VB. /* Initialize the VB.
*/ */
tnl->vb.Size = MAX2( IMM_SIZE,
tnl->vb.Size = MAX2( IMM_SIZE,
ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES); ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES);








tnl->NeedProjCoords = GL_TRUE; tnl->NeedProjCoords = GL_TRUE;
/* Hook our functions into exec and compile dispatch tables. /* Hook our functions into exec and compile dispatch tables.
*/ */
_mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
} }


tnl->pipeline.run_state_changes |= 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->pipeline.build_state_trigger);


tnl->eval.EvalNewState |= new_state; tnl->eval.EvalNewState |= new_state;
_tnl_wakeup_exec( GLcontext *ctx ) _tnl_wakeup_exec( GLcontext *ctx )
{ {
TNLcontext *tnl = TNL_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx);
install_driver_callbacks(ctx); install_driver_callbacks(ctx);
ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;


/* Hook our functions into exec and compile dispatch tables. /* 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. /* Call all appropriate driver callbacks to revive state.
*/ */


/* Assume we haven't been getting state updates either: /* Assume we haven't been getting state updates either:
*/ */
_tnl_InvalidateState( ctx, ~0 );
_tnl_InvalidateState( ctx, ~0 );
tnl->pipeline.run_input_changes = ~0; tnl->pipeline.run_input_changes = ~0;
} }



Loading…
Cancel
Save