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