mesa: fix typo (s/feadback/feedback/). Fixes broken selection/feedback.
[mesa.git] / src / mesa / main / mtypes.h
index 76b36d60f1b4011b722eebb08e2839c55ca7f0c7..19cf6f56d1a91a91f032c3a697ff03f64fd906fa 100644 (file)
 
 
 #include "glheader.h"
-#include <GL/internal/glcore.h>        /* GLimports/GLexports/GLcontextModes */
+#include <GL/internal/glcore.h>        /* __GLcontextModes (GLvisual) */
 #include "config.h"            /* Hardwired parameters */
-#include "glapitable.h"
-#include "glthread.h"
+#include "glapi/glapi.h"
 #include "math/m_matrix.h"     /* GLmatrix */
 #include "bitset.h"
 
@@ -47,7 +46,7 @@
 /**
  * Special, internal token
  */
-#define GL_SHADER_PROGRAM 0x9999
+#define GL_SHADER_PROGRAM_MESA 0x9999
 
 
 /**
@@ -123,6 +122,7 @@ typedef int GLfixed;
 /*@{*/
 struct _mesa_HashTable;
 struct gl_pixelstore_attrib;
+struct gl_program_cache;
 struct gl_texture_format;
 struct gl_texture_image;
 struct gl_texture_object;
@@ -149,7 +149,8 @@ enum
    VERT_ATTRIB_COLOR1 = 4,
    VERT_ATTRIB_FOG = 5,
    VERT_ATTRIB_COLOR_INDEX = 6,
-   VERT_ATTRIB_SEVEN = 7,
+   VERT_ATTRIB_POINT_SIZE = 6,  /*alias*/
+   VERT_ATTRIB_EDGEFLAG = 7,
    VERT_ATTRIB_TEX0 = 8,
    VERT_ATTRIB_TEX1 = 9,
    VERT_ATTRIB_TEX2 = 10,
@@ -189,7 +190,7 @@ enum
 #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_SEVEN       (1 << VERT_ATTRIB_SEVEN)
+#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)
@@ -306,7 +307,8 @@ enum
    FRAG_RESULT_COLR = 0,
    FRAG_RESULT_COLH = 1,
    FRAG_RESULT_DEPR = 2,
-   FRAG_RESULT_MAX = 3
+   FRAG_RESULT_DATA0 = 3,
+   FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
 };
 
 
@@ -380,6 +382,13 @@ enum {
                             BUFFER_BIT_COLOR7)
 
 
+/** The pixel transfer path has three color tables: */
+/*@{*/
+#define COLORTABLE_PRECONVOLUTION  0
+#define COLORTABLE_POSTCONVOLUTION 1
+#define COLORTABLE_POSTCOLORMATRIX 2
+#define COLORTABLE_MAX 3
+/*@}*/
 
 
 /**
@@ -613,11 +622,11 @@ 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.
     */
    /*@{*/
    GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
-   GLfloat Index;                      /**< Current color index */
-   GLboolean EdgeFlag;                 /**< Current edge flag */
    /*@}*/
 
    /**
@@ -660,9 +669,7 @@ struct gl_enable_attrib
    GLboolean Blend;
    GLbitfield ClipPlanes;
    GLboolean ColorMaterial;
-   GLboolean ColorTable;                /* SGI_color_table */
-   GLboolean PostColorMatrixColorTable; /* SGI_color_table */
-   GLboolean PostConvolutionColorTable; /* SGI_color_table */
+   GLboolean ColorTable[COLORTABLE_MAX];
    GLboolean Convolution1D;
    GLboolean Convolution2D;
    GLboolean Separable2D;
@@ -911,7 +918,6 @@ struct gl_line_attrib
    GLushort StipplePattern;    /**< Stipple pattern */
    GLint StippleFactor;                /**< Stipple repeat factor */
    GLfloat Width;              /**< Line width */
-   GLfloat _Width;             /**< Clamped Line width */
 };
 
 
@@ -953,6 +959,7 @@ struct gl_list_extensions
 struct gl_multisample_attrib
 {
    GLboolean Enabled;
+   GLboolean _Enabled;   /**< true if Enabled and multisample buffer */
    GLboolean SampleAlphaToCoverage;
    GLboolean SampleAlphaToOne;
    GLboolean SampleCoverage;
@@ -961,75 +968,92 @@ struct gl_multisample_attrib
 };
 
 
+/**
+ * A pixelmap (see glPixelMap)
+ */
+struct gl_pixelmap
+{
+   GLint Size;
+   GLfloat Map[MAX_PIXEL_MAP_TABLE];
+   GLubyte Map8[MAX_PIXEL_MAP_TABLE];  /**< converted to 8-bit color */
+};
+
+
+/**
+ * Collection of all pixelmaps
+ */
+struct gl_pixelmaps
+{
+   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).
  */
 struct gl_pixel_attrib
 {
    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;
-   GLfloat ZoomX, ZoomY;
-   /* XXX move these out of gl_pixel_attrib */
-   GLint MapStoSsize;          /**< Size of each pixel map */
-   GLint MapItoIsize;
-   GLint MapItoRsize;
-   GLint MapItoGsize;
-   GLint MapItoBsize;
-   GLint MapItoAsize;
-   GLint MapRtoRsize;
-   GLint MapGtoGsize;
-   GLint MapBtoBsize;
-   GLint MapAtoAsize;
-   GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */
-   GLfloat MapItoI[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
-   GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE];  /**< converted to 8-bit color */
-   GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
-   GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
-   GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
-   GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
-   /** GL_EXT_histogram */
-   GLboolean HistogramEnabled;
-   GLboolean MinMaxEnabled;
-   /** GL_SGI_color_matrix */
-   GLfloat PostColorMatrixScale[4];  /**< RGBA */
-   GLfloat PostColorMatrixBias[4];   /**< RGBA */
-   /** GL_SGI_color_table */
-   GLfloat ColorTableScale[4];
-   GLfloat ColorTableBias[4];
-   GLboolean ColorTableEnabled;
-   GLfloat PCCTscale[4];
-   GLfloat PCCTbias[4];
-   GLboolean PostConvolutionColorTableEnabled;
-   GLfloat PCMCTscale[4];
-   GLfloat PCMCTbias[4];
-   GLboolean PostColorMatrixColorTableEnabled;
-   /** GL_SGI_texture_color_table */
-   GLfloat TextureColorTableScale[4];
-   GLfloat TextureColorTableBias[4];
-   /** Convolution */
+
+   /* There are multiple color table stages: */
+   GLboolean ColorTableEnabled[COLORTABLE_MAX];
+   GLfloat ColorTableScale[COLORTABLE_MAX][4];  /**< RGBA */
+   GLfloat ColorTableBias[COLORTABLE_MAX][4];   /**< RGBA */
+
+   /* Convolution (GL_EXT_convolution) */
    GLboolean Convolution1DEnabled;
    GLboolean Convolution2DEnabled;
    GLboolean Separable2DEnabled;
    GLfloat ConvolutionBorderColor[3][4];
    GLenum ConvolutionBorderMode[3];
-   GLfloat ConvolutionFilterScale[3][4];
-   GLfloat ConvolutionFilterBias[3][4];
+   GLfloat ConvolutionFilterScale[3][4];  /**< RGBA */
+   GLfloat ConvolutionFilterBias[3][4];   /**< RGBA */
    GLfloat PostConvolutionScale[4];  /**< RGBA */
    GLfloat PostConvolutionBias[4];   /**< RGBA */
+
+   /* Color matrix (GL_SGI_color_matrix) */
+   /* Note: the color matrix is not part of this attrib group */
+   GLfloat PostColorMatrixScale[4];  /**< RGBA */
+   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 */
+   GLfloat TextureColorTableScale[4];
+   GLfloat TextureColorTableBias[4];
 };
 
 
@@ -1040,7 +1064,6 @@ struct gl_point_attrib
 {
    GLboolean SmoothFlag;       /**< True if GL_POINT_SMOOTH is enabled */
    GLfloat Size;               /**< User-specified point size */
-   GLfloat _Size;              /**< Size clamped to Const.Min/MaxPointSize */
    GLfloat Params[3];          /**< GL_EXT_point_parameters */
    GLfloat MinSize, MaxSize;   /**< GL_EXT_point_parameters */
    GLfloat Threshold;          /**< GL_EXT_point_parameters */
@@ -1104,17 +1127,19 @@ struct gl_stencil_attrib
 };
 
 
-#define NUM_TEXTURE_TARGETS 5   /* 1D, 2D, 3D, CUBE and RECT */
+#define NUM_TEXTURE_TARGETS 7   /* 1D, 2D, 3D, CUBE, RECT, 1D_STACK, and 2D_STACK */
 
 /**
  * An index for each type of texture object
  */
 /*@{*/
-#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_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
 /*@}*/
 
 /**
@@ -1122,11 +1147,13 @@ struct gl_stencil_attrib
  * Used for Texture.Unit[]._ReallyEnabled flags.
  */
 /*@{*/
-#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_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)
 /*@}*/
 
 
@@ -1263,15 +1290,22 @@ struct gl_texture_format
                                 *   GL_DEPTH_COMPONENT.
                                 */
    GLenum DataType;            /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
-   GLubyte RedBits;            /**< Bits per texel component */
-   GLubyte GreenBits;          /**< These are just rough approximations for */
-   GLubyte BlueBits;           /**< compressed texture formats. */
+
+   /**
+    * Bits per texel component.  These are just rough approximations
+    * for compressed texture formats.
+    */
+   /*@{*/
+   GLubyte RedBits;
+   GLubyte GreenBits;
+   GLubyte BlueBits;
    GLubyte AlphaBits;
    GLubyte LuminanceBits;
    GLubyte IntensityBits;
    GLubyte IndexBits;
    GLubyte DepthBits;
    GLubyte StencilBits;        /**< GL_EXT_packed_depth_stencil */
+   /*@}*/
 
    GLuint TexelBytes;          /**< Bytes per texel, 0 if compressed format */
 
@@ -1293,8 +1327,6 @@ struct gl_texture_format
 };
 
 
-#define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
-
 /**
  * Texture image state.  Describes the dimensions of a texture image,
  * the texel format and pointers to Texel Fetch functions.
@@ -1335,7 +1367,7 @@ struct gl_texture_image
    GLboolean IsCompressed;     /**< GL_ARB_texture_compression */
    GLuint CompressedSize;      /**< GL_ARB_texture_compression */
 
-   GLuint RowStride;           /**< == Width unless IsClientData and padded */
+   GLuint RowStride;           /**< Padded width in units of texels */
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
    GLvoid *Data;               /**< Image data, accessed via FetchTexel() */
@@ -1359,7 +1391,7 @@ struct gl_texture_image
 #define FACE_NEG_Y   3
 #define FACE_POS_Z   4
 #define FACE_NEG_Z   5
-#define MAX_FACES  6
+#define MAX_FACES    6
 /*@}*/
 
 
@@ -1393,11 +1425,16 @@ struct gl_texture_object
    GLfloat ShadowAmbient;       /**< GL_ARB_shadow_ambient */
    GLenum CompareMode;         /**< GL_ARB_shadow */
    GLenum CompareFunc;         /**< GL_ARB_shadow */
+   GLenum _Function;           /**< Comparison function derived from 
+                                * \c CompareOperator, \c CompareMode, and
+                                * \c CompareFunc.
+                                */
    GLenum DepthMode;           /**< GL_ARB_depth_texture */
    GLint _MaxLevel;            /**< actual max mipmap level (q in the spec) */
    GLfloat _MaxLambda;         /**< = _MaxLevel - BaseLevel (q - b in spec) */
+   GLint CropRect[4];           /**< GL_OES_draw_texture */
    GLboolean GenerateMipmap;    /**< GL_SGIS_generate_mipmap */
-   GLboolean Complete;         /**< Is texture object complete? */
+   GLboolean _Complete;                /**< Is texture object complete? */
 
    /** Actual texture images, indexed by [cube face] and [mipmap level] */
    struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
@@ -1405,7 +1442,6 @@ struct gl_texture_object
    /** GL_EXT_paletted_texture */
    struct gl_color_table Palette;
 
-
    /**
     * \name For device driver.
     * Note: instead of attaching driver data to this pointer, it's preferable
@@ -1464,7 +1500,7 @@ struct gl_texture_unit
    GLbitfield _GenBitT;
    GLbitfield _GenBitR;
    GLbitfield _GenBitQ;
-   GLbitfield _GenFlags;       /**< bitwise or of GenBit[STRQ] */
+   GLbitfield _GenFlags;       /**< bitwise or of _GenBit[STRQ] */
    GLfloat ObjectPlaneS[4];
    GLfloat ObjectPlaneT[4];
    GLfloat ObjectPlaneR[4];
@@ -1497,33 +1533,20 @@ struct gl_texture_unit
    struct gl_texture_object *Current3D;
    struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
    struct gl_texture_object *CurrentRect;    /**< GL_NV_texture_rectangle */
+   struct gl_texture_object *Current1DArray; /**< GL_MESA_texture_array */
+   struct gl_texture_object *Current2DArray; /**< GL_MESA_texture_array */
 
    struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
 
-   struct gl_texture_object Saved1D;  /**< only used by glPush/PopAttrib */
-   struct gl_texture_object Saved2D;
-   struct gl_texture_object Saved3D;
-   struct gl_texture_object SavedCubeMap;
-   struct gl_texture_object SavedRect;
-
-   /* GL_SGI_texture_color_table */
+   /** GL_SGI_texture_color_table */
+   /*@{*/
    struct gl_color_table ColorTable;
    struct gl_color_table ProxyColorTable;
    GLboolean ColorTableEnabled;
+   /*@}*/
 };
 
-struct texenvprog_cache_item {
-   GLuint hash;
-   void *key;
-   struct gl_fragment_program *data;
-   struct texenvprog_cache_item *next;
-};
 
-struct texenvprog_cache {
-   struct texenvprog_cache_item **items;
-   GLuint size, n_items;
-   GLcontext *ctx;
-};
 
 /**
  * Texture attribute group (GL_TEXTURE_BIT).
@@ -1544,18 +1567,12 @@ struct gl_texture_attrib
 
    struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
 
-   struct gl_texture_object *Proxy1D;
-   struct gl_texture_object *Proxy2D;
-   struct gl_texture_object *Proxy3D;
-   struct gl_texture_object *ProxyCubeMap;
-   struct gl_texture_object *ProxyRect;
+   /** Proxy texture objects */
+   struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
 
    /** GL_EXT_shared_texture_palette */
    GLboolean SharedPalette;
    struct gl_color_table Palette;
-   
-   /** Cached texenv fragment programs */
-   struct texenvprog_cache env_fp_cache;
 };
 
 
@@ -1637,8 +1654,6 @@ struct gl_pixelstore_attrib
 };
 
 
-#define CA_CLIENT_DATA     0x1 /**< Data not allocated by mesa */
-
 
 /**
  * Client vertex array attributes
@@ -1650,14 +1665,12 @@ struct gl_client_array
    GLsizei Stride;             /**< user-specified stride */
    GLsizei StrideB;            /**< actual stride in bytes */
    const GLubyte *Ptr;          /**< Points to array data */
-   GLbitfield Enabled;         /**< one of the _NEW_ARRAY_ bits */
+   GLboolean Enabled;          /**< Enabled flag is a boolean */
    GLboolean Normalized;        /**< GL_ARB_vertex_program */
 
    /**< GL_ARB_vertex_buffer_object */
    struct gl_buffer_object *BufferObj;
    GLuint _MaxElement;
-
-   GLbitfield Flags;
 };
 
 
@@ -1678,8 +1691,9 @@ struct gl_array_object
    struct gl_client_array SecondaryColor;
    struct gl_client_array FogCoord;
    struct gl_client_array Index;
-   struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
    struct gl_client_array EdgeFlag;
+   struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
+   struct gl_client_array PointSize;
    /*@}*/
 
    /** Generic arrays for vertex programs/shaders */
@@ -1840,6 +1854,7 @@ enum register_file
 /** Vertex and fragment instructions */
 struct prog_instruction;
 struct gl_program_parameter_list;
+struct gl_uniform_list;
 
 
 /**
@@ -1859,6 +1874,8 @@ struct gl_program
    GLbitfield InputsRead;     /**< Bitmask of which input regs are read */
    GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
    GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS];  /**< TEXTURE_x_BIT bitmask */
+   GLbitfield SamplersUsed;   /**< Bitfield of which samplers are used */
+   GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
 
    /** Named parameters, constants, etc. from program text */
    struct gl_program_parameter_list *Parameters;
@@ -1870,6 +1887,11 @@ struct gl_program
    /** Vertex program user-defined attributes */
    struct gl_program_parameter_list *Attributes;
 
+   /** Map from sampler unit to texture unit (set by glUniform1i()) */
+   GLubyte SamplerUnits[MAX_SAMPLERS];
+   /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
+   GLubyte SamplerTargets[MAX_SAMPLERS];
+
    /** Logical counts */
    /*@{*/
    GLuint NumInstructions;
@@ -1910,7 +1932,10 @@ struct gl_fragment_program
 {
    struct gl_program Base;   /**< base class */
    GLenum FogOption;
-   GLboolean UsesKill;
+   GLboolean UsesKill;          /**< shader uses KIL instruction */
+   GLboolean UsesPointCoord;    /**< shader uses gl_PointCoord */
+   GLboolean UsesFrontFacing;   /**< shader used gl_FrontFacing */
+   GLboolean UsesFogFragCoord;  /**< shader used gl_FogFragCoord */
 };
 
 
@@ -1933,16 +1958,18 @@ struct gl_vertex_program_state
    GLboolean _Enabled;              /**< Enabled and valid program? */
    GLboolean PointSizeEnabled;      /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
    GLboolean TwoSideEnabled;        /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
-   struct gl_vertex_program *Current;  /**< ptr to currently bound program */
+   struct gl_vertex_program *Current;  /**< user-bound vertex program */
 
-   /** Currently enabled and valid program (including internal programs) */
+   /** Currently enabled and valid program (including internal programs
+    * and compiled shader programs).
+    */
    struct gl_vertex_program *_Current;
 
-   GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /**< Env params */
+   GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
 
    /* For GL_NV_vertex_program only: */
-   GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
-   GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
+   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? */
    GLboolean _MaintainTnlProgram;
@@ -1950,6 +1977,9 @@ struct gl_vertex_program_state
    /** Program to emulate fixed-function T&L (see above) */
    struct gl_vertex_program *_TnlProgram;
 
+   /** Cache of fixed-function programs */
+   struct gl_program_cache *Cache;
+
 #if FEATURE_MESA_program_debug
    GLprogramcallbackMESA Callback;
    GLvoid *CallbackData;
@@ -1966,19 +1996,26 @@ struct gl_fragment_program_state
 {
    GLboolean Enabled;     /**< User-set fragment program enable flag */
    GLboolean _Enabled;    /**< Fragment program enabled and valid? */
-   struct gl_fragment_program *Current;  /**< User-bound program */
+   GLboolean _Active;
+   struct gl_fragment_program *Current;  /**< User-bound fragment program */
 
-   /** Currently enabled and valid program (including internal programs) */
+   /** Currently enabled and valid program (including internal programs
+    * and compiled shader programs).
+    */
    struct gl_fragment_program *_Current;
 
-   GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /**< Env params */
+   GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
 
    /** Should fixed-function texturing be implemented with a fragment prog? */
    GLboolean _MaintainTexEnvProgram;
+   GLboolean _UseTexEnvProgram;
 
    /** Program to emulate fixed-function texture env/combine (see above) */
    struct gl_fragment_program *_TexEnvProgram;
 
+   /** Cache of fixed-function programs */
+   struct gl_program_cache *Cache;
+
 #if FEATURE_MESA_program_debug
    GLprogramcallbackMESA Callback;
    GLvoid *CallbackData;
@@ -2036,10 +2073,11 @@ struct gl_ati_fragment_shader_state
  */
 struct gl_query_object
 {
-   GLuint Id;
-   GLuint64EXT Result; /* the counter */
-   GLboolean Active;   /* inside Begin/EndQuery */
-   GLboolean Ready;    /* result is ready */
+   GLenum Target;      /**< The query target, when active */
+   GLuint Id;          /**< hash table ID/name */
+   GLuint64EXT Result; /**< the counter */
+   GLboolean Active;   /**< inside Begin/EndQuery */
+   GLboolean Ready;    /**< result is ready? */
 };
 
 
@@ -2056,7 +2094,7 @@ struct gl_query_state
 
 
 /**
- * A GLSL shader object.
+ * A GLSL vertex or fragment shader object.
  */
 struct gl_shader
 {
@@ -2067,14 +2105,15 @@ struct gl_shader
 
    const GLchar *Source;  /**< Source code string */
    GLboolean CompileStatus;
-   GLuint NumPrograms;  /**< size of Programs[] array */
-   struct gl_program **Programs;  /**< Post-compile assembly code */
+   struct gl_program *Program;  /**< Post-compile assembly code */
    GLchar *InfoLog;
+   GLboolean Main;  /**< shader defines main() */
 };
 
 
 /**
- * A GLSL program object.  Basically a linked collection of "shaders".
+ * A GLSL program object.
+ * Basically a linked collection of vertex and fragment shaders.
  */
 struct gl_shader_program
 {
@@ -2086,12 +2125,14 @@ struct gl_shader_program
    GLuint NumShaders;          /**< number of attached shaders */
    struct gl_shader **Shaders; /**< List of attached the shaders */
 
+   /** User-defined attribute bindings (glBindAttribLocation) */
+   struct gl_program_parameter_list *Attributes;
+
    /* post-link info: */
    struct gl_vertex_program *VertexProgram;     /**< Linked vertex program */
    struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
-   struct gl_program_parameter_list *Uniforms; /**< Plus constants, etc */
+   struct gl_uniform_list *Uniforms;
    struct gl_program_parameter_list *Varying;
-   struct gl_program_parameter_list *Attributes; /**< Vertex attributes */
    GLboolean LinkStatus;   /**< GL_LINK_STATUS */
    GLboolean Validated;
    GLchar *InfoLog;
@@ -2103,9 +2144,12 @@ struct gl_shader_program
  */
 struct gl_shader_state
 {
-   GLboolean _VertexShaderPresent;
-   GLboolean _FragmentShaderPresent;
-   struct gl_shader_program *CurrentProgram;
+   struct gl_shader_program *CurrentProgram; /**< The user-bound program */
+   /** Driver-selectable options: */
+   GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
+   GLboolean EmitCondCodes;             /**< Use condition codes? */
+   GLboolean EmitComments;              /**< Annotated instructions */
+   void *MemPool;
 };
 
 
@@ -2128,6 +2172,8 @@ struct gl_shared_state
    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;
    /*@}*/
 
    /**
@@ -2137,22 +2183,21 @@ struct gl_shared_state
     * \todo Improve the granularity of locking.
     */
    /*@{*/
-   _glthread_Mutex TexMutex;              /**< texobj thread safety */
-   GLuint TextureStateStamp;              /**< state notification for shared tex  */
+   _glthread_Mutex TexMutex;           /**< texobj thread safety */
+   GLuint TextureStateStamp;           /**< state notification for shared tex */
    /*@}*/
 
 
-
    /**
     * \name Vertex/fragment programs
     */
    /*@{*/
    struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
 #if FEATURE_ARB_vertex_program
-   struct gl_program *DefaultVertexProgram;
+   struct gl_vertex_program *DefaultVertexProgram;
 #endif
 #if FEATURE_ARB_fragment_program
-   struct gl_program *DefaultFragmentProgram;
+   struct gl_fragment_program *DefaultFragmentProgram;
 #endif
    /*@}*/
 
@@ -2195,6 +2240,8 @@ struct gl_shared_state
  */
 struct gl_renderbuffer
 {
+#define RB_MAGIC 0xaabbccdd
+   int Magic; /** XXX TEMPORARY DEBUG INFO */
    _glthread_Mutex Mutex;                 /**< for thread safety */
    GLuint ClassID;        /**< Useful for drivers */
    GLuint Name;
@@ -2212,7 +2259,7 @@ struct gl_renderbuffer
    GLubyte IndexBits;
    GLubyte DepthBits;
    GLubyte StencilBits;
-   GLvoid *Data;
+   GLvoid *Data;        /**< This may not be used by some kinds of RBs */
 
    /* Used to wrap one renderbuffer around another: */
    struct gl_renderbuffer *Wrapped;
@@ -2292,17 +2339,24 @@ struct gl_renderbuffer
  */
 struct gl_renderbuffer_attachment
 {
-   GLenum Type;  /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
+   GLenum Type;  /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
    GLboolean Complete;
 
-   /* IF Type == GL_RENDERBUFFER_EXT: */
+   /**
+    * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
+    * application supplied renderbuffer object.
+    */
    struct gl_renderbuffer *Renderbuffer;
 
-   /* IF Type == GL_TEXTURE: */
+   /**
+    * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
+    * supplied texture object.
+    */
    struct gl_texture_object *Texture;
-   GLuint TextureLevel;
-   GLuint CubeMapFace;  /* 0 .. 5, for cube map textures */
-   GLuint Zoffset;      /* for 3D textures */
+   GLuint TextureLevel; /**< Attached mipmap level. */
+   GLuint CubeMapFace;  /**< 0 .. 5, for cube map textures. */
+   GLuint Zoffset;      /**< Slice for 3D textures,  or layer for both 1D
+                         * and 2D array textures */
 };
 
 
@@ -2316,6 +2370,7 @@ struct gl_framebuffer
    _glthread_Mutex Mutex;                 /**< for thread safety */
    GLuint Name;      /* if zero, this is a window system framebuffer */
    GLint RefCount;
+   GLboolean DeletePending;
 
    GLvisual Visual;    /**< The framebuffer's visual.
                              Immutable if this is a window system buffer.
@@ -2349,13 +2404,11 @@ struct gl_framebuffer
    GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
    GLenum ColorReadBuffer;
 
-   /* These are computed from ColorDrawBuffer and ColorReadBuffer */
-   GLbitfield _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
+   /** Computed from ColorDraw/ReadBuffer above */
+   GLuint _NumColorDrawBuffers;
+   GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
    GLint _ColorReadBufferIndex; /* -1 = None */
-
-   /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
-   GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
-   struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
+   struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
    /** The Actual depth/stencil buffers to use.  May be wrappers around the
@@ -2407,6 +2460,7 @@ struct gl_constants
    GLint MaxTextureLevels;             /**< Maximum number of allowed mipmap levels. */ 
    GLint Max3DTextureLevels;           /**< Maximum number of allowed mipmap levels for 3D texture targets. */
    GLint MaxCubeTextureLevels;          /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
+   GLint MaxArrayTextureLayers;         /**< Maximum number of layers in an array texture. */
    GLint MaxTextureRectSize;            /* GL_NV_texture_rectangle */
    GLuint MaxTextureCoordUnits;
    GLuint MaxTextureImageUnits;
@@ -2446,7 +2500,7 @@ struct gl_constants
    GLuint MaxRenderbufferSize;
    /* GL_ARB_vertex_shader */
    GLuint MaxVertexTextureImageUnits;
-   GLuint MaxVarying;
+   GLuint MaxVarying;  /**< Number of float[4] vectors */
 };
 
 
@@ -2466,6 +2520,7 @@ struct gl_extensions
    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;
@@ -2547,6 +2602,7 @@ struct gl_extensions
    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;
@@ -2554,6 +2610,7 @@ struct gl_extensions
    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;
@@ -2583,7 +2640,7 @@ struct gl_extensions
 /**
  * A stack of matrices (projection, modelview, color, texture, etc).
  */
-struct matrix_stack
+struct gl_matrix_stack
 {
    GLmatrix *Top;      /**< points into Stack */
    GLmatrix *Stack;    /**< array [MaxDepth] of GLmatrix */
@@ -2680,7 +2737,8 @@ struct matrix_stack
 #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_SEVEN
+#define _NEW_ARRAY_EDGEFLAG         VERT_BIT_EDGEFLAG
+#define _NEW_ARRAY_POINT_SIZE       VERT_BIT_COLOR_INDEX  /* aliased */
 #define _NEW_ARRAY_TEXCOORD_0       VERT_BIT_TEX0
 #define _NEW_ARRAY_TEXCOORD_1       VERT_BIT_TEX1
 #define _NEW_ARRAY_TEXCOORD_2       VERT_BIT_TEX2
@@ -2689,7 +2747,7 @@ struct matrix_stack
 #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         0x10000  /* start at bit 16 */
+#define _NEW_ARRAY_ATTRIB_0         VERT_BIT_GENERIC0  /* start at bit 16 */
 #define _NEW_ARRAY_ALL              0xffffffff
 
 
@@ -2698,6 +2756,7 @@ struct matrix_stack
 /*@}*/
 
 
+
 /**
  * \name A bunch of flags that we think might be useful to drivers.
  * 
@@ -2814,9 +2873,8 @@ struct mesa_display_list
 /**
  * State used during display list compilation and execution.
  */
-struct mesa_list_state
+struct gl_dlist_state
 {
-   struct mesa_display_list *CallStack[MAX_LIST_NESTING];
    GLuint CallDepth;           /**< Current recursion calling depth */
 
    struct mesa_display_list *CurrentList;
@@ -2853,17 +2911,6 @@ struct mesa_list_state
  */
 struct __GLcontextRec
 {
-   /**
-    * \name OS related interfaces. 
-    *
-    * These \b must be the first members of this structure, because they are
-    * exposed to the outside world (i.e. GLX extension).
-    */
-   /*@{*/
-   __GLimports imports;
-   __GLexports exports;
-   /*@}*/
-
    /** State possibly shared with other contexts in the address space */
    struct gl_shared_state *Shared;
 
@@ -2886,26 +2933,25 @@ struct __GLcontextRec
    struct dd_function_table Driver;
 
    void *DriverCtx;    /**< Points to device driver context/state */
-   void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
 
    /** Core/Driver constants */
    struct gl_constants Const;
 
    /** \name The various 4x4 matrix stacks */
    /*@{*/
-   struct matrix_stack ModelviewMatrixStack;
-   struct matrix_stack ProjectionMatrixStack;
-   struct matrix_stack ColorMatrixStack;
-   struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
-   struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
-   struct matrix_stack *CurrentStack; /**< Points to one of the above 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];
+   struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
    /*@}*/
 
    /** Combined modelview and projection matrix */
    GLmatrix _ModelProjectMatrix;
 
    /** \name Display lists */
-   struct mesa_list_state ListState;
+   struct gl_dlist_state ListState;
 
    GLboolean ExecuteFlag;      /**< Execute GL commands? */
    GLboolean CompileFlag;      /**< Compile GL commands into display list? */
@@ -2963,6 +3009,7 @@ struct __GLcontextRec
 
    /** \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;
@@ -2973,12 +3020,14 @@ struct __GLcontextRec
    struct gl_feedback   Feedback;  /**< Feedback */
    struct gl_selection  Select;    /**< Selection */
 
-   struct gl_color_table ColorTable;       /**< Pre-convolution */
-   struct gl_color_table ProxyColorTable;  /**< Pre-convolution */
+   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
 
    struct gl_program_state Program;        /**< for vertex or fragment progs */
    struct gl_vertex_program_state VertexProgram;   /**< GL_ARB/NV_vertex_program */
@@ -3000,7 +3049,10 @@ struct __GLcontextRec
 
    /** \name Derived state */
    /*@{*/
-   GLbitfield _TriangleCaps;      /**< bitwise-or of DD_* flags */
+   /** Bitwise-or of DD_* flags.  Note that this bitfield may be used before
+    * state validation so they need to always be current.
+    */
+   GLbitfield _TriangleCaps;
    GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
    GLfloat _EyeZDir[3];
    GLfloat _ModelViewInvScale;
@@ -3016,12 +3068,6 @@ struct __GLcontextRec
 
    struct gl_list_extensions ListExt; /**< driver dlist extensions */
 
-
-   GLuint _Facing; /**< This is a hack for 2-sided stencil test.
-                   *
-                   * We don't have a better way to communicate this value from
-                   * swrast_setup to swrast. */
-
    /** \name For debugging/development only */
    /*@{*/
    GLboolean FirstTimeCurrent;