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