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