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