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