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