Move the computation of the viewport matrix into a new update_viewport_matrix()
[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.5
11 *
12 * Copyright (C) 1999-2006 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 <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
40 #include "config.h" /* Hardwired parameters */
41 #include "glapitable.h"
42 #include "glthread.h"
43 #include "math/m_matrix.h" /* GLmatrix */
44
45
46 /**
47 * Color channel data type.
48 */
49 #if CHAN_BITS == 8
50 typedef GLubyte GLchan;
51 #define CHAN_MAX 255
52 #define CHAN_MAXF 255.0F
53 #define CHAN_TYPE GL_UNSIGNED_BYTE
54 #elif CHAN_BITS == 16
55 typedef GLushort GLchan;
56 #define CHAN_MAX 65535
57 #define CHAN_MAXF 65535.0F
58 #define CHAN_TYPE GL_UNSIGNED_SHORT
59 #elif CHAN_BITS == 32
60 typedef GLfloat GLchan;
61 #define CHAN_MAX 1.0
62 #define CHAN_MAXF 1.0F
63 #define CHAN_TYPE GL_FLOAT
64 #else
65 #error "illegal number of color channel bits"
66 #endif
67
68
69 /**
70 * Stencil buffer data type.
71 */
72 #if STENCIL_BITS==8
73 typedef GLubyte GLstencil;
74 #elif STENCIL_BITS==16
75 typedef GLushort GLstencil;
76 #else
77 # error "illegal number of stencil bits"
78 #endif
79
80
81 /**
82 * Fixed point data type.
83 */
84 typedef int GLfixed;
85 /*
86 * Fixed point arithmetic macros
87 */
88 #ifndef FIXED_FRAC_BITS
89 #define FIXED_FRAC_BITS 11
90 #endif
91
92 #define FIXED_SHIFT FIXED_FRAC_BITS
93 #define FIXED_ONE (1 << FIXED_SHIFT)
94 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
95 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
96 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
97 #define FIXED_EPSILON 1
98 #define FIXED_SCALE ((float) FIXED_ONE)
99 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
100 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
101 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
102 #define IntToFixed(I) ((I) << FIXED_SHIFT)
103 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
104 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
105 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
106 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
107 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
108 #define PosFloatToFixed(X) FloatToFixed(X)
109 #define SignedFloatToFixed(X) FloatToFixed(X)
110
111
112
113 /**
114 * \name Some forward type declarations
115 */
116 /*@{*/
117 struct _mesa_HashTable;
118 struct gl_pixelstore_attrib;
119 struct gl_texture_format;
120 struct gl_texture_image;
121 struct gl_texture_object;
122 typedef struct __GLcontextRec GLcontext;
123 typedef struct __GLcontextModesRec GLvisual;
124 typedef struct gl_framebuffer GLframebuffer;
125 /*@}*/
126
127
128
129 /**
130 * Indexes for vertex program attributes.
131 * GL_NV_vertex_program aliases generic attributes over the conventional
132 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
133 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
134 * generic attributes are distinct/separate).
135 */
136 enum
137 {
138 VERT_ATTRIB_POS = 0,
139 VERT_ATTRIB_WEIGHT = 1,
140 VERT_ATTRIB_NORMAL = 2,
141 VERT_ATTRIB_COLOR0 = 3,
142 VERT_ATTRIB_COLOR1 = 4,
143 VERT_ATTRIB_FOG = 5,
144 VERT_ATTRIB_SIX = 6,
145 VERT_ATTRIB_SEVEN = 7,
146 VERT_ATTRIB_TEX0 = 8,
147 VERT_ATTRIB_TEX1 = 9,
148 VERT_ATTRIB_TEX2 = 10,
149 VERT_ATTRIB_TEX3 = 11,
150 VERT_ATTRIB_TEX4 = 12,
151 VERT_ATTRIB_TEX5 = 13,
152 VERT_ATTRIB_TEX6 = 14,
153 VERT_ATTRIB_TEX7 = 15,
154 VERT_ATTRIB_GENERIC0 = 16,
155 VERT_ATTRIB_GENERIC1 = 17,
156 VERT_ATTRIB_GENERIC2 = 18,
157 VERT_ATTRIB_GENERIC3 = 19,
158 VERT_ATTRIB_MAX = 16 /* XXX not counting generic attribs yet */
159 };
160
161 /**
162 * Bitflags for vertex attributes.
163 * These are used in bitfields in many places.
164 */
165 /*@{*/
166 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
167 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
168 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
169 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
170 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
171 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
172 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
173 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
174 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
175 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
176 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
177 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
178 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
179 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
180 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
181 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
182 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
183 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
184 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
185 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
186
187 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
188 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
189 /*@}*/
190
191 /**
192 * Indexes for vertex program result attributes
193 */
194 /*@{*/
195 #define VERT_RESULT_HPOS 0
196 #define VERT_RESULT_COL0 1
197 #define VERT_RESULT_COL1 2
198 #define VERT_RESULT_FOGC 3
199 #define VERT_RESULT_TEX0 4
200 #define VERT_RESULT_TEX1 5
201 #define VERT_RESULT_TEX2 6
202 #define VERT_RESULT_TEX3 7
203 #define VERT_RESULT_TEX4 8
204 #define VERT_RESULT_TEX5 9
205 #define VERT_RESULT_TEX6 10
206 #define VERT_RESULT_TEX7 11
207 #define VERT_RESULT_PSIZ 12
208 #define VERT_RESULT_BFC0 13
209 #define VERT_RESULT_BFC1 14
210 #define VERT_RESULT_MAX 15
211 /*@}*/
212
213
214 /**
215 * Indexes for fragment program input attributes.
216 */
217 enum
218 {
219 FRAG_ATTRIB_WPOS = 0,
220 FRAG_ATTRIB_COL0 = 1,
221 FRAG_ATTRIB_COL1 = 2,
222 FRAG_ATTRIB_FOGC = 3,
223 FRAG_ATTRIB_TEX0 = 4,
224 FRAG_ATTRIB_TEX1 = 5,
225 FRAG_ATTRIB_TEX2 = 6,
226 FRAG_ATTRIB_TEX3 = 7,
227 FRAG_ATTRIB_TEX4 = 8,
228 FRAG_ATTRIB_TEX5 = 9,
229 FRAG_ATTRIB_TEX6 = 10,
230 FRAG_ATTRIB_TEX7 = 11,
231 FRAG_ATTRIB_MAX = 12
232 };
233
234 /**
235 * Bitflags for fragment program input attributes.
236 */
237 /*@{*/
238 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
239 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
240 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
241 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
242 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
243 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
244 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
245 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
246 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
247 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
248 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
249 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
250
251 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
252 FRAG_BIT_TEX1| \
253 FRAG_BIT_TEX2| \
254 FRAG_BIT_TEX3| \
255 FRAG_BIT_TEX4| \
256 FRAG_BIT_TEX5| \
257 FRAG_BIT_TEX6| \
258 FRAG_BIT_TEX7)
259 /*@}*/
260
261
262 /**
263 * Fragment program results
264 */
265 /*@{*/
266 #define FRAG_RESULT_COLR 0
267 #define FRAG_RESULT_COLH 1
268 #define FRAG_RESULT_DEPR 2
269 #define FRAG_RESULT_MAX 3
270 /*@}*/
271
272
273 /**
274 * Indexes for all renderbuffers
275 */
276 enum {
277 BUFFER_FRONT_LEFT = 0, /* the four standard color buffers */
278 BUFFER_BACK_LEFT = 1,
279 BUFFER_FRONT_RIGHT = 2,
280 BUFFER_BACK_RIGHT = 3,
281 BUFFER_AUX0 = 4, /* optional aux buffer */
282 BUFFER_AUX1 = 5,
283 BUFFER_AUX2 = 6,
284 BUFFER_AUX3 = 7,
285 BUFFER_DEPTH = 8,
286 BUFFER_STENCIL = 9,
287 BUFFER_ACCUM = 10,
288 BUFFER_COLOR0 = 11, /* generic renderbuffers */
289 BUFFER_COLOR1 = 12,
290 BUFFER_COLOR2 = 13,
291 BUFFER_COLOR3 = 14,
292 BUFFER_COLOR4 = 15,
293 BUFFER_COLOR5 = 16,
294 BUFFER_COLOR6 = 17,
295 BUFFER_COLOR7 = 18,
296 BUFFER_COUNT = 19
297 };
298
299 /**
300 * Bit flags for all renderbuffers
301 */
302 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
303 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
304 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
305 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
306 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
307 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
308 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
309 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
310 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
311 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
312 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
313 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
314 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
315 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
316 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
317 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
318 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
319 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
320 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
321
322 /**
323 * Mask of all the color buffer bits (but not accum).
324 */
325 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
326 BUFFER_BIT_BACK_LEFT | \
327 BUFFER_BIT_FRONT_RIGHT | \
328 BUFFER_BIT_BACK_RIGHT | \
329 BUFFER_BIT_AUX0 | \
330 BUFFER_BIT_AUX1 | \
331 BUFFER_BIT_AUX2 | \
332 BUFFER_BIT_AUX3 | \
333 BUFFER_BIT_COLOR0 | \
334 BUFFER_BIT_COLOR1 | \
335 BUFFER_BIT_COLOR2 | \
336 BUFFER_BIT_COLOR3 | \
337 BUFFER_BIT_COLOR4 | \
338 BUFFER_BIT_COLOR5 | \
339 BUFFER_BIT_COLOR6 | \
340 BUFFER_BIT_COLOR7)
341
342
343
344
345 /**
346 * Data structure for color tables
347 */
348 struct gl_color_table
349 {
350 GLenum InternalFormat; /**< The user-specified format */
351 GLenum _BaseFormat; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
352 GLuint Size; /**< number of entries (rows) in table */
353 GLvoid *Table; /**< points to data of <Type> */
354 GLenum Type; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
355 GLubyte RedSize;
356 GLubyte GreenSize;
357 GLubyte BlueSize;
358 GLubyte AlphaSize;
359 GLubyte LuminanceSize;
360 GLubyte IntensitySize;
361 };
362
363
364 /**
365 * \name Bit flags used for updating material values.
366 */
367 /*@{*/
368 #define MAT_ATTRIB_FRONT_AMBIENT 0
369 #define MAT_ATTRIB_BACK_AMBIENT 1
370 #define MAT_ATTRIB_FRONT_DIFFUSE 2
371 #define MAT_ATTRIB_BACK_DIFFUSE 3
372 #define MAT_ATTRIB_FRONT_SPECULAR 4
373 #define MAT_ATTRIB_BACK_SPECULAR 5
374 #define MAT_ATTRIB_FRONT_EMISSION 6
375 #define MAT_ATTRIB_BACK_EMISSION 7
376 #define MAT_ATTRIB_FRONT_SHININESS 8
377 #define MAT_ATTRIB_BACK_SHININESS 9
378 #define MAT_ATTRIB_FRONT_INDEXES 10
379 #define MAT_ATTRIB_BACK_INDEXES 11
380 #define MAT_ATTRIB_MAX 12
381
382 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
383 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
384 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
385 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
386 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
387 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
388
389 #define MAT_INDEX_AMBIENT 0
390 #define MAT_INDEX_DIFFUSE 1
391 #define MAT_INDEX_SPECULAR 2
392
393 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
394 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
395 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
396 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
397 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
398 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
399 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
400 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
401 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
402 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
403 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
404 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
405
406
407 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
408 MAT_BIT_FRONT_AMBIENT | \
409 MAT_BIT_FRONT_DIFFUSE | \
410 MAT_BIT_FRONT_SPECULAR | \
411 MAT_BIT_FRONT_SHININESS | \
412 MAT_BIT_FRONT_INDEXES)
413
414 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
415 MAT_BIT_BACK_AMBIENT | \
416 MAT_BIT_BACK_DIFFUSE | \
417 MAT_BIT_BACK_SPECULAR | \
418 MAT_BIT_BACK_SHININESS | \
419 MAT_BIT_BACK_INDEXES)
420
421 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
422 /*@}*/
423
424
425 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
426 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
427
428 /**
429 * Material shininess lookup table.
430 */
431 struct gl_shine_tab
432 {
433 struct gl_shine_tab *next, *prev;
434 GLfloat tab[SHINE_TABLE_SIZE+1];
435 GLfloat shininess;
436 GLuint refcount;
437 };
438
439
440 /**
441 * Light source state.
442 */
443 struct gl_light
444 {
445 struct gl_light *next; /**< double linked list with sentinel */
446 struct gl_light *prev;
447
448 GLfloat Ambient[4]; /**< ambient color */
449 GLfloat Diffuse[4]; /**< diffuse color */
450 GLfloat Specular[4]; /**< specular color */
451 GLfloat EyePosition[4]; /**< position in eye coordinates */
452 GLfloat EyeDirection[4]; /**< spotlight dir in eye coordinates */
453 GLfloat SpotExponent;
454 GLfloat SpotCutoff; /**< in degrees */
455 GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */
456 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
457 GLfloat ConstantAttenuation;
458 GLfloat LinearAttenuation;
459 GLfloat QuadraticAttenuation;
460 GLboolean Enabled; /**< On/off flag */
461
462 /**
463 * \name Derived fields
464 */
465 /*@{*/
466 GLbitfield _Flags; /**< State */
467
468 GLfloat _Position[4]; /**< position in eye/obj coordinates */
469 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
470 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
471 GLfloat _NormDirection[4]; /**< normalized spotlight direction */
472 GLfloat _VP_inf_spot_attenuation;
473
474 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
475 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
476 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
477 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
478 GLfloat _dli; /**< CI diffuse light intensity */
479 GLfloat _sli; /**< CI specular light intensity */
480 /*@}*/
481 };
482
483
484 /**
485 * Light model state.
486 */
487 struct gl_lightmodel
488 {
489 GLfloat Ambient[4]; /**< ambient color */
490 GLboolean LocalViewer; /**< Local (or infinite) view point? */
491 GLboolean TwoSide; /**< Two (or one) sided lighting? */
492 GLenum ColorControl; /**< either GL_SINGLE_COLOR
493 * or GL_SEPARATE_SPECULAR_COLOR */
494 };
495
496
497 /**
498 * Material state.
499 */
500 struct gl_material
501 {
502 GLfloat Attrib[MAT_ATTRIB_MAX][4];
503 };
504
505
506 /**
507 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
508 */
509 struct gl_accum_attrib
510 {
511 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
512 };
513
514
515 /**
516 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
517 */
518 struct gl_colorbuffer_attrib
519 {
520 GLuint ClearIndex; /**< Index to use for glClear */
521 GLclampf ClearColor[4]; /**< Color to use for glClear */
522
523 GLuint IndexMask; /**< Color index write mask */
524 GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
525
526 GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
527
528 /**
529 * \name alpha testing
530 */
531 /*@{*/
532 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
533 GLenum AlphaFunc; /**< Alpha test function */
534 GLclampf AlphaRef; /**< Alpha reference value */
535 /*@}*/
536
537 /**
538 * \name Blending
539 */
540 /*@{*/
541 GLboolean BlendEnabled; /**< Blending enabled flag */
542 GLenum BlendSrcRGB; /**< Blending source operator */
543 GLenum BlendDstRGB; /**< Blending destination operator */
544 GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
545 GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
546 GLenum BlendEquationRGB; /**< Blending equation */
547 GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
548 GLfloat BlendColor[4]; /**< Blending color */
549 /*@}*/
550
551 /**
552 * \name Logic op
553 */
554 /*@{*/
555 GLenum LogicOp; /**< Logic operator */
556 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
557 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
558 GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
559 /*@}*/
560
561 GLboolean DitherFlag; /**< Dither enable flag */
562
563 GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
564 GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
565 };
566
567
568 /**
569 * Current attribute group (GL_CURRENT_BIT).
570 */
571 struct gl_current_attrib
572 {
573 /**
574 * \name Values valid only when FLUSH_VERTICES has been called.
575 */
576 /*@{*/
577 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Current vertex attributes
578 * indexed by VERT_ATTRIB_* */
579 GLfloat Index; /**< Current color index */
580 GLboolean EdgeFlag; /**< Current edge flag */
581 /*@}*/
582
583 /**
584 * \name Values are always valid.
585 *
586 * \note BTW, note how similar this set of attributes is to the SWvertex
587 * data type in the software rasterizer...
588 */
589 /*@{*/
590 GLfloat RasterPos[4]; /**< Current raster position */
591 GLfloat RasterDistance; /**< Current raster distance */
592 GLfloat RasterColor[4]; /**< Current raster color */
593 GLfloat RasterSecondaryColor[4]; /**< Current raster secondary color */
594 GLfloat RasterIndex; /**< Current raster index */
595 GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];/**< Current raster texcoords */
596 GLboolean RasterPosValid; /**< Raster pos valid flag */
597 /*@}*/
598 };
599
600
601 /**
602 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
603 */
604 struct gl_depthbuffer_attrib
605 {
606 GLenum Func; /**< Function for depth buffer compare */
607 GLclampd Clear; /**< Value to clear depth buffer to */
608 GLboolean Test; /**< Depth buffering enabled flag */
609 GLboolean Mask; /**< Depth buffer writable? */
610 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
611 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
612 };
613
614
615 /**
616 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
617 */
618 struct gl_enable_attrib
619 {
620 GLboolean AlphaTest;
621 GLboolean AutoNormal;
622 GLboolean Blend;
623 GLbitfield ClipPlanes;
624 GLboolean ColorMaterial;
625 GLboolean ColorTable; /* SGI_color_table */
626 GLboolean PostColorMatrixColorTable; /* SGI_color_table */
627 GLboolean PostConvolutionColorTable; /* SGI_color_table */
628 GLboolean Convolution1D;
629 GLboolean Convolution2D;
630 GLboolean Separable2D;
631 GLboolean CullFace;
632 GLboolean DepthTest;
633 GLboolean Dither;
634 GLboolean Fog;
635 GLboolean Histogram;
636 GLboolean Light[MAX_LIGHTS];
637 GLboolean Lighting;
638 GLboolean LineSmooth;
639 GLboolean LineStipple;
640 GLboolean IndexLogicOp;
641 GLboolean ColorLogicOp;
642 GLboolean Map1Color4;
643 GLboolean Map1Index;
644 GLboolean Map1Normal;
645 GLboolean Map1TextureCoord1;
646 GLboolean Map1TextureCoord2;
647 GLboolean Map1TextureCoord3;
648 GLboolean Map1TextureCoord4;
649 GLboolean Map1Vertex3;
650 GLboolean Map1Vertex4;
651 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
652 GLboolean Map2Color4;
653 GLboolean Map2Index;
654 GLboolean Map2Normal;
655 GLboolean Map2TextureCoord1;
656 GLboolean Map2TextureCoord2;
657 GLboolean Map2TextureCoord3;
658 GLboolean Map2TextureCoord4;
659 GLboolean Map2Vertex3;
660 GLboolean Map2Vertex4;
661 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
662 GLboolean MinMax;
663 GLboolean Normalize;
664 GLboolean PixelTexture;
665 GLboolean PointSmooth;
666 GLboolean PolygonOffsetPoint;
667 GLboolean PolygonOffsetLine;
668 GLboolean PolygonOffsetFill;
669 GLboolean PolygonSmooth;
670 GLboolean PolygonStipple;
671 GLboolean RescaleNormals;
672 GLboolean Scissor;
673 GLboolean Stencil;
674 GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
675 GLboolean MultisampleEnabled; /* GL_ARB_multisample */
676 GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
677 GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
678 GLboolean SampleCoverage; /* GL_ARB_multisample */
679 GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
680 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
681 GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
682 GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
683 /* SGI_texture_color_table */
684 GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
685 /* GL_ARB_vertex_program / GL_NV_vertex_program */
686 GLboolean VertexProgram;
687 GLboolean VertexProgramPointSize;
688 GLboolean VertexProgramTwoSide;
689 /* GL_ARB_point_sprite / GL_NV_point_sprite */
690 GLboolean PointSprite;
691 GLboolean FragmentShaderATI;
692 };
693
694
695 /**
696 * Evaluator attribute group (GL_EVAL_BIT).
697 */
698 struct gl_eval_attrib
699 {
700 /**
701 * \name Enable bits
702 */
703 /*@{*/
704 GLboolean Map1Color4;
705 GLboolean Map1Index;
706 GLboolean Map1Normal;
707 GLboolean Map1TextureCoord1;
708 GLboolean Map1TextureCoord2;
709 GLboolean Map1TextureCoord3;
710 GLboolean Map1TextureCoord4;
711 GLboolean Map1Vertex3;
712 GLboolean Map1Vertex4;
713 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
714 GLboolean Map2Color4;
715 GLboolean Map2Index;
716 GLboolean Map2Normal;
717 GLboolean Map2TextureCoord1;
718 GLboolean Map2TextureCoord2;
719 GLboolean Map2TextureCoord3;
720 GLboolean Map2TextureCoord4;
721 GLboolean Map2Vertex3;
722 GLboolean Map2Vertex4;
723 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
724 GLboolean AutoNormal;
725 /*@}*/
726
727 /**
728 * \name Map Grid endpoints and divisions and calculated du values
729 */
730 /*@{*/
731 GLint MapGrid1un;
732 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
733 GLint MapGrid2un, MapGrid2vn;
734 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
735 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
736 /*@}*/
737 };
738
739
740 /**
741 * Fog attribute group (GL_FOG_BIT).
742 */
743 struct gl_fog_attrib
744 {
745 GLboolean Enabled; /**< Fog enabled flag */
746 GLfloat Color[4]; /**< Fog color */
747 GLfloat Density; /**< Density >= 0.0 */
748 GLfloat Start; /**< Start distance in eye coords */
749 GLfloat End; /**< End distance in eye coords */
750 GLfloat Index; /**< Fog index */
751 GLenum Mode; /**< Fog mode */
752 GLboolean ColorSumEnabled;
753 GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
754 GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
755 };
756
757
758 /**
759 * Hint attribute group (GL_HINT_BIT).
760 *
761 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
762 */
763 struct gl_hint_attrib
764 {
765 GLenum PerspectiveCorrection;
766 GLenum PointSmooth;
767 GLenum LineSmooth;
768 GLenum PolygonSmooth;
769 GLenum Fog;
770 GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
771 GLenum TextureCompression; /**< GL_ARB_texture_compression */
772 GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
773 GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
774 };
775
776
777 /**
778 * Histogram attributes.
779 */
780 struct gl_histogram_attrib
781 {
782 GLuint Width; /**< number of table entries */
783 GLint Format; /**< GL_ALPHA, GL_RGB, etc */
784 GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
785 GLboolean Sink; /**< terminate image transfer? */
786 GLubyte RedSize; /**< Bits per counter */
787 GLubyte GreenSize;
788 GLubyte BlueSize;
789 GLubyte AlphaSize;
790 GLubyte LuminanceSize;
791 };
792
793
794 /**
795 * Color Min/max state.
796 */
797 struct gl_minmax_attrib
798 {
799 GLenum Format;
800 GLboolean Sink;
801 GLfloat Min[4], Max[4]; /**< RGBA */
802 };
803
804
805 /**
806 * Image convolution state.
807 */
808 struct gl_convolution_attrib
809 {
810 GLenum Format;
811 GLenum InternalFormat;
812 GLuint Width;
813 GLuint Height;
814 GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
815 };
816
817
818 /**
819 * Light state flags.
820 */
821 /*@{*/
822 #define LIGHT_SPOT 0x1
823 #define LIGHT_LOCAL_VIEWER 0x2
824 #define LIGHT_POSITIONAL 0x4
825 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
826 /*@}*/
827
828
829 /**
830 * Lighting attribute group (GL_LIGHT_BIT).
831 */
832 struct gl_light_attrib
833 {
834 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
835 struct gl_lightmodel Model; /**< Lighting model */
836
837 /**
838 * Must flush FLUSH_VERTICES before referencing:
839 */
840 /*@{*/
841 struct gl_material Material; /**< Includes front & back values */
842 /*@}*/
843
844 GLboolean Enabled; /**< Lighting enabled flag */
845 GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
846 GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
847 GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
848 GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
849 GLboolean ColorMaterialEnabled;
850
851 struct gl_light EnabledList; /**< List sentinel */
852
853 /**
854 * Derived state for optimizations:
855 */
856 /*@{*/
857 GLboolean _NeedEyeCoords;
858 GLboolean _NeedVertices; /**< Use fast shader? */
859 GLbitfield _Flags; /**< LIGHT_* flags, see above */
860 GLfloat _BaseColor[2][3];
861 /*@}*/
862 };
863
864
865 /**
866 * Line attribute group (GL_LINE_BIT).
867 */
868 struct gl_line_attrib
869 {
870 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
871 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
872 GLushort StipplePattern; /**< Stipple pattern */
873 GLint StippleFactor; /**< Stipple repeat factor */
874 GLfloat Width; /**< Line width */
875 GLfloat _Width; /**< Clamped Line width */
876 };
877
878
879 /**
880 * Display list attribute group (GL_LIST_BIT).
881 */
882 struct gl_list_attrib
883 {
884 GLuint ListBase;
885 };
886
887
888 /**
889 * Used by device drivers to hook new commands into display lists.
890 */
891 struct gl_list_instruction
892 {
893 GLuint Size;
894 void (*Execute)( GLcontext *ctx, void *data );
895 void (*Destroy)( GLcontext *ctx, void *data );
896 void (*Print)( GLcontext *ctx, void *data );
897 };
898
899 #define MAX_DLIST_EXT_OPCODES 16
900
901 /**
902 * Used by device drivers to hook new commands into display lists.
903 */
904 struct gl_list_extensions
905 {
906 struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
907 GLuint NumOpcodes;
908 };
909
910
911 /**
912 * Multisample attribute group (GL_MULTISAMPLE_BIT).
913 */
914 struct gl_multisample_attrib
915 {
916 GLboolean Enabled;
917 GLboolean SampleAlphaToCoverage;
918 GLboolean SampleAlphaToOne;
919 GLboolean SampleCoverage;
920 GLfloat SampleCoverageValue;
921 GLboolean SampleCoverageInvert;
922 };
923
924
925 /**
926 * Pixel attribute group (GL_PIXEL_MODE_BIT).
927 */
928 struct gl_pixel_attrib
929 {
930 GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
931 GLfloat RedBias, RedScale;
932 GLfloat GreenBias, GreenScale;
933 GLfloat BlueBias, BlueScale;
934 GLfloat AlphaBias, AlphaScale;
935 GLfloat DepthBias, DepthScale;
936 GLint IndexShift, IndexOffset;
937 GLboolean MapColorFlag;
938 GLboolean MapStencilFlag;
939 GLfloat ZoomX, ZoomY;
940 /* XXX move these out of gl_pixel_attrib */
941 GLint MapStoSsize; /**< Size of each pixel map */
942 GLint MapItoIsize;
943 GLint MapItoRsize;
944 GLint MapItoGsize;
945 GLint MapItoBsize;
946 GLint MapItoAsize;
947 GLint MapRtoRsize;
948 GLint MapGtoGsize;
949 GLint MapBtoBsize;
950 GLint MapAtoAsize;
951 GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */
952 GLfloat MapItoI[MAX_PIXEL_MAP_TABLE];
953 GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
954 GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
955 GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
956 GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
957 GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
958 GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
959 GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
960 GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
961 GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
962 GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
963 GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
964 GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
965 /** GL_EXT_histogram */
966 GLboolean HistogramEnabled;
967 GLboolean MinMaxEnabled;
968 /** GL_SGI_color_matrix */
969 GLfloat PostColorMatrixScale[4]; /**< RGBA */
970 GLfloat PostColorMatrixBias[4]; /**< RGBA */
971 /** GL_SGI_color_table */
972 GLfloat ColorTableScale[4];
973 GLfloat ColorTableBias[4];
974 GLboolean ColorTableEnabled;
975 GLfloat PCCTscale[4];
976 GLfloat PCCTbias[4];
977 GLboolean PostConvolutionColorTableEnabled;
978 GLfloat PCMCTscale[4];
979 GLfloat PCMCTbias[4];
980 GLboolean PostColorMatrixColorTableEnabled;
981 /** GL_SGI_texture_color_table */
982 GLfloat TextureColorTableScale[4];
983 GLfloat TextureColorTableBias[4];
984 /** Convolution */
985 GLboolean Convolution1DEnabled;
986 GLboolean Convolution2DEnabled;
987 GLboolean Separable2DEnabled;
988 GLfloat ConvolutionBorderColor[3][4];
989 GLenum ConvolutionBorderMode[3];
990 GLfloat ConvolutionFilterScale[3][4];
991 GLfloat ConvolutionFilterBias[3][4];
992 GLfloat PostConvolutionScale[4]; /**< RGBA */
993 GLfloat PostConvolutionBias[4]; /**< RGBA */
994 };
995
996
997 /**
998 * Point attribute group (GL_POINT_BIT).
999 */
1000 struct gl_point_attrib
1001 {
1002 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
1003 GLfloat Size; /**< User-specified point size */
1004 GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */
1005 GLfloat Params[3]; /**< GL_EXT_point_parameters */
1006 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
1007 GLfloat Threshold; /**< GL_EXT_point_parameters */
1008 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
1009 GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
1010 GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV/ARB_point_sprite */
1011 GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
1012 GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
1013 };
1014
1015
1016 /**
1017 * Polygon attribute group (GL_POLYGON_BIT).
1018 */
1019 struct gl_polygon_attrib
1020 {
1021 GLenum FrontFace; /**< Either GL_CW or GL_CCW */
1022 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
1023 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
1024 GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
1025 GLboolean CullFlag; /**< Culling on/off flag */
1026 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
1027 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
1028 GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
1029 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
1030 GLfloat OffsetUnits; /**< Polygon offset units, from user */
1031 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
1032 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
1033 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
1034 };
1035
1036
1037 /**
1038 * Scissor attributes (GL_SCISSOR_BIT).
1039 */
1040 struct gl_scissor_attrib
1041 {
1042 GLboolean Enabled; /**< Scissor test enabled? */
1043 GLint X, Y; /**< Lower left corner of box */
1044 GLsizei Width, Height; /**< Size of box */
1045 };
1046
1047
1048 /**
1049 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1050 */
1051 struct gl_stencil_attrib
1052 {
1053 GLboolean Enabled; /**< Enabled flag */
1054 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
1055 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 1) */
1056 GLboolean _TestTwoSide;
1057 GLenum Function[2]; /**< Stencil function */
1058 GLenum FailFunc[2]; /**< Fail function */
1059 GLenum ZPassFunc[2]; /**< Depth buffer pass function */
1060 GLenum ZFailFunc[2]; /**< Depth buffer fail function */
1061 GLint Ref[2]; /**< Reference value */
1062 GLuint ValueMask[2]; /**< Value mask */
1063 GLuint WriteMask[2]; /**< Write mask */
1064 GLuint Clear; /**< Clear value */
1065 };
1066
1067
1068 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1069
1070 /**
1071 * An index for each type of texture object
1072 */
1073 /*@{*/
1074 #define TEXTURE_1D_INDEX 0
1075 #define TEXTURE_2D_INDEX 1
1076 #define TEXTURE_3D_INDEX 2
1077 #define TEXTURE_CUBE_INDEX 3
1078 #define TEXTURE_RECT_INDEX 4
1079 /*@}*/
1080
1081 /**
1082 * Bit flags for each type of texture object
1083 * Used for Texture.Unit[]._ReallyEnabled flags.
1084 */
1085 /*@{*/
1086 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1087 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1088 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1089 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1090 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1091 /*@}*/
1092
1093
1094 /**
1095 * TexGenEnabled flags.
1096 */
1097 /*@{*/
1098 #define S_BIT 1
1099 #define T_BIT 2
1100 #define R_BIT 4
1101 #define Q_BIT 8
1102 /*@}*/
1103
1104
1105 /**
1106 * Bit flag versions of the corresponding GL_ constants.
1107 */
1108 /*@{*/
1109 #define TEXGEN_SPHERE_MAP 0x1
1110 #define TEXGEN_OBJ_LINEAR 0x2
1111 #define TEXGEN_EYE_LINEAR 0x4
1112 #define TEXGEN_REFLECTION_MAP_NV 0x8
1113 #define TEXGEN_NORMAL_MAP_NV 0x10
1114
1115 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1116 TEXGEN_REFLECTION_MAP_NV | \
1117 TEXGEN_NORMAL_MAP_NV)
1118 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1119 TEXGEN_REFLECTION_MAP_NV | \
1120 TEXGEN_NORMAL_MAP_NV | \
1121 TEXGEN_EYE_LINEAR)
1122 /*@}*/
1123
1124
1125 /* A selection of state flags to make driver and module's lives easier. */
1126 #define ENABLE_TEXGEN0 0x1
1127 #define ENABLE_TEXGEN1 0x2
1128 #define ENABLE_TEXGEN2 0x4
1129 #define ENABLE_TEXGEN3 0x8
1130 #define ENABLE_TEXGEN4 0x10
1131 #define ENABLE_TEXGEN5 0x20
1132 #define ENABLE_TEXGEN6 0x40
1133 #define ENABLE_TEXGEN7 0x80
1134
1135 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1136 #define ENABLE_TEXMAT1 0x2
1137 #define ENABLE_TEXMAT2 0x4
1138 #define ENABLE_TEXMAT3 0x8
1139 #define ENABLE_TEXMAT4 0x10
1140 #define ENABLE_TEXMAT5 0x20
1141 #define ENABLE_TEXMAT6 0x40
1142 #define ENABLE_TEXMAT7 0x80
1143
1144 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1145 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1146
1147
1148 /**
1149 * Texel fetch function prototype. We use texel fetch functions to
1150 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1151 * texture images. These functions help to isolate us from the gritty
1152 * details of all the various texture image encodings.
1153 *
1154 * \param texImage texture image.
1155 * \param col texel column.
1156 * \param row texel row.
1157 * \param img texel image level/layer.
1158 * \param texelOut output texel (up to 4 GLchans)
1159 */
1160 typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
1161 GLint col, GLint row, GLint img,
1162 GLchan *texelOut );
1163
1164 /**
1165 * As above, but returns floats.
1166 * Used for depth component images and for upcoming signed/float
1167 * texture images.
1168 */
1169 typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
1170 GLint col, GLint row, GLint img,
1171 GLfloat *texelOut );
1172
1173
1174 typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
1175 GLint col, GLint row, GLint img,
1176 const void *texel);
1177
1178 /**
1179 * TexImage store function. This is called by the glTex[Sub]Image
1180 * functions and is responsible for converting the user-specified texture
1181 * image into a specific (hardware) image format.
1182 */
1183 typedef GLboolean (*StoreTexImageFunc)(GLcontext *ctx, GLuint dims,
1184 GLenum baseInternalFormat,
1185 const struct gl_texture_format *dstFormat,
1186 GLvoid *dstAddr,
1187 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
1188 GLint dstRowStride, GLint dstImageStride,
1189 GLint srcWidth, GLint srcHeight, GLint srcDepth,
1190 GLenum srcFormat, GLenum srcType,
1191 const GLvoid *srcAddr,
1192 const struct gl_pixelstore_attrib *srcPacking);
1193
1194
1195
1196 /**
1197 * Texture format record
1198 */
1199 struct gl_texture_format
1200 {
1201 GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
1202
1203 GLenum BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1204 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1205 * GL_INTENSITY, GL_COLOR_INDEX or
1206 * GL_DEPTH_COMPONENT.
1207 */
1208 GLenum DataType; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1209 GLubyte RedBits; /**< Bits per texel component */
1210 GLubyte GreenBits; /**< These are just rough approximations for */
1211 GLubyte BlueBits; /**< compressed texture formats. */
1212 GLubyte AlphaBits;
1213 GLubyte LuminanceBits;
1214 GLubyte IntensityBits;
1215 GLubyte IndexBits;
1216 GLubyte DepthBits;
1217 GLubyte StencilBits; /**< GL_EXT_packed_depth_stencil */
1218
1219 GLuint TexelBytes; /**< Bytes per texel, 0 if compressed format */
1220
1221 StoreTexImageFunc StoreImage;
1222
1223 /**
1224 * \name Texel fetch function pointers
1225 */
1226 /*@{*/
1227 FetchTexelFuncC FetchTexel1D;
1228 FetchTexelFuncC FetchTexel2D;
1229 FetchTexelFuncC FetchTexel3D;
1230 FetchTexelFuncF FetchTexel1Df;
1231 FetchTexelFuncF FetchTexel2Df;
1232 FetchTexelFuncF FetchTexel3Df;
1233 /*@}*/
1234
1235 StoreTexelFunc StoreTexel;
1236 };
1237
1238
1239 /**
1240 * Texture image state. Describes the dimensions of a texture image,
1241 * the texel format and pointers to Texel Fetch functions.
1242 */
1243 struct gl_texture_image
1244 {
1245 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1246 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1247 * GL_INTENSITY, GL_COLOR_INDEX,
1248 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1249 * only. Used for choosing TexEnv arithmetic.
1250 */
1251 GLint InternalFormat; /**< Internal format as given by the user */
1252 GLuint Border; /**< 0 or 1 */
1253 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
1254 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
1255 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
1256 GLuint RowStride; /**< == Width unless IsClientData and padded */
1257 GLuint ImageStride; /**< Stride between images, in texels */
1258 GLuint Width2; /**< = Width - 2*Border */
1259 GLuint Height2; /**< = Height - 2*Border */
1260 GLuint Depth2; /**< = Depth - 2*Border */
1261 GLuint WidthLog2; /**< = log2(Width2) */
1262 GLuint HeightLog2; /**< = log2(Height2) */
1263 GLuint DepthLog2; /**< = log2(Depth2) */
1264 GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
1265 GLfloat WidthScale; /**< used for mipmap LOD computation */
1266 GLfloat HeightScale; /**< used for mipmap LOD computation */
1267 GLfloat DepthScale; /**< used for mipmap LOD computation */
1268 GLvoid *Data; /**< Image data, accessed via FetchTexel() */
1269 GLboolean IsClientData; /**< Data owned by client? */
1270 GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
1271
1272 const struct gl_texture_format *TexFormat;
1273
1274 struct gl_texture_object *TexObject; /**< Pointer back to parent object */
1275
1276 FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
1277 FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
1278
1279 GLboolean IsCompressed; /**< GL_ARB_texture_compression */
1280 GLuint CompressedSize; /**< GL_ARB_texture_compression */
1281
1282 /**
1283 * \name For device driver:
1284 */
1285 /*@{*/
1286 void *DriverData; /**< Arbitrary device driver data */
1287 /*@}*/
1288 };
1289
1290
1291 /**
1292 * Indexes for cube map faces.
1293 */
1294 /*@{*/
1295 #define FACE_POS_X 0
1296 #define FACE_NEG_X 1
1297 #define FACE_POS_Y 2
1298 #define FACE_NEG_Y 3
1299 #define FACE_POS_Z 4
1300 #define FACE_NEG_Z 5
1301 #define MAX_FACES 6
1302 /*@}*/
1303
1304
1305 /**
1306 * Texture object state. Contains the array of mipmap images, border color,
1307 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1308 * color palette.
1309 */
1310 struct gl_texture_object
1311 {
1312 _glthread_Mutex Mutex; /**< for thread safety */
1313 GLint RefCount; /**< reference count */
1314 GLuint Name; /**< the user-visible texture object ID */
1315 GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1316 GLfloat Priority; /**< in [0,1] */
1317 GLfloat BorderColor[4]; /**< unclamped */
1318 GLchan _BorderChan[4]; /**< clamped, as GLchan */
1319 GLenum WrapS; /**< S-axis texture image wrap mode */
1320 GLenum WrapT; /**< T-axis texture image wrap mode */
1321 GLenum WrapR; /**< R-axis texture image wrap mode */
1322 GLenum MinFilter; /**< minification filter */
1323 GLenum MagFilter; /**< magnification filter */
1324 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
1325 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
1326 GLfloat LodBias; /**< OpenGL 1.4 */
1327 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
1328 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
1329 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1330 GLboolean CompareFlag; /**< GL_SGIX_shadow */
1331 GLenum CompareOperator; /**< GL_SGIX_shadow */
1332 GLfloat ShadowAmbient; /**< GL_ARB_shadow_ambient */
1333 GLenum CompareMode; /**< GL_ARB_shadow */
1334 GLenum CompareFunc; /**< GL_ARB_shadow */
1335 GLenum DepthMode; /**< GL_ARB_depth_texture */
1336 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
1337 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1338 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
1339 GLboolean Complete; /**< Is texture object complete? */
1340
1341 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1342 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1343
1344 /** GL_EXT_paletted_texture */
1345 struct gl_color_table Palette;
1346
1347
1348 /**
1349 * \name For device driver.
1350 * Note: instead of attaching driver data to this pointer, it's preferable
1351 * to instead use this struct as a base class for your own texture object
1352 * class. Driver->NewTextureObject() can be used to implement the
1353 * allocation.
1354 */
1355 void *DriverData; /**< Arbitrary device driver data */
1356 };
1357
1358
1359 /**
1360 * Texture combine environment state.
1361 *
1362 * \todo
1363 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1364 * structure will need to be expanded for 4 elements.
1365 */
1366 struct gl_tex_env_combine_state
1367 {
1368 GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1369 GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1370 GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1371 GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1372 GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1373 GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1374 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1375 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1376 GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
1377 GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
1378 };
1379
1380
1381 /**
1382 * Texture unit state. Contains enable flags, texture environment/function/
1383 * combiners, texgen state, pointers to current texture objects and
1384 * post-filter color tables.
1385 */
1386 struct gl_texture_unit
1387 {
1388 GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1389 GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1390
1391 GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1392 GLfloat EnvColor[4];
1393 GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1394 /** \name Tex coord generation mode
1395 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1396 /*@{*/
1397 GLenum GenModeS;
1398 GLenum GenModeT;
1399 GLenum GenModeR;
1400 GLenum GenModeQ;
1401 /*@}*/
1402 GLbitfield _GenBitS;
1403 GLbitfield _GenBitT;
1404 GLbitfield _GenBitR;
1405 GLbitfield _GenBitQ;
1406 GLbitfield _GenFlags; /**< bitwise or of GenBit[STRQ] */
1407 GLfloat ObjectPlaneS[4];
1408 GLfloat ObjectPlaneT[4];
1409 GLfloat ObjectPlaneR[4];
1410 GLfloat ObjectPlaneQ[4];
1411 GLfloat EyePlaneS[4];
1412 GLfloat EyePlaneT[4];
1413 GLfloat EyePlaneR[4];
1414 GLfloat EyePlaneQ[4];
1415 GLfloat LodBias; /**< for biasing mipmap levels */
1416
1417 /**
1418 * \name GL_EXT_texture_env_combine
1419 */
1420 struct gl_tex_env_combine_state Combine;
1421
1422 /**
1423 * Derived state based on \c EnvMode and the \c BaseFormat of the
1424 * currently enabled texture.
1425 */
1426 struct gl_tex_env_combine_state _EnvMode;
1427
1428 /**
1429 * Currently enabled combiner state. This will point to either
1430 * \c Combine or \c _EnvMode.
1431 */
1432 struct gl_tex_env_combine_state *_CurrentCombine;
1433
1434 struct gl_texture_object *Current1D;
1435 struct gl_texture_object *Current2D;
1436 struct gl_texture_object *Current3D;
1437 struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
1438 struct gl_texture_object *CurrentRect; /**< GL_NV_texture_rectangle */
1439
1440 struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
1441
1442 struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */
1443 struct gl_texture_object Saved2D;
1444 struct gl_texture_object Saved3D;
1445 struct gl_texture_object SavedCubeMap;
1446 struct gl_texture_object SavedRect;
1447
1448 /* GL_SGI_texture_color_table */
1449 struct gl_color_table ColorTable;
1450 struct gl_color_table ProxyColorTable;
1451 GLboolean ColorTableEnabled;
1452 };
1453
1454 struct texenvprog_cache {
1455 GLuint hash;
1456 void *key;
1457 void *data;
1458 struct texenvprog_cache *next;
1459 };
1460
1461 /**
1462 * Texture attribute group (GL_TEXTURE_BIT).
1463 */
1464 struct gl_texture_attrib
1465 {
1466 /**
1467 * name multitexture
1468 */
1469 /**@{*/
1470 GLuint CurrentUnit; /**< Active texture unit */
1471 GLbitfield _EnabledUnits; /**< one bit set for each really-enabled unit */
1472 GLbitfield _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
1473 GLbitfield _GenFlags; /**< for texgen */
1474 GLbitfield _TexGenEnabled;
1475 GLbitfield _TexMatEnabled;
1476 /**@}*/
1477
1478 struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
1479
1480 struct gl_texture_object *Proxy1D;
1481 struct gl_texture_object *Proxy2D;
1482 struct gl_texture_object *Proxy3D;
1483 struct gl_texture_object *ProxyCubeMap;
1484 struct gl_texture_object *ProxyRect;
1485
1486 /** GL_EXT_shared_texture_palette */
1487 GLboolean SharedPalette;
1488 struct gl_color_table Palette;
1489
1490 /** Cached texenv fragment programs */
1491 struct texenvprog_cache *env_fp_cache;
1492 };
1493
1494
1495 /**
1496 * Transformation attribute group (GL_TRANSFORM_BIT).
1497 */
1498 struct gl_transform_attrib
1499 {
1500 GLenum MatrixMode; /**< Matrix mode */
1501 GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */
1502 GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */
1503 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
1504 GLboolean Normalize; /**< Normalize all normals? */
1505 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1506 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1507
1508 GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */
1509 GLfloat CullEyePos[4];
1510 GLfloat CullObjPos[4];
1511 };
1512
1513
1514 /**
1515 * Viewport attribute group (GL_VIEWPORT_BIT).
1516 */
1517 struct gl_viewport_attrib
1518 {
1519 GLint X, Y; /**< position */
1520 GLsizei Width, Height; /**< size */
1521 GLfloat Near, Far; /**< Depth buffer range */
1522 GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
1523 };
1524
1525
1526 /**
1527 * Node for the attribute stack.
1528 */
1529 struct gl_attrib_node
1530 {
1531 GLbitfield kind;
1532 void *data;
1533 struct gl_attrib_node *next;
1534 };
1535
1536
1537 /**
1538 * GL_ARB_vertex/pixel_buffer_object buffer object
1539 */
1540 struct gl_buffer_object
1541 {
1542 GLint RefCount;
1543 GLuint Name;
1544 GLenum Usage;
1545 GLenum Access;
1546 GLvoid *Pointer; /**< Only valid while buffer is mapped */
1547 GLsizeiptrARB Size; /**< Size of storage in bytes */
1548 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1549 GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
1550 };
1551
1552
1553
1554 /**
1555 * Client pixel packing/unpacking attributes
1556 */
1557 struct gl_pixelstore_attrib
1558 {
1559 GLint Alignment;
1560 GLint RowLength;
1561 GLint SkipPixels;
1562 GLint SkipRows;
1563 GLint ImageHeight; /**< for GL_EXT_texture3D */
1564 GLint SkipImages; /**< for GL_EXT_texture3D */
1565 GLboolean SwapBytes;
1566 GLboolean LsbFirst;
1567 GLboolean ClientStorage; /**< GL_APPLE_client_storage */
1568 GLboolean Invert; /**< GL_MESA_pack_invert */
1569 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
1570 };
1571
1572
1573 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1574
1575
1576 /**
1577 * Client vertex array attributes
1578 */
1579 struct gl_client_array
1580 {
1581 GLint Size; /**< components per element (1,2,3,4) */
1582 GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
1583 GLsizei Stride; /**< user-specified stride */
1584 GLsizei StrideB; /**< actual stride in bytes */
1585 const GLubyte *Ptr; /**< Points to array data */
1586 GLbitfield Enabled; /**< one of the _NEW_ARRAY_ bits */
1587 GLboolean Normalized; /**< GL_ARB_vertex_program */
1588
1589 /**< GL_ARB_vertex_buffer_object */
1590 struct gl_buffer_object *BufferObj;
1591 GLuint _MaxElement;
1592
1593 GLbitfield Flags;
1594 };
1595
1596
1597 /**
1598 * Vertex array state
1599 */
1600 struct gl_array_attrib
1601 {
1602 struct gl_client_array Vertex; /**< client data descriptors */
1603 struct gl_client_array Normal;
1604 struct gl_client_array Color;
1605 struct gl_client_array SecondaryColor;
1606 struct gl_client_array FogCoord;
1607 struct gl_client_array Index;
1608 struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
1609 struct gl_client_array EdgeFlag;
1610
1611 struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
1612
1613 GLint ActiveTexture; /**< Client Active Texture */
1614 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1615 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1616
1617 GLbitfield _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
1618 GLbitfield NewState; /**< _NEW_ARRAY_* */
1619
1620 #if FEATURE_ARB_vertex_buffer_object
1621 struct gl_buffer_object *NullBufferObj;
1622 struct gl_buffer_object *ArrayBufferObj;
1623 struct gl_buffer_object *ElementArrayBufferObj;
1624 #endif
1625 GLuint _MaxElement; /* Min of all enabled array's maxes */
1626 };
1627
1628
1629 /**
1630 * Feedback buffer state
1631 */
1632 struct gl_feedback
1633 {
1634 GLenum Type;
1635 GLbitfield _Mask; /* FB_* bits */
1636 GLfloat *Buffer;
1637 GLuint BufferSize;
1638 GLuint Count;
1639 };
1640
1641
1642 /**
1643 * Selection buffer state
1644 */
1645 struct gl_selection
1646 {
1647 GLuint *Buffer; /**< selection buffer */
1648 GLuint BufferSize; /**< size of the selection buffer */
1649 GLuint BufferCount; /**< number of values in the selection buffer */
1650 GLuint Hits; /**< number of records in the selection buffer */
1651 GLuint NameStackDepth; /**< name stack depth */
1652 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1653 GLboolean HitFlag; /**< hit flag */
1654 GLfloat HitMinZ; /**< minimum hit depth */
1655 GLfloat HitMaxZ; /**< maximum hit depth */
1656 };
1657
1658
1659 /**
1660 * 1-D Evaluator control points
1661 */
1662 struct gl_1d_map
1663 {
1664 GLuint Order; /**< Number of control points */
1665 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1666 GLfloat *Points; /**< Points to contiguous control points */
1667 };
1668
1669
1670 /**
1671 * 2-D Evaluator control points
1672 */
1673 struct gl_2d_map
1674 {
1675 GLuint Uorder; /**< Number of control points in U dimension */
1676 GLuint Vorder; /**< Number of control points in V dimension */
1677 GLfloat u1, u2, du;
1678 GLfloat v1, v2, dv;
1679 GLfloat *Points; /**< Points to contiguous control points */
1680 };
1681
1682
1683 /**
1684 * All evaluator control point state
1685 */
1686 struct gl_evaluators
1687 {
1688 /**
1689 * \name 1-D maps
1690 */
1691 /*@{*/
1692 struct gl_1d_map Map1Vertex3;
1693 struct gl_1d_map Map1Vertex4;
1694 struct gl_1d_map Map1Index;
1695 struct gl_1d_map Map1Color4;
1696 struct gl_1d_map Map1Normal;
1697 struct gl_1d_map Map1Texture1;
1698 struct gl_1d_map Map1Texture2;
1699 struct gl_1d_map Map1Texture3;
1700 struct gl_1d_map Map1Texture4;
1701 struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
1702 /*@}*/
1703
1704 /**
1705 * \name 2-D maps
1706 */
1707 /*@{*/
1708 struct gl_2d_map Map2Vertex3;
1709 struct gl_2d_map Map2Vertex4;
1710 struct gl_2d_map Map2Index;
1711 struct gl_2d_map Map2Color4;
1712 struct gl_2d_map Map2Normal;
1713 struct gl_2d_map Map2Texture1;
1714 struct gl_2d_map Map2Texture2;
1715 struct gl_2d_map Map2Texture3;
1716 struct gl_2d_map Map2Texture4;
1717 struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
1718 /*@}*/
1719 };
1720
1721
1722 /**
1723 * State used during execution of fragment programs.
1724 */
1725 struct fp_machine
1726 {
1727 GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
1728 GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
1729 GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
1730 GLuint CondCodes[4];
1731 };
1732
1733
1734 /**
1735 * Names of the various vertex/fragment program register files, etc.
1736 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1737 * All values should fit in a 4-bit field.
1738 */
1739 enum register_file
1740 {
1741 PROGRAM_TEMPORARY = 0,
1742 PROGRAM_LOCAL_PARAM = 1,
1743 PROGRAM_ENV_PARAM = 2,
1744 PROGRAM_STATE_VAR = 3,
1745 PROGRAM_INPUT = 4,
1746 PROGRAM_OUTPUT = 5,
1747 PROGRAM_NAMED_PARAM = 6,
1748 PROGRAM_CONSTANT = 7,
1749 PROGRAM_WRITE_ONLY = 8,
1750 PROGRAM_ADDRESS = 9,
1751 PROGRAM_UNDEFINED = 15 /* invalid value */
1752 };
1753
1754
1755 /** Vertex and fragment instructions */
1756 struct prog_instruction;
1757 struct program_parameter_list;
1758
1759
1760 /**
1761 * Base class for any kind of program object
1762 */
1763 struct program
1764 {
1765 GLuint Id;
1766 GLubyte *String; /**< Null-terminated program text */
1767 GLint RefCount;
1768 GLenum Target;
1769 GLenum Format; /**< String encoding format */
1770 GLboolean Resident;
1771
1772 struct prog_instruction *Instructions;
1773
1774 GLbitfield InputsRead; /* Bitmask of which input regs are read */
1775 GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */
1776
1777 /** Named parameters, constants, etc. from program text */
1778 struct program_parameter_list *Parameters;
1779 /** Numbered local parameters */
1780 GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
1781
1782 /** Logical counts */
1783 /*@{*/
1784 GLuint NumInstructions;
1785 GLuint NumTemporaries;
1786 GLuint NumParameters;
1787 GLuint NumAttributes;
1788 GLuint NumAddressRegs;
1789 /*@}*/
1790 /** Native, actual h/w counts */
1791 /*@{*/
1792 GLuint NumNativeInstructions;
1793 GLuint NumNativeTemporaries;
1794 GLuint NumNativeParameters;
1795 GLuint NumNativeAttributes;
1796 GLuint NumNativeAddressRegs;
1797 /*@}*/
1798 };
1799
1800
1801 /** Vertex program object */
1802 struct vertex_program
1803 {
1804 struct program Base; /* base class */
1805 GLboolean IsNVProgram; /* GL_NV_vertex_program ? */
1806 GLboolean IsPositionInvariant; /* GL_ARB_vertex_program / GL_NV_vertex_program1_1 */
1807 void *TnlData; /* should probably use Base.DriverData */
1808 };
1809
1810
1811 /** Fragment program object */
1812 struct fragment_program
1813 {
1814 struct program Base; /**< base class */
1815 GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
1816 GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
1817 GLuint NumTexInstructions;
1818 GLuint NumTexIndirections;
1819 GLuint NumNativeAluInstructions; /**< GL_ARB_fragment_program */
1820 GLuint NumNativeTexInstructions;
1821 GLuint NumNativeTexIndirections;
1822 GLenum FogOption;
1823 GLboolean UsesKill;
1824 };
1825
1826
1827 /**
1828 * State common to vertex and fragment programs.
1829 */
1830 struct gl_program_state
1831 {
1832 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1833 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1834 };
1835
1836
1837 /**
1838 * State vars for GL_ARB/GL_NV_vertex_program
1839 */
1840 struct gl_vertex_program_state
1841 {
1842 GLboolean Enabled; /**< GL_VERTEX_PROGRAM_ARB/NV */
1843 GLboolean _Enabled; /**< Enabled and valid program? */
1844 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1845 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1846 struct vertex_program *Current; /**< ptr to currently bound program */
1847 struct vertex_program *_Current; /**< ptr to currently bound
1848 program, including internal
1849 (t_vp_build.c) programs */
1850
1851 GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1852 GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1853
1854 GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
1855 /* Only used during program execution (may be moved someday): */
1856 GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
1857 GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
1858 GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
1859 GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
1860 GLint AddressReg[4];
1861
1862 #if FEATURE_MESA_program_debug
1863 GLprogramcallbackMESA Callback;
1864 GLvoid *CallbackData;
1865 GLboolean CallbackEnabled;
1866 GLuint CurrentPosition;
1867 #endif
1868 };
1869
1870
1871 /**
1872 * Context state for GL_ARB/NV_fragment_program
1873 */
1874 struct gl_fragment_program_state
1875 {
1876 GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
1877 GLboolean _Enabled; /* Enabled and valid program? */
1878 GLboolean _Active;
1879 struct fragment_program *Current; /* ptr to currently bound program */
1880 struct fragment_program *_Current; /* ptr to currently active program
1881 (including internal programs) */
1882 struct fp_machine Machine; /* machine state */
1883 GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
1884
1885 #if FEATURE_MESA_program_debug
1886 GLprogramcallbackMESA Callback;
1887 GLvoid *CallbackData;
1888 GLboolean CallbackEnabled;
1889 GLuint CurrentPosition;
1890 #endif
1891 };
1892
1893
1894 /**
1895 * ATI_fragment_shader runtime state
1896 */
1897 #define ATI_FS_INPUT_PRIMARY 0
1898 #define ATI_FS_INPUT_SECONDARY 1
1899
1900 struct atifs_instruction;
1901 struct atifs_setupinst;
1902
1903 /**
1904 * State for executing ATI fragment shader.
1905 */
1906 struct atifs_machine
1907 {
1908 GLfloat Registers[6][4]; /** six temporary registers */
1909 GLfloat PrevPassRegisters[6][4];
1910 GLfloat Inputs[2][4]; /** Primary, secondary input colors */
1911 };
1912
1913
1914 /**
1915 * ATI fragment shader
1916 */
1917 struct ati_fragment_shader
1918 {
1919 GLuint Id;
1920 GLint RefCount;
1921 struct atifs_instruction *Instructions[2];
1922 struct atifs_setupinst *SetupInst[2];
1923 GLfloat Constants[8][4];
1924 GLbitfield LocalConstDef; /** Indicates which constants have been set */
1925 GLubyte numArithInstr[2];
1926 GLubyte regsAssigned[2];
1927 GLubyte NumPasses; /** 1 or 2 */
1928 GLubyte cur_pass;
1929 GLubyte last_optype;
1930 GLboolean interpinp1;
1931 GLboolean isValid;
1932 GLuint swizzlerq;
1933 };
1934
1935 /**
1936 * Context state for GL_ATI_fragment_shader
1937 */
1938 struct gl_ati_fragment_shader_state
1939 {
1940 GLboolean Enabled;
1941 GLboolean _Enabled; /** enabled and valid shader? */
1942 GLboolean Compiling;
1943 GLfloat GlobalConstants[8][4];
1944 struct atifs_machine Machine; /* machine state */
1945 struct ati_fragment_shader *Current;
1946 };
1947
1948
1949 /**
1950 * Occlusion/timer query object.
1951 */
1952 struct gl_query_object
1953 {
1954 GLuint Id;
1955 GLuint64EXT Result; /* the counter */
1956 GLboolean Active; /* inside Begin/EndQuery */
1957 GLboolean Ready; /* result is ready */
1958 };
1959
1960
1961 /**
1962 * Context state for query objects.
1963 */
1964 struct gl_query_state
1965 {
1966 struct _mesa_HashTable *QueryObjects;
1967 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
1968 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
1969 };
1970
1971
1972 /**
1973 * Context state for vertex/fragment shaders.
1974 */
1975 struct gl_shader_objects_state
1976 {
1977 struct gl2_program_intf **CurrentProgram;
1978 GLboolean _VertexShaderPresent;
1979 GLboolean _FragmentShaderPresent;
1980 };
1981
1982
1983 /**
1984 * State which can be shared by multiple contexts:
1985 */
1986 struct gl_shared_state
1987 {
1988 _glthread_Mutex Mutex; /**< for thread safety */
1989 GLint RefCount; /**< Reference count */
1990 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
1991 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
1992
1993 /**
1994 * \name Default texture objects (shared by all multi-texture units)
1995 */
1996 /*@{*/
1997 struct gl_texture_object *Default1D;
1998 struct gl_texture_object *Default2D;
1999 struct gl_texture_object *Default3D;
2000 struct gl_texture_object *DefaultCubeMap;
2001 struct gl_texture_object *DefaultRect;
2002 /*@}*/
2003
2004 /**
2005 * \name Vertex/fragment programs
2006 */
2007 /*@{*/
2008 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
2009 #if FEATURE_ARB_vertex_program
2010 struct program *DefaultVertexProgram;
2011 #endif
2012 #if FEATURE_ARB_fragment_program
2013 struct program *DefaultFragmentProgram;
2014 #endif
2015 /*@}*/
2016
2017 #if FEATURE_ATI_fragment_shader
2018 struct _mesa_HashTable *ATIShaders;
2019 struct ati_fragment_shader *DefaultFragmentShader;
2020 #endif
2021
2022 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2023 struct _mesa_HashTable *BufferObjects;
2024 #endif
2025
2026 struct _mesa_HashTable *GL2Objects;
2027
2028 #if FEATURE_EXT_framebuffer_object
2029 struct _mesa_HashTable *RenderBuffers;
2030 struct _mesa_HashTable *FrameBuffers;
2031 #endif
2032
2033 void *DriverData; /**< Device driver shared state */
2034 };
2035
2036
2037
2038
2039 /**
2040 * A renderbuffer stores colors or depth values or stencil values.
2041 * A framebuffer object will have a collection of these.
2042 * Data are read/written to the buffer with a handful of Get/Put functions.
2043 *
2044 * Instances of this object are allocated with the Driver's NewRenderbuffer
2045 * hook. Drivers will likely wrap this class inside a driver-specific
2046 * class to simulate inheritance.
2047 */
2048 struct gl_renderbuffer
2049 {
2050 _glthread_Mutex Mutex; /**< for thread safety */
2051 GLuint ClassID; /**< Useful for drivers */
2052 GLuint Name;
2053 GLint RefCount;
2054 GLuint Width, Height;
2055 GLenum InternalFormat; /**< The user-specified format */
2056 GLenum _ActualFormat; /**< The driver-chosen format */
2057 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2058 GL_STENCIL_INDEX. */
2059 GLenum DataType; /**< Type of values passed to the Get/Put functions */
2060 GLubyte RedBits; /**< Bits of red per pixel */
2061 GLubyte GreenBits;
2062 GLubyte BlueBits;
2063 GLubyte AlphaBits;
2064 GLubyte IndexBits;
2065 GLubyte DepthBits;
2066 GLubyte StencilBits;
2067 GLvoid *Data;
2068
2069 /* Used to wrap one renderbuffer around another: */
2070 struct gl_renderbuffer *Wrapped;
2071
2072 /* Delete this renderbuffer */
2073 void (*Delete)(struct gl_renderbuffer *rb);
2074
2075 /* Allocate new storage for this renderbuffer */
2076 GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
2077 GLenum internalFormat,
2078 GLuint width, GLuint height);
2079
2080 /* Lock/Unlock are called before/after calling the Get/Put functions.
2081 * Not sure this is the right place for these yet.
2082 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2083 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2084 */
2085
2086 /* Return a pointer to the element/pixel at (x,y).
2087 * Should return NULL if the buffer memory can't be directly addressed.
2088 */
2089 void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb,
2090 GLint x, GLint y);
2091
2092 /* Get/Read a row of values.
2093 * The values will be of format _BaseFormat and type DataType.
2094 */
2095 void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2096 GLint x, GLint y, void *values);
2097
2098 /* Get/Read values at arbitrary locations.
2099 * The values will be of format _BaseFormat and type DataType.
2100 */
2101 void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2102 const GLint x[], const GLint y[], void *values);
2103
2104 /* Put/Write a row of values.
2105 * The values will be of format _BaseFormat and type DataType.
2106 */
2107 void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2108 GLint x, GLint y, const void *values, const GLubyte *mask);
2109
2110 /* Put/Write a row of RGB values. This is a special-case routine that's
2111 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2112 * a common case for glDrawPixels and some triangle routines.
2113 * The values will be of format GL_RGB and type DataType.
2114 */
2115 void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2116 GLint x, GLint y, const void *values, const GLubyte *mask);
2117
2118
2119 /* Put/Write a row of identical values.
2120 * The values will be of format _BaseFormat and type DataType.
2121 */
2122 void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2123 GLint x, GLint y, const void *value, const GLubyte *mask);
2124
2125 /* Put/Write values at arbitrary locations.
2126 * The values will be of format _BaseFormat and type DataType.
2127 */
2128 void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
2129 const GLint x[], const GLint y[], const void *values,
2130 const GLubyte *mask);
2131 /* Put/Write identical values at arbitrary locations.
2132 * The values will be of format _BaseFormat and type DataType.
2133 */
2134 void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb,
2135 GLuint count, const GLint x[], const GLint y[],
2136 const void *value, const GLubyte *mask);
2137 };
2138
2139
2140 /**
2141 * A renderbuffer attachment point points to either a texture object
2142 * (and specifies a mipmap level, cube face or 3D texture slice) or
2143 * points to a renderbuffer.
2144 */
2145 struct gl_renderbuffer_attachment
2146 {
2147 GLenum Type; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2148 GLboolean Complete;
2149
2150 /* IF Type == GL_RENDERBUFFER_EXT: */
2151 struct gl_renderbuffer *Renderbuffer;
2152
2153 /* IF Type == GL_TEXTURE: */
2154 struct gl_texture_object *Texture;
2155 GLuint TextureLevel;
2156 GLuint CubeMapFace; /* 0 .. 5, for cube map textures */
2157 GLuint Zoffset; /* for 3D textures */
2158 };
2159
2160
2161 /**
2162 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2163 * In C++ terms, think of this as a base class from which device drivers
2164 * will make derived classes.
2165 */
2166 struct gl_framebuffer
2167 {
2168 _glthread_Mutex Mutex; /**< for thread safety */
2169 GLuint Name; /* if zero, this is a window system framebuffer */
2170 GLint RefCount;
2171
2172 GLvisual Visual; /**< The framebuffer's visual.
2173 Immutable if this is a window system buffer.
2174 Computed from attachments if user-made FBO. */
2175
2176 GLboolean Initialized;
2177
2178 GLuint Width, Height; /**< size of frame buffer in pixels */
2179
2180 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2181 /*@{*/
2182 GLint _Xmin, _Xmax; /**< inclusive */
2183 GLint _Ymin, _Ymax; /**< exclusive */
2184 /*@}*/
2185
2186 /** \name Derived 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 GLenum _Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2194
2195 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2196 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
2197
2198 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2199 * attribute group and GL_PIXEL attribute group, respectively.
2200 */
2201 GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
2202 GLenum ColorReadBuffer;
2203
2204 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2205 GLbitfield _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
2206 GLint _ColorReadBufferIndex; /* -1 = None */
2207
2208 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2209 GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
2210 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
2211 struct gl_renderbuffer *_ColorReadBuffer;
2212
2213 /** The Actual depth/stencil buffers to use. May be wrappers around the
2214 * depth/stencil buffers attached above. */
2215 struct gl_renderbuffer *_DepthBuffer;
2216 struct gl_renderbuffer *_StencilBuffer;
2217
2218 /** Delete this framebuffer */
2219 void (*Delete)(struct gl_framebuffer *fb);
2220 };
2221
2222
2223 /**
2224 * Limits for vertex and fragment programs.
2225 */
2226 struct gl_program_constants
2227 {
2228 /* logical limits */
2229 GLuint MaxInstructions;
2230 GLuint MaxAluInstructions; /* fragment programs only, for now */
2231 GLuint MaxTexInstructions; /* fragment programs only, for now */
2232 GLuint MaxTexIndirections; /* fragment programs only, for now */
2233 GLuint MaxAttribs;
2234 GLuint MaxTemps;
2235 GLuint MaxAddressRegs; /* vertex program only, for now */
2236 GLuint MaxParameters;
2237 GLuint MaxLocalParams;
2238 GLuint MaxEnvParams;
2239 /* native/hardware limits */
2240 GLuint MaxNativeInstructions;
2241 GLuint MaxNativeAluInstructions; /* fragment programs only, for now */
2242 GLuint MaxNativeTexInstructions; /* fragment programs only, for now */
2243 GLuint MaxNativeTexIndirections; /* fragment programs only, for now */
2244 GLuint MaxNativeAttribs;
2245 GLuint MaxNativeTemps;
2246 GLuint MaxNativeAddressRegs; /* vertex program only, for now */
2247 GLuint MaxNativeParameters;
2248 };
2249
2250
2251 /**
2252 * Constants which may be overridden by device driver during context creation
2253 * but are never changed after that.
2254 */
2255 struct gl_constants
2256 {
2257 GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
2258 GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2259 GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2260 GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
2261 GLuint MaxTextureCoordUnits;
2262 GLuint MaxTextureImageUnits;
2263 GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */
2264 GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
2265 GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
2266 GLuint MaxArrayLockSize;
2267 GLint SubPixelBits;
2268 GLfloat MinPointSize, MaxPointSize; /* aliased */
2269 GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
2270 GLfloat PointSizeGranularity;
2271 GLfloat MinLineWidth, MaxLineWidth; /* aliased */
2272 GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
2273 GLfloat LineWidthGranularity;
2274 GLuint MaxColorTableSize;
2275 GLuint MaxConvolutionWidth;
2276 GLuint MaxConvolutionHeight;
2277 GLuint MaxClipPlanes;
2278 GLuint MaxLights;
2279 GLfloat MaxShininess; /* GL_NV_light_max_exponent */
2280 GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
2281 GLuint MaxViewportWidth, MaxViewportHeight;
2282 struct gl_program_constants VertexProgram; /* GL_ARB_vertex_program */
2283 struct gl_program_constants FragmentProgram; /* GL_ARB_fragment_program */
2284 /* shared by vertex and fragment program: */
2285 GLuint MaxProgramMatrices;
2286 GLuint MaxProgramMatrixStackDepth;
2287 /* vertex array / buffer object bounds checking */
2288 GLboolean CheckArrayBounds;
2289 /* GL_ARB_draw_buffers */
2290 GLuint MaxDrawBuffers;
2291 /* GL_OES_read_format */
2292 GLenum ColorReadFormat;
2293 GLenum ColorReadType;
2294 /* GL_EXT_framebuffer_object */
2295 GLuint MaxColorAttachments;
2296 GLuint MaxRenderbufferSize;
2297 };
2298
2299
2300 /**
2301 * Enable flag for each OpenGL extension. Different device drivers will
2302 * enable different extensions at runtime.
2303 */
2304 struct gl_extensions
2305 {
2306 /**
2307 * \name Flags to quickly test if certain extensions are available.
2308 *
2309 * Not every extension needs to have such a flag, but it's encouraged.
2310 */
2311 /*@{*/
2312 GLboolean dummy; /* don't remove this! */
2313 GLboolean ARB_depth_texture;
2314 GLboolean ARB_draw_buffers;
2315 GLboolean ARB_fragment_program;
2316 GLboolean ARB_fragment_shader;
2317 GLboolean ARB_half_float_pixel;
2318 GLboolean ARB_imaging;
2319 GLboolean ARB_multisample;
2320 GLboolean ARB_multitexture;
2321 GLboolean ARB_occlusion_query;
2322 GLboolean ARB_point_sprite;
2323 GLboolean ARB_shader_objects;
2324 GLboolean ARB_shading_language_100;
2325 GLboolean ARB_shadow;
2326 GLboolean ARB_texture_border_clamp;
2327 GLboolean ARB_texture_compression;
2328 GLboolean ARB_texture_cube_map;
2329 GLboolean ARB_texture_env_combine;
2330 GLboolean ARB_texture_env_crossbar;
2331 GLboolean ARB_texture_env_dot3;
2332 GLboolean ARB_texture_float;
2333 GLboolean ARB_texture_mirrored_repeat;
2334 GLboolean ARB_texture_non_power_of_two;
2335 GLboolean ARB_transpose_matrix;
2336 GLboolean ARB_vertex_buffer_object;
2337 GLboolean ARB_vertex_program;
2338 GLboolean ARB_vertex_shader;
2339 GLboolean ARB_window_pos;
2340 GLboolean EXT_abgr;
2341 GLboolean EXT_bgra;
2342 GLboolean EXT_blend_color;
2343 GLboolean EXT_blend_equation_separate;
2344 GLboolean EXT_blend_func_separate;
2345 GLboolean EXT_blend_logic_op;
2346 GLboolean EXT_blend_minmax;
2347 GLboolean EXT_blend_subtract;
2348 GLboolean EXT_clip_volume_hint;
2349 GLboolean EXT_cull_vertex;
2350 GLboolean EXT_convolution;
2351 GLboolean EXT_compiled_vertex_array;
2352 GLboolean EXT_copy_texture;
2353 GLboolean EXT_depth_bounds_test;
2354 GLboolean EXT_draw_range_elements;
2355 GLboolean EXT_framebuffer_object;
2356 GLboolean EXT_fog_coord;
2357 GLboolean EXT_framebuffer_blit;
2358 GLboolean EXT_histogram;
2359 GLboolean EXT_multi_draw_arrays;
2360 GLboolean EXT_paletted_texture;
2361 GLboolean EXT_packed_depth_stencil;
2362 GLboolean EXT_packed_pixels;
2363 GLboolean EXT_pixel_buffer_object;
2364 GLboolean EXT_point_parameters;
2365 GLboolean EXT_polygon_offset;
2366 GLboolean EXT_rescale_normal;
2367 GLboolean EXT_shadow_funcs;
2368 GLboolean EXT_secondary_color;
2369 GLboolean EXT_separate_specular_color;
2370 GLboolean EXT_shared_texture_palette;
2371 GLboolean EXT_stencil_wrap;
2372 GLboolean EXT_stencil_two_side;
2373 GLboolean EXT_subtexture;
2374 GLboolean EXT_texture;
2375 GLboolean EXT_texture_object;
2376 GLboolean EXT_texture3D;
2377 GLboolean EXT_texture_compression_s3tc;
2378 GLboolean EXT_texture_env_add;
2379 GLboolean EXT_texture_env_combine;
2380 GLboolean EXT_texture_env_dot3;
2381 GLboolean EXT_texture_filter_anisotropic;
2382 GLboolean EXT_texture_lod_bias;
2383 GLboolean EXT_texture_mirror_clamp;
2384 GLboolean EXT_timer_query;
2385 GLboolean EXT_vertex_array;
2386 GLboolean EXT_vertex_array_set;
2387 /* vendor extensions */
2388 GLboolean APPLE_client_storage;
2389 GLboolean APPLE_packed_pixels;
2390 GLboolean ATI_texture_mirror_once;
2391 GLboolean ATI_texture_env_combine3;
2392 GLboolean ATI_fragment_shader;
2393 GLboolean IBM_rasterpos_clip;
2394 GLboolean IBM_multimode_draw_arrays;
2395 GLboolean MESA_pack_invert;
2396 GLboolean MESA_packed_depth_stencil;
2397 GLboolean MESA_program_debug;
2398 GLboolean MESA_resize_buffers;
2399 GLboolean MESA_ycbcr_texture;
2400 GLboolean NV_blend_square;
2401 GLboolean NV_fragment_program;
2402 GLboolean NV_light_max_exponent;
2403 GLboolean NV_point_sprite;
2404 GLboolean NV_texgen_reflection;
2405 GLboolean NV_texture_rectangle;
2406 GLboolean NV_vertex_program;
2407 GLboolean NV_vertex_program1_1;
2408 GLboolean OES_read_format;
2409 GLboolean SGI_color_matrix;
2410 GLboolean SGI_color_table;
2411 GLboolean SGI_texture_color_table;
2412 GLboolean SGIS_generate_mipmap;
2413 GLboolean SGIS_texture_edge_clamp;
2414 GLboolean SGIS_texture_lod;
2415 GLboolean SGIX_depth_texture;
2416 GLboolean SGIX_shadow;
2417 GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
2418 GLboolean TDFX_texture_compression_FXT1;
2419 GLboolean S3_s3tc;
2420 /*@}*/
2421 /* The extension string */
2422 const GLubyte *String;
2423 };
2424
2425
2426 /**
2427 * A stack of matrices (projection, modelview, color, texture, etc).
2428 */
2429 struct matrix_stack
2430 {
2431 GLmatrix *Top; /**< points into Stack */
2432 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
2433 GLuint Depth; /**< 0 <= Depth < MaxDepth */
2434 GLuint MaxDepth; /**< size of Stack[] array */
2435 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2436 };
2437
2438
2439 /**
2440 * \name Bits for image transfer operations
2441 *
2442 * \sa __GLcontextRec::ImageTransferState.
2443 */
2444 /*@{*/
2445 #define IMAGE_SCALE_BIAS_BIT 0x1
2446 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2447 #define IMAGE_MAP_COLOR_BIT 0x4
2448 #define IMAGE_COLOR_TABLE_BIT 0x8
2449 #define IMAGE_CONVOLUTION_BIT 0x10
2450 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2451 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2452 #define IMAGE_COLOR_MATRIX_BIT 0x80
2453 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2454 #define IMAGE_HISTOGRAM_BIT 0x200
2455 #define IMAGE_MIN_MAX_BIT 0x400
2456 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2457
2458
2459 /** Pixel Transfer ops up to convolution */
2460 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2461 IMAGE_SHIFT_OFFSET_BIT | \
2462 IMAGE_MAP_COLOR_BIT | \
2463 IMAGE_COLOR_TABLE_BIT)
2464
2465 /** Pixel transfer ops after convolution */
2466 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2467 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2468 IMAGE_COLOR_MATRIX_BIT | \
2469 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2470 IMAGE_HISTOGRAM_BIT | \
2471 IMAGE_MIN_MAX_BIT)
2472 /*@}*/
2473
2474
2475 /**
2476 * \name Bits to indicate what state has changed.
2477 *
2478 * 4 unused flags.
2479 */
2480 /*@{*/
2481 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2482 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2483 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2484 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2485 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2486 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2487 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2488 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2489 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2490 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2491 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2492 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2493 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2494 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2495 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2496 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2497 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2498 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2499 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2500 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2501 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2502 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2503 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2504 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2505 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2506 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2507 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2508 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2509 #define _NEW_ALL ~0
2510 /*@}*/
2511
2512
2513 /**
2514 * \name Bits to track array state changes
2515 *
2516 * Also used to summarize array enabled.
2517 */
2518 /*@{*/
2519 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2520 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2521 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2522 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2523 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2524 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2525 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2526 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2527 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2528 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2529 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2530 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2531 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2532 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2533 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2534 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2535 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2536 #define _NEW_ARRAY_ALL 0xffffffff
2537
2538
2539 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2540 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2541 /*@}*/
2542
2543
2544 /**
2545 * \name A bunch of flags that we think might be useful to drivers.
2546 *
2547 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2548 */
2549 /*@{*/
2550 #define DD_FLATSHADE 0x1
2551 #define DD_SEPARATE_SPECULAR 0x2
2552 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2553 #define DD_TRI_LIGHT_TWOSIDE 0x8
2554 #define DD_TRI_UNFILLED 0x10
2555 #define DD_TRI_SMOOTH 0x20
2556 #define DD_TRI_STIPPLE 0x40
2557 #define DD_TRI_OFFSET 0x80
2558 #define DD_LINE_SMOOTH 0x100
2559 #define DD_LINE_STIPPLE 0x200
2560 #define DD_LINE_WIDTH 0x400
2561 #define DD_POINT_SMOOTH 0x800
2562 #define DD_POINT_SIZE 0x1000
2563 #define DD_POINT_ATTEN 0x2000
2564 #define DD_TRI_TWOSTENCIL 0x4000
2565 /*@}*/
2566
2567
2568 /**
2569 * \name Define the state changes under which each of these bits might change
2570 */
2571 /*@{*/
2572 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2573 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2574 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2575 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2576 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2577 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2578 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2579 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2580 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2581 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2582 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2583 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2584 #define _DD_NEW_POINT_SIZE _NEW_POINT
2585 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2586 /*@}*/
2587
2588
2589 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2590 _NEW_TEXTURE | \
2591 _NEW_POINT | \
2592 _NEW_MODELVIEW)
2593
2594 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2595 _NEW_TEXTURE)
2596
2597 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2598
2599
2600
2601
2602 /*
2603 * Forward declaration of display list data types:
2604 */
2605 union node;
2606 typedef union node Node;
2607
2608
2609 /* This has to be included here. */
2610 #include "dd.h"
2611
2612
2613 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2614
2615 /**
2616 * Core Mesa's support for tnl modules:
2617 */
2618 struct gl_tnl_module
2619 {
2620 /**
2621 * Vertex format to be lazily swapped into current dispatch.
2622 */
2623 const GLvertexformat *Current;
2624
2625 /**
2626 * \name Record of functions swapped out.
2627 * On restore, only need to swap these functions back in.
2628 */
2629 /*@{*/
2630 struct {
2631 _glapi_proc * location;
2632 _glapi_proc function;
2633 } Swapped[NUM_VERTEX_FORMAT_ENTRIES];
2634 GLuint SwapCount;
2635 /*@}*/
2636 };
2637
2638 /* Strictly this is a tnl/ private concept, but it doesn't seem
2639 * worthwhile adding a tnl private structure just to hold this one bit
2640 * of information:
2641 */
2642 #define MESA_DLIST_DANGLING_REFS 0x1
2643
2644 /* Provide a location where information about a display list can be
2645 * collected. Could be extended with driverPrivate structures,
2646 * etc. in the future.
2647 */
2648 struct mesa_display_list
2649 {
2650 Node *node;
2651 GLuint id;
2652 GLbitfield flags;
2653 };
2654
2655
2656 /**
2657 * State used during display list compilation and execution.
2658 */
2659 struct mesa_list_state
2660 {
2661 struct mesa_display_list *CallStack[MAX_LIST_NESTING];
2662 GLuint CallDepth; /**< Current recursion calling depth */
2663
2664 struct mesa_display_list *CurrentList;
2665 Node *CurrentListPtr; /**< Head of list being compiled */
2666 GLuint CurrentListNum; /**< Number of the list being compiled */
2667 Node *CurrentBlock; /**< Pointer to current block of nodes */
2668 GLuint CurrentPos; /**< Index into current block of nodes */
2669
2670 GLvertexformat ListVtxfmt;
2671
2672 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
2673 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
2674
2675 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
2676 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
2677
2678 GLubyte ActiveIndex;
2679 GLfloat CurrentIndex;
2680
2681 GLubyte ActiveEdgeFlag;
2682 GLboolean CurrentEdgeFlag;
2683 };
2684
2685
2686 /**
2687 * Mesa rendering context.
2688 *
2689 * This is the central context data structure for Mesa. Almost all
2690 * OpenGL state is contained in this structure.
2691 * Think of this as a base class from which device drivers will derive
2692 * sub classes.
2693 *
2694 * The GLcontext typedef names this structure.
2695 */
2696 struct __GLcontextRec
2697 {
2698 /**
2699 * \name OS related interfaces.
2700 *
2701 * These \b must be the first members of this structure, because they are
2702 * exposed to the outside world (i.e. GLX extension).
2703 */
2704 /*@{*/
2705 __GLimports imports;
2706 __GLexports exports;
2707 /*@}*/
2708
2709 /** State possibly shared with other contexts in the address space */
2710 struct gl_shared_state *Shared;
2711
2712 /** \name API function pointer tables */
2713 /*@{*/
2714 struct _glapi_table *Save; /**< Display list save functions */
2715 struct _glapi_table *Exec; /**< Execute functions */
2716 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
2717 /*@}*/
2718
2719 GLvisual Visual;
2720 GLframebuffer *DrawBuffer; /**< buffer for writing */
2721 GLframebuffer *ReadBuffer; /**< buffer for reading */
2722 GLframebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
2723 GLframebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
2724
2725 /**
2726 * Device driver function pointer table
2727 */
2728 struct dd_function_table Driver;
2729
2730 void *DriverCtx; /**< Points to device driver context/state */
2731 void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
2732
2733 /** Core/Driver constants */
2734 struct gl_constants Const;
2735
2736 /** \name The various 4x4 matrix stacks */
2737 /*@{*/
2738 struct matrix_stack ModelviewMatrixStack;
2739 struct matrix_stack ProjectionMatrixStack;
2740 struct matrix_stack ColorMatrixStack;
2741 struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
2742 struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
2743 struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
2744 /*@}*/
2745
2746 /** Combined modelview and projection matrix */
2747 GLmatrix _ModelProjectMatrix;
2748
2749 /** \name Display lists */
2750 struct mesa_list_state ListState;
2751
2752 GLboolean ExecuteFlag; /**< Execute GL commands? */
2753 GLboolean CompileFlag; /**< Compile GL commands into display list? */
2754
2755 /** Extension information */
2756 struct gl_extensions Extensions;
2757
2758 /** \name State attribute stack (for glPush/PopAttrib) */
2759 /*@{*/
2760 GLuint AttribStackDepth;
2761 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
2762 /*@}*/
2763
2764 /** \name Renderer attribute groups
2765 *
2766 * We define a struct for each attribute group to make pushing and popping
2767 * attributes easy. Also it's a good organization.
2768 */
2769 /*@{*/
2770 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
2771 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
2772 struct gl_current_attrib Current; /**< Current attributes */
2773 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
2774 struct gl_eval_attrib Eval; /**< Eval attributes */
2775 struct gl_fog_attrib Fog; /**< Fog attributes */
2776 struct gl_hint_attrib Hint; /**< Hint attributes */
2777 struct gl_light_attrib Light; /**< Light attributes */
2778 struct gl_line_attrib Line; /**< Line attributes */
2779 struct gl_list_attrib List; /**< List attributes */
2780 struct gl_multisample_attrib Multisample;
2781 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
2782 struct gl_point_attrib Point; /**< Point attributes */
2783 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
2784 GLuint PolygonStipple[32]; /**< Polygon stipple */
2785 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
2786 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
2787 struct gl_texture_attrib Texture; /**< Texture attributes */
2788 struct gl_transform_attrib Transform; /**< Transformation attributes */
2789 struct gl_viewport_attrib Viewport; /**< Viewport attributes */
2790 /*@}*/
2791
2792 /** \name Client attribute stack */
2793 /*@{*/
2794 GLuint ClientAttribStackDepth;
2795 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
2796 /*@}*/
2797
2798 /** \name Client attribute groups */
2799 /*@{*/
2800 struct gl_array_attrib Array; /**< Vertex arrays */
2801 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
2802 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
2803 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
2804 /*@}*/
2805
2806 /** \name Other assorted state (not pushed/popped on attribute stack) */
2807 /*@{*/
2808 struct gl_histogram_attrib Histogram;
2809 struct gl_minmax_attrib MinMax;
2810 struct gl_convolution_attrib Convolution1D;
2811 struct gl_convolution_attrib Convolution2D;
2812 struct gl_convolution_attrib Separable2D;
2813
2814 struct gl_evaluators EvalMap; /**< All evaluators */
2815 struct gl_feedback Feedback; /**< Feedback */
2816 struct gl_selection Select; /**< Selection */
2817
2818 struct gl_color_table ColorTable; /**< Pre-convolution */
2819 struct gl_color_table ProxyColorTable; /**< Pre-convolution */
2820 struct gl_color_table PostConvolutionColorTable;
2821 struct gl_color_table ProxyPostConvolutionColorTable;
2822 struct gl_color_table PostColorMatrixColorTable;
2823 struct gl_color_table ProxyPostColorMatrixColorTable;
2824
2825 struct gl_program_state Program; /**< for vertex or fragment progs */
2826 struct gl_vertex_program_state VertexProgram; /**< GL_ARB/NV_vertex_program */
2827 struct gl_fragment_program_state FragmentProgram; /**< GL_ARB/NV_vertex_program */
2828 struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
2829
2830 struct fragment_program *_TexEnvProgram; /**< Texture state as fragment program */
2831 struct vertex_program *_TnlProgram; /**< Fixed func TNL state as vertex program */
2832
2833 GLboolean _MaintainTnlProgram;
2834 GLboolean _MaintainTexEnvProgram;
2835 GLboolean _UseTexEnvProgram;
2836
2837 struct gl_query_state Query; /**< GL_ARB_occlusion_query */
2838
2839 struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
2840 /*@}*/
2841
2842 #if FEATURE_EXT_framebuffer_object
2843 struct gl_renderbuffer *CurrentRenderbuffer;
2844 #endif
2845
2846 GLenum ErrorValue; /**< Last error code */
2847 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2848 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
2849
2850 /** \name Derived state */
2851 /*@{*/
2852 GLbitfield _TriangleCaps; /**< bitwise-or of DD_* flags */
2853 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
2854 GLfloat _EyeZDir[3];
2855 GLfloat _ModelViewInvScale;
2856 GLboolean _NeedEyeCoords;
2857 GLboolean _ForceEyeCoords;
2858 GLenum _CurrentProgram; /* currently executing program */
2859
2860 struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
2861 struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
2862 /**@}*/
2863
2864 struct gl_list_extensions ListExt; /**< driver dlist extensions */
2865
2866
2867 GLuint _Facing; /**< This is a hack for 2-sided stencil test.
2868 *
2869 * We don't have a better way to communicate this value from
2870 * swrast_setup to swrast. */
2871
2872 /** \name For debugging/development only */
2873 /*@{*/
2874 GLboolean FirstTimeCurrent;
2875 /*@}*/
2876
2877 /** Dither disable via MESA_NO_DITHER env var */
2878 GLboolean NoDither;
2879
2880 /** software compression/decompression supported or not */
2881 GLboolean Mesa_DXTn;
2882
2883 /** Core tnl module support */
2884 struct gl_tnl_module TnlModule;
2885
2886 /**
2887 * \name Hooks for module contexts.
2888 *
2889 * These will eventually live in the driver or elsewhere.
2890 */
2891 /*@{*/
2892 void *swrast_context;
2893 void *swsetup_context;
2894 void *swtnl_context;
2895 void *swtnl_im;
2896 void *acache_context;
2897 void *aelt_context;
2898 /*@}*/
2899 };
2900
2901
2902 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2903 extern const char *_mesa_prim_name[GL_POLYGON+4];
2904
2905
2906 #ifdef DEBUG
2907 extern int MESA_VERBOSE;
2908 extern int MESA_DEBUG_FLAGS;
2909 # define MESA_FUNCTION __FUNCTION__
2910 #else
2911 # define MESA_VERBOSE 0
2912 # define MESA_DEBUG_FLAGS 0
2913 # define MESA_FUNCTION "a function"
2914 # ifndef NDEBUG
2915 # define NDEBUG
2916 # endif
2917 #endif
2918
2919
2920 enum _verbose
2921 {
2922 VERBOSE_VARRAY = 0x0001,
2923 VERBOSE_TEXTURE = 0x0002,
2924 VERBOSE_IMMEDIATE = 0x0004,
2925 VERBOSE_PIPELINE = 0x0008,
2926 VERBOSE_DRIVER = 0x0010,
2927 VERBOSE_STATE = 0x0020,
2928 VERBOSE_API = 0x0040,
2929 VERBOSE_DISPLAY_LIST = 0x0100,
2930 VERBOSE_LIGHTING = 0x0200,
2931 VERBOSE_PRIMS = 0x0400,
2932 VERBOSE_VERTS = 0x0800,
2933 VERBOSE_DISASSEM = 0x1000
2934 };
2935
2936
2937 enum _debug
2938 {
2939 DEBUG_ALWAYS_FLUSH = 0x1
2940 };
2941
2942
2943
2944 #define Elements(x) sizeof(x)/sizeof(*(x))
2945
2946
2947 #endif /* TYPES_H */