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