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