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