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