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