Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

mtypes.h

Go to the documentation of this file.
/**
 * \file mtypes.h
 * Main Mesa data structures.
 *
 * Please try to mark derived values with a leading underscore ('_').
 */

/*
 * Mesa 3-D graphics library
 * Version:  6.5.3
 *
 * Copyright (C) 1999-2007  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.
 */



#ifndef TYPES_H
#define TYPES_H


#include "glheader.h"
#include <GL/internal/glcore.h>     /* __GLcontextModes (GLvisual) */
#include "config.h"           /* Hardwired parameters */
#include "glapi/glapitable.h"
#include "glapi/glthread.h"
#include "math/m_matrix.h"    /* GLmatrix */
#include "bitset.h"


/**
 * Special, internal token
 */
00050 #define GL_SHADER_PROGRAM_MESA 0x9999


/**
 * Color channel data type.
 */
#if CHAN_BITS == 8
00057    typedef GLubyte GLchan;
#define CHAN_MAX 255
#define CHAN_MAXF 255.0F
#define CHAN_TYPE GL_UNSIGNED_BYTE
#elif CHAN_BITS == 16
   typedef GLushort GLchan;
#define CHAN_MAX 65535
#define CHAN_MAXF 65535.0F
#define CHAN_TYPE GL_UNSIGNED_SHORT
#elif CHAN_BITS == 32
   typedef GLfloat GLchan;
#define CHAN_MAX 1.0
#define CHAN_MAXF 1.0F
#define CHAN_TYPE GL_FLOAT
#else
#error "illegal number of color channel bits"
#endif


/**
 * Stencil buffer data type.
 */
#if STENCIL_BITS==8
00080    typedef GLubyte GLstencil;
#elif STENCIL_BITS==16
   typedef GLushort GLstencil;
#else
#  error "illegal number of stencil bits"
#endif


/**
 * Fixed point data type.
 */
00091 typedef int GLfixed;
/*
 * Fixed point arithmetic macros
 */
#ifndef FIXED_FRAC_BITS
#define FIXED_FRAC_BITS 11
#endif

#define FIXED_SHIFT     FIXED_FRAC_BITS
#define FIXED_ONE       (1 << FIXED_SHIFT)
#define FIXED_HALF      (1 << (FIXED_SHIFT-1))
#define FIXED_FRAC_MASK (FIXED_ONE - 1)
#define FIXED_INT_MASK  (~FIXED_FRAC_MASK)
#define FIXED_EPSILON   1
#define FIXED_SCALE     ((float) FIXED_ONE)
#define FIXED_DBL_SCALE ((double) FIXED_ONE)
#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
#define IntToFixed(I)   ((I) << FIXED_SHIFT)
#define FixedToInt(X)   ((X) >> FIXED_SHIFT)
#define FixedToUns(X)   (((unsigned int)(X)) >> FIXED_SHIFT)
#define FixedCeil(X)    (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
#define FixedFloor(X)   ((X) & FIXED_INT_MASK)
#define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
#define PosFloatToFixed(X)      FloatToFixed(X)
#define SignedFloatToFixed(X)   FloatToFixed(X)



/**
 * \name Some forward type declarations
 */
/*@{*/
struct _mesa_HashTable;
struct gl_pixelstore_attrib;
struct gl_texture_format;
struct gl_texture_image;
struct gl_texture_object;
typedef struct __GLcontextRec GLcontext;
typedef struct __GLcontextModesRec GLvisual;
typedef struct gl_framebuffer GLframebuffer;
/*@}*/



/**
 * Indexes for vertex program attributes.
 * GL_NV_vertex_program aliases generic attributes over the conventional
 * attributes.  In GL_ARB_vertex_program shader the aliasing is optional.
 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
 * generic attributes are distinct/separate).
 */
enum
{
   VERT_ATTRIB_POS = 0,
   VERT_ATTRIB_WEIGHT = 1,
   VERT_ATTRIB_NORMAL = 2,
   VERT_ATTRIB_COLOR0 = 3,
   VERT_ATTRIB_COLOR1 = 4,
   VERT_ATTRIB_FOG = 5,
   VERT_ATTRIB_COLOR_INDEX = 6,
   VERT_ATTRIB_EDGEFLAG = 7,
   VERT_ATTRIB_TEX0 = 8,
   VERT_ATTRIB_TEX1 = 9,
   VERT_ATTRIB_TEX2 = 10,
   VERT_ATTRIB_TEX3 = 11,
   VERT_ATTRIB_TEX4 = 12,
   VERT_ATTRIB_TEX5 = 13,
   VERT_ATTRIB_TEX6 = 14,
   VERT_ATTRIB_TEX7 = 15,
   VERT_ATTRIB_GENERIC0 = 16,
   VERT_ATTRIB_GENERIC1 = 17,
   VERT_ATTRIB_GENERIC2 = 18,
   VERT_ATTRIB_GENERIC3 = 19,
   VERT_ATTRIB_GENERIC4 = 20,
   VERT_ATTRIB_GENERIC5 = 21,
   VERT_ATTRIB_GENERIC6 = 22,
   VERT_ATTRIB_GENERIC7 = 23,
   VERT_ATTRIB_GENERIC8 = 24,
   VERT_ATTRIB_GENERIC9 = 25,
   VERT_ATTRIB_GENERIC10 = 26,
   VERT_ATTRIB_GENERIC11 = 27,
   VERT_ATTRIB_GENERIC12 = 28,
   VERT_ATTRIB_GENERIC13 = 29,
   VERT_ATTRIB_GENERIC14 = 30,
   VERT_ATTRIB_GENERIC15 = 31,
   VERT_ATTRIB_MAX = 32
};

/**
 * Bitflags for vertex attributes.
 * These are used in bitfields in many places.
 */
/*@{*/
00185 #define VERT_BIT_POS         (1 << VERT_ATTRIB_POS)
#define VERT_BIT_WEIGHT      (1 << VERT_ATTRIB_WEIGHT)
#define VERT_BIT_NORMAL      (1 << VERT_ATTRIB_NORMAL)
#define VERT_BIT_COLOR0      (1 << VERT_ATTRIB_COLOR0)
#define VERT_BIT_COLOR1      (1 << VERT_ATTRIB_COLOR1)
#define VERT_BIT_FOG         (1 << VERT_ATTRIB_FOG)
#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
#define VERT_BIT_EDGEFLAG    (1 << VERT_ATTRIB_EDGEFLAG)
#define VERT_BIT_TEX0        (1 << VERT_ATTRIB_TEX0)
#define VERT_BIT_TEX1        (1 << VERT_ATTRIB_TEX1)
#define VERT_BIT_TEX2        (1 << VERT_ATTRIB_TEX2)
#define VERT_BIT_TEX3        (1 << VERT_ATTRIB_TEX3)
#define VERT_BIT_TEX4        (1 << VERT_ATTRIB_TEX4)
#define VERT_BIT_TEX5        (1 << VERT_ATTRIB_TEX5)
#define VERT_BIT_TEX6        (1 << VERT_ATTRIB_TEX6)
#define VERT_BIT_TEX7        (1 << VERT_ATTRIB_TEX7)
#define VERT_BIT_GENERIC0    (1 << VERT_ATTRIB_GENERIC0)
#define VERT_BIT_GENERIC1    (1 << VERT_ATTRIB_GENERIC1)
#define VERT_BIT_GENERIC2    (1 << VERT_ATTRIB_GENERIC2)
#define VERT_BIT_GENERIC3    (1 << VERT_ATTRIB_GENERIC3)
#define VERT_BIT_GENERIC4    (1 << VERT_ATTRIB_GENERIC4)
#define VERT_BIT_GENERIC5    (1 << VERT_ATTRIB_GENERIC5)
#define VERT_BIT_GENERIC6    (1 << VERT_ATTRIB_GENERIC6)
#define VERT_BIT_GENERIC7    (1 << VERT_ATTRIB_GENERIC7)
#define VERT_BIT_GENERIC8    (1 << VERT_ATTRIB_GENERIC8)
#define VERT_BIT_GENERIC9    (1 << VERT_ATTRIB_GENERIC9)
#define VERT_BIT_GENERIC10   (1 << VERT_ATTRIB_GENERIC10)
#define VERT_BIT_GENERIC11   (1 << VERT_ATTRIB_GENERIC11)
#define VERT_BIT_GENERIC12   (1 << VERT_ATTRIB_GENERIC12)
#define VERT_BIT_GENERIC13   (1 << VERT_ATTRIB_GENERIC13)
#define VERT_BIT_GENERIC14   (1 << VERT_ATTRIB_GENERIC14)
#define VERT_BIT_GENERIC15   (1 << VERT_ATTRIB_GENERIC15)

#define VERT_BIT_TEX(u)  (1 << (VERT_ATTRIB_TEX0 + (u)))
#define VERT_BIT_GENERIC(g)  (1 << (VERT_ATTRIB_GENERIC0 + (g)))
/*@}*/


/**
 * Indexes for vertex program result attributes
 */
/*@{*/
00227 #define VERT_RESULT_HPOS 0
#define VERT_RESULT_COL0 1
#define VERT_RESULT_COL1 2
#define VERT_RESULT_FOGC 3
#define VERT_RESULT_TEX0 4
#define VERT_RESULT_TEX1 5
#define VERT_RESULT_TEX2 6
#define VERT_RESULT_TEX3 7
#define VERT_RESULT_TEX4 8
#define VERT_RESULT_TEX5 9
#define VERT_RESULT_TEX6 10
#define VERT_RESULT_TEX7 11
#define VERT_RESULT_PSIZ 12
#define VERT_RESULT_BFC0 13
#define VERT_RESULT_BFC1 14
#define VERT_RESULT_EDGE 15
00243 #define VERT_RESULT_VAR0 16  /**< shader varying */
#define VERT_RESULT_MAX  (VERT_RESULT_VAR0 + MAX_VARYING)
/*@}*/


/**
 * Indexes for fragment program input attributes.
 */
enum
{
   FRAG_ATTRIB_WPOS = 0,
   FRAG_ATTRIB_COL0 = 1,
   FRAG_ATTRIB_COL1 = 2,
   FRAG_ATTRIB_FOGC = 3,
   FRAG_ATTRIB_TEX0 = 4,
   FRAG_ATTRIB_TEX1 = 5,
   FRAG_ATTRIB_TEX2 = 6,
   FRAG_ATTRIB_TEX3 = 7,
   FRAG_ATTRIB_TEX4 = 8,
   FRAG_ATTRIB_TEX5 = 9,
   FRAG_ATTRIB_TEX6 = 10,
   FRAG_ATTRIB_TEX7 = 11,
00265    FRAG_ATTRIB_VAR0 = 12,  /**< shader varying */
   FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
};

/**
 * Bitflags for fragment program input attributes.
 */
/*@{*/
00273 #define FRAG_BIT_WPOS  (1 << FRAG_ATTRIB_WPOS)
#define FRAG_BIT_COL0  (1 << FRAG_ATTRIB_COL0)
#define FRAG_BIT_COL1  (1 << FRAG_ATTRIB_COL1)
#define FRAG_BIT_FOGC  (1 << FRAG_ATTRIB_FOGC)
#define FRAG_BIT_TEX0  (1 << FRAG_ATTRIB_TEX0)
#define FRAG_BIT_TEX1  (1 << FRAG_ATTRIB_TEX1)
#define FRAG_BIT_TEX2  (1 << FRAG_ATTRIB_TEX2)
#define FRAG_BIT_TEX3  (1 << FRAG_ATTRIB_TEX3)
#define FRAG_BIT_TEX4  (1 << FRAG_ATTRIB_TEX4)
#define FRAG_BIT_TEX5  (1 << FRAG_ATTRIB_TEX5)
#define FRAG_BIT_TEX6  (1 << FRAG_ATTRIB_TEX6)
#define FRAG_BIT_TEX7  (1 << FRAG_ATTRIB_TEX7)
#define FRAG_BIT_VAR0  (1 << FRAG_ATTRIB_VAR0)

#define FRAG_BIT_TEX(U)  (FRAG_BIT_TEX0 << (U))
#define FRAG_BIT_VAR(V)  (FRAG_BIT_VAR0 << (V))

#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
                     FRAG_BIT_TEX1| \
                     FRAG_BIT_TEX2| \
                     FRAG_BIT_TEX3| \
                     FRAG_BIT_TEX4| \
                     FRAG_BIT_TEX5| \
                     FRAG_BIT_TEX6| \
                     FRAG_BIT_TEX7)
/*@}*/


/**
 * Fragment program results
 */
enum
{
   FRAG_RESULT_COLR = 0,
   FRAG_RESULT_COLH = 1,
   FRAG_RESULT_DEPR = 2,
   FRAG_RESULT_DATA0 = 3,
   FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
};


/**
 * Indexes for all renderbuffers
 */
enum {
   BUFFER_FRONT_LEFT  = 0,  /* the four standard color buffers */
   BUFFER_BACK_LEFT   = 1,
   BUFFER_FRONT_RIGHT = 2,
   BUFFER_BACK_RIGHT  = 3,
   BUFFER_AUX0        = 4,  /* optional aux buffer */
   BUFFER_AUX1        = 5,
   BUFFER_AUX2        = 6,
   BUFFER_AUX3        = 7,
   BUFFER_DEPTH       = 8,
   BUFFER_STENCIL     = 9,
   BUFFER_ACCUM       = 10,
   BUFFER_COLOR0      = 11, /* generic renderbuffers */
   BUFFER_COLOR1      = 12,
   BUFFER_COLOR2      = 13,
   BUFFER_COLOR3      = 14,
   BUFFER_COLOR4      = 15,
   BUFFER_COLOR5      = 16,
   BUFFER_COLOR6      = 17,
   BUFFER_COLOR7      = 18,
   BUFFER_COUNT       = 19
};

/**
 * Bit flags for all renderbuffers
 */
00343 #define BUFFER_BIT_FRONT_LEFT   (1 << BUFFER_FRONT_LEFT)
#define BUFFER_BIT_BACK_LEFT    (1 << BUFFER_BACK_LEFT)
#define BUFFER_BIT_FRONT_RIGHT  (1 << BUFFER_FRONT_RIGHT)
#define BUFFER_BIT_BACK_RIGHT   (1 << BUFFER_BACK_RIGHT)
#define BUFFER_BIT_AUX0         (1 << BUFFER_AUX0)
#define BUFFER_BIT_AUX1         (1 << BUFFER_AUX1)
#define BUFFER_BIT_AUX2         (1 << BUFFER_AUX2)
#define BUFFER_BIT_AUX3         (1 << BUFFER_AUX3)
#define BUFFER_BIT_DEPTH        (1 << BUFFER_DEPTH)
#define BUFFER_BIT_STENCIL      (1 << BUFFER_STENCIL)
#define BUFFER_BIT_ACCUM        (1 << BUFFER_ACCUM)
#define BUFFER_BIT_COLOR0       (1 << BUFFER_COLOR0)
#define BUFFER_BIT_COLOR1       (1 << BUFFER_COLOR1)
#define BUFFER_BIT_COLOR2       (1 << BUFFER_COLOR2)
#define BUFFER_BIT_COLOR3       (1 << BUFFER_COLOR3)
#define BUFFER_BIT_COLOR4       (1 << BUFFER_COLOR4)
#define BUFFER_BIT_COLOR5       (1 << BUFFER_COLOR5)
#define BUFFER_BIT_COLOR6       (1 << BUFFER_COLOR6)
#define BUFFER_BIT_COLOR7       (1 << BUFFER_COLOR7)

/**
 * Mask of all the color buffer bits (but not accum).
 */
00366 #define BUFFER_BITS_COLOR  (BUFFER_BIT_FRONT_LEFT | \
                            BUFFER_BIT_BACK_LEFT | \
                            BUFFER_BIT_FRONT_RIGHT | \
                            BUFFER_BIT_BACK_RIGHT | \
                            BUFFER_BIT_AUX0 | \
                            BUFFER_BIT_AUX1 | \
                            BUFFER_BIT_AUX2 | \
                            BUFFER_BIT_AUX3 | \
                            BUFFER_BIT_COLOR0 | \
                            BUFFER_BIT_COLOR1 | \
                            BUFFER_BIT_COLOR2 | \
                            BUFFER_BIT_COLOR3 | \
                            BUFFER_BIT_COLOR4 | \
                            BUFFER_BIT_COLOR5 | \
                            BUFFER_BIT_COLOR6 | \
                            BUFFER_BIT_COLOR7)


/** The pixel transfer path has three color tables: */
/*@{*/
00386 #define COLORTABLE_PRECONVOLUTION  0
#define COLORTABLE_POSTCONVOLUTION 1
#define COLORTABLE_POSTCOLORMATRIX 2
#define COLORTABLE_MAX 3
/*@}*/


/**
 * Data structure for color tables
 */
00396 struct gl_color_table
{
00398    GLenum InternalFormat;      /**< The user-specified format */
00399    GLenum _BaseFormat;         /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
00400    GLuint Size;                /**< number of entries in table */
00401    GLfloat *TableF;            /**< Color table, floating point values */
00402    GLubyte *TableUB;           /**< Color table, ubyte values */
   GLubyte RedSize;
   GLubyte GreenSize;
   GLubyte BlueSize;
   GLubyte AlphaSize;
   GLubyte LuminanceSize;
   GLubyte IntensitySize;
};


/**
 * \name Bit flags used for updating material values.
 */
/*@{*/
#define MAT_ATTRIB_FRONT_AMBIENT           0 
#define MAT_ATTRIB_BACK_AMBIENT            1
#define MAT_ATTRIB_FRONT_DIFFUSE           2 
#define MAT_ATTRIB_BACK_DIFFUSE            3
#define MAT_ATTRIB_FRONT_SPECULAR          4 
#define MAT_ATTRIB_BACK_SPECULAR           5
#define MAT_ATTRIB_FRONT_EMISSION          6
#define MAT_ATTRIB_BACK_EMISSION           7
#define MAT_ATTRIB_FRONT_SHININESS         8
#define MAT_ATTRIB_BACK_SHININESS          9
#define MAT_ATTRIB_FRONT_INDEXES           10
#define MAT_ATTRIB_BACK_INDEXES            11
#define MAT_ATTRIB_MAX                     12

#define MAT_ATTRIB_AMBIENT(f)  (MAT_ATTRIB_FRONT_AMBIENT+(f))  
#define MAT_ATTRIB_DIFFUSE(f)  (MAT_ATTRIB_FRONT_DIFFUSE+(f))  
#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) 
#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) 
#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
#define MAT_ATTRIB_INDEXES(f)  (MAT_ATTRIB_FRONT_INDEXES+(f))  

#define MAT_INDEX_AMBIENT  0
#define MAT_INDEX_DIFFUSE  1
#define MAT_INDEX_SPECULAR 2

#define MAT_BIT_FRONT_AMBIENT         (1<<MAT_ATTRIB_FRONT_AMBIENT)
#define MAT_BIT_BACK_AMBIENT          (1<<MAT_ATTRIB_BACK_AMBIENT)
#define MAT_BIT_FRONT_DIFFUSE         (1<<MAT_ATTRIB_FRONT_DIFFUSE)
#define MAT_BIT_BACK_DIFFUSE          (1<<MAT_ATTRIB_BACK_DIFFUSE)
#define MAT_BIT_FRONT_SPECULAR        (1<<MAT_ATTRIB_FRONT_SPECULAR)
#define MAT_BIT_BACK_SPECULAR         (1<<MAT_ATTRIB_BACK_SPECULAR)
#define MAT_BIT_FRONT_EMISSION        (1<<MAT_ATTRIB_FRONT_EMISSION)
#define MAT_BIT_BACK_EMISSION         (1<<MAT_ATTRIB_BACK_EMISSION)
#define MAT_BIT_FRONT_SHININESS       (1<<MAT_ATTRIB_FRONT_SHININESS)
#define MAT_BIT_BACK_SHININESS        (1<<MAT_ATTRIB_BACK_SHININESS)
#define MAT_BIT_FRONT_INDEXES         (1<<MAT_ATTRIB_FRONT_INDEXES)
#define MAT_BIT_BACK_INDEXES          (1<<MAT_ATTRIB_BACK_INDEXES)


#define FRONT_MATERIAL_BITS   (MAT_BIT_FRONT_EMISSION |     \
                         MAT_BIT_FRONT_AMBIENT |      \
                         MAT_BIT_FRONT_DIFFUSE |      \
                         MAT_BIT_FRONT_SPECULAR |     \
                         MAT_BIT_FRONT_SHININESS |    \
                         MAT_BIT_FRONT_INDEXES)

#define BACK_MATERIAL_BITS    (MAT_BIT_BACK_EMISSION |      \
                         MAT_BIT_BACK_AMBIENT |       \
                         MAT_BIT_BACK_DIFFUSE |       \
                         MAT_BIT_BACK_SPECULAR |      \
                         MAT_BIT_BACK_SHININESS |     \
                         MAT_BIT_BACK_INDEXES)

#define ALL_MATERIAL_BITS     (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
/*@}*/


00473 #define EXP_TABLE_SIZE 512    /**< Specular exponent lookup table sizes */
00474 #define SHINE_TABLE_SIZE 256  /**< Material shininess lookup table sizes */

/**
 * Material shininess lookup table.
 */
00479 struct gl_shine_tab
{
   struct gl_shine_tab *next, *prev;
   GLfloat tab[SHINE_TABLE_SIZE+1];
   GLfloat shininess;
   GLuint refcount;
};


/**
 * Light source state.
 */
00491 struct gl_light
{
00493    struct gl_light *next;     /**< double linked list with sentinel */
   struct gl_light *prev;

00496    GLfloat Ambient[4];        /**< ambient color */
00497    GLfloat Diffuse[4];        /**< diffuse color */
00498    GLfloat Specular[4];       /**< specular color */
00499    GLfloat EyePosition[4];    /**< position in eye coordinates */
00500    GLfloat EyeDirection[4];   /**< spotlight dir in eye coordinates */
   GLfloat SpotExponent;
00502    GLfloat SpotCutoff;        /**< in degrees */
00503    GLfloat _CosCutoffNeg;     /**< = cos(SpotCutoff) */
00504    GLfloat _CosCutoff;        /**< = MAX(0, cos(SpotCutoff)) */
   GLfloat ConstantAttenuation;
   GLfloat LinearAttenuation;
   GLfloat QuadraticAttenuation;
00508    GLboolean Enabled;         /**< On/off flag */

   /** 
    * \name Derived fields
    */
   /*@{*/
00514    GLbitfield _Flags;         /**< State */

00516    GLfloat _Position[4];      /**< position in eye/obj coordinates */
00517    GLfloat _VP_inf_norm[3];   /**< Norm direction to infinite light */
00518    GLfloat _h_inf_norm[3];    /**< Norm( _VP_inf_norm + <0,0,1> ) */
00519    GLfloat _NormDirection[4]; /**< normalized spotlight direction */
   GLfloat _VP_inf_spot_attenuation;

00522    GLfloat _SpotExpTable[EXP_TABLE_SIZE][2];  /**< to replace a pow() call */
00523    GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
00524    GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
00525    GLfloat _MatSpecular[2][3];      /**< material spec * light specular */
00526    GLfloat _dli;        /**< CI diffuse light intensity */
00527    GLfloat _sli;        /**< CI specular light intensity */
   /*@}*/
};


/**
 * Light model state.
 */
00535 struct gl_lightmodel
{
00537    GLfloat Ambient[4];        /**< ambient color */
00538    GLboolean LocalViewer;     /**< Local (or infinite) view point? */
00539    GLboolean TwoSide;         /**< Two (or one) sided lighting? */
00540    GLenum ColorControl;       /**< either GL_SINGLE_COLOR
                         *    or GL_SEPARATE_SPECULAR_COLOR */
};


/**
 * Material state.
 */
00548 struct gl_material
{
   GLfloat Attrib[MAT_ATTRIB_MAX][4];
};


/**
 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
 */
00557 struct gl_accum_attrib
{
00559    GLfloat ClearColor[4];     /**< Accumulation buffer clear color */
};


/**
 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
 */
00566 struct gl_colorbuffer_attrib
{
00568    GLuint ClearIndex;               /**< Index to use for glClear */
00569    GLclampf ClearColor[4];          /**< Color to use for glClear */

00571    GLuint IndexMask;                /**< Color index write mask */
00572    GLubyte ColorMask[4];            /**< Each flag is 0xff or 0x0 */

00574    GLenum DrawBuffer[MAX_DRAW_BUFFERS];   /**< Which buffer to draw into */

   /** 
    * \name alpha testing
    */
   /*@{*/
00580    GLboolean AlphaEnabled;          /**< Alpha test enabled flag */
00581    GLenum AlphaFunc;                /**< Alpha test function */
00582    GLclampf AlphaRef;               /**< Alpha reference value */
   /*@}*/

   /** 
    * \name Blending
    */
   /*@{*/
00589    GLboolean BlendEnabled;          /**< Blending enabled flag */
00590    GLenum BlendSrcRGB;              /**< Blending source operator */
00591    GLenum BlendDstRGB;              /**< Blending destination operator */
00592    GLenum BlendSrcA;                /**< GL_INGR_blend_func_separate */
00593    GLenum BlendDstA;                /**< GL_INGR_blend_func_separate */
00594    GLenum BlendEquationRGB;         /**< Blending equation */
00595    GLenum BlendEquationA;           /**< GL_EXT_blend_equation_separate */
00596    GLfloat BlendColor[4];           /**< Blending color */
   /*@}*/

   /** 
    * \name Logic op
    */
   /*@{*/
00603    GLenum LogicOp;                  /**< Logic operator */
00604    GLboolean IndexLogicOpEnabled;   /**< Color index logic op enabled flag */
00605    GLboolean ColorLogicOpEnabled;   /**< RGBA logic op enabled flag */
00606    GLboolean _LogicOpEnabled;       /**< RGBA logic op + EXT_blend_logic_op enabled flag */
   /*@}*/

00609    GLboolean DitherFlag;            /**< Dither enable flag */

00611    GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
00612    GLenum ClampReadColor;     /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
};


/**
 * Current attribute group (GL_CURRENT_BIT).
 */
00619 struct gl_current_attrib
{
   /**
    * \name Current vertex attributes.
    * \note Values are valid only after FLUSH_VERTICES has been called.
    * \note Index and Edgeflag current values are stored as floats in the 
    * SIX and SEVEN attribute slots.
    */
   /*@{*/
00628    GLfloat Attrib[VERT_ATTRIB_MAX][4];    /**< Position, color, texcoords, etc */
   /*@}*/

   /**
    * \name Current raster position attributes (always valid).
    * \note This set of attributes is very similar to the SWvertex struct.
    */
   /*@{*/
   GLfloat RasterPos[4];
   GLfloat RasterDistance;
   GLfloat RasterColor[4];
   GLfloat RasterSecondaryColor[4];
   GLfloat RasterIndex;
   GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
   GLboolean RasterPosValid;
   /*@}*/
};


/**
 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
 */
00650 struct gl_depthbuffer_attrib
{
00652    GLenum Func;               /**< Function for depth buffer compare */
00653    GLclampd Clear;            /**< Value to clear depth buffer to */
00654    GLboolean Test;            /**< Depth buffering enabled flag */
00655    GLboolean Mask;            /**< Depth buffer writable? */
00656    GLboolean BoundsTest;        /**< GL_EXT_depth_bounds_test */
00657    GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
};


/**
 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
 */
00664 struct gl_enable_attrib
{
   GLboolean AlphaTest;
   GLboolean AutoNormal;
   GLboolean Blend;
   GLbitfield ClipPlanes;
   GLboolean ColorMaterial;
   GLboolean ColorTable[COLORTABLE_MAX];
   GLboolean Convolution1D;
   GLboolean Convolution2D;
   GLboolean Separable2D;
   GLboolean CullFace;
   GLboolean DepthTest;
   GLboolean Dither;
   GLboolean Fog;
   GLboolean Histogram;
   GLboolean Light[MAX_LIGHTS];
   GLboolean Lighting;
   GLboolean LineSmooth;
   GLboolean LineStipple;
   GLboolean IndexLogicOp;
   GLboolean ColorLogicOp;
   GLboolean Map1Color4;
   GLboolean Map1Index;
   GLboolean Map1Normal;
   GLboolean Map1TextureCoord1;
   GLboolean Map1TextureCoord2;
   GLboolean Map1TextureCoord3;
   GLboolean Map1TextureCoord4;
   GLboolean Map1Vertex3;
   GLboolean Map1Vertex4;
   GLboolean Map1Attrib[16];  /* GL_NV_vertex_program */
   GLboolean Map2Color4;
   GLboolean Map2Index;
   GLboolean Map2Normal;
   GLboolean Map2TextureCoord1;
   GLboolean Map2TextureCoord2;
   GLboolean Map2TextureCoord3;
   GLboolean Map2TextureCoord4;
   GLboolean Map2Vertex3;
   GLboolean Map2Vertex4;
   GLboolean Map2Attrib[16];  /* GL_NV_vertex_program */
   GLboolean MinMax;
   GLboolean Normalize;
   GLboolean PixelTexture;
   GLboolean PointSmooth;
   GLboolean PolygonOffsetPoint;
   GLboolean PolygonOffsetLine;
   GLboolean PolygonOffsetFill;
   GLboolean PolygonSmooth;
   GLboolean PolygonStipple;
   GLboolean RescaleNormals;
   GLboolean Scissor;
   GLboolean Stencil;
   GLboolean StencilTwoSide;          /* GL_EXT_stencil_two_side */
   GLboolean MultisampleEnabled;      /* GL_ARB_multisample */
   GLboolean SampleAlphaToCoverage;   /* GL_ARB_multisample */
   GLboolean SampleAlphaToOne;        /* GL_ARB_multisample */
   GLboolean SampleCoverage;          /* GL_ARB_multisample */
   GLboolean SampleCoverageInvert;    /* GL_ARB_multisample */
   GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
   GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
   GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
   /* SGI_texture_color_table */
   GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
   /* GL_ARB_vertex_program / GL_NV_vertex_program */
   GLboolean VertexProgram;
   GLboolean VertexProgramPointSize;
   GLboolean VertexProgramTwoSide;
   /* GL_ARB_point_sprite / GL_NV_point_sprite */
   GLboolean PointSprite;
   GLboolean FragmentShaderATI;
};


/**
 * Evaluator attribute group (GL_EVAL_BIT).
 */
00742 struct gl_eval_attrib
{
   /**
    * \name Enable bits 
    */
   /*@{*/
   GLboolean Map1Color4;
   GLboolean Map1Index;
   GLboolean Map1Normal;
   GLboolean Map1TextureCoord1;
   GLboolean Map1TextureCoord2;
   GLboolean Map1TextureCoord3;
   GLboolean Map1TextureCoord4;
   GLboolean Map1Vertex3;
   GLboolean Map1Vertex4;
   GLboolean Map1Attrib[16];  /* GL_NV_vertex_program */
   GLboolean Map2Color4;
   GLboolean Map2Index;
   GLboolean Map2Normal;
   GLboolean Map2TextureCoord1;
   GLboolean Map2TextureCoord2;
   GLboolean Map2TextureCoord3;
   GLboolean Map2TextureCoord4;
   GLboolean Map2Vertex3;
   GLboolean Map2Vertex4;
   GLboolean Map2Attrib[16];  /* GL_NV_vertex_program */
   GLboolean AutoNormal;
   /*@}*/
   
   /**
    * \name Map Grid endpoints and divisions and calculated du values
    */
   /*@{*/
   GLint MapGrid1un;
   GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
   GLint MapGrid2un, MapGrid2vn;
   GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
   GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
   /*@}*/
};


/**
 * Fog attribute group (GL_FOG_BIT).
 */
00787 struct gl_fog_attrib
{
00789    GLboolean Enabled;         /**< Fog enabled flag */
00790    GLfloat Color[4];          /**< Fog color */
00791    GLfloat Density;           /**< Density >= 0.0 */
00792    GLfloat Start;       /**< Start distance in eye coords */
00793    GLfloat End;               /**< End distance in eye coords */
00794    GLfloat Index;       /**< Fog index */
00795    GLenum Mode;               /**< Fog mode */
   GLboolean ColorSumEnabled;
00797    GLenum FogCoordinateSource;  /**< GL_EXT_fog_coord */
00798    GLfloat _Scale;            /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
};


/** 
 * Hint attribute group (GL_HINT_BIT).
 * 
 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
 */
00807 struct gl_hint_attrib
{
   GLenum PerspectiveCorrection;
   GLenum PointSmooth;
   GLenum LineSmooth;
   GLenum PolygonSmooth;
   GLenum Fog;
00814    GLenum ClipVolumeClipping;   /**< GL_EXT_clip_volume_hint */
00815    GLenum TextureCompression;   /**< GL_ARB_texture_compression */
00816    GLenum GenerateMipmap;       /**< GL_SGIS_generate_mipmap */
00817    GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
};


/**
 * Histogram attributes.
 */
00824 struct gl_histogram_attrib
{
00826    GLuint Width;                    /**< number of table entries */
00827    GLint Format;                    /**< GL_ALPHA, GL_RGB, etc */
00828    GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
00829    GLboolean Sink;                        /**< terminate image transfer? */
00830    GLubyte RedSize;                       /**< Bits per counter */
   GLubyte GreenSize;
   GLubyte BlueSize;
   GLubyte AlphaSize;
   GLubyte LuminanceSize;
};


/**
 * Color Min/max state.
 */
00841 struct gl_minmax_attrib
{
   GLenum Format;
   GLboolean Sink;
00845    GLfloat Min[4], Max[4];   /**< RGBA */
};


/**
 * Image convolution state.
 */
00852 struct gl_convolution_attrib
{
   GLenum Format;
   GLenum InternalFormat;
   GLuint Width;
   GLuint Height;
   GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
};


/**
 * Light state flags.
 */
/*@{*/
00866 #define LIGHT_SPOT         0x1
#define LIGHT_LOCAL_VIEWER 0x2
#define LIGHT_POSITIONAL   0x4
#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
/*@}*/


/**
 * Lighting attribute group (GL_LIGHT_BIT).
 */
00876 struct gl_light_attrib
{
00878    struct gl_light Light[MAX_LIGHTS];     /**< Array of light sources */
00879    struct gl_lightmodel Model;            /**< Lighting model */

   /**
    * Must flush FLUSH_VERTICES before referencing:
    */
   /*@{*/
00885    struct gl_material Material;     /**< Includes front & back values */
   /*@}*/

00888    GLboolean Enabled;               /**< Lighting enabled flag */
00889    GLenum ShadeModel;               /**< GL_FLAT or GL_SMOOTH */
00890    GLenum ColorMaterialFace;        /**< GL_FRONT, BACK or FRONT_AND_BACK */
00891    GLenum ColorMaterialMode;        /**< GL_AMBIENT, GL_DIFFUSE, etc */
00892    GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
   GLboolean ColorMaterialEnabled;
   GLenum ClampVertexColor;

00896    struct gl_light EnabledList;         /**< List sentinel */

   /** 
    * Derived state for optimizations: 
    */
   /*@{*/
00902    GLboolean _NeedEyeCoords;        
00903    GLboolean _NeedVertices;         /**< Use fast shader? */
00904    GLbitfield  _Flags;                /**< LIGHT_* flags, see above */
   GLfloat _BaseColor[2][3];
   /*@}*/
};


/**
 * Line attribute group (GL_LINE_BIT).
 */
00913 struct gl_line_attrib
{
00915    GLboolean SmoothFlag;      /**< GL_LINE_SMOOTH enabled? */
00916    GLboolean StippleFlag;     /**< GL_LINE_STIPPLE enabled? */
00917    GLushort StipplePattern;   /**< Stipple pattern */
00918    GLint StippleFactor;       /**< Stipple repeat factor */
00919    GLfloat Width;       /**< Line width */
};


/**
 * Display list attribute group (GL_LIST_BIT).
 */
00926 struct gl_list_attrib
{
   GLuint ListBase;
};


/**
 * Used by device drivers to hook new commands into display lists.
 */
00935 struct gl_list_instruction
{
   GLuint Size;
   void (*Execute)( GLcontext *ctx, void *data );
   void (*Destroy)( GLcontext *ctx, void *data );
   void (*Print)( GLcontext *ctx, void *data );
};

#define MAX_DLIST_EXT_OPCODES 16

/**
 * Used by device drivers to hook new commands into display lists.
 */
00948 struct gl_list_extensions
{
   struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
   GLuint NumOpcodes;
};


/**
 * Multisample attribute group (GL_MULTISAMPLE_BIT).
 */
00958 struct gl_multisample_attrib
{
   GLboolean Enabled;
00961    GLboolean _Enabled;   /**< true if Enabled and multisample buffer */
   GLboolean SampleAlphaToCoverage;
   GLboolean SampleAlphaToOne;
   GLboolean SampleCoverage;
   GLfloat SampleCoverageValue;
   GLboolean SampleCoverageInvert;
};


/**
 * A pixelmap (see glPixelMap)
 */
00973 struct gl_pixelmap
{
   GLint Size;
   GLfloat Map[MAX_PIXEL_MAP_TABLE];
00977    GLubyte Map8[MAX_PIXEL_MAP_TABLE];  /**< converted to 8-bit color */
};


/**
 * Collection of all pixelmaps
 */
00984 struct gl_pixelmaps
{
00986    struct gl_pixelmap RtoR;  /**< i.e. GL_PIXEL_MAP_R_TO_R */
   struct gl_pixelmap GtoG;
   struct gl_pixelmap BtoB;
   struct gl_pixelmap AtoA;
   struct gl_pixelmap ItoR;
   struct gl_pixelmap ItoG;
   struct gl_pixelmap ItoB;
   struct gl_pixelmap ItoA;
   struct gl_pixelmap ItoI;
   struct gl_pixelmap StoS;
};


/**
 * Pixel attribute group (GL_PIXEL_MODE_BIT).
 */
01002 struct gl_pixel_attrib
{
01004    GLenum ReadBuffer;         /**< source buffer for glRead/CopyPixels() */

   /*--- Begin Pixel Transfer State ---*/
   /* Fields are in the order in which they're applied... */

   /* Scale & Bias (index shift, offset) */
   GLfloat RedBias, RedScale;
   GLfloat GreenBias, GreenScale;
   GLfloat BlueBias, BlueScale;
   GLfloat AlphaBias, AlphaScale;
   GLfloat DepthBias, DepthScale;
   GLint IndexShift, IndexOffset;

   /* Pixel Maps */
   /* Note: actual pixel maps are not part of this attrib group */
   GLboolean MapColorFlag;
   GLboolean MapStencilFlag;

   /* There are multiple color table stages: */
   GLboolean ColorTableEnabled[COLORTABLE_MAX];
01024    GLfloat ColorTableScale[COLORTABLE_MAX][4];  /**< RGBA */
01025    GLfloat ColorTableBias[COLORTABLE_MAX][4];   /**< RGBA */

   /* Convolution (GL_EXT_convolution) */
   GLboolean Convolution1DEnabled;
   GLboolean Convolution2DEnabled;
   GLboolean Separable2DEnabled;
   GLfloat ConvolutionBorderColor[3][4];
   GLenum ConvolutionBorderMode[3];
01033    GLfloat ConvolutionFilterScale[3][4];  /**< RGBA */
01034    GLfloat ConvolutionFilterBias[3][4];   /**< RGBA */
01035    GLfloat PostConvolutionScale[4];  /**< RGBA */
01036    GLfloat PostConvolutionBias[4];   /**< RGBA */

   /* Color matrix (GL_SGI_color_matrix) */
   /* Note: the color matrix is not part of this attrib group */
01040    GLfloat PostColorMatrixScale[4];  /**< RGBA */
01041    GLfloat PostColorMatrixBias[4];   /**< RGBA */

   /* Histogram & minmax (GL_EXT_histogram) */
   /* Note: histogram and minmax data are not part of this attrib group */
   GLboolean HistogramEnabled;
   GLboolean MinMaxEnabled;

   /*--- End Pixel Transfer State ---*/

   /* Pixel Zoom */
   GLfloat ZoomX, ZoomY;

   /** GL_SGI_texture_color_table */
01054    GLfloat TextureColorTableScale[4];
   GLfloat TextureColorTableBias[4];
};


/**
 * Point attribute group (GL_POINT_BIT).
 */
01062 struct gl_point_attrib
{
01064    GLboolean SmoothFlag;      /**< True if GL_POINT_SMOOTH is enabled */
01065    GLfloat Size;        /**< User-specified point size */
01066    GLfloat Params[3];         /**< GL_EXT_point_parameters */
01067    GLfloat MinSize, MaxSize;  /**< GL_EXT_point_parameters */
01068    GLfloat Threshold;         /**< GL_EXT_point_parameters */
01069    GLboolean _Attenuated;     /**< True if Params != [1, 0, 0] */
01070    GLboolean PointSprite;     /**< GL_NV/ARB_point_sprite */
01071    GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite */
01072    GLenum SpriteRMode;        /**< GL_NV_point_sprite (only!) */
01073    GLenum SpriteOrigin;       /**< GL_ARB_point_sprite */
};


/**
 * Polygon attribute group (GL_POLYGON_BIT).
 */
01080 struct gl_polygon_attrib
{
01082    GLenum FrontFace;          /**< Either GL_CW or GL_CCW */
01083    GLenum FrontMode;          /**< Either GL_POINT, GL_LINE or GL_FILL */
01084    GLenum BackMode;           /**< Either GL_POINT, GL_LINE or GL_FILL */
01085    GLboolean _FrontBit;       /**< 0=GL_CCW, 1=GL_CW */
01086    GLboolean CullFlag;        /**< Culling on/off flag */
01087    GLboolean SmoothFlag;      /**< True if GL_POLYGON_SMOOTH is enabled */
01088    GLboolean StippleFlag;     /**< True if GL_POLYGON_STIPPLE is enabled */
01089    GLenum CullFaceMode;       /**< Culling mode GL_FRONT or GL_BACK */
01090    GLfloat OffsetFactor;      /**< Polygon offset factor, from user */
01091    GLfloat OffsetUnits;       /**< Polygon offset units, from user */
01092    GLboolean OffsetPoint;     /**< Offset in GL_POINT mode */
01093    GLboolean OffsetLine;      /**< Offset in GL_LINE mode */
01094    GLboolean OffsetFill;      /**< Offset in GL_FILL mode */
};


/**
 * Scissor attributes (GL_SCISSOR_BIT).
 */
01101 struct gl_scissor_attrib
{
01103    GLboolean Enabled;         /**< Scissor test enabled? */
01104    GLint X, Y;                /**< Lower left corner of box */
01105    GLsizei Width, Height;     /**< Size of box */
};


/**
 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
 */
01112 struct gl_stencil_attrib
{
01114    GLboolean Enabled;         /**< Enabled flag */
01115    GLboolean TestTwoSide;     /**< GL_EXT_stencil_two_side */
01116    GLubyte ActiveFace;        /**< GL_EXT_stencil_two_side (0 or 1) */
   GLboolean _TestTwoSide;
01118    GLenum Function[2];        /**< Stencil function */
01119    GLenum FailFunc[2];        /**< Fail function */
01120    GLenum ZPassFunc[2];       /**< Depth buffer pass function */
01121    GLenum ZFailFunc[2];       /**< Depth buffer fail function */
01122    GLint Ref[2];        /**< Reference value */
01123    GLuint ValueMask[2];       /**< Value mask */
01124    GLuint WriteMask[2];       /**< Write mask */
01125    GLuint Clear;        /**< Clear value */
};


#define NUM_TEXTURE_TARGETS 7   /* 1D, 2D, 3D, CUBE, RECT, 1D_STACK, and 2D_STACK */

/**
 * An index for each type of texture object
 */
/*@{*/
01135 #define TEXTURE_1D_INDEX       0
#define TEXTURE_2D_INDEX       1
#define TEXTURE_3D_INDEX       2
#define TEXTURE_CUBE_INDEX     3
#define TEXTURE_RECT_INDEX     4
#define TEXTURE_1D_ARRAY_INDEX 5
#define TEXTURE_2D_ARRAY_INDEX 6
/*@}*/

/**
 * Bit flags for each type of texture object
 * Used for Texture.Unit[]._ReallyEnabled flags.
 */
/*@{*/
01149 #define TEXTURE_1D_BIT       (1 << TEXTURE_1D_INDEX)
#define TEXTURE_2D_BIT       (1 << TEXTURE_2D_INDEX)
#define TEXTURE_3D_BIT       (1 << TEXTURE_3D_INDEX)
#define TEXTURE_CUBE_BIT     (1 << TEXTURE_CUBE_INDEX)
#define TEXTURE_RECT_BIT     (1 << TEXTURE_RECT_INDEX)
#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
/*@}*/


/**
 * TexGenEnabled flags.
 */
/*@{*/
01163 #define S_BIT 1
#define T_BIT 2
#define R_BIT 4
#define Q_BIT 8
/*@}*/


/**
 * Bit flag versions of the corresponding GL_ constants.
 */
/*@{*/
01174 #define TEXGEN_SPHERE_MAP        0x1
#define TEXGEN_OBJ_LINEAR        0x2
#define TEXGEN_EYE_LINEAR        0x4
#define TEXGEN_REFLECTION_MAP_NV 0x8
#define TEXGEN_NORMAL_MAP_NV     0x10

#define TEXGEN_NEED_NORMALS      (TEXGEN_SPHERE_MAP        | \
                          TEXGEN_REFLECTION_MAP_NV | \
                          TEXGEN_NORMAL_MAP_NV)
#define TEXGEN_NEED_EYE_COORD    (TEXGEN_SPHERE_MAP        | \
                          TEXGEN_REFLECTION_MAP_NV | \
                          TEXGEN_NORMAL_MAP_NV     | \
                          TEXGEN_EYE_LINEAR)
/*@}*/


/* A selection of state flags to make driver and module's lives easier. */
#define ENABLE_TEXGEN0        0x1
#define ENABLE_TEXGEN1        0x2
#define ENABLE_TEXGEN2        0x4
#define ENABLE_TEXGEN3        0x8
#define ENABLE_TEXGEN4        0x10
#define ENABLE_TEXGEN5        0x20
#define ENABLE_TEXGEN6        0x40
#define ENABLE_TEXGEN7        0x80

#define ENABLE_TEXMAT0        0x1   /* Ie. not the identity matrix */
#define ENABLE_TEXMAT1        0x2
#define ENABLE_TEXMAT2        0x4
#define ENABLE_TEXMAT3        0x8
#define ENABLE_TEXMAT4        0x10
#define ENABLE_TEXMAT5        0x20
#define ENABLE_TEXMAT6        0x40
#define ENABLE_TEXMAT7        0x80

#define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
#define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))


/**
 * Texel fetch function prototype.  We use texel fetch functions to
 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
 * texture images.  These functions help to isolate us from the gritty
 * details of all the various texture image encodings.
 * 
 * \param texImage texture image.
 * \param col texel column.
 * \param row texel row.
 * \param img texel image level/layer.
 * \param texelOut output texel (up to 4 GLchans)
 */
01225 typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
                                 GLint col, GLint row, GLint img,
                                 GLchan *texelOut );

/**
 * As above, but returns floats.
 * Used for depth component images and for upcoming signed/float
 * texture images.
 */
01234 typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
                                 GLint col, GLint row, GLint img,
                                 GLfloat *texelOut );


typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
                               GLint col, GLint row, GLint img,
                               const void *texel);


/**
 * This macro defines the (many) parameters to the texstore functions.
 * \param dims  either 1 or 2 or 3
 * \param baseInternalFormat  user-specified base internal format
 * \param dstFormat  destination Mesa texture format
 * \param dstAddr  destination image address
 * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels
 * \param dstRowStride  destination image row stride, in bytes
 * \param dstImageOffsets  offset of each 2D slice within 3D texture, in texels
 * \param srcWidth/Height/Depth  source image size, in pixels
 * \param srcFormat  incoming image format
 * \param srcType  incoming image data type
 * \param srcAddr  source image address
 * \param srcPacking  source image packing parameters
 */
01259 #define TEXSTORE_PARAMS \
      GLcontext *ctx, GLuint dims, \
      GLenum baseInternalFormat, \
      const struct gl_texture_format *dstFormat, \
      GLvoid *dstAddr, \
      GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
      GLint dstRowStride, const GLuint *dstImageOffsets, \
      GLint srcWidth, GLint srcHeight, GLint srcDepth, \
      GLenum srcFormat, GLenum srcType, \
      const GLvoid *srcAddr, \
      const struct gl_pixelstore_attrib *srcPacking



/**
 * Texture image storage function.
 */
01276 typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);


/**
 * Texture format record 
 */
01282 struct gl_texture_format
{
01284    GLint MesaFormat;          /**< One of the MESA_FORMAT_* values */

01286    GLenum BaseFormat;         /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
                         *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
                         *   GL_INTENSITY, GL_COLOR_INDEX or
                         *   GL_DEPTH_COMPONENT.
                         */
01291    GLenum DataType;           /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */

   /**
    * Bits per texel component.  These are just rough approximations
    * for compressed texture formats.
    */
   /*@{*/
01298    GLubyte RedBits;
   GLubyte GreenBits;
   GLubyte BlueBits;
   GLubyte AlphaBits;
   GLubyte LuminanceBits;
   GLubyte IntensityBits;
   GLubyte IndexBits;
   GLubyte DepthBits;
01306    GLubyte StencilBits;       /**< GL_EXT_packed_depth_stencil */
   /*@}*/

01309    GLuint TexelBytes;         /**< Bytes per texel, 0 if compressed format */

   StoreTexImageFunc StoreImage;

   /**
    * \name Texel fetch function pointers
    */
   /*@{*/
   FetchTexelFuncC FetchTexel1D;
   FetchTexelFuncC FetchTexel2D;
   FetchTexelFuncC FetchTexel3D;
   FetchTexelFuncF FetchTexel1Df;
   FetchTexelFuncF FetchTexel2Df;
   FetchTexelFuncF FetchTexel3Df;
   /*@}*/

   StoreTexelFunc StoreTexel;
};


/**
 * Texture image state.  Describes the dimensions of a texture image,
 * the texel format and pointers to Texel Fetch functions.
 */
01333 struct gl_texture_image
{
01335    GLenum _BaseFormat;        /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
                         *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
                         *   GL_INTENSITY, GL_COLOR_INDEX,
                         *   GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
                                 *   only. Used for choosing TexEnv arithmetic.
                         */
01341    GLint InternalFormat;      /**< Internal format as given by the user */
01342    GLuint Border;       /**< 0 or 1 */
01343    GLuint Width;        /**< = 2^WidthLog2 + 2*Border */
01344    GLuint Height;       /**< = 2^HeightLog2 + 2*Border */
01345    GLuint Depth;        /**< = 2^DepthLog2 + 2*Border */
01346    GLuint Width2;       /**< = Width - 2*Border */
01347    GLuint Height2;            /**< = Height - 2*Border */
01348    GLuint Depth2;       /**< = Depth - 2*Border */
01349    GLuint WidthLog2;          /**< = log2(Width2) */
01350    GLuint HeightLog2;         /**< = log2(Height2) */
01351    GLuint DepthLog2;          /**< = log2(Depth2) */
01352    GLuint MaxLog2;            /**< = MAX(WidthLog2, HeightLog2) */
01353    GLfloat WidthScale;        /**< used for mipmap LOD computation */
01354    GLfloat HeightScale;       /**< used for mipmap LOD computation */
01355    GLfloat DepthScale;        /**< used for mipmap LOD computation */
01356    GLboolean IsClientData;    /**< Data owned by client? */
01357    GLboolean _IsPowerOfTwo;   /**< Are all dimensions powers of two? */

   const struct gl_texture_format *TexFormat;

01361    struct gl_texture_object *TexObject;  /**< Pointer back to parent object */

01363    FetchTexelFuncC FetchTexelc;     /**< GLchan texel fetch function pointer */
01364    FetchTexelFuncF FetchTexelf;     /**< Float texel fetch function pointer */

01366    GLboolean IsCompressed;    /**< GL_ARB_texture_compression */
01367    GLuint CompressedSize;     /**< GL_ARB_texture_compression */

01369    GLuint RowStride;          /**< Padded width in units of texels */
01370    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                     each 2D slice in 'Data', in texels */
01372    GLvoid *Data;        /**< Image data, accessed via FetchTexel() */

   /**
    * \name For device driver:
    */
   /*@{*/
01378    void *DriverData;          /**< Arbitrary device driver data */
   /*@}*/
};


/**
 * Indexes for cube map faces.
 */
/*@{*/
01387 #define FACE_POS_X   0
#define FACE_NEG_X   1
#define FACE_POS_Y   2
#define FACE_NEG_Y   3
#define FACE_POS_Z   4
#define FACE_NEG_Z   5
#define MAX_FACES    6
/*@}*/


/**
 * Texture object state.  Contains the array of mipmap images, border color,
 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
 * color palette.
 */
01402 struct gl_texture_object
{
01404    _glthread_Mutex Mutex;     /**< for thread safety */
01405    GLint RefCount;            /**< reference count */
01406    GLuint Name;               /**< the user-visible texture object ID */
01407    GLenum Target;               /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
01408    GLfloat Priority;          /**< in [0,1] */
01409    GLfloat BorderColor[4];    /**< unclamped */
01410    GLchan _BorderChan[4];     /**< clamped, as GLchan */
01411    GLenum WrapS;        /**< S-axis texture image wrap mode */
01412    GLenum WrapT;        /**< T-axis texture image wrap mode */
01413    GLenum WrapR;        /**< R-axis texture image wrap mode */
01414    GLenum MinFilter;          /**< minification filter */
01415    GLenum MagFilter;          /**< magnification filter */
01416    GLfloat MinLod;            /**< min lambda, OpenGL 1.2 */
01417    GLfloat MaxLod;            /**< max lambda, OpenGL 1.2 */
01418    GLfloat LodBias;           /**< OpenGL 1.4 */
01419    GLint BaseLevel;           /**< min mipmap level, OpenGL 1.2 */
01420    GLint MaxLevel;            /**< max mipmap level, OpenGL 1.2 */
01421    GLfloat MaxAnisotropy;     /**< GL_EXT_texture_filter_anisotropic */
01422    GLboolean CompareFlag;     /**< GL_SGIX_shadow */
01423    GLenum CompareOperator;    /**< GL_SGIX_shadow */
01424    GLfloat ShadowAmbient;       /**< GL_ARB_shadow_ambient */
01425    GLenum CompareMode;        /**< GL_ARB_shadow */
01426    GLenum CompareFunc;        /**< GL_ARB_shadow */
01427    GLenum _Function;          /**< Comparison function derived from 
                         * \c CompareOperator, \c CompareMode, and
                         * \c CompareFunc.
                         */
01431    GLenum DepthMode;          /**< GL_ARB_depth_texture */
01432    GLint _MaxLevel;           /**< actual max mipmap level (q in the spec) */
01433    GLfloat _MaxLambda;        /**< = _MaxLevel - BaseLevel (q - b in spec) */
01434    GLboolean GenerateMipmap;    /**< GL_SGIS_generate_mipmap */
01435    GLboolean _Complete;       /**< Is texture object complete? */

   /** Actual texture images, indexed by [cube face] and [mipmap level] */
01438    struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];

   /** GL_EXT_paletted_texture */
01441    struct gl_color_table Palette;


   /**
    * \name For device driver.
    * Note: instead of attaching driver data to this pointer, it's preferable
    * to instead use this struct as a base class for your own texture object
    * class.  Driver->NewTextureObject() can be used to implement the
    * allocation.
    */
01451    void *DriverData;    /**< Arbitrary device driver data */
};


/**
 * Texture combine environment state.
 * 
 * \todo
 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
 * structure will need to be expanded for 4 elements.
 */
01462 struct gl_tex_env_combine_state
{
01464    GLenum ModeRGB;       /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
01465    GLenum ModeA;         /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
01466    GLenum SourceRGB[3];  /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
01467    GLenum SourceA[3];    /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
01468    GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
01469    GLenum OperandA[3];   /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
01470    GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
01471    GLuint ScaleShiftA;   /**< 0, 1 or 2 */
01472    GLuint _NumArgsRGB;   /**< Number of inputs used for the combine mode. */
01473    GLuint _NumArgsA;     /**< Number of inputs used for the combine mode. */
};


/**
 * Texture unit state.  Contains enable flags, texture environment/function/
 * combiners, texgen state, pointers to current texture objects and
 * post-filter color tables.
 */
01482 struct gl_texture_unit
{
01484    GLbitfield Enabled;          /**< bitmask of TEXTURE_*_BIT flags */
01485    GLbitfield _ReallyEnabled;   /**< 0 or exactly one of TEXTURE_*_BIT flags */

01487    GLenum EnvMode;              /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
   GLfloat EnvColor[4];
01489    GLbitfield TexGenEnabled;  /**< Bitwise-OR of [STRQ]_BIT values */
   /** \name Tex coord generation mode
    * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
   /*@{*/
   GLenum GenModeS;           
   GLenum GenModeT;
   GLenum GenModeR;
   GLenum GenModeQ;
   /*@}*/
   GLbitfield _GenBitS;
   GLbitfield _GenBitT;
   GLbitfield _GenBitR;
   GLbitfield _GenBitQ;
01502    GLbitfield _GenFlags;      /**< bitwise or of _GenBit[STRQ] */
   GLfloat ObjectPlaneS[4];
   GLfloat ObjectPlaneT[4];
   GLfloat ObjectPlaneR[4];
   GLfloat ObjectPlaneQ[4];
   GLfloat EyePlaneS[4];
   GLfloat EyePlaneT[4];
   GLfloat EyePlaneR[4];
   GLfloat EyePlaneQ[4];
01511    GLfloat LodBias;           /**< for biasing mipmap levels */

   /** 
    * \name GL_EXT_texture_env_combine 
    */
   struct gl_tex_env_combine_state Combine;

   /**
    * Derived state based on \c EnvMode and the \c BaseFormat of the
    * currently enabled texture.
    */
01522    struct gl_tex_env_combine_state _EnvMode;

   /**
    * Currently enabled combiner state.  This will point to either
    * \c Combine or \c _EnvMode.
    */
01528    struct gl_tex_env_combine_state *_CurrentCombine;

   struct gl_texture_object *Current1D;
   struct gl_texture_object *Current2D;
   struct gl_texture_object *Current3D;
01533    struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
01534    struct gl_texture_object *CurrentRect;    /**< GL_NV_texture_rectangle */
01535    struct gl_texture_object *Current1DArray; /**< GL_MESA_texture_array */
01536    struct gl_texture_object *Current2DArray; /**< GL_MESA_texture_array */

01538    struct gl_texture_object *_Current; /**< Points to really enabled tex obj */

   /** GL_SGI_texture_color_table */
   /*@{*/
01542    struct gl_color_table ColorTable;
   struct gl_color_table ProxyColorTable;
   GLboolean ColorTableEnabled;
   /*@}*/
};


struct texenvprog_cache_item;

struct texenvprog_cache
{
   struct texenvprog_cache_item **items;
   GLuint size, n_items;
   GLcontext *ctx;
};


/**
 * Texture attribute group (GL_TEXTURE_BIT).
 */
01562 struct gl_texture_attrib
{
   /**
    * name multitexture 
    */
   /**@{*/
01568    GLuint CurrentUnit;         /**< Active texture unit */
01569    GLbitfield _EnabledUnits;  /**< one bit set for each really-enabled unit */
01570    GLbitfield _EnabledCoordUnits;   /**< one bit per enabled coordinate unit */
01571    GLbitfield _GenFlags;            /**< for texgen */
   GLbitfield _TexGenEnabled;
   GLbitfield _TexMatEnabled;
   /**@}*/

   struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];

   /** Proxy texture objects */
01579    struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];

   /** GL_EXT_shared_texture_palette */
01582    GLboolean SharedPalette;
   struct gl_color_table Palette;
   
   /** Cached texenv fragment programs */
01586    struct texenvprog_cache env_fp_cache;
};


/**
 * Transformation attribute group (GL_TRANSFORM_BIT).
 */
01593 struct gl_transform_attrib
{
01595    GLenum MatrixMode;                     /**< Matrix mode */
01596    GLfloat EyeUserPlane[MAX_CLIP_PLANES][4];    /**< User clip planes */
01597    GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4];  /**< derived */
01598    GLbitfield ClipPlanesEnabled;                /**< on/off bitmask */
01599    GLboolean Normalize;                   /**< Normalize all normals? */
01600    GLboolean RescaleNormals;              /**< GL_EXT_rescale_normal */
01601    GLboolean RasterPositionUnclipped;           /**< GL_IBM_rasterpos_clip */

01603    GLboolean CullVertexFlag;  /**< True if GL_CULL_VERTEX_EXT is enabled */
   GLfloat CullEyePos[4];
   GLfloat CullObjPos[4];
};


/**
 * Viewport attribute group (GL_VIEWPORT_BIT).
 */
01612 struct gl_viewport_attrib
{
01614    GLint X, Y;                /**< position */
01615    GLsizei Width, Height;     /**< size */
01616    GLfloat Near, Far;         /**< Depth buffer range */
01617    GLmatrix _WindowMap;       /**< Mapping transformation as a matrix. */
};


/**
 * Node for the attribute stack.
 */
01624 struct gl_attrib_node
{
   GLbitfield kind;
   void *data;
   struct gl_attrib_node *next;
};


/**
 * GL_ARB_vertex/pixel_buffer_object buffer object
 */
01635 struct gl_buffer_object
{
   GLint RefCount;
   GLuint Name;
   GLenum Usage;
   GLenum Access;
01641    GLvoid *Pointer;          /**< Only valid while buffer is mapped */
01642    GLsizeiptrARB Size;       /**< Size of storage in bytes */
01643    GLubyte *Data;            /**< Location of storage either in RAM or VRAM. */
01644    GLboolean OnCard;         /**< Is buffer in VRAM? (hardware drivers) */
};



/**
 * Client pixel packing/unpacking attributes
 */
01652 struct gl_pixelstore_attrib
{
   GLint Alignment;
   GLint RowLength;
   GLint SkipPixels;
   GLint SkipRows;
01658    GLint ImageHeight;     /**< for GL_EXT_texture3D */
01659    GLint SkipImages;      /**< for GL_EXT_texture3D */
   GLboolean SwapBytes;
   GLboolean LsbFirst;
01662    GLboolean ClientStorage; /**< GL_APPLE_client_storage */
01663    GLboolean Invert;        /**< GL_MESA_pack_invert */
01664    struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
};



/**
 * Client vertex array attributes
 */
01672 struct gl_client_array
{
01674    GLint Size;                  /**< components per element (1,2,3,4) */
01675    GLenum Type;                 /**< datatype: GL_FLOAT, GL_INT, etc */
01676    GLsizei Stride;            /**< user-specified stride */
01677    GLsizei StrideB;           /**< actual stride in bytes */
01678    const GLubyte *Ptr;          /**< Points to array data */
01679    GLboolean Enabled;         /**< Enabled flag is a boolean */
01680    GLboolean Normalized;        /**< GL_ARB_vertex_program */

   /**< GL_ARB_vertex_buffer_object */
   struct gl_buffer_object *BufferObj;
   GLuint _MaxElement;
};


/**
 * Collection of vertex arrays.  Defined by the GL_APPLE_vertex_array_object
 * extension, but a nice encapsulation in any case.
 */
01692 struct gl_array_object
{
   /** Name of the array object as received from glGenVertexArrayAPPLE. */
01695    GLuint Name;

   /** Conventional vertex arrays */
   /*@{*/
01699    struct gl_client_array Vertex;
   struct gl_client_array Normal;
   struct gl_client_array Color;
   struct gl_client_array SecondaryColor;
   struct gl_client_array FogCoord;
   struct gl_client_array Index;
   struct gl_client_array EdgeFlag;
   struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
   /*@}*/

   /** Generic arrays for vertex programs/shaders */
01710    struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];

   /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
01713    GLbitfield _Enabled;
};


/**
 * Vertex array state
 */
01720 struct gl_array_attrib
{
   struct gl_array_object *ArrayObj;
   struct gl_array_object *DefaultArrayObj;

01725    GLint ActiveTexture;       /**< Client Active Texture */
01726    GLuint LockFirst;            /**< GL_EXT_compiled_vertex_array */
01727    GLuint LockCount;            /**< GL_EXT_compiled_vertex_array */

01729    GLbitfield NewState;       /**< mask of _NEW_ARRAY_* values */

#if FEATURE_ARB_vertex_buffer_object
   struct gl_buffer_object *NullBufferObj;
   struct gl_buffer_object *ArrayBufferObj;
   struct gl_buffer_object *ElementArrayBufferObj;
#endif
   GLuint _MaxElement;          /* Min of all enabled array's maxes */
};


/**
 * Feedback buffer state
 */
01743 struct gl_feedback
{
   GLenum Type;
   GLbitfield _Mask;          /* FB_* bits */
   GLfloat *Buffer;
   GLuint BufferSize;
   GLuint Count;
};


/**
 * Selection buffer state
 */
01756 struct gl_selection
{
01758    GLuint *Buffer;      /**< selection buffer */
01759    GLuint BufferSize;   /**< size of the selection buffer */
01760    GLuint BufferCount;  /**< number of values in the selection buffer */
01761    GLuint Hits;         /**< number of records in the selection buffer */
01762    GLuint NameStackDepth; /**< name stack depth */
01763    GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
01764    GLboolean HitFlag;   /**< hit flag */
01765    GLfloat HitMinZ;     /**< minimum hit depth */
01766    GLfloat HitMaxZ;     /**< maximum hit depth */
};


/**
 * 1-D Evaluator control points
 */
01773 struct gl_1d_map
{
01775    GLuint Order;  /**< Number of control points */
01776    GLfloat u1, u2, du;  /**< u1, u2, 1.0/(u2-u1) */
01777    GLfloat *Points;     /**< Points to contiguous control points */
};


/**
 * 2-D Evaluator control points
 */
01784 struct gl_2d_map
{
01786    GLuint Uorder;       /**< Number of control points in U dimension */
01787    GLuint Vorder;       /**< Number of control points in V dimension */
   GLfloat u1, u2, du;
   GLfloat v1, v2, dv;
01790    GLfloat *Points;           /**< Points to contiguous control points */
};


/**
 * All evaluator control point state
 */
01797 struct gl_evaluators
{
   /** 
    * \name 1-D maps
    */
   /*@{*/
   struct gl_1d_map Map1Vertex3;
   struct gl_1d_map Map1Vertex4;
   struct gl_1d_map Map1Index;
   struct gl_1d_map Map1Color4;
   struct gl_1d_map Map1Normal;
   struct gl_1d_map Map1Texture1;
   struct gl_1d_map Map1Texture2;
   struct gl_1d_map Map1Texture3;
   struct gl_1d_map Map1Texture4;
01812    struct gl_1d_map Map1Attrib[16];  /**< GL_NV_vertex_program */
   /*@}*/

   /** 
    * \name 2-D maps 
    */
   /*@{*/
   struct gl_2d_map Map2Vertex3;
   struct gl_2d_map Map2Vertex4;
   struct gl_2d_map Map2Index;
   struct gl_2d_map Map2Color4;
   struct gl_2d_map Map2Normal;
   struct gl_2d_map Map2Texture1;
   struct gl_2d_map Map2Texture2;
   struct gl_2d_map Map2Texture3;
   struct gl_2d_map Map2Texture4;
01828    struct gl_2d_map Map2Attrib[16];  /**< GL_NV_vertex_program */
   /*@}*/
};


/**
 * Names of the various vertex/fragment program register files, etc.
 *
 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
 * All values should fit in a 4-bit field.
 *
 * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
 * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
 * be "uniform" variables since they can only be set outside glBegin/End.
 * They're also all stored in the same Parameters array.
 */
01844 enum register_file
{
01846    PROGRAM_TEMPORARY = 0,   /**< machine->Temporary[] */
01847    PROGRAM_LOCAL_PARAM = 1, /**< gl_program->LocalParams[] */
01848    PROGRAM_ENV_PARAM = 2,   /**< gl_program->Parameters[] */
01849    PROGRAM_STATE_VAR = 3,   /**< gl_program->Parameters[] */
01850    PROGRAM_INPUT = 4,       /**< machine->Inputs[] */
01851    PROGRAM_OUTPUT = 5,      /**< machine->Outputs[] */
01852    PROGRAM_NAMED_PARAM = 6, /**< gl_program->Parameters[] */
01853    PROGRAM_CONSTANT = 7,    /**< gl_program->Parameters[] */
01854    PROGRAM_UNIFORM = 8,     /**< gl_program->Parameters[] */
01855    PROGRAM_VARYING = 9,     /**< machine->Inputs[]/Outputs[] */
01856    PROGRAM_WRITE_ONLY = 10, /**< A dummy, write-only register */
01857    PROGRAM_ADDRESS = 11,    /**< machine->AddressReg */
01858    PROGRAM_SAMPLER = 12,    /**< for shader samplers, compile-time only */
01859    PROGRAM_UNDEFINED = 13,  /**< Invalid value */
   PROGRAM_FILE_MAX
};


/** Vertex and fragment instructions */
struct prog_instruction;
struct gl_program_parameter_list;
struct gl_uniform_list;


/**
 * Base class for any kind of program object
 */
01873 struct gl_program
{
   GLuint Id;
01876    GLubyte *String;  /**< Null-terminated program text */
   GLint RefCount;
01878    GLenum Target;    /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */
01879    GLenum Format;    /**< String encoding format */
   GLboolean Resident;

   struct prog_instruction *Instructions;

01884    GLbitfield InputsRead;     /**< Bitmask of which input regs are read */
01885    GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
01886    GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS];  /**< TEXTURE_x_BIT bitmask */
01887    GLbitfield SamplersUsed;   /**< Bitfield of which samplers are used */
01888    GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */

   /** Named parameters, constants, etc. from program text */
01891    struct gl_program_parameter_list *Parameters;
   /** Numbered local parameters */
01893    GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];

   /** Vertex/fragment shader varying vars */
01896    struct gl_program_parameter_list *Varying;
   /** Vertex program user-defined attributes */
01898    struct gl_program_parameter_list *Attributes;

   /** Map from sampler unit to texture unit (set by glUniform1i()) */
01901    GLubyte SamplerUnits[MAX_SAMPLERS];
   /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
01903    GLubyte SamplerTargets[MAX_SAMPLERS];

   /** Logical counts */
   /*@{*/
01907    GLuint NumInstructions;
   GLuint NumTemporaries;
   GLuint NumParameters;
   GLuint NumAttributes;
   GLuint NumAddressRegs;
   GLuint NumAluInstructions;
   GLuint NumTexInstructions;
   GLuint NumTexIndirections;
   /*@}*/
   /** Native, actual h/w counts */
   /*@{*/
01918    GLuint NumNativeInstructions;
   GLuint NumNativeTemporaries;
   GLuint NumNativeParameters;
   GLuint NumNativeAttributes;
   GLuint NumNativeAddressRegs;
   GLuint NumNativeAluInstructions;
   GLuint NumNativeTexInstructions;
   GLuint NumNativeTexIndirections;
   /*@}*/
};


/** Vertex program object */
01931 struct gl_vertex_program
{
01933    struct gl_program Base;   /**< base class */
01934    GLboolean IsNVProgram;    /**< is this a GL_NV_vertex_program program? */
   GLboolean IsPositionInvariant;
01936    void *TnlData;       /**< should probably use Base.DriverData */
};


/** Fragment program object */
01941 struct gl_fragment_program
{
01943    struct gl_program Base;   /**< base class */
   GLenum FogOption;
   GLboolean UsesKill;
};


/**
 * State common to vertex and fragment programs.
 */
01952 struct gl_program_state
{
   GLint ErrorPos;                       /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
   const char *ErrorString;              /* GL_PROGRAM_ERROR_STRING_ARB/NV */
};


/**
 * Context state for vertex programs.
 */
01962 struct gl_vertex_program_state
{
01964    GLboolean Enabled;               /**< GL_VERTEX_PROGRAM_ARB/NV */
01965    GLboolean _Enabled;              /**< Enabled and valid program? */
01966    GLboolean PointSizeEnabled;      /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
01967    GLboolean TwoSideEnabled;        /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
01968    struct gl_vertex_program *Current;  /**< user-bound vertex program */

   /** Currently enabled and valid program (including internal programs
    * and compiled shader programs).
    */
01973    struct gl_vertex_program *_Current;

01975    GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */

   /* For GL_NV_vertex_program only: */
   GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
   GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];

   /** Should fixed-function T&L be implemented with a vertex prog? */
01982    GLboolean _MaintainTnlProgram;

   /** Program to emulate fixed-function T&L (see above) */
01985    struct gl_vertex_program *_TnlProgram;

#if FEATURE_MESA_program_debug
   GLprogramcallbackMESA Callback;
   GLvoid *CallbackData;
   GLboolean CallbackEnabled;
   GLuint CurrentPosition;
#endif
};


/**
 * Context state for fragment programs.
 */
01999 struct gl_fragment_program_state
{
02001    GLboolean Enabled;     /**< User-set fragment program enable flag */
02002    GLboolean _Enabled;    /**< Fragment program enabled and valid? */
   GLboolean _Active;
02004    struct gl_fragment_program *Current;  /**< User-bound fragment program */

   /** Currently enabled and valid program (including internal programs
    * and compiled shader programs).
    */
02009    struct gl_fragment_program *_Current;

02011    GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */

   /** Should fixed-function texturing be implemented with a fragment prog? */
02014    GLboolean _MaintainTexEnvProgram;
   GLboolean _UseTexEnvProgram;

   /** Program to emulate fixed-function texture env/combine (see above) */
02018    struct gl_fragment_program *_TexEnvProgram;

#if FEATURE_MESA_program_debug
   GLprogramcallbackMESA Callback;
   GLvoid *CallbackData;
   GLboolean CallbackEnabled;
   GLuint CurrentPosition;
#endif
};


/**
 * ATI_fragment_shader runtime state
 */
02032 #define ATI_FS_INPUT_PRIMARY 0
#define ATI_FS_INPUT_SECONDARY 1

struct atifs_instruction;
struct atifs_setupinst;

/**
 * ATI fragment shader
 */
02041 struct ati_fragment_shader
{
   GLuint Id;
   GLint RefCount;
   struct atifs_instruction *Instructions[2];
   struct atifs_setupinst *SetupInst[2];
   GLfloat Constants[8][4];
   GLbitfield LocalConstDef;  /** Indicates which constants have been set */
02049    GLubyte numArithInstr[2];
   GLubyte regsAssigned[2];
   GLubyte NumPasses;         /** 1 or 2 */
02052    GLubyte cur_pass;
   GLubyte last_optype;
   GLboolean interpinp1;
   GLboolean isValid;
   GLuint swizzlerq;
};

/**
 * Context state for GL_ATI_fragment_shader
 */
02062 struct gl_ati_fragment_shader_state
{
   GLboolean Enabled;
   GLboolean _Enabled;                      /** enabled and valid shader? */
02066    GLboolean Compiling;
   GLfloat GlobalConstants[8][4];
   struct ati_fragment_shader *Current;
};


/**
 * Occlusion/timer query object.
 */
02075 struct gl_query_object
{
   GLuint Id;
   GLuint64EXT Result; /* the counter */
   GLboolean Active;   /* inside Begin/EndQuery */
   GLboolean Ready;    /* result is ready */
};


/**
 * Context state for query objects.
 */
02087 struct gl_query_state
{
   struct _mesa_HashTable *QueryObjects;
   struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
   struct gl_query_object *CurrentTimerObject;     /* GL_EXT_timer_query */
};



/**
 * A GLSL vertex or fragment shader object.
 */
02099 struct gl_shader
{
02101    GLenum Type;  /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */
02102    GLuint Name;  /**< AKA the handle */
02103    GLint RefCount;  /**< Reference count */
   GLboolean DeletePending;

02106    const GLchar *Source;  /**< Source code string */
   GLboolean CompileStatus;
02108    struct gl_program *Program;  /**< Post-compile assembly code */
   GLchar *InfoLog;
02110    GLboolean Main;  /**< shader defines main() */
};


/**
 * A GLSL program object.
 * Basically a linked collection of vertex and fragment shaders.
 */
02118 struct gl_shader_program
{
02120    GLenum Type;  /**< Always GL_SHADER_PROGRAM (internal token) */
02121    GLuint Name;  /**< aka handle or ID */
02122    GLint RefCount;  /**< Reference count */
   GLboolean DeletePending;

02125    GLuint NumShaders;          /**< number of attached shaders */
02126    struct gl_shader **Shaders; /**< List of attached the shaders */

   /** User-defined attribute bindings (glBindAttribLocation) */
02129    struct gl_program_parameter_list *Attributes;

   /* post-link info: */
02132    struct gl_vertex_program *VertexProgram;     /**< Linked vertex program */
02133    struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
   struct gl_uniform_list *Uniforms;
   struct gl_program_parameter_list *Varying;
02136    GLboolean LinkStatus;   /**< GL_LINK_STATUS */
   GLboolean Validated;
   GLchar *InfoLog;
};   


/**
 * Context state for GLSL vertex/fragment shaders.
 */
02145 struct gl_shader_state
{
02147    struct gl_shader_program *CurrentProgram; /**< The user-bound program */
   /** Driver-selectable options: */
02149    GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
02150    GLboolean EmitCondCodes;             /**< Use condition codes? */
02151    GLboolean EmitComments;              /**< Annotated instructions */
   void *MemPool;
};


/**
 * State which can be shared by multiple contexts:
 */
02159 struct gl_shared_state
{
02161    _glthread_Mutex Mutex;              /**< for thread safety */
02162    GLint RefCount;                     /**< Reference count */
02163    struct _mesa_HashTable *DisplayList;      /**< Display lists hash table */
02164    struct _mesa_HashTable *TexObjects;       /**< Texture objects hash table */

   /**
    * \name Default texture objects (shared by all multi-texture units)
    */
   /*@{*/
   struct gl_texture_object *Default1D;
   struct gl_texture_object *Default2D;
   struct gl_texture_object *Default3D;
   struct gl_texture_object *DefaultCubeMap;
   struct gl_texture_object *DefaultRect;
   struct gl_texture_object *Default1DArray;
   struct gl_texture_object *Default2DArray;
   /*@}*/

   /**
    * \name Thread safety and statechange notification for texture
    * objects. 
    *
    * \todo Improve the granularity of locking.
    */
   /*@{*/
02186    _glthread_Mutex TexMutex;        /**< texobj thread safety */
02187    GLuint TextureStateStamp;          /**< state notification for shared tex */
   /*@}*/


   /**
    * \name Vertex/fragment programs
    */
   /*@{*/
02195    struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
#if FEATURE_ARB_vertex_program
   struct gl_vertex_program *DefaultVertexProgram;
#endif
#if FEATURE_ARB_fragment_program
   struct gl_fragment_program *DefaultFragmentProgram;
#endif
   /*@}*/

#if FEATURE_ATI_fragment_shader
   struct _mesa_HashTable *ATIShaders;
   struct ati_fragment_shader *DefaultFragmentShader;
#endif

#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
   struct _mesa_HashTable *BufferObjects;
#endif

#if FEATURE_ARB_shader_objects
   /** Table of both gl_shader and gl_shader_program objects */
02215    struct _mesa_HashTable *ShaderObjects;
#endif

#if FEATURE_EXT_framebuffer_object
   struct _mesa_HashTable *RenderBuffers;
   struct _mesa_HashTable *FrameBuffers;
#endif

   /** Objects associated with the GL_APPLE_vertex_array_object extension. */
02224    struct _mesa_HashTable *ArrayObjects;

02226    void *DriverData;  /**< Device driver shared state */
};




/**
 * A renderbuffer stores colors or depth values or stencil values.
 * A framebuffer object will have a collection of these.
 * Data are read/written to the buffer with a handful of Get/Put functions.
 *
 * Instances of this object are allocated with the Driver's NewRenderbuffer
 * hook.  Drivers will likely wrap this class inside a driver-specific
 * class to simulate inheritance.
 */
02241 struct gl_renderbuffer
{
#define RB_MAGIC 0xaabbccdd
   int Magic; /** XXX TEMPORARY DEBUG INFO */
02245    _glthread_Mutex Mutex;              /**< for thread safety */
02246    GLuint ClassID;        /**< Useful for drivers */
   GLuint Name;
   GLint RefCount;
   GLuint Width, Height;
02250    GLenum InternalFormat; /**< The user-specified format */
02251    GLenum _ActualFormat;  /**< The driver-chosen format */
02252    GLenum _BaseFormat;    /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
                               GL_STENCIL_INDEX. */
02254    GLenum DataType;      /**< Type of values passed to the Get/Put functions */
02255    GLubyte RedBits;      /**< Bits of red per pixel */
   GLubyte GreenBits;
   GLubyte BlueBits;
   GLubyte AlphaBits;
   GLubyte IndexBits;
   GLubyte DepthBits;
   GLubyte StencilBits;
02262    GLvoid *Data;        /**< This may not be used by some kinds of RBs */

   /* Used to wrap one renderbuffer around another: */
   struct gl_renderbuffer *Wrapped;

   /* Delete this renderbuffer */
   void (*Delete)(struct gl_renderbuffer *rb);

   /* Allocate new storage for this renderbuffer */
   GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
                             GLenum internalFormat,
                             GLuint width, GLuint height);

   /* Lock/Unlock are called before/after calling the Get/Put functions.
    * Not sure this is the right place for these yet.
   void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
   void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
    */

   /* Return a pointer to the element/pixel at (x,y).
    * Should return NULL if the buffer memory can't be directly addressed.
    */
   void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb,
                       GLint x, GLint y);

   /* Get/Read a row of values.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                  GLint x, GLint y, void *values);

   /* Get/Read values at arbitrary locations.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                     const GLint x[], const GLint y[], void *values);

   /* Put/Write a row of values.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                  GLint x, GLint y, const void *values, const GLubyte *mask);

   /* Put/Write a row of RGB values.  This is a special-case routine that's
    * only used for RGBA renderbuffers when the source data is GL_RGB. That's
    * a common case for glDrawPixels and some triangle routines.
    * The values will be of format GL_RGB and type DataType.
    */
   void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                    GLint x, GLint y, const void *values, const GLubyte *mask);


   /* Put/Write a row of identical values.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                     GLint x, GLint y, const void *value, const GLubyte *mask);

   /* Put/Write values at arbitrary locations.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
                     const GLint x[], const GLint y[], const void *values,
                     const GLubyte *mask);
   /* Put/Write identical values at arbitrary locations.
    * The values will be of format _BaseFormat and type DataType.
    */
   void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb,
                         GLuint count, const GLint x[], const GLint y[],
                         const void *value, const GLubyte *mask);
};


/**
 * A renderbuffer attachment point points to either a texture object
 * (and specifies a mipmap level, cube face or 3D texture slice) or
 * points to a renderbuffer.
 */
02340 struct gl_renderbuffer_attachment
{
02342    GLenum Type;  /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
   GLboolean Complete;

   /**
    * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
    * application supplied renderbuffer object.
    */
02349    struct gl_renderbuffer *Renderbuffer;

   /**
    * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
    * supplied texture object.
    */
02355    struct gl_texture_object *Texture;
02356    GLuint TextureLevel; /**< Attached mipmap level. */
02357    GLuint CubeMapFace;  /**< 0 .. 5, for cube map textures. */
02358    GLuint Zoffset;      /**< Slice for 3D textures,  or layer for both 1D
                         * and 2D array textures */
};


/**
 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
 * In C++ terms, think of this as a base class from which device drivers
 * will make derived classes.
 */
02368 struct gl_framebuffer
{
02370    _glthread_Mutex Mutex;              /**< for thread safety */
   GLuint Name;      /* if zero, this is a window system framebuffer */
   GLint RefCount;
   GLboolean DeletePending;

02375    GLvisual Visual;     /**< The framebuffer's visual.
                             Immutable if this is a window system buffer.
                             Computed from attachments if user-made FBO. */

   GLboolean Initialized;

02381    GLuint Width, Height;      /**< size of frame buffer in pixels */

   /** \name  Drawing bounds (Intersection of buffer size and scissor box) */
   /*@{*/
02385    GLint _Xmin, _Xmax;  /**< inclusive */
02386    GLint _Ymin, _Ymax;  /**< exclusive */
   /*@}*/

   /** \name  Derived Z buffer stuff */
   /*@{*/
02391    GLuint _DepthMax;    /**< Max depth buffer value */
02392    GLfloat _DepthMaxF;  /**< Float max depth buffer value */
02393    GLfloat _MRD;  /**< minimum resolvable difference in Z values */
   /*@}*/

   GLenum _Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */

   /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
   struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];

   /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
    * attribute group and GL_PIXEL attribute group, respectively.
    */
   GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
   GLenum ColorReadBuffer;

   /** Computed from ColorDraw/ReadBuffer above */
02408    GLuint _NumColorDrawBuffers;
02409    GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
   GLint _ColorReadBufferIndex; /* -1 = None */
   struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
   struct gl_renderbuffer *_ColorReadBuffer;

   /** The Actual depth/stencil buffers to use.  May be wrappers around the
    * depth/stencil buffers attached above. */
02416    struct gl_renderbuffer *_DepthBuffer;
   struct gl_renderbuffer *_StencilBuffer;

   /** Delete this framebuffer */
   void (*Delete)(struct gl_framebuffer *fb);
};


/**
 * Limits for vertex and fragment programs.
 */
02427 struct gl_program_constants
{
   /* logical limits */
   GLuint MaxInstructions;
   GLuint MaxAluInstructions; /* fragment programs only, for now */
   GLuint MaxTexInstructions; /* fragment programs only, for now */
   GLuint MaxTexIndirections; /* fragment programs only, for now */
   GLuint MaxAttribs;
   GLuint MaxTemps;
   GLuint MaxAddressRegs; /* vertex program only, for now */
   GLuint MaxParameters;
   GLuint MaxLocalParams;
   GLuint MaxEnvParams;
   /* native/hardware limits */
   GLuint MaxNativeInstructions;
   GLuint MaxNativeAluInstructions; /* fragment programs only, for now */
   GLuint MaxNativeTexInstructions; /* fragment programs only, for now */
   GLuint MaxNativeTexIndirections; /* fragment programs only, for now */
   GLuint MaxNativeAttribs;
   GLuint MaxNativeTemps;
   GLuint MaxNativeAddressRegs; /* vertex program only, for now */
   GLuint MaxNativeParameters;
   /* For shaders */
   GLuint MaxUniformComponents;
};


/**
 * Constants which may be overridden by device driver during context creation
 * but are never changed after that.
 */
02458 struct gl_constants
{
02460    GLint MaxTextureLevels;          /**< Maximum number of allowed mipmap levels. */ 
02461    GLint Max3DTextureLevels;        /**< Maximum number of allowed mipmap levels for 3D texture targets. */
02462    GLint MaxCubeTextureLevels;          /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
02463    GLint MaxArrayTextureLayers;         /**< Maximum number of layers in an array texture. */
   GLint MaxTextureRectSize;            /* GL_NV_texture_rectangle */
   GLuint MaxTextureCoordUnits;
   GLuint MaxTextureImageUnits;
   GLuint MaxTextureUnits;              /* = MIN(CoordUnits, ImageUnits) */
   GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
   GLfloat MaxTextureLodBias;           /* GL_EXT_texture_lod_bias */
   GLuint MaxArrayLockSize;
   GLint SubPixelBits;
   GLfloat MinPointSize, MaxPointSize;          /* aliased */
   GLfloat MinPointSizeAA, MaxPointSizeAA;      /* antialiased */
   GLfloat PointSizeGranularity;
   GLfloat MinLineWidth, MaxLineWidth;          /* aliased */
   GLfloat MinLineWidthAA, MaxLineWidthAA;      /* antialiased */
   GLfloat LineWidthGranularity;
   GLuint MaxColorTableSize;
   GLuint MaxConvolutionWidth;
   GLuint MaxConvolutionHeight;
   GLuint MaxClipPlanes;
   GLuint MaxLights;
   GLfloat MaxShininess;                  /* GL_NV_light_max_exponent */
   GLfloat MaxSpotExponent;               /* GL_NV_light_max_exponent */
   GLuint MaxViewportWidth, MaxViewportHeight;
   struct gl_program_constants VertexProgram;    /* GL_ARB_vertex_program */
   struct gl_program_constants FragmentProgram;  /* GL_ARB_fragment_program */
   /* shared by vertex and fragment program: */
   GLuint MaxProgramMatrices;
   GLuint MaxProgramMatrixStackDepth;
   /* vertex array / buffer object bounds checking */
   GLboolean CheckArrayBounds;
   /* GL_ARB_draw_buffers */
   GLuint MaxDrawBuffers;
   /* GL_OES_read_format */
   GLenum ColorReadFormat;
   GLenum ColorReadType;
   /* GL_EXT_framebuffer_object */
   GLuint MaxColorAttachments;
   GLuint MaxRenderbufferSize;
   /* GL_ARB_vertex_shader */
   GLuint MaxVertexTextureImageUnits;
   GLuint MaxVarying;
};


/**
 * Enable flag for each OpenGL extension.  Different device drivers will
 * enable different extensions at runtime.
 */
02511 struct gl_extensions
{
   /**
    * \name Flags to quickly test if certain extensions are available.
    * 
    * Not every extension needs to have such a flag, but it's encouraged.
    */
   /*@{*/
   GLboolean dummy;  /* don't remove this! */
   GLboolean ARB_depth_texture;
   GLboolean ARB_draw_buffers;
   GLboolean ARB_fragment_program;
   GLboolean ARB_fragment_program_shadow;
   GLboolean ARB_fragment_shader;
   GLboolean ARB_half_float_pixel;
   GLboolean ARB_imaging;
   GLboolean ARB_multisample;
   GLboolean ARB_multitexture;
   GLboolean ARB_occlusion_query;
   GLboolean ARB_point_sprite;
   GLboolean ARB_shader_objects;
   GLboolean ARB_shading_language_100;
   GLboolean ARB_shading_language_120;
   GLboolean ARB_shadow;
   GLboolean ARB_texture_border_clamp;
   GLboolean ARB_texture_compression;
   GLboolean ARB_texture_cube_map;
   GLboolean ARB_texture_env_combine;
   GLboolean ARB_texture_env_crossbar;
   GLboolean ARB_texture_env_dot3;
   GLboolean ARB_texture_float;
   GLboolean ARB_texture_mirrored_repeat;
   GLboolean ARB_texture_non_power_of_two;
   GLboolean ARB_transpose_matrix;
   GLboolean ARB_vertex_buffer_object;
   GLboolean ARB_vertex_program;
   GLboolean ARB_vertex_shader;
   GLboolean ARB_window_pos;
   GLboolean EXT_abgr;
   GLboolean EXT_bgra;
   GLboolean EXT_blend_color;
   GLboolean EXT_blend_equation_separate;
   GLboolean EXT_blend_func_separate;
   GLboolean EXT_blend_logic_op;
   GLboolean EXT_blend_minmax;
   GLboolean EXT_blend_subtract;
   GLboolean EXT_clip_volume_hint;
   GLboolean EXT_cull_vertex;
   GLboolean EXT_convolution;
   GLboolean EXT_compiled_vertex_array;
   GLboolean EXT_copy_texture;
   GLboolean EXT_depth_bounds_test;
   GLboolean EXT_draw_range_elements;
   GLboolean EXT_framebuffer_object;
   GLboolean EXT_fog_coord;
   GLboolean EXT_framebuffer_blit;
   GLboolean EXT_gpu_program_parameters;
   GLboolean EXT_histogram;
   GLboolean EXT_multi_draw_arrays;
   GLboolean EXT_paletted_texture;
   GLboolean EXT_packed_depth_stencil;
   GLboolean EXT_packed_pixels;
   GLboolean EXT_pixel_buffer_object;
   GLboolean EXT_point_parameters;
   GLboolean EXT_polygon_offset;
   GLboolean EXT_rescale_normal;
   GLboolean EXT_shadow_funcs;
   GLboolean EXT_secondary_color;
   GLboolean EXT_separate_specular_color;
   GLboolean EXT_shared_texture_palette;
   GLboolean EXT_stencil_wrap;
   GLboolean EXT_stencil_two_side;
   GLboolean EXT_subtexture;
   GLboolean EXT_texture;
   GLboolean EXT_texture_object;
   GLboolean EXT_texture3D;
   GLboolean EXT_texture_compression_s3tc;
   GLboolean EXT_texture_env_add;
   GLboolean EXT_texture_env_combine;
   GLboolean EXT_texture_env_dot3;
   GLboolean EXT_texture_filter_anisotropic;
   GLboolean EXT_texture_lod_bias;
   GLboolean EXT_texture_mirror_clamp;
   GLboolean EXT_texture_sRGB;
   GLboolean EXT_timer_query;
   GLboolean EXT_vertex_array;
   GLboolean EXT_vertex_array_set;
   /* vendor extensions */
   GLboolean APPLE_client_storage;
   GLboolean APPLE_packed_pixels;
   GLboolean APPLE_vertex_array_object;
   GLboolean ATI_texture_mirror_once;
   GLboolean ATI_texture_env_combine3;
   GLboolean ATI_fragment_shader;
   GLboolean ATI_separate_stencil;
   GLboolean IBM_rasterpos_clip;
   GLboolean IBM_multimode_draw_arrays;
   GLboolean MESA_pack_invert;
   GLboolean MESA_packed_depth_stencil;
   GLboolean MESA_program_debug;
   GLboolean MESA_resize_buffers;
   GLboolean MESA_ycbcr_texture;
   GLboolean MESA_texture_array;
   GLboolean NV_blend_square;
   GLboolean NV_fragment_program;
   GLboolean NV_light_max_exponent;
   GLboolean NV_point_sprite;
   GLboolean NV_texgen_reflection;
   GLboolean NV_texture_rectangle;
   GLboolean NV_vertex_program;
   GLboolean NV_vertex_program1_1;
   GLboolean OES_read_format;
   GLboolean SGI_color_matrix;
   GLboolean SGI_color_table;
   GLboolean SGI_texture_color_table;
   GLboolean SGIS_generate_mipmap;
   GLboolean SGIS_texture_edge_clamp;
   GLboolean SGIS_texture_lod;
   GLboolean SGIX_depth_texture;
   GLboolean SGIX_shadow;
   GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
   GLboolean TDFX_texture_compression_FXT1;
   GLboolean S3_s3tc;
   /*@}*/
   /* The extension string */
   const GLubyte *String;
};


/**
 * A stack of matrices (projection, modelview, color, texture, etc).
 */
02643 struct gl_matrix_stack
{
02645    GLmatrix *Top;      /**< points into Stack */
02646    GLmatrix *Stack;    /**< array [MaxDepth] of GLmatrix */
02647    GLuint Depth;       /**< 0 <= Depth < MaxDepth */
02648    GLuint MaxDepth;    /**< size of Stack[] array */
02649    GLuint DirtyFlag;   /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
};


/**
 * \name Bits for image transfer operations 
 *
 * \sa __GLcontextRec::ImageTransferState.
 */
/*@{*/
#define IMAGE_SCALE_BIAS_BIT                      0x1
#define IMAGE_SHIFT_OFFSET_BIT                    0x2
#define IMAGE_MAP_COLOR_BIT                       0x4
#define IMAGE_COLOR_TABLE_BIT                     0x8
#define IMAGE_CONVOLUTION_BIT                     0x10
#define IMAGE_POST_CONVOLUTION_SCALE_BIAS         0x20
#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT    0x40
#define IMAGE_COLOR_MATRIX_BIT                    0x80
#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT   0x100
#define IMAGE_HISTOGRAM_BIT                       0x200
#define IMAGE_MIN_MAX_BIT                         0x400
#define IMAGE_CLAMP_BIT                           0x800 /* extra */


/** Pixel Transfer ops up to convolution */
02674 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT |     \
                                    IMAGE_SHIFT_OFFSET_BIT |   \
                                    IMAGE_MAP_COLOR_BIT |      \
                                    IMAGE_COLOR_TABLE_BIT)

/** Pixel transfer ops after convolution */
02680 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS |      \
                                     IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
                                     IMAGE_COLOR_MATRIX_BIT |                 \
                                     IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
                                     IMAGE_HISTOGRAM_BIT |                    \
                                     IMAGE_MIN_MAX_BIT)
/*@}*/


/**
 * \name Bits to indicate what state has changed.  
 *
 * 4 unused flags.
 */
/*@{*/
02695 #define _NEW_MODELVIEW        0x1        /**< __GLcontextRec::ModelView */
02696 #define _NEW_PROJECTION       0x2        /**< __GLcontextRec::Projection */
02697 #define _NEW_TEXTURE_MATRIX   0x4        /**< __GLcontextRec::TextureMatrix */
02698 #define _NEW_COLOR_MATRIX     0x8        /**< __GLcontextRec::ColorMatrix */
02699 #define _NEW_ACCUM            0x10       /**< __GLcontextRec::Accum */
02700 #define _NEW_COLOR            0x20       /**< __GLcontextRec::Color */
02701 #define _NEW_DEPTH            0x40       /**< __GLcontextRec::Depth */
02702 #define _NEW_EVAL       0x80       /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
02703 #define _NEW_FOG        0x100      /**< __GLcontextRec::Fog */
02704 #define _NEW_HINT       0x200      /**< __GLcontextRec::Hint */
02705 #define _NEW_LIGHT            0x400      /**< __GLcontextRec::Light */
02706 #define _NEW_LINE       0x800      /**< __GLcontextRec::Line */
02707 #define _NEW_PIXEL            0x1000     /**< __GLcontextRec::Pixel */
02708 #define _NEW_POINT            0x2000     /**< __GLcontextRec::Point */
02709 #define _NEW_POLYGON          0x4000     /**< __GLcontextRec::Polygon */
02710 #define _NEW_POLYGONSTIPPLE   0x8000     /**< __GLcontextRec::PolygonStipple */
02711 #define _NEW_SCISSOR          0x10000    /**< __GLcontextRec::Scissor */
02712 #define _NEW_STENCIL          0x20000    /**< __GLcontextRec::Stencil */
02713 #define _NEW_TEXTURE          0x40000    /**< __GLcontextRec::Texture */
02714 #define _NEW_TRANSFORM        0x80000    /**< __GLcontextRec::Transform */
02715 #define _NEW_VIEWPORT         0x100000   /**< __GLcontextRec::Viewport */
02716 #define _NEW_PACKUNPACK       0x200000   /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
02717 #define _NEW_ARRAY              0x400000   /**< __GLcontextRec::Array */
02718 #define _NEW_RENDERMODE       0x800000   /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
02719 #define _NEW_BUFFERS            0x1000000  /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
02720 #define _NEW_MULTISAMPLE        0x2000000  /**< __GLcontextRec::Multisample */
02721 #define _NEW_TRACK_MATRIX       0x4000000  /**< __GLcontextRec::VertexProgram */
02722 #define _NEW_PROGRAM            0x8000000  /**< __GLcontextRec::VertexProgram */
#define _NEW_ALL ~0
/*@}*/


/**
 * \name Bits to track array state changes 
 *
 * Also used to summarize array enabled.
 */
/*@{*/
#define _NEW_ARRAY_VERTEX           VERT_BIT_POS
#define _NEW_ARRAY_WEIGHT           VERT_BIT_WEIGHT
#define _NEW_ARRAY_NORMAL           VERT_BIT_NORMAL
#define _NEW_ARRAY_COLOR0           VERT_BIT_COLOR0
#define _NEW_ARRAY_COLOR1           VERT_BIT_COLOR1
#define _NEW_ARRAY_FOGCOORD         VERT_BIT_FOG
#define _NEW_ARRAY_INDEX            VERT_BIT_COLOR_INDEX
#define _NEW_ARRAY_EDGEFLAG         VERT_BIT_EDGEFLAG
#define _NEW_ARRAY_TEXCOORD_0       VERT_BIT_TEX0
#define _NEW_ARRAY_TEXCOORD_1       VERT_BIT_TEX1
#define _NEW_ARRAY_TEXCOORD_2       VERT_BIT_TEX2
#define _NEW_ARRAY_TEXCOORD_3       VERT_BIT_TEX3
#define _NEW_ARRAY_TEXCOORD_4       VERT_BIT_TEX4
#define _NEW_ARRAY_TEXCOORD_5       VERT_BIT_TEX5
#define _NEW_ARRAY_TEXCOORD_6       VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7       VERT_BIT_TEX7
#define _NEW_ARRAY_ATTRIB_0         VERT_BIT_GENERIC0  /* start at bit 16 */
#define _NEW_ARRAY_ALL              0xffffffff


#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
/*@}*/


/**
 * \name A bunch of flags that we think might be useful to drivers.
 * 
 * Set in the __GLcontextRec::_TriangleCaps bitfield.
 */
/*@{*/
#define DD_FLATSHADE                0x1
#define DD_SEPARATE_SPECULAR        0x2
#define DD_TRI_CULL_FRONT_BACK      0x4 /* special case on some hw */
#define DD_TRI_LIGHT_TWOSIDE        0x8
#define DD_TRI_UNFILLED             0x10
#define DD_TRI_SMOOTH               0x20
#define DD_TRI_STIPPLE              0x40
#define DD_TRI_OFFSET               0x80
#define DD_LINE_SMOOTH              0x100
#define DD_LINE_STIPPLE             0x200
#define DD_LINE_WIDTH               0x400
#define DD_POINT_SMOOTH             0x800
#define DD_POINT_SIZE               0x1000
#define DD_POINT_ATTEN              0x2000
#define DD_TRI_TWOSTENCIL           0x4000
/*@}*/


/**
 * \name Define the state changes under which each of these bits might change
 */
/*@{*/
#define _DD_NEW_FLATSHADE                _NEW_LIGHT
#define _DD_NEW_SEPARATE_SPECULAR        (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
#define _DD_NEW_TRI_CULL_FRONT_BACK      _NEW_POLYGON
#define _DD_NEW_TRI_LIGHT_TWOSIDE        _NEW_LIGHT
#define _DD_NEW_TRI_UNFILLED             _NEW_POLYGON
#define _DD_NEW_TRI_SMOOTH               _NEW_POLYGON
#define _DD_NEW_TRI_STIPPLE              _NEW_POLYGON
#define _DD_NEW_TRI_OFFSET               _NEW_POLYGON
#define _DD_NEW_LINE_SMOOTH              _NEW_LINE
#define _DD_NEW_LINE_STIPPLE             _NEW_LINE
#define _DD_NEW_LINE_WIDTH               _NEW_LINE
#define _DD_NEW_POINT_SMOOTH             _NEW_POINT
#define _DD_NEW_POINT_SIZE               _NEW_POINT
#define _DD_NEW_POINT_ATTEN              _NEW_POINT
/*@}*/


#define _MESA_NEW_NEED_EYE_COORDS         (_NEW_LIGHT |           \
                                           _NEW_TEXTURE |   \
                                           _NEW_POINT |           \
                                           _NEW_PROGRAM |   \
                                           _NEW_MODELVIEW)

#define _MESA_NEW_NEED_NORMALS            (_NEW_LIGHT |           \
                                           _NEW_TEXTURE)

#define _IMAGE_NEW_TRANSFER_STATE         (_NEW_PIXEL | _NEW_COLOR_MATRIX)




/*
 * Forward declaration of display list data types:
 */
union node;
typedef union node Node;


/* This has to be included here. */
#include "dd.h"


#define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))

/**
 * Core Mesa's support for tnl modules:
 */
02833 struct gl_tnl_module
{
   /**
    * Vertex format to be lazily swapped into current dispatch.
    */
02838    const GLvertexformat *Current;

   /**
    * \name Record of functions swapped out.  
    * On restore, only need to swap these functions back in.
    */
   /*@{*/
   struct {
       _glapi_proc * location;
       _glapi_proc function;
   } Swapped[NUM_VERTEX_FORMAT_ENTRIES];
   GLuint SwapCount;
   /*@}*/
};

/* Strictly this is a tnl/ private concept, but it doesn't seem
 * worthwhile adding a tnl private structure just to hold this one bit
 * of information:
 */
#define MESA_DLIST_DANGLING_REFS     0x1 

/* Provide a location where information about a display list can be
 * collected.  Could be extended with driverPrivate structures,
 * etc. in the future.
 */
struct mesa_display_list
{
   Node *node;
   GLuint id;
   GLbitfield flags;
};


/**
 * State used during display list compilation and execution.
 */
02874 struct gl_dlist_state
{
02876    GLuint CallDepth;          /**< Current recursion calling depth */

   struct mesa_display_list *CurrentList;
02879    Node *CurrentListPtr;      /**< Head of list being compiled */
02880    GLuint CurrentListNum;     /**< Number of the list being compiled */
02881    Node *CurrentBlock;        /**< Pointer to current block of nodes */
02882    GLuint CurrentPos;         /**< Index into current block of nodes */

   GLvertexformat ListVtxfmt;

   GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
   GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
   
   GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
   GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];

   GLubyte ActiveIndex;
   GLfloat CurrentIndex;
   
   GLubyte ActiveEdgeFlag;
   GLboolean CurrentEdgeFlag;
};


/**
 * Mesa rendering context.
 *
 * This is the central context data structure for Mesa.  Almost all
 * OpenGL state is contained in this structure.
 * Think of this as a base class from which device drivers will derive
 * sub classes.
 *
 * The GLcontext typedef names this structure.
 */
02910 struct __GLcontextRec
{
   /** State possibly shared with other contexts in the address space */
02913    struct gl_shared_state *Shared;

   /** \name API function pointer tables */
   /*@{*/
02917    struct _glapi_table *Save; /**< Display list save functions */
02918    struct _glapi_table *Exec; /**< Execute functions */
02919    struct _glapi_table *CurrentDispatch;  /**< == Save or Exec !! */
   /*@}*/

   GLvisual Visual;
02923    GLframebuffer *DrawBuffer; /**< buffer for writing */
02924    GLframebuffer *ReadBuffer; /**< buffer for reading */
02925    GLframebuffer *WinSysDrawBuffer;  /**< set with MakeCurrent */
02926    GLframebuffer *WinSysReadBuffer;  /**< set with MakeCurrent */

   /**
    * Device driver function pointer table
    */
02931    struct dd_function_table Driver;

02933    void *DriverCtx;     /**< Points to device driver context/state */

   /** Core/Driver constants */
02936    struct gl_constants Const;

   /** \name The various 4x4 matrix stacks */
   /*@{*/
   struct gl_matrix_stack ModelviewMatrixStack;
   struct gl_matrix_stack ProjectionMatrixStack;
   struct gl_matrix_stack ColorMatrixStack;
   struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
   struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
02945    struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
   /*@}*/

   /** Combined modelview and projection matrix */
02949    GLmatrix _ModelProjectMatrix;

   /** \name Display lists */
   struct gl_dlist_state ListState;

02954    GLboolean ExecuteFlag;     /**< Execute GL commands? */
02955    GLboolean CompileFlag;     /**< Compile GL commands into display list? */

   /** Extension information */
02958    struct gl_extensions Extensions;

   /** \name State attribute stack (for glPush/PopAttrib) */
   /*@{*/
   GLuint AttribStackDepth;
   struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
   /*@}*/

   /** \name Renderer attribute groups
    * 
    * We define a struct for each attribute group to make pushing and popping
    * attributes easy.  Also it's a good organization.
    */
   /*@{*/
02972    struct gl_accum_attrib     Accum;            /**< Accum buffer attributes */
02973    struct gl_colorbuffer_attrib     Color;            /**< Color buffer attributes */
02974    struct gl_current_attrib   Current;    /**< Current attributes */
02975    struct gl_depthbuffer_attrib     Depth;            /**< Depth buffer attributes */
02976    struct gl_eval_attrib      Eval;       /**< Eval attributes */
02977    struct gl_fog_attrib       Fog;        /**< Fog attributes */
02978    struct gl_hint_attrib      Hint;       /**< Hint attributes */
02979    struct gl_light_attrib     Light;            /**< Light attributes */
02980    struct gl_line_attrib      Line;       /**< Line attributes */
02981    struct gl_list_attrib      List;       /**< List attributes */
   struct gl_multisample_attrib Multisample;
02983    struct gl_pixel_attrib     Pixel;            /**< Pixel attributes */
02984    struct gl_point_attrib     Point;            /**< Point attributes */
02985    struct gl_polygon_attrib   Polygon;    /**< Polygon attributes */
02986    GLuint PolygonStipple[32];             /**< Polygon stipple */
02987    struct gl_scissor_attrib   Scissor;    /**< Scissor attributes */
02988    struct gl_stencil_attrib   Stencil;    /**< Stencil buffer attributes */
02989    struct gl_texture_attrib   Texture;    /**< Texture attributes */
02990    struct gl_transform_attrib Transform;  /**< Transformation attributes */
02991    struct gl_viewport_attrib  Viewport;   /**< Viewport attributes */
   /*@}*/

   /** \name Client attribute stack */
   /*@{*/
   GLuint ClientAttribStackDepth;
   struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
   /*@}*/

   /** \name Client attribute groups */
   /*@{*/
03002    struct gl_array_attrib     Array;      /**< Vertex arrays */
03003    struct gl_pixelstore_attrib      Pack; /**< Pixel packing */
03004    struct gl_pixelstore_attrib      Unpack;     /**< Pixel unpacking */
03005    struct gl_pixelstore_attrib      DefaultPacking;   /**< Default params */
   /*@}*/

   /** \name Other assorted state (not pushed/popped on attribute stack) */
   /*@{*/
   struct gl_pixelmaps          PixelMaps;
   struct gl_histogram_attrib Histogram;
   struct gl_minmax_attrib    MinMax;
   struct gl_convolution_attrib Convolution1D;
   struct gl_convolution_attrib Convolution2D;
   struct gl_convolution_attrib Separable2D;

03017    struct gl_evaluators EvalMap;   /**< All evaluators */
03018    struct gl_feedback   Feedback;  /**< Feedback */
03019    struct gl_selection  Select;    /**< Selection */

   struct gl_color_table ColorTable[COLORTABLE_MAX];
   struct gl_color_table ProxyColorTable[COLORTABLE_MAX];
#if 0
   struct gl_color_table PostConvolutionColorTable;
   struct gl_color_table ProxyPostConvolutionColorTable;
   struct gl_color_table PostColorMatrixColorTable;
   struct gl_color_table ProxyPostColorMatrixColorTable;
#endif

03030    struct gl_program_state Program;        /**< for vertex or fragment progs */
03031    struct gl_vertex_program_state VertexProgram;   /**< GL_ARB/NV_vertex_program */
03032    struct gl_fragment_program_state FragmentProgram;  /**< GL_ARB/NV_vertex_program */
03033    struct gl_ati_fragment_shader_state ATIFragmentShader;  /**< GL_ATI_fragment_shader */

03035    struct gl_query_state Query;  /**< GL_ARB_occlusion_query */

03037    struct gl_shader_state Shader; /**< GLSL shader object state */
   /*@}*/

#if FEATURE_EXT_framebuffer_object
   struct gl_renderbuffer *CurrentRenderbuffer;
#endif

03044    GLenum ErrorValue;        /**< Last error code */
03045    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
03046    GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */

   /** \name Derived state */
   /*@{*/
   /** Bitwise-or of DD_* flags.  Note that this bitfield may be used before
    * state validation so they need to always be current.
    */
03053    GLbitfield _TriangleCaps;
03054    GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
   GLfloat _EyeZDir[3];
   GLfloat _ModelViewInvScale;
   GLboolean _NeedEyeCoords;
   GLboolean _ForceEyeCoords; 
   GLenum _CurrentProgram;    /* currently executing program */

   GLuint TextureStateTimestamp; /* detect changes to shared state */

03063    struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
03064    struct gl_shine_tab *_ShineTabList;  /**< MRU list of inactive shine tables */
   /**@}*/

03067    struct gl_list_extensions ListExt; /**< driver dlist extensions */

   /** \name For debugging/development only */
   /*@{*/
   GLboolean FirstTimeCurrent;
   /*@}*/

   /** Dither disable via MESA_NO_DITHER env var */
03075    GLboolean NoDither;

   /** software compression/decompression supported or not */
03078    GLboolean Mesa_DXTn;

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

   /**
    * \name Hooks for module contexts.  
    *
    * These will eventually live in the driver or elsewhere.
    */
   /*@{*/
   void *swrast_context;
   void *swsetup_context;
   void *swtnl_context;
   void *swtnl_im;
   void *acache_context;
   void *aelt_context;
   /*@}*/
};


/** The string names for GL_POINT, GL_LINE_LOOP, etc */
extern const char *_mesa_prim_name[GL_POLYGON+4];


#ifdef DEBUG
extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS;
# define MESA_FUNCTION __FUNCTION__
#else
# define MESA_VERBOSE 0
# define MESA_DEBUG_FLAGS 0
# define MESA_FUNCTION "a function"
# ifndef NDEBUG
#  define NDEBUG
# endif
#endif


enum _verbose
{
   VERBOSE_VARRAY       = 0x0001,
   VERBOSE_TEXTURE            = 0x0002,
   VERBOSE_IMMEDIATE          = 0x0004,
   VERBOSE_PIPELINE           = 0x0008,
   VERBOSE_DRIVER       = 0x0010,
   VERBOSE_STATE        = 0x0020,
   VERBOSE_API                = 0x0040,
   VERBOSE_DISPLAY_LIST       = 0x0100,
   VERBOSE_LIGHTING           = 0x0200,
   VERBOSE_PRIMS        = 0x0400,
   VERBOSE_VERTS        = 0x0800,
   VERBOSE_DISASSEM           = 0x1000
};


enum _debug
{
   DEBUG_ALWAYS_FLUSH         = 0x1
};



#define Elements(x) sizeof(x)/sizeof(*(x))


#endif /* TYPES_H */

Generated by  Doxygen 1.6.0   Back to index