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