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