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