init secondary color to (0,0,0,1). remove some redundant initializations.
[mesa.git] / src / mesa / main / mtypes.h
1 /**
2 * \file mtypes.h
3 * Main Mesa data structures.
4 *
5 * Please try to mark derived values with a leading underscore ('_').
6 */
7
8 /*
9 * Mesa 3-D graphics library
10 * Version: 6.1
11 *
12 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32
33
34 #ifndef TYPES_H
35 #define TYPES_H
36
37
38 #include "glheader.h"
39 #include "config.h" /* Hardwired parameters */
40 #include "glapitable.h"
41 #include "glthread.h"
42 #include "math/m_matrix.h" /* GLmatrix */
43
44
45 /**
46 * Color channel data type.
47 */
48 #if CHAN_BITS == 8
49 typedef GLubyte GLchan;
50 #define CHAN_MAX 255
51 #define CHAN_MAXF 255.0F
52 #define CHAN_TYPE GL_UNSIGNED_BYTE
53 #elif CHAN_BITS == 16
54 typedef GLushort GLchan;
55 #define CHAN_MAX 65535
56 #define CHAN_MAXF 65535.0F
57 #define CHAN_TYPE GL_UNSIGNED_SHORT
58 #elif CHAN_BITS == 32
59 typedef GLfloat GLchan;
60 #define CHAN_MAX 1.0
61 #define CHAN_MAXF 1.0F
62 #define CHAN_TYPE GL_FLOAT
63 #else
64 #error "illegal number of color channel bits"
65 #endif
66
67
68 /**
69 * Accumulation buffer data type.
70 */
71 #if ACCUM_BITS==8
72 typedef GLbyte GLaccum;
73 #elif ACCUM_BITS==16
74 typedef GLshort GLaccum;
75 #elif ACCUM_BITS==32
76 typedef GLfloat GLaccum;
77 #else
78 # error "illegal number of accumulation bits"
79 #endif
80
81
82 /**
83 * Stencil buffer data type.
84 */
85 #if STENCIL_BITS==8
86 typedef GLubyte GLstencil;
87 # define STENCIL_MAX 0xff
88 #elif STENCIL_BITS==16
89 typedef GLushort GLstencil;
90 # define STENCIL_MAX 0xffff
91 #else
92 # error "illegal number of stencil bits"
93 #endif
94
95
96 /**
97 * Depth buffer data type.
98 *
99 * \note Must be 32-bits!
100 */
101 typedef GLuint GLdepth;
102
103
104 /**
105 * Fixed point data type.
106 */
107 typedef int GLfixed;
108 /*
109 * Fixed point arithmetic macros
110 */
111 #define FIXED_FRAC_BITS 11
112
113 #define FIXED_SHIFT FIXED_FRAC_BITS
114 #define FIXED_ONE (1 << FIXED_SHIFT)
115 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
116 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
117 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
118 #define FIXED_EPSILON 1
119 #define FIXED_SCALE ((float) FIXED_ONE)
120 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
121 #define IntToFixed(I) ((I) << FIXED_SHIFT)
122 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
123 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
124 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
125 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
126 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
127 #define PosFloatToFixed(X) FloatToFixed(X)
128 #define SignedFloatToFixed(X) FloatToFixed(X)
129
130
131
132 /**
133 * \name Some forward type declarations
134 */
135 /*@{*/
136 struct _mesa_HashTable;
137 struct gl_texture_image;
138 struct gl_texture_object;
139 typedef struct __GLcontextRec GLcontext;
140 typedef struct __GLcontextModesRec GLvisual;
141 typedef struct gl_frame_buffer GLframebuffer;
142 /*@}*/
143
144
145
146 /**
147 * These define the aliases between numbered vertex attributes and
148 * conventional OpenGL vertex attributes. We use these values in
149 * quite a few places.
150 *
151 * New in Mesa 4.1.
152 */
153 enum {
154 VERT_ATTRIB_POS = 0,
155 VERT_ATTRIB_WEIGHT = 1,
156 VERT_ATTRIB_NORMAL = 2,
157 VERT_ATTRIB_COLOR0 = 3,
158 VERT_ATTRIB_COLOR1 = 4,
159 VERT_ATTRIB_FOG = 5,
160 VERT_ATTRIB_SIX = 6,
161 VERT_ATTRIB_SEVEN = 7,
162 VERT_ATTRIB_TEX0 = 8,
163 VERT_ATTRIB_TEX1 = 9,
164 VERT_ATTRIB_TEX2 = 10,
165 VERT_ATTRIB_TEX3 = 11,
166 VERT_ATTRIB_TEX4 = 12,
167 VERT_ATTRIB_TEX5 = 13,
168 VERT_ATTRIB_TEX6 = 14,
169 VERT_ATTRIB_TEX7 = 15,
170 VERT_ATTRIB_MAX = 16
171 } ;
172
173 /* These are used in bitfields in many places */
174 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
175 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
176 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
177 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
178 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
179 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
180 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
181 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
182 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
183 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
184 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
185 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
186 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
187 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
188 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
189 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
190
191 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
192
193
194 /* Fragment programs use a different but related set of attributes:
195 */
196
197 /* Fragment input registers / attributes */
198 #define FRAG_ATTRIB_WPOS 0
199 #define FRAG_ATTRIB_COL0 1
200 #define FRAG_ATTRIB_COL1 2
201 #define FRAG_ATTRIB_FOGC 3
202 #define FRAG_ATTRIB_TEX0 4
203 #define FRAG_ATTRIB_TEX1 5
204 #define FRAG_ATTRIB_TEX2 6
205 #define FRAG_ATTRIB_TEX3 7
206 #define FRAG_ATTRIB_TEX4 8
207 #define FRAG_ATTRIB_TEX5 9
208 #define FRAG_ATTRIB_TEX6 10
209 #define FRAG_ATTRIB_TEX7 11
210
211 /* Bitmasks for the above */
212 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
213 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
214 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
215 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
216 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
217 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
218 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
219 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
220 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
221 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
222 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
223 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
224
225 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
226 FRAG_BIT_TEX1| \
227 FRAG_BIT_TEX2| \
228 FRAG_BIT_TEX3| \
229 FRAG_BIT_TEX4| \
230 FRAG_BIT_TEX5| \
231 FRAG_BIT_TEX6| \
232 FRAG_BIT_TEX7)
233
234
235
236 /**
237 * Maximum number of temporary vertices required for clipping.
238 *
239 * Used in array_cache and tnl modules.
240 */
241 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
242
243
244 /**
245 * Data structure for color tables
246 */
247 struct gl_color_table {
248 GLenum Format; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
249 GLenum IntFormat;
250 GLuint Size; /**< number of entries (rows) in table */
251 GLvoid *Table; /**< either GLfloat * or GLchan * */
252 GLboolean FloatTable; /**< are entries stored as floats? */
253 GLubyte RedSize;
254 GLubyte GreenSize;
255 GLubyte BlueSize;
256 GLubyte AlphaSize;
257 GLubyte LuminanceSize;
258 GLubyte IntensitySize;
259 };
260
261
262 /**
263 * \name Bit flags used for updating material values.
264 */
265 /*@{*/
266 #define MAT_ATTRIB_FRONT_AMBIENT 0
267 #define MAT_ATTRIB_BACK_AMBIENT 1
268 #define MAT_ATTRIB_FRONT_DIFFUSE 2
269 #define MAT_ATTRIB_BACK_DIFFUSE 3
270 #define MAT_ATTRIB_FRONT_SPECULAR 4
271 #define MAT_ATTRIB_BACK_SPECULAR 5
272 #define MAT_ATTRIB_FRONT_EMISSION 6
273 #define MAT_ATTRIB_BACK_EMISSION 7
274 #define MAT_ATTRIB_FRONT_SHININESS 8
275 #define MAT_ATTRIB_BACK_SHININESS 9
276 #define MAT_ATTRIB_FRONT_INDEXES 10
277 #define MAT_ATTRIB_BACK_INDEXES 11
278 #define MAT_ATTRIB_MAX 12
279
280 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
281 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
282 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
283 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
284 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
285 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
286
287 #define MAT_INDEX_AMBIENT 0
288 #define MAT_INDEX_DIFFUSE 1
289 #define MAT_INDEX_SPECULAR 2
290
291 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
292 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
293 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
294 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
295 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
296 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
297 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
298 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
299 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
300 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
301 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
302 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
303
304
305 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
306 MAT_BIT_FRONT_AMBIENT | \
307 MAT_BIT_FRONT_DIFFUSE | \
308 MAT_BIT_FRONT_SPECULAR | \
309 MAT_BIT_FRONT_SHININESS | \
310 MAT_BIT_FRONT_INDEXES)
311
312 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
313 MAT_BIT_BACK_AMBIENT | \
314 MAT_BIT_BACK_DIFFUSE | \
315 MAT_BIT_BACK_SPECULAR | \
316 MAT_BIT_BACK_SHININESS | \
317 MAT_BIT_BACK_INDEXES)
318
319 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
320 /*@}*/
321
322
323 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
324 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
325
326 /**
327 * Material shininess lookup table.
328 */
329 struct gl_shine_tab {
330 struct gl_shine_tab *next, *prev;
331 GLfloat tab[SHINE_TABLE_SIZE+1];
332 GLfloat shininess;
333 GLuint refcount;
334 };
335
336
337 /**
338 * Light.
339 */
340 struct gl_light {
341 struct gl_light *next; /**< double linked list with sentinel */
342 struct gl_light *prev;
343
344 GLfloat Ambient[4]; /**< ambient color */
345 GLfloat Diffuse[4]; /**< diffuse color */
346 GLfloat Specular[4]; /**< specular color */
347 GLfloat EyePosition[4]; /**< position in eye coordinates */
348 GLfloat EyeDirection[4]; /**< spotlight dir in eye coordinates */
349 GLfloat SpotExponent;
350 GLfloat SpotCutoff; /**< in degrees */
351 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
352 GLfloat ConstantAttenuation;
353 GLfloat LinearAttenuation;
354 GLfloat QuadraticAttenuation;
355 GLboolean Enabled; /**< On/off flag */
356
357 /**
358 * \name Derived fields
359 */
360 /*@{*/
361 GLuint _Flags; /**< State */
362
363 GLfloat _Position[4]; /**< position in eye/obj coordinates */
364 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
365 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
366 GLfloat _NormDirection[4]; /**< normalized spotlight direction */
367 GLfloat _VP_inf_spot_attenuation;
368
369 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
370 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
371 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
372 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
373 GLfloat _dli; /**< CI diffuse light intensity */
374 GLfloat _sli; /**< CI specular light intensity */
375 /*@}*/
376 };
377
378
379 /**
380 * Light model.
381 */
382 struct gl_lightmodel {
383 GLfloat Ambient[4]; /**< ambient color */
384 GLboolean LocalViewer; /**< Local (or infinite) view point? */
385 GLboolean TwoSide; /**< Two (or one) sided lighting? */
386 GLenum ColorControl; /**< either GL_SINGLE_COLOR
387 * or GL_SEPARATE_SPECULAR_COLOR */
388 };
389
390
391 /**
392 * Material.
393 */
394 struct gl_material
395 {
396 GLfloat Attrib[MAT_ATTRIB_MAX][4];
397 };
398
399
400 /**
401 * Accumulation buffer attributes.
402 */
403 struct gl_accum_attrib {
404 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
405 };
406
407
408 /**
409 * \name Clipping planes bits
410 *
411 * Used in gl_colorbuffer_attrib::_DrawDestMask and
412 * gl_colorbuffer_attrib::_ReadSrcMask below to identify color buffers.
413 */
414 /*@{*/
415 #define FRONT_LEFT_BIT 0x1
416 #define FRONT_RIGHT_BIT 0x2
417 #define BACK_LEFT_BIT 0x4
418 #define BACK_RIGHT_BIT 0x8
419 #define AUX0_BIT 0x10
420 #define AUX1_BIT 0x20
421 #define AUX2_BIT 0x40
422 #define AUX3_BIT 0x80
423 /*@}*/
424
425
426 /**
427 * Color buffers attributes.
428 */
429 struct gl_colorbuffer_attrib {
430 GLuint ClearIndex; /**< Index to use for glClear */
431 GLclampf ClearColor[4]; /**< Color to use for glClear */
432
433 GLuint IndexMask; /**< Color index write mask */
434 GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
435
436 GLenum DrawBuffer; /**< Which buffer to draw into */
437 GLubyte _DrawDestMask; /**< bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
438
439 /**
440 * \name alpha testing
441 */
442 /*@{*/
443 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
444 GLenum AlphaFunc; /**< Alpha test function */
445 GLclampf AlphaRef; /**< Alpha reference value */
446 /*@}*/
447
448 /**
449 * \name Blending
450 */
451 /*@{*/
452 GLboolean BlendEnabled; /**< Blending enabled flag */
453 GLenum BlendSrcRGB; /**< Blending source operator */
454 GLenum BlendDstRGB; /**< Blending destination operator */
455 GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
456 GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
457 GLenum BlendEquationRGB; /**< Blending equation */
458 GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
459 GLfloat BlendColor[4]; /**< Blending color */
460 /*@}*/
461
462 /**
463 * \name Logic op
464 */
465 /*@{*/
466 GLenum LogicOp; /**< Logic operator */
467 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
468 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
469 GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
470 /*@}*/
471
472 GLboolean DitherFlag; /**< Dither enable flag */
473 };
474
475
476 /**
477 * Current attributes.
478 */
479 struct gl_current_attrib {
480 /**
481 * \name Values valid only when FLUSH_VERTICES has been called.
482 */
483 /*@{*/
484 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Current vertex attributes
485 * indexed by VERT_ATTRIB_* */
486 GLfloat Index; /**< Current color index */
487 GLboolean EdgeFlag; /**< Current edge flag */
488 /*@}*/
489
490 /**
491 * \name Values are always valid.
492 *
493 * \note BTW, note how similar this set of attributes is to the SWvertex
494 * data type in the software rasterizer...
495 */
496 /*@{*/
497 GLfloat RasterPos[4]; /**< Current raster position */
498 GLfloat RasterDistance; /**< Current raster distance */
499 GLfloat RasterColor[4]; /**< Current raster color */
500 GLfloat RasterSecondaryColor[4]; /**< Current raster secondary color */
501 GLfloat RasterIndex; /**< Current raster index */
502 GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];/**< Current raster texcoords */
503 GLboolean RasterPosValid; /**< Raster pos valid flag */
504 /*@}*/
505 };
506
507
508 /**
509 * Depth buffer attributes.
510 */
511 struct gl_depthbuffer_attrib {
512 GLenum Func; /**< Function for depth buffer compare */
513 GLclampd Clear; /**< Value to clear depth buffer to */
514 GLboolean Test; /**< Depth buffering enabled flag */
515 GLboolean Mask; /**< Depth buffer writable? */
516 GLboolean OcclusionTest; /**< GL_HP_occlusion_test */
517 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
518 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
519 };
520
521
522 /**
523 * glEnable()/glDisable() attributes.
524 */
525 struct gl_enable_attrib {
526 GLboolean AlphaTest;
527 GLboolean AutoNormal;
528 GLboolean Blend;
529 GLuint ClipPlanes;
530 GLboolean ColorMaterial;
531 GLboolean ColorTable; /* SGI_color_table */
532 GLboolean PostColorMatrixColorTable; /* SGI_color_table */
533 GLboolean PostConvolutionColorTable; /* SGI_color_table */
534 GLboolean Convolution1D;
535 GLboolean Convolution2D;
536 GLboolean Separable2D;
537 GLboolean CullFace;
538 GLboolean DepthTest;
539 GLboolean Dither;
540 GLboolean Fog;
541 GLboolean Histogram;
542 GLboolean Light[MAX_LIGHTS];
543 GLboolean Lighting;
544 GLboolean LineSmooth;
545 GLboolean LineStipple;
546 GLboolean IndexLogicOp;
547 GLboolean ColorLogicOp;
548 GLboolean Map1Color4;
549 GLboolean Map1Index;
550 GLboolean Map1Normal;
551 GLboolean Map1TextureCoord1;
552 GLboolean Map1TextureCoord2;
553 GLboolean Map1TextureCoord3;
554 GLboolean Map1TextureCoord4;
555 GLboolean Map1Vertex3;
556 GLboolean Map1Vertex4;
557 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
558 GLboolean Map2Color4;
559 GLboolean Map2Index;
560 GLboolean Map2Normal;
561 GLboolean Map2TextureCoord1;
562 GLboolean Map2TextureCoord2;
563 GLboolean Map2TextureCoord3;
564 GLboolean Map2TextureCoord4;
565 GLboolean Map2Vertex3;
566 GLboolean Map2Vertex4;
567 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
568 GLboolean MinMax;
569 GLboolean Normalize;
570 GLboolean PixelTexture;
571 GLboolean PointSmooth;
572 GLboolean PolygonOffsetPoint;
573 GLboolean PolygonOffsetLine;
574 GLboolean PolygonOffsetFill;
575 GLboolean PolygonSmooth;
576 GLboolean PolygonStipple;
577 GLboolean RescaleNormals;
578 GLboolean Scissor;
579 GLboolean Stencil;
580 GLboolean MultisampleEnabled; /* GL_ARB_multisample */
581 GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
582 GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
583 GLboolean SampleCoverage; /* GL_ARB_multisample */
584 GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
585 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
586 GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
587 GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
588 /* SGI_texture_color_table */
589 GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
590 /* GL_NV_vertex_program */
591 GLboolean VertexProgram;
592 GLboolean VertexProgramPointSize;
593 GLboolean VertexProgramTwoSide;
594 /* GL_ARB_point_sprite / GL_NV_point_sprite */
595 GLboolean PointSprite;
596 };
597
598
599 /**
600 * Eval attributes.
601 */
602 struct gl_eval_attrib {
603 /**
604 * \name Enable bits
605 */
606 /*@{*/
607 GLboolean Map1Color4;
608 GLboolean Map1Index;
609 GLboolean Map1Normal;
610 GLboolean Map1TextureCoord1;
611 GLboolean Map1TextureCoord2;
612 GLboolean Map1TextureCoord3;
613 GLboolean Map1TextureCoord4;
614 GLboolean Map1Vertex3;
615 GLboolean Map1Vertex4;
616 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
617 GLboolean Map2Color4;
618 GLboolean Map2Index;
619 GLboolean Map2Normal;
620 GLboolean Map2TextureCoord1;
621 GLboolean Map2TextureCoord2;
622 GLboolean Map2TextureCoord3;
623 GLboolean Map2TextureCoord4;
624 GLboolean Map2Vertex3;
625 GLboolean Map2Vertex4;
626 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
627 GLboolean AutoNormal;
628 /*@}*/
629
630 /**
631 * \name Map Grid endpoints and divisions and calculated du values
632 */
633 /*@{*/
634 GLint MapGrid1un;
635 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
636 GLint MapGrid2un, MapGrid2vn;
637 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
638 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
639 /*@}*/
640 };
641
642
643 /**
644 * Fog attributes.
645 */
646 struct gl_fog_attrib {
647 GLboolean Enabled; /**< Fog enabled flag */
648 GLfloat Color[4]; /**< Fog color */
649 GLfloat Density; /**< Density >= 0.0 */
650 GLfloat Start; /**< Start distance in eye coords */
651 GLfloat End; /**< End distance in eye coords */
652 GLfloat Index; /**< Fog index */
653 GLenum Mode; /**< Fog mode */
654 GLboolean ColorSumEnabled;
655 GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
656 };
657
658
659 /**
660 * Hint attributes.
661 *
662 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
663 */
664 struct gl_hint_attrib {
665 GLenum PerspectiveCorrection;
666 GLenum PointSmooth;
667 GLenum LineSmooth;
668 GLenum PolygonSmooth;
669 GLenum Fog;
670 GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
671 GLenum TextureCompression; /**< GL_ARB_texture_compression */
672 GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
673 };
674
675
676 /**
677 * Histogram attributes.
678 */
679 struct gl_histogram_attrib {
680 GLuint Width; /**< number of table entries */
681 GLint Format; /**< GL_ALPHA, GL_RGB, etc */
682 GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
683 GLboolean Sink; /**< terminate image transfer? */
684 GLubyte RedSize; /**< Bits per counter */
685 GLubyte GreenSize;
686 GLubyte BlueSize;
687 GLubyte AlphaSize;
688 GLubyte LuminanceSize;
689 };
690
691
692 struct gl_minmax_attrib {
693 GLenum Format;
694 GLboolean Sink;
695 GLfloat Min[4], Max[4]; /**< RGBA */
696 };
697
698
699 struct gl_convolution_attrib {
700 GLenum Format;
701 GLenum InternalFormat;
702 GLuint Width;
703 GLuint Height;
704 GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
705 };
706
707
708 #define LIGHT_SPOT 0x1
709 #define LIGHT_LOCAL_VIEWER 0x2
710 #define LIGHT_POSITIONAL 0x4
711 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
712
713 /**
714 * Lighting attributes.
715 */
716 struct gl_light_attrib {
717 struct gl_light Light[MAX_LIGHTS]; /**< Array of lights */
718 struct gl_lightmodel Model; /**< Lighting model */
719
720 /**
721 * Must flush FLUSH_VERTICES before referencing:
722 */
723 /*@{*/
724 struct gl_material Material; /**< Includes front & back values */
725 /*@}*/
726
727 GLboolean Enabled; /**< Lighting enabled flag */
728 GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
729 GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
730 GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
731 GLuint ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
732 GLboolean ColorMaterialEnabled;
733
734 struct gl_light EnabledList; /**< List sentinel */
735
736 /**
737 * Derived for optimizations:
738 */
739 /*@{*/
740 GLboolean _NeedEyeCoords;
741 GLboolean _NeedVertices; /**< Use fast shader? */
742 GLuint _Flags; /**< LIGHT_* flags, see above */
743 GLfloat _BaseColor[2][3];
744 /*@}*/
745 };
746
747
748 /**
749 * Line attributes.
750 */
751 struct gl_line_attrib {
752 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
753 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
754 GLushort StipplePattern; /**< Stipple pattern */
755 GLint StippleFactor; /**< Stipple repeat factor */
756 GLfloat Width; /**< Line width */
757 GLfloat _Width; /**< Clamped Line width */
758 };
759
760
761 struct gl_list_attrib {
762 GLuint ListBase;
763 };
764
765
766 struct gl_list_opcode {
767 GLuint size;
768 void (*execute)( GLcontext *ctx, void *data );
769 void (*destroy)( GLcontext *ctx, void *data );
770 void (*print)( GLcontext *ctx, void *data );
771 };
772
773 #define GL_MAX_EXT_OPCODES 16
774
775 struct gl_list_extensions {
776 struct gl_list_opcode opcode[GL_MAX_EXT_OPCODES];
777 GLuint nr_opcodes;
778 };
779
780
781 struct gl_multisample_attrib {
782 GLboolean Enabled;
783 GLboolean SampleAlphaToCoverage;
784 GLboolean SampleAlphaToOne;
785 GLboolean SampleCoverage;
786 GLfloat SampleCoverageValue;
787 GLboolean SampleCoverageInvert;
788 };
789
790
791 /**
792 * Pixel attributes.
793 */
794 struct gl_pixel_attrib {
795 GLenum ReadBuffer; /**< source buffer for glReadPixels()/glCopyPixels() */
796 GLubyte _ReadSrcMask; /**< Not really a mask, but like _DrawDestMask
797 *
798 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
799 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
800 GLfloat RedBias, RedScale;
801 GLfloat GreenBias, GreenScale;
802 GLfloat BlueBias, BlueScale;
803 GLfloat AlphaBias, AlphaScale;
804 GLfloat DepthBias, DepthScale;
805 GLint IndexShift, IndexOffset;
806 GLboolean MapColorFlag;
807 GLboolean MapStencilFlag;
808 GLfloat ZoomX, ZoomY;
809 /* XXX move these out of gl_pixel_attrib */
810 GLint MapStoSsize; /**< Size of each pixel map */
811 GLint MapItoIsize;
812 GLint MapItoRsize;
813 GLint MapItoGsize;
814 GLint MapItoBsize;
815 GLint MapItoAsize;
816 GLint MapRtoRsize;
817 GLint MapGtoGsize;
818 GLint MapBtoBsize;
819 GLint MapAtoAsize;
820 GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */
821 GLint MapItoI[MAX_PIXEL_MAP_TABLE];
822 GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
823 GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
824 GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
825 GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
826 GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
827 GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
828 GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
829 GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
830 GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
831 GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
832 GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
833 GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
834 /** GL_EXT_histogram */
835 GLboolean HistogramEnabled;
836 GLboolean MinMaxEnabled;
837 /** GL_SGIS_pixel_texture */
838 GLboolean PixelTextureEnabled;
839 GLenum FragmentRgbSource;
840 GLenum FragmentAlphaSource;
841 /** GL_SGI_color_matrix */
842 GLfloat PostColorMatrixScale[4]; /**< RGBA */
843 GLfloat PostColorMatrixBias[4]; /**< RGBA */
844 /** GL_SGI_color_table */
845 GLfloat ColorTableScale[4];
846 GLfloat ColorTableBias[4];
847 GLboolean ColorTableEnabled;
848 GLfloat PCCTscale[4];
849 GLfloat PCCTbias[4];
850 GLboolean PostConvolutionColorTableEnabled;
851 GLfloat PCMCTscale[4];
852 GLfloat PCMCTbias[4];
853 GLboolean PostColorMatrixColorTableEnabled;
854 /** GL_SGI_texture_color_table */
855 GLfloat TextureColorTableScale[4];
856 GLfloat TextureColorTableBias[4];
857 /** Convolution */
858 GLboolean Convolution1DEnabled;
859 GLboolean Convolution2DEnabled;
860 GLboolean Separable2DEnabled;
861 GLfloat ConvolutionBorderColor[3][4];
862 GLenum ConvolutionBorderMode[3];
863 GLfloat ConvolutionFilterScale[3][4];
864 GLfloat ConvolutionFilterBias[3][4];
865 GLfloat PostConvolutionScale[4]; /**< RGBA */
866 GLfloat PostConvolutionBias[4]; /**< RGBA */
867 };
868
869
870 /**
871 * Point attributes.
872 */
873 struct gl_point_attrib {
874 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
875 GLfloat Size; /**< User-specified point size */
876 GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */
877 GLfloat Params[3]; /**< GL_EXT_point_parameters */
878 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
879 GLfloat Threshold; /**< GL_EXT_point_parameters */
880 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
881 GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
882 GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
883 GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
884 };
885
886
887 /**
888 * Polygon attributes.
889 */
890 struct gl_polygon_attrib {
891 GLenum FrontFace; /**< Either GL_CW or GL_CCW */
892 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
893 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
894 GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
895 GLboolean CullFlag; /**< Culling on/off flag */
896 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
897 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
898 GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
899 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
900 GLfloat OffsetUnits; /**< Polygon offset units, from user */
901 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
902 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
903 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
904 };
905
906
907 /**
908 * Scissor attributes.
909 */
910 struct gl_scissor_attrib {
911 GLboolean Enabled; /**< Scissor test enabled? */
912 GLint X, Y; /**< Lower left corner of box */
913 GLsizei Width, Height; /**< Size of box */
914 };
915
916
917 /**
918 * Stencil attributes.
919 */
920 struct gl_stencil_attrib {
921 GLboolean Enabled; /**< Enabled flag */
922 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
923 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 1) */
924 GLenum Function[2]; /**< Stencil function */
925 GLenum FailFunc[2]; /**< Fail function */
926 GLenum ZPassFunc[2]; /**< Depth buffer pass function */
927 GLenum ZFailFunc[2]; /**< Depth buffer fail function */
928 GLstencil Ref[2]; /**< Reference value */
929 GLstencil ValueMask[2]; /**< Value mask */
930 GLstencil WriteMask[2]; /**< Write mask */
931 GLstencil Clear; /**< Clear value */
932 };
933
934
935 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
936
937 #define TEXTURE_1D_INDEX 0
938 #define TEXTURE_2D_INDEX 1
939 #define TEXTURE_3D_INDEX 2
940 #define TEXTURE_CUBE_INDEX 3
941 #define TEXTURE_RECT_INDEX 4
942
943 /* Texture.Unit[]._ReallyEnabled flags: */
944 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
945 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
946 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
947 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
948 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
949
950
951 /* TexGenEnabled flags */
952 #define S_BIT 1
953 #define T_BIT 2
954 #define R_BIT 4
955 #define Q_BIT 8
956
957 /* Bitmap versions of the GL_ constants. */
958 #define TEXGEN_SPHERE_MAP 0x1
959 #define TEXGEN_OBJ_LINEAR 0x2
960 #define TEXGEN_EYE_LINEAR 0x4
961 #define TEXGEN_REFLECTION_MAP_NV 0x8
962 #define TEXGEN_NORMAL_MAP_NV 0x10
963
964 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
965 TEXGEN_REFLECTION_MAP_NV | \
966 TEXGEN_NORMAL_MAP_NV)
967 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
968 TEXGEN_REFLECTION_MAP_NV | \
969 TEXGEN_NORMAL_MAP_NV | \
970 TEXGEN_EYE_LINEAR)
971
972 /* A selection of state flags to make driver and module's lives easier. */
973 #define ENABLE_TEXGEN0 0x1
974 #define ENABLE_TEXGEN1 0x2
975 #define ENABLE_TEXGEN2 0x4
976 #define ENABLE_TEXGEN3 0x8
977 #define ENABLE_TEXGEN4 0x10
978 #define ENABLE_TEXGEN5 0x20
979 #define ENABLE_TEXGEN6 0x40
980 #define ENABLE_TEXGEN7 0x80
981
982 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
983 #define ENABLE_TEXMAT1 0x2
984 #define ENABLE_TEXMAT2 0x4
985 #define ENABLE_TEXMAT3 0x8
986 #define ENABLE_TEXMAT4 0x10
987 #define ENABLE_TEXMAT5 0x20
988 #define ENABLE_TEXMAT6 0x40
989 #define ENABLE_TEXMAT7 0x80
990
991 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
992 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
993
994
995 /**
996 * Texel fetch function prototype. We use texel fetch functions to
997 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
998 * texture images. These functions help to isolate us from the gritty
999 * details of all the various texture image encodings.
1000 *
1001 * \param texImage texture image.
1002 * \param col texel column.
1003 * \param row texel row.
1004 * \param img texel image level/layer.
1005 * \param texelOut output texel (up to 4 GLchans)
1006 */
1007 typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
1008 GLint col, GLint row, GLint img,
1009 GLchan *texelOut );
1010
1011 /**
1012 * As above, but returns floats.
1013 * Used for depth component images and for upcoming signed/float
1014 * texture images.
1015 */
1016 typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
1017 GLint col, GLint row, GLint img,
1018 GLfloat *texelOut );
1019
1020 /**
1021 * Texture format record
1022 */
1023 struct gl_texture_format {
1024 GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
1025
1026 GLenum BaseFormat; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
1027 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
1028 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
1029 */
1030 GLubyte RedBits; /**< Bits per texel component */
1031 GLubyte GreenBits; /**< These are just rough approximations for */
1032 GLubyte BlueBits; /**< compressed texture formats. */
1033 GLubyte AlphaBits;
1034 GLubyte LuminanceBits;
1035 GLubyte IntensityBits;
1036 GLubyte IndexBits;
1037 GLubyte DepthBits;
1038
1039 GLint TexelBytes; /**< Bytes per texel (0 for compressed formats */
1040
1041 /**
1042 * \name Texel fetch function pointers
1043 */
1044 /*@{*/
1045 FetchTexelFuncC FetchTexel1D;
1046 FetchTexelFuncC FetchTexel2D;
1047 FetchTexelFuncC FetchTexel3D;
1048 FetchTexelFuncF FetchTexel1Df;
1049 FetchTexelFuncF FetchTexel2Df;
1050 FetchTexelFuncF FetchTexel3Df;
1051 /*@}*/
1052 };
1053
1054
1055 /**
1056 * Texture image record
1057 */
1058 struct gl_texture_image {
1059 GLenum Format; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1060 * GL_INTENSITY, GL_RGB, GL_RGBA,
1061 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1062 * Used for choosing TexEnv arithmetic.
1063 */
1064 GLint IntFormat; /**< Internal format as given by the user */
1065 GLuint Border; /**< 0 or 1 */
1066 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
1067 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
1068 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
1069 GLuint RowStride; /**< == Width unless IsClientData and padded */
1070 GLuint Width2; /**< = Width - 2*Border */
1071 GLuint Height2; /**< = Height - 2*Border */
1072 GLuint Depth2; /**< = Depth - 2*Border */
1073 GLuint WidthLog2; /**< = log2(Width2) */
1074 GLuint HeightLog2; /**< = log2(Height2) */
1075 GLuint DepthLog2; /**< = log2(Depth2) */
1076 GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
1077 GLfloat WidthScale; /**< used for mipmap LOD computation */
1078 GLfloat HeightScale; /**< used for mipmap LOD computation */
1079 GLfloat DepthScale; /**< used for mipmap LOD computation */
1080 GLvoid *Data; /**< Image data, accessed via FetchTexel() */
1081 GLboolean IsClientData; /**< Data owned by client? */
1082 GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
1083
1084 const struct gl_texture_format *TexFormat;
1085
1086 FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
1087 FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
1088
1089 GLboolean IsCompressed; /**< GL_ARB_texture_compression */
1090 GLuint CompressedSize; /**< GL_ARB_texture_compression */
1091
1092 /**
1093 * \name For device driver:
1094 */
1095 /*@{*/
1096 void *DriverData; /**< Arbitrary device driver data */
1097 /*@}*/
1098 };
1099
1100 #define FACE_POS_X 0
1101 #define FACE_NEG_X 1
1102 #define FACE_POS_Y 2
1103 #define FACE_NEG_Y 3
1104 #define FACE_POS_Z 4
1105 #define FACE_NEG_Z 5
1106 #define MAX_FACES 6
1107
1108 /**
1109 * Texture object record
1110 */
1111 struct gl_texture_object {
1112 _glthread_Mutex Mutex; /**< for thread safety */
1113 GLint RefCount; /**< reference count */
1114 GLuint Name; /**< an unsigned integer */
1115 GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1116 GLfloat Priority; /**< in [0,1] */
1117 GLfloat BorderColor[4]; /**< unclamped */
1118 GLchan _BorderChan[4]; /**< clamped, as GLchan */
1119 /** \name Wrap modes
1120 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1121 /*@{*/
1122 GLenum WrapS;
1123 GLenum WrapT;
1124 GLenum WrapR;
1125 /*@}*/
1126 GLenum MinFilter; /**< minification filter */
1127 GLenum MagFilter; /**< magnification filter */
1128 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
1129 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
1130 GLfloat LodBias; /**< OpenGL 1.4 */
1131 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
1132 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
1133 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1134 GLboolean CompareFlag; /**< GL_SGIX_shadow */
1135 GLenum CompareOperator; /**< GL_SGIX_shadow */
1136 GLfloat ShadowAmbient;
1137 GLenum CompareMode; /**< GL_ARB_shadow */
1138 GLenum CompareFunc; /**< GL_ARB_shadow */
1139 GLenum DepthMode; /**< GL_ARB_depth_texture */
1140 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
1141 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1142 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
1143 GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
1144
1145 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1146
1147 /** GL_EXT_paletted_texture */
1148 struct gl_color_table Palette;
1149
1150 GLboolean Complete; /**< Is texture object complete? */
1151 struct gl_texture_object *Next; /**< Next in linked list */
1152
1153 /**
1154 * \name For device driver
1155 */
1156 /*@{*/
1157 void *DriverData; /**< Arbitrary device driver data */
1158 /*@}*/
1159 };
1160
1161 /**
1162 * Texture combine environment state.
1163 *
1164 * \todo
1165 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1166 * structure will need to be expanded for 4 elements.
1167 */
1168 struct gl_tex_env_combine_state {
1169 GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1170 GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1171 GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1172 GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1173 GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1174 GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1175 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1176 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1177 GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
1178 GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
1179 };
1180
1181 /**
1182 * Texture unit record
1183 */
1184 struct gl_texture_unit {
1185 GLuint Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1186 GLuint _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1187
1188 GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1189 GLfloat EnvColor[4];
1190 GLuint TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1191 /** \name Tex coord generation mode
1192 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1193 /*@{*/
1194 GLenum GenModeS;
1195 GLenum GenModeT;
1196 GLenum GenModeR;
1197 GLenum GenModeQ;
1198 /*@}*/
1199 GLuint _GenBitS;
1200 GLuint _GenBitT;
1201 GLuint _GenBitR;
1202 GLuint _GenBitQ;
1203 GLuint _GenFlags; /**< bitwise or of GenBit[STRQ] */
1204 GLfloat ObjectPlaneS[4];
1205 GLfloat ObjectPlaneT[4];
1206 GLfloat ObjectPlaneR[4];
1207 GLfloat ObjectPlaneQ[4];
1208 GLfloat EyePlaneS[4];
1209 GLfloat EyePlaneT[4];
1210 GLfloat EyePlaneR[4];
1211 GLfloat EyePlaneQ[4];
1212 GLfloat LodBias; /**< for biasing mipmap levels */
1213
1214 /**
1215 * \name GL_EXT_texture_env_combine
1216 */
1217 struct gl_tex_env_combine_state Combine;
1218
1219 /**
1220 * Derived state based on \c EnvMode and the \c BaseFormat of the
1221 * currently enabled texture.
1222 */
1223 struct gl_tex_env_combine_state _EnvMode;
1224
1225 /**
1226 * Currently enabled combiner state. This will point to either
1227 * \c Combine or \c _EnvMode.
1228 */
1229 struct gl_tex_env_combine_state *_CurrentCombine;
1230
1231 struct gl_texture_object *Current1D;
1232 struct gl_texture_object *Current2D;
1233 struct gl_texture_object *Current3D;
1234 struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
1235 struct gl_texture_object *CurrentRect; /**< GL_NV_texture_rectangle */
1236
1237 struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
1238
1239 struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */
1240 struct gl_texture_object Saved2D;
1241 struct gl_texture_object Saved3D;
1242 struct gl_texture_object SavedCubeMap;
1243 struct gl_texture_object SavedRect;
1244
1245 /* GL_SGI_texture_color_table */
1246 struct gl_color_table ColorTable;
1247 struct gl_color_table ProxyColorTable;
1248 GLboolean ColorTableEnabled;
1249 };
1250
1251
1252 /**
1253 * Texture attributes
1254 */
1255 struct gl_texture_attrib {
1256 /**
1257 * name multitexture
1258 */
1259 /**@{*/
1260 GLuint CurrentUnit; /**< Active texture unit */
1261 GLuint _EnabledUnits; /**< one bit set for each really-enabled unit */
1262 GLuint _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
1263 GLuint _GenFlags; /**< for texgen */
1264 GLuint _TexGenEnabled;
1265 GLuint _TexMatEnabled;
1266 /**@}*/
1267
1268 struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
1269
1270 struct gl_texture_object *Proxy1D;
1271 struct gl_texture_object *Proxy2D;
1272 struct gl_texture_object *Proxy3D;
1273 struct gl_texture_object *ProxyCubeMap;
1274 struct gl_texture_object *ProxyRect;
1275
1276 /** GL_EXT_shared_texture_palette */
1277 GLboolean SharedPalette;
1278 struct gl_color_table Palette;
1279 };
1280
1281
1282 /**
1283 * Transformation attributes.
1284 */
1285 struct gl_transform_attrib {
1286 GLenum MatrixMode; /**< Matrix mode */
1287 GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */
1288 GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */
1289 GLuint ClipPlanesEnabled; /**< on/off bitmask */
1290 GLboolean Normalize; /**< Normalize all normals? */
1291 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1292 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1293 };
1294
1295
1296 /**
1297 * Viewport attributes.
1298 */
1299 struct gl_viewport_attrib {
1300 GLint X, Y; /**< position */
1301 GLsizei Width, Height; /**< size */
1302 GLfloat Near, Far; /**< Depth buffer range */
1303 GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
1304 };
1305
1306
1307 /**
1308 * Node for the attribute stack
1309 */
1310 struct gl_attrib_node {
1311 GLbitfield kind;
1312 void *data;
1313 struct gl_attrib_node *next;
1314 };
1315
1316
1317 /**
1318 * GL_ARB_vertex_buffer_object buffer object
1319 */
1320 struct gl_buffer_object {
1321 GLint RefCount;
1322 GLuint Name;
1323 GLenum Usage;
1324 GLenum Access;
1325 GLvoid *Pointer; /**< Only valid while buffer is mapped */
1326 GLuint Size; /**< Size of data array in bytes */
1327 GLubyte *Data; /**< The storage */
1328 };
1329
1330
1331
1332 /**
1333 * Client pixel packing/unpacking attributes
1334 */
1335 struct gl_pixelstore_attrib {
1336 GLint Alignment;
1337 GLint RowLength;
1338 GLint SkipPixels;
1339 GLint SkipRows;
1340 GLint ImageHeight; /**< for GL_EXT_texture3D */
1341 GLint SkipImages; /**< for GL_EXT_texture3D */
1342 GLboolean SwapBytes;
1343 GLboolean LsbFirst;
1344 GLboolean ClientStorage; /**< GL_APPLE_client_storage */
1345 GLboolean Invert; /**< GL_MESA_pack_invert */
1346 };
1347
1348
1349 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1350
1351
1352 /**
1353 * Client vertex array attributes
1354 */
1355 struct gl_client_array {
1356 GLint Size;
1357 GLenum Type;
1358 GLsizei Stride; /**< user-specified stride */
1359 GLsizei StrideB; /**< actual stride in bytes */
1360 const GLubyte *Ptr;
1361 GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
1362 GLboolean Normalized; /**< GL_ARB_vertex_program */
1363
1364 /**< GL_ARB_vertex_buffer_object */
1365 struct gl_buffer_object *BufferObj;
1366 GLuint _MaxElement;
1367
1368 GLuint Flags;
1369 };
1370
1371
1372 /**
1373 * Array attributes.
1374 */
1375 struct gl_array_attrib {
1376 struct gl_client_array Vertex; /**< client data descriptors */
1377 struct gl_client_array Normal;
1378 struct gl_client_array Color;
1379 struct gl_client_array SecondaryColor;
1380 struct gl_client_array FogCoord;
1381 struct gl_client_array Index;
1382 struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
1383 struct gl_client_array EdgeFlag;
1384
1385 struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
1386
1387 GLint ActiveTexture; /**< Client Active Texture */
1388 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1389 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1390
1391 GLuint _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
1392 GLuint NewState; /**< _NEW_ARRAY_* */
1393
1394 #if FEATURE_ARB_vertex_buffer_object
1395 struct gl_buffer_object *NullBufferObj;
1396 struct gl_buffer_object *ArrayBufferObj;
1397 struct gl_buffer_object *ElementArrayBufferObj;
1398 #endif
1399 GLuint _MaxElement; /* Min of all enabled array's maxes */
1400 };
1401
1402
1403 struct gl_feedback {
1404 GLenum Type;
1405 GLuint _Mask; /* FB_* bits */
1406 GLfloat *Buffer;
1407 GLuint BufferSize;
1408 GLuint Count;
1409 };
1410
1411
1412 /**
1413 * Selection attributes.
1414 */
1415 struct gl_selection {
1416 GLuint *Buffer; /**< selection buffer */
1417 GLuint BufferSize; /**< size of the selection buffer */
1418 GLuint BufferCount; /**< number of values in the selection buffer */
1419 GLuint Hits; /**< number of records in the selection buffer */
1420 GLuint NameStackDepth; /**< name stack depth */
1421 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1422 GLboolean HitFlag; /**< hit flag */
1423 GLfloat HitMinZ; /**< minimum hit depth */
1424 GLfloat HitMaxZ; /**< maximum hit depth */
1425 };
1426
1427
1428 /**
1429 * 1-D Evaluator control points
1430 */
1431 struct gl_1d_map
1432 {
1433 GLuint Order; /**< Number of control points */
1434 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1435 GLfloat *Points; /**< Points to contiguous control points */
1436 };
1437
1438
1439 /**
1440 * 2-D Evaluator control points
1441 */
1442 struct gl_2d_map
1443 {
1444 GLuint Uorder; /**< Number of control points in U dimension */
1445 GLuint Vorder; /**< Number of control points in V dimension */
1446 GLfloat u1, u2, du;
1447 GLfloat v1, v2, dv;
1448 GLfloat *Points; /**< Points to contiguous control points */
1449 };
1450
1451
1452 /**
1453 * All evaluator control points
1454 */
1455 struct gl_evaluators
1456 {
1457 /**
1458 * \name 1-D maps
1459 */
1460 /*@{*/
1461 struct gl_1d_map Map1Vertex3;
1462 struct gl_1d_map Map1Vertex4;
1463 struct gl_1d_map Map1Index;
1464 struct gl_1d_map Map1Color4;
1465 struct gl_1d_map Map1Normal;
1466 struct gl_1d_map Map1Texture1;
1467 struct gl_1d_map Map1Texture2;
1468 struct gl_1d_map Map1Texture3;
1469 struct gl_1d_map Map1Texture4;
1470 struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
1471 /*@}*/
1472
1473 /**
1474 * \name 2-D maps
1475 */
1476 /*@{*/
1477 struct gl_2d_map Map2Vertex3;
1478 struct gl_2d_map Map2Vertex4;
1479 struct gl_2d_map Map2Index;
1480 struct gl_2d_map Map2Color4;
1481 struct gl_2d_map Map2Normal;
1482 struct gl_2d_map Map2Texture1;
1483 struct gl_2d_map Map2Texture2;
1484 struct gl_2d_map Map2Texture3;
1485 struct gl_2d_map Map2Texture4;
1486 struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
1487 /*@}*/
1488 };
1489
1490
1491 /**
1492 * NV_fragment_program runtime state
1493 */
1494 struct fp_machine
1495 {
1496 GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
1497 GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
1498 GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
1499 GLuint CondCodes[4];
1500 };
1501
1502
1503 /**
1504 * Names of the various vertex/fragment register files
1505 */
1506 enum register_file
1507 {
1508 PROGRAM_TEMPORARY = 10,
1509 PROGRAM_INPUT,
1510 PROGRAM_OUTPUT,
1511 PROGRAM_LOCAL_PARAM,
1512 PROGRAM_ENV_PARAM,
1513 PROGRAM_NAMED_PARAM,
1514 PROGRAM_STATE_VAR,
1515 PROGRAM_WRITE_ONLY,
1516 PROGRAM_ADDRESS
1517 };
1518
1519
1520 /* Vertex and fragment instructions */
1521 struct vp_instruction;
1522 struct fp_instruction;
1523
1524 struct program_parameter_list;
1525
1526
1527 /**
1528 * Base class for any kind of program object
1529 */
1530 struct program
1531 {
1532 GLuint Id;
1533 GLubyte *String; /* Null-terminated program text */
1534 GLenum Target;
1535 GLenum Format; /* String encoding format */
1536 GLint RefCount;
1537 GLboolean Resident;
1538 GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
1539 GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */
1540 GLuint NumTemporaries;
1541 GLuint NumParameters;
1542 GLuint NumAttributes;
1543 GLuint NumAddressRegs;
1544 };
1545
1546
1547 /** Vertex program object */
1548 struct vertex_program
1549 {
1550 struct program Base; /* base class */
1551 struct vp_instruction *Instructions; /* Compiled instructions */
1552 GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
1553 GLuint InputsRead; /* Bitmask of which input regs are read */
1554 GLuint OutputsWritten; /* Bitmask of which output regs are written to */
1555 struct program_parameter_list *Parameters; /**< array [NumParameters] */
1556 };
1557
1558
1559 /** Fragment program object */
1560 struct fragment_program
1561 {
1562 struct program Base; /**< base class */
1563 struct fp_instruction *Instructions; /**< Compiled instructions */
1564 GLuint InputsRead; /**< Bitmask of which input regs are read */
1565 GLuint OutputsWritten; /**< Bitmask of which output regs are written to */
1566 GLuint TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_INDEX bitmask */
1567 GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
1568 GLuint NumTexInstructions;
1569 GLuint NumTexIndirections;
1570 struct program_parameter_list *Parameters; /**< array [NumParameters] */
1571 };
1572
1573
1574 /**
1575 * State common to vertex and fragment programs.
1576 */
1577 struct program_state {
1578 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_NV */
1579 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_NV */
1580 };
1581
1582
1583 /**
1584 * State vars for GL_NV_vertex_program
1585 */
1586 struct vertex_program_state
1587 {
1588 GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */
1589 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1590 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1591 struct vertex_program *Current; /**< ptr to currently bound program */
1592
1593 GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1594 GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1595
1596 GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
1597 /* Only used during program execution (may be moved someday): */
1598 GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
1599 GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
1600 GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
1601 GLint AddressReg[4];
1602
1603 #if FEATURE_MESA_program_debug
1604 GLprogramcallbackMESA Callback;
1605 GLvoid *CallbackData;
1606 GLboolean CallbackEnabled;
1607 GLuint CurrentPosition;
1608 #endif
1609 };
1610
1611
1612 /*
1613 * State for GL_ARB/NV_fragment_program
1614 */
1615 struct fragment_program_state
1616 {
1617 GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
1618 struct fragment_program *Current; /* ptr to currently bound program */
1619 struct fp_machine Machine; /* machine state */
1620 GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
1621
1622 #if FEATURE_MESA_program_debug
1623 GLprogramcallbackMESA Callback;
1624 GLvoid *CallbackData;
1625 GLboolean CallbackEnabled;
1626 GLuint CurrentPosition;
1627 #endif
1628 };
1629
1630
1631 /*
1632 * State for GL_ARB_occlusion_query
1633 */
1634 struct occlusion_state
1635 {
1636 GLboolean Active;
1637 GLuint CurrentQueryObject;
1638 GLuint PassedCounter;
1639 struct _mesa_HashTable *QueryObjects;
1640 };
1641
1642
1643 /**
1644 * State which can be shared by multiple contexts:
1645 */
1646 struct gl_shared_state
1647 {
1648 _glthread_Mutex Mutex; /**< for thread safety */
1649 GLint RefCount; /**< Reference count */
1650 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
1651 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
1652 struct gl_texture_object *TexObjectList;/**< Linked list of texture objects */
1653
1654 /**
1655 * \name Default texture objects (shared by all multi-texture units)
1656 */
1657 /*@{*/
1658 struct gl_texture_object *Default1D;
1659 struct gl_texture_object *Default2D;
1660 struct gl_texture_object *Default3D;
1661 struct gl_texture_object *DefaultCubeMap;
1662 struct gl_texture_object *DefaultRect;
1663 /*@}*/
1664
1665 /**
1666 * \name GL_NV_vertex/_program
1667 */
1668 /*@{*/
1669 struct _mesa_HashTable *Programs;
1670 #if FEATURE_ARB_vertex_program
1671 struct program *DefaultVertexProgram;
1672 #endif
1673 #if FEATURE_ARB_fragment_program
1674 struct program *DefaultFragmentProgram;
1675 #endif
1676 /*@}*/
1677
1678 #if FEATURE_ARB_vertex_buffer_object
1679 struct _mesa_HashTable *BufferObjects;
1680 #endif
1681
1682 void *DriverData; /**< Device driver shared state */
1683 };
1684
1685
1686 /**
1687 * Frame buffer.
1688 *
1689 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1690 * depth, accum, stencil, and software-simulated alpha buffers.
1691 * In C++ terms, think of this as a base class from which device drivers
1692 * will make derived classes.
1693 */
1694 struct gl_frame_buffer
1695 {
1696 GLvisual Visual; /**< The corresponding visual */
1697
1698 GLuint Width, Height; /**< size of frame buffer in pixels */
1699
1700 GLboolean UseSoftwareDepthBuffer;
1701 GLboolean UseSoftwareAccumBuffer;
1702 GLboolean UseSoftwareStencilBuffer;
1703 GLboolean UseSoftwareAlphaBuffers;
1704
1705 /** \name Software depth (aka Z) buffer */
1706 /*@{*/
1707 GLvoid *DepthBuffer; /**< array [Width*Height] of GLushort or GLuint*/
1708 /*@}*/
1709
1710 /** \name Software stencil buffer */
1711 /*@{*/
1712 GLstencil *Stencil; /**< array [Width*Height] of GLstencil values */
1713 /*@}*/
1714
1715 /** \name Software accumulation buffer */
1716 /*@{*/
1717 GLaccum *Accum; /**< array [4*Width*Height] of GLaccum values */
1718 /*@}*/
1719
1720 /** \name Software alpha planes */
1721 /*@{*/
1722 GLchan *FrontLeftAlpha; /**< array [Width*Height] of GLchan */
1723 GLchan *BackLeftAlpha; /**< array [Width*Height] of GLchan */
1724 GLchan *FrontRightAlpha; /**< array [Width*Height] of GLchan */
1725 GLchan *BackRightAlpha; /**< array [Width*Height] of GLchan */
1726 /*@}*/
1727
1728 /**
1729 * \name Drawing bounds
1730 *
1731 * Intersection of window size and scissor box
1732 */
1733 /*@{*/
1734 GLint _Xmin; /**< inclusive */
1735 GLint _Ymin; /**< inclusive */
1736 GLint _Xmax; /**< exclusive */
1737 GLint _Ymax; /**< exclusive */
1738 /*@}*/
1739 };
1740
1741
1742 /**
1743 * Constants which may be overridden by device driver during context creation
1744 * but are never changed after that.
1745 */
1746 struct gl_constants
1747 {
1748 GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
1749 GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1750 GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1751 GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
1752 GLuint MaxTextureCoordUnits;
1753 GLuint MaxTextureImageUnits;
1754 GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */
1755 GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
1756 GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
1757 GLuint MaxArrayLockSize;
1758 GLint SubPixelBits;
1759 GLfloat MinPointSize, MaxPointSize; /* aliased */
1760 GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
1761 GLfloat PointSizeGranularity;
1762 GLfloat MinLineWidth, MaxLineWidth; /* aliased */
1763 GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
1764 GLfloat LineWidthGranularity;
1765 GLuint NumAuxBuffers;
1766 GLuint MaxColorTableSize;
1767 GLuint MaxConvolutionWidth;
1768 GLuint MaxConvolutionHeight;
1769 GLuint MaxClipPlanes;
1770 GLuint MaxLights;
1771 GLfloat MaxShininess; /* GL_NV_light_max_exponent */
1772 GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
1773 /* GL_ARB_vertex_program */
1774 GLuint MaxVertexProgramInstructions;
1775 GLuint MaxVertexProgramAttribs;
1776 GLuint MaxVertexProgramTemps;
1777 GLuint MaxVertexProgramLocalParams;
1778 GLuint MaxVertexProgramEnvParams;
1779 GLuint MaxVertexProgramAddressRegs;
1780 /* GL_ARB_fragment_program */
1781 GLuint MaxFragmentProgramInstructions;
1782 GLuint MaxFragmentProgramAttribs;
1783 GLuint MaxFragmentProgramTemps;
1784 GLuint MaxFragmentProgramLocalParams;
1785 GLuint MaxFragmentProgramEnvParams;
1786 GLuint MaxFragmentProgramAddressRegs;
1787 GLuint MaxFragmentProgramAluInstructions;
1788 GLuint MaxFragmentProgramTexInstructions;
1789 GLuint MaxFragmentProgramTexIndirections;
1790 /* vertex or fragment program */
1791 GLuint MaxProgramMatrices;
1792 GLuint MaxProgramMatrixStackDepth;
1793 /* vertex array / buffer object bounds checking */
1794 GLboolean CheckArrayBounds;
1795 };
1796
1797
1798 /**
1799 * List of extensions.
1800 */
1801 struct gl_extensions
1802 {
1803 /**
1804 * \name Flags to quickly test if certain extensions are available.
1805 *
1806 * Not every extension needs to have such a flag, but it's encouraged.
1807 */
1808 /*@{*/
1809 GLboolean dummy; /* don't remove this! */
1810 GLboolean ARB_depth_texture;
1811 GLboolean ARB_fragment_program;
1812 GLboolean ARB_imaging;
1813 GLboolean ARB_multisample;
1814 GLboolean ARB_multitexture;
1815 GLboolean ARB_occlusion_query;
1816 GLboolean ARB_point_sprite;
1817 GLboolean ARB_shadow;
1818 GLboolean ARB_texture_border_clamp;
1819 GLboolean ARB_texture_compression;
1820 GLboolean ARB_texture_cube_map;
1821 GLboolean ARB_texture_env_combine;
1822 GLboolean ARB_texture_env_crossbar;
1823 GLboolean ARB_texture_env_dot3;
1824 GLboolean ARB_texture_mirrored_repeat;
1825 GLboolean ARB_texture_non_power_of_two;
1826 GLboolean ARB_transpose_matrix;
1827 GLboolean ARB_vertex_buffer_object;
1828 GLboolean ARB_vertex_program;
1829 GLboolean ARB_window_pos;
1830 GLboolean EXT_abgr;
1831 GLboolean EXT_bgra;
1832 GLboolean EXT_blend_color;
1833 GLboolean EXT_blend_equation_separate;
1834 GLboolean EXT_blend_func_separate;
1835 GLboolean EXT_blend_logic_op;
1836 GLboolean EXT_blend_minmax;
1837 GLboolean EXT_blend_subtract;
1838 GLboolean EXT_clip_volume_hint;
1839 GLboolean EXT_convolution;
1840 GLboolean EXT_compiled_vertex_array;
1841 GLboolean EXT_copy_texture;
1842 GLboolean EXT_depth_bounds_test;
1843 GLboolean EXT_draw_range_elements;
1844 GLboolean EXT_fog_coord;
1845 GLboolean EXT_histogram;
1846 GLboolean EXT_multi_draw_arrays;
1847 GLboolean EXT_paletted_texture;
1848 GLboolean EXT_packed_pixels;
1849 GLboolean EXT_point_parameters;
1850 GLboolean EXT_polygon_offset;
1851 GLboolean EXT_rescale_normal;
1852 GLboolean EXT_shadow_funcs;
1853 GLboolean EXT_secondary_color;
1854 GLboolean EXT_separate_specular_color;
1855 GLboolean EXT_shared_texture_palette;
1856 GLboolean EXT_stencil_wrap;
1857 GLboolean EXT_stencil_two_side;
1858 GLboolean EXT_subtexture;
1859 GLboolean EXT_texture;
1860 GLboolean EXT_texture_object;
1861 GLboolean EXT_texture3D;
1862 GLboolean EXT_texture_compression_s3tc;
1863 GLboolean EXT_texture_env_add;
1864 GLboolean EXT_texture_env_combine;
1865 GLboolean EXT_texture_env_dot3;
1866 GLboolean EXT_texture_filter_anisotropic;
1867 GLboolean EXT_texture_lod_bias;
1868 GLboolean EXT_texture_mirror_clamp;
1869 GLboolean EXT_vertex_array;
1870 GLboolean EXT_vertex_array_set;
1871 /* vendor extensions */
1872 GLboolean APPLE_client_storage;
1873 GLboolean APPLE_packed_pixels;
1874 GLboolean ATI_texture_mirror_once;
1875 GLboolean ATI_texture_env_combine3;
1876 GLboolean HP_occlusion_test;
1877 GLboolean IBM_rasterpos_clip;
1878 GLboolean IBM_multimode_draw_arrays;
1879 GLboolean MESA_pack_invert;
1880 GLboolean MESA_packed_depth_stencil;
1881 GLboolean MESA_program_debug;
1882 GLboolean MESA_resize_buffers;
1883 GLboolean MESA_ycbcr_texture;
1884 GLboolean NV_blend_square;
1885 GLboolean NV_fragment_program;
1886 GLboolean NV_light_max_exponent;
1887 GLboolean NV_point_sprite;
1888 GLboolean NV_texgen_reflection;
1889 GLboolean NV_texture_rectangle;
1890 GLboolean NV_vertex_program;
1891 GLboolean NV_vertex_program1_1;
1892 GLboolean SGI_color_matrix;
1893 GLboolean SGI_color_table;
1894 GLboolean SGI_texture_color_table;
1895 GLboolean SGIS_generate_mipmap;
1896 GLboolean SGIS_pixel_texture;
1897 GLboolean SGIS_texture_edge_clamp;
1898 GLboolean SGIS_texture_lod;
1899 GLboolean SGIX_depth_texture;
1900 GLboolean SGIX_pixel_texture;
1901 GLboolean SGIX_shadow;
1902 GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
1903 GLboolean TDFX_texture_compression_FXT1;
1904 GLboolean S3_s3tc;
1905 /*@}*/
1906 /* The extension string */
1907 const GLubyte *String;
1908 };
1909
1910
1911 /**
1912 * A stack of matrices (projection, modelview, color, texture, etc).
1913 */
1914 struct matrix_stack
1915 {
1916 GLmatrix *Top; /**< points into Stack */
1917 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
1918 GLuint Depth; /**< 0 <= Depth < MaxDepth */
1919 GLuint MaxDepth; /**< size of Stack[] array */
1920 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1921 };
1922
1923
1924 /**
1925 * \name Bits for image transfer operations
1926 *
1927 * \sa __GLcontextRec::ImageTransferState.
1928 */
1929 /*@{*/
1930 #define IMAGE_SCALE_BIAS_BIT 0x1
1931 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1932 #define IMAGE_MAP_COLOR_BIT 0x4
1933 #define IMAGE_COLOR_TABLE_BIT 0x8
1934 #define IMAGE_CONVOLUTION_BIT 0x10
1935 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1936 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1937 #define IMAGE_COLOR_MATRIX_BIT 0x80
1938 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1939 #define IMAGE_HISTOGRAM_BIT 0x200
1940 #define IMAGE_MIN_MAX_BIT 0x400
1941
1942 /** Transfer ops up to convolution */
1943 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1944 IMAGE_SHIFT_OFFSET_BIT | \
1945 IMAGE_MAP_COLOR_BIT | \
1946 IMAGE_COLOR_TABLE_BIT)
1947
1948 /** Transfer ops after convolution */
1949 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1950 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1951 IMAGE_COLOR_MATRIX_BIT | \
1952 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1953 IMAGE_HISTOGRAM_BIT | \
1954 IMAGE_MIN_MAX_BIT)
1955 /*@}*/
1956
1957
1958 /**
1959 * \name Bits to indicate what state has changed.
1960 *
1961 * 4 unused flags.
1962 */
1963 /*@{*/
1964 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1965 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1966 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1967 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1968 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1969 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1970 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1971 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1972 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1973 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1974 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1975 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1976 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1977 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1978 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1979 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1980 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1981 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1982 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1983 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1984 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1985 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1986 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1987 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1988 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1989 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1990 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1991 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1992 #define _NEW_ALL ~0
1993 /*@}*/
1994
1995
1996 /**
1997 * \name Bits to track array state changes
1998 *
1999 * Also used to summarize array enabled.
2000 */
2001 /*@{*/
2002 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2003 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2004 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2005 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2006 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2007 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2008 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2009 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2010 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2011 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2012 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2013 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2014 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2015 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2016 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2017 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2018 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2019 #define _NEW_ARRAY_ALL 0xffffffff
2020
2021
2022 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2023 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2024 /*@}*/
2025
2026
2027 /**
2028 * \name A bunch of flags that we think might be useful to drivers.
2029 *
2030 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2031 */
2032 /*@{*/
2033 #define DD_FLATSHADE 0x1
2034 #define DD_SEPARATE_SPECULAR 0x2
2035 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2036 #define DD_TRI_LIGHT_TWOSIDE 0x8
2037 #define DD_TRI_UNFILLED 0x10
2038 #define DD_TRI_SMOOTH 0x20
2039 #define DD_TRI_STIPPLE 0x40
2040 #define DD_TRI_OFFSET 0x80
2041 #define DD_LINE_SMOOTH 0x100
2042 #define DD_LINE_STIPPLE 0x200
2043 #define DD_LINE_WIDTH 0x400
2044 #define DD_POINT_SMOOTH 0x800
2045 #define DD_POINT_SIZE 0x1000
2046 #define DD_POINT_ATTEN 0x2000
2047 /*@}*/
2048
2049
2050 /**
2051 * \name Define the state changes under which each of these bits might change
2052 */
2053 /*@{*/
2054 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2055 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2056 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2057 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2058 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2059 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2060 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2061 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2062 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2063 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2064 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2065 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2066 #define _DD_NEW_POINT_SIZE _NEW_POINT
2067 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2068 /*@}*/
2069
2070
2071 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2072 _NEW_TEXTURE | \
2073 _NEW_POINT | \
2074 _NEW_MODELVIEW)
2075
2076 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2077 _NEW_TEXTURE)
2078
2079 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2080
2081
2082
2083
2084 /*
2085 * Forward declaration of display list data types:
2086 */
2087 union node;
2088 typedef union node Node;
2089
2090
2091 /* This has to be included here. */
2092 #include "dd.h"
2093
2094
2095 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2096
2097 /**
2098 * Core Mesa's support for tnl modules:
2099 */
2100 struct gl_tnl_module {
2101 /**
2102 * Vertex format to be lazily swapped into current dispatch.
2103 */
2104 GLvertexformat *Current;
2105
2106 /**
2107 * \name Record of functions swapped out.
2108 * On restore, only need to swap these functions back in.
2109 */
2110 /*@{*/
2111 void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
2112 GLuint SwapCount;
2113 /*@}*/
2114 };
2115
2116 struct mesa_list_state {
2117 GLuint CallDepth; /**< Current recursion calling depth */
2118 Node *CurrentListPtr; /**< Head of list being compiled */
2119 GLuint CurrentListNum; /**< Number of the list being compiled */
2120 Node *CurrentBlock; /**< Pointer to current block of nodes */
2121 GLuint CurrentPos; /**< Index into current block of nodes */
2122 GLvertexformat ListVtxfmt;
2123
2124 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
2125 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
2126
2127 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
2128 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
2129
2130 GLubyte ActiveIndex;
2131 GLfloat CurrentIndex;
2132
2133 GLubyte ActiveEdgeFlag;
2134 GLboolean CurrentEdgeFlag;
2135 };
2136
2137
2138 /**
2139 * Mesa context
2140 *
2141 * This is the central context data structure for Mesa. Almost all
2142 * OpenGL state is contained in this structure.
2143 * Think of this as a base class from which device drivers will derive
2144 * sub classes.
2145 */
2146 struct __GLcontextRec {
2147 /**
2148 * \name OS related interfaces.
2149 *
2150 * These \b must be the first members of this structure, because they are
2151 * exposed to the outside world (i.e. GLX extension).
2152 */
2153 /*@{*/
2154 __GLimports imports;
2155 __GLexports exports;
2156 /*@}*/
2157
2158 /** State possibly shared with other contexts in the address space */
2159 struct gl_shared_state *Shared;
2160
2161 /** \name API function pointer tables */
2162 /*@{*/
2163 struct _glapi_table *Save; /**< Display list save functions */
2164 struct _glapi_table *Exec; /**< Execute functions */
2165 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
2166 /*@}*/
2167
2168 GLvisual Visual;
2169 GLframebuffer *DrawBuffer; /**< buffer for writing */
2170 GLframebuffer *ReadBuffer; /**< buffer for reading */
2171
2172 /**
2173 * Device driver function pointer table
2174 */
2175 struct dd_function_table Driver;
2176
2177 void *DriverCtx; /**< Points to device driver context/state */
2178 void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
2179
2180 /** Core/Driver constants */
2181 struct gl_constants Const;
2182
2183 /** \name The various 4x4 matrix stacks */
2184 /*@{*/
2185 struct matrix_stack ModelviewMatrixStack;
2186 struct matrix_stack ProjectionMatrixStack;
2187 struct matrix_stack ColorMatrixStack;
2188 struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
2189 struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
2190 struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
2191 /*@}*/
2192
2193 /** Combined modelview and projection matrix */
2194 GLmatrix _ModelProjectMatrix;
2195
2196 /** \name Display lists */
2197 struct mesa_list_state ListState;
2198
2199 GLboolean ExecuteFlag; /**< Execute GL commands? */
2200 GLboolean CompileFlag; /**< Compile GL commands into display list? */
2201
2202 /** Extensions */
2203 struct gl_extensions Extensions;
2204
2205 /** \name Renderer attribute stack */
2206 /*@{*/
2207 GLuint AttribStackDepth;
2208 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
2209 /*@}*/
2210
2211 /** \name Renderer attribute groups
2212 *
2213 * We define a struct for each attribute group to make pushing and popping
2214 * attributes easy. Also it's a good organization.
2215 */
2216 /*@{*/
2217 struct gl_accum_attrib Accum; /**< Accumulation buffer attributes */
2218 struct gl_colorbuffer_attrib Color; /**< Color buffers attributes */
2219 struct gl_current_attrib Current; /**< Current attributes */
2220 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
2221 struct gl_eval_attrib Eval; /**< Eval attributes */
2222 struct gl_fog_attrib Fog; /**< Fog attributes */
2223 struct gl_hint_attrib Hint; /**< Hint attributes */
2224 struct gl_light_attrib Light; /**< Light attributes */
2225 struct gl_line_attrib Line; /**< Line attributes */
2226 struct gl_list_attrib List; /**< List attributes */
2227 struct gl_multisample_attrib Multisample;
2228 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
2229 struct gl_point_attrib Point; /**< Point attributes */
2230 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
2231 GLuint PolygonStipple[32]; /**< Polygon stipple */
2232 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
2233 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
2234 struct gl_texture_attrib Texture; /**< Texture attributes */
2235 struct gl_transform_attrib Transform; /**< Transformation attributes */
2236 struct gl_viewport_attrib Viewport; /**< Viewport attributes */
2237 /*@}*/
2238
2239 /** \name Other attribute groups */
2240 /*@{*/
2241 struct gl_histogram_attrib Histogram;
2242 struct gl_minmax_attrib MinMax;
2243 struct gl_convolution_attrib Convolution1D;
2244 struct gl_convolution_attrib Convolution2D;
2245 struct gl_convolution_attrib Separable2D;
2246 /*@}*/
2247
2248 /** \name Client attribute stack */
2249 /*@{*/
2250 GLuint ClientAttribStackDepth;
2251 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
2252 /*@}*/
2253
2254 /** \name Client attribute groups */
2255 /*@{*/
2256 struct gl_array_attrib Array; /**< Vertex arrays */
2257 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
2258 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
2259
2260 struct gl_evaluators EvalMap; /**< All evaluators */
2261 struct gl_feedback Feedback; /**< Feedback */
2262 struct gl_selection Select; /**< Selection */
2263
2264 struct gl_color_table ColorTable; /**< Pre-convolution */
2265 struct gl_color_table ProxyColorTable; /**< Pre-convolution */
2266 struct gl_color_table PostConvolutionColorTable;
2267 struct gl_color_table ProxyPostConvolutionColorTable;
2268 struct gl_color_table PostColorMatrixColorTable;
2269 struct gl_color_table ProxyPostColorMatrixColorTable;
2270
2271 struct program_state Program; /**< for vertex or fragment progs */
2272 struct vertex_program_state VertexProgram; /**< GL_NV_vertex_program */
2273 struct fragment_program_state FragmentProgram; /**< GL_NV_fragment_program */
2274
2275 struct occlusion_state Occlusion; /**< GL_ARB_occlusion_query */
2276
2277 GLenum ErrorValue; /**< Last error code */
2278 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2279 GLuint NewState; /**< bitwise-or of _NEW_* flags */
2280 /*@}*/
2281
2282 /** \name Derived */
2283 /*@{*/
2284 GLuint _TriangleCaps; /**< bitwise-or of DD_* flags */
2285 GLuint _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
2286 GLfloat _EyeZDir[3];
2287 GLfloat _ModelViewInvScale;
2288 GLuint _NeedEyeCoords;
2289 GLuint _ForceEyeCoords;
2290 GLboolean _RotateMode;
2291 GLenum _CurrentProgram; /* currently executing program */
2292
2293 struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
2294 struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
2295 /**@}*/
2296
2297 struct gl_list_extensions listext; /**< driver dlist extensions */
2298
2299
2300 GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
2301 GLboolean OcclusionResultSaved; /**< for GL_HP_occlusion_test */
2302 GLuint _Facing; /**< This is a hack for 2-sided stencil test.
2303 *
2304 * We don't have a better way to communicate this value from
2305 * swrast_setup to swrast. */
2306
2307
2308 /** \name Z buffer stuff */
2309 /*@{*/
2310 GLuint DepthMax; /**< Max depth buffer value */
2311 GLfloat DepthMaxF; /**< Float max depth buffer value */
2312 GLfloat MRD; /**< minimum resolvable difference in Z values */
2313 /*@}*/
2314
2315 /** Should 3Dfx Glide driver catch signals? */
2316 GLboolean CatchSignals;
2317
2318 /** \name For debugging/development only */
2319 /*@{*/
2320 GLboolean FirstTimeCurrent;
2321 /*@}*/
2322
2323 /** Dither disable via MESA_NO_DITHER env var */
2324 GLboolean NoDither;
2325
2326 /** Core tnl module support */
2327 struct gl_tnl_module TnlModule;
2328
2329 /**
2330 * \name Hooks for module contexts.
2331 *
2332 * These will eventually live in the driver or elsewhere.
2333 */
2334 /*@{*/
2335 void *swrast_context;
2336 void *swsetup_context;
2337 void *swtnl_context;
2338 void *swtnl_im;
2339 void *acache_context;
2340 void *aelt_context;
2341 /*@}*/
2342 };
2343
2344
2345 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2346 extern const char *_mesa_prim_name[GL_POLYGON+4];
2347
2348
2349 #ifdef MESA_DEBUG
2350 extern int MESA_VERBOSE;
2351 extern int MESA_DEBUG_FLAGS;
2352 # define MESA_FUNCTION __FUNCTION__
2353 #else
2354 # define MESA_VERBOSE 0
2355 # define MESA_DEBUG_FLAGS 0
2356 # define MESA_FUNCTION "a function"
2357 # ifndef NDEBUG
2358 # define NDEBUG
2359 # endif
2360 #endif
2361
2362
2363 enum _verbose {
2364 VERBOSE_VARRAY = 0x0001,
2365 VERBOSE_TEXTURE = 0x0002,
2366 VERBOSE_IMMEDIATE = 0x0004,
2367 VERBOSE_PIPELINE = 0x0008,
2368 VERBOSE_DRIVER = 0x0010,
2369 VERBOSE_STATE = 0x0020,
2370 VERBOSE_API = 0x0040,
2371 VERBOSE_DISPLAY_LIST = 0x0100,
2372 VERBOSE_LIGHTING = 0x0200,
2373 VERBOSE_PRIMS = 0x0400,
2374 VERBOSE_VERTS = 0x0800
2375 };
2376
2377
2378 enum _debug {
2379 DEBUG_ALWAYS_FLUSH = 0x1
2380 };
2381
2382
2383
2384 #define Elements(x) sizeof(x)/sizeof(*(x))
2385
2386
2387 #endif /* TYPES_H */