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