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