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