Removed gl_texture_object's DeletePending. Changed a comment.
[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.3
11 *
12 * Copyright (C) 1999-2005 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 "config.h" /* Hardwired parameters */
40 #include "glapitable.h"
41 #include "glthread.h"
42 #include "math/m_matrix.h" /* GLmatrix */
43
44
45 /**
46 * Color channel data type.
47 */
48 #if CHAN_BITS == 8
49 typedef GLubyte GLchan;
50 #define CHAN_MAX 255
51 #define CHAN_MAXF 255.0F
52 #define CHAN_TYPE GL_UNSIGNED_BYTE
53 #elif CHAN_BITS == 16
54 typedef GLushort GLchan;
55 #define CHAN_MAX 65535
56 #define CHAN_MAXF 65535.0F
57 #define CHAN_TYPE GL_UNSIGNED_SHORT
58 #elif CHAN_BITS == 32
59 typedef GLfloat GLchan;
60 #define CHAN_MAX 1.0
61 #define CHAN_MAXF 1.0F
62 #define CHAN_TYPE GL_FLOAT
63 #else
64 #error "illegal number of color channel bits"
65 #endif
66
67
68 /**
69 * Accumulation buffer data type.
70 */
71 #if ACCUM_BITS==8
72 typedef GLbyte GLaccum;
73 #elif ACCUM_BITS==16
74 typedef GLshort GLaccum;
75 #elif ACCUM_BITS==32
76 typedef GLfloat GLaccum;
77 #else
78 # error "illegal number of accumulation bits"
79 #endif
80
81
82 /**
83 * Stencil buffer data type.
84 */
85 #if STENCIL_BITS==8
86 typedef GLubyte GLstencil;
87 # define STENCIL_MAX 0xff
88 #elif STENCIL_BITS==16
89 typedef GLushort GLstencil;
90 # define STENCIL_MAX 0xffff
91 #else
92 # error "illegal number of stencil bits"
93 #endif
94
95
96 /**
97 * Depth buffer data type.
98 *
99 * \note Must be 32-bits!
100 */
101 typedef GLuint GLdepth;
102
103
104 /**
105 * Fixed point data type.
106 */
107 typedef int GLfixed;
108 /*
109 * Fixed point arithmetic macros
110 */
111 #ifndef FIXED_FRAC_BITS
112 #define FIXED_FRAC_BITS 11
113 #endif
114
115 #define FIXED_SHIFT FIXED_FRAC_BITS
116 #define FIXED_ONE (1 << FIXED_SHIFT)
117 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
118 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
119 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
120 #define FIXED_EPSILON 1
121 #define FIXED_SCALE ((float) FIXED_ONE)
122 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
123 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
124 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
125 #define IntToFixed(I) ((I) << FIXED_SHIFT)
126 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
127 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
128 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
129 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
130 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
131 #define PosFloatToFixed(X) FloatToFixed(X)
132 #define SignedFloatToFixed(X) FloatToFixed(X)
133
134
135
136 /**
137 * \name Some forward type declarations
138 */
139 /*@{*/
140 struct _mesa_HashTable;
141 struct gl_texture_image;
142 struct gl_texture_object;
143 typedef struct __GLcontextRec GLcontext;
144 typedef struct __GLcontextModesRec GLvisual;
145 typedef struct gl_frame_buffer GLframebuffer;
146 struct gl_pixelstore_attrib;
147 struct gl_texture_format;
148 /*@}*/
149
150
151
152 /**
153 * Indexes for vertex program attributes.
154 * GL_NV_vertex_program aliases generic attributes over the conventional
155 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
156 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
157 * generic attributes are distinct/separate).
158 */
159 enum
160 {
161 VERT_ATTRIB_POS = 0,
162 VERT_ATTRIB_WEIGHT = 1,
163 VERT_ATTRIB_NORMAL = 2,
164 VERT_ATTRIB_COLOR0 = 3,
165 VERT_ATTRIB_COLOR1 = 4,
166 VERT_ATTRIB_FOG = 5,
167 VERT_ATTRIB_SIX = 6,
168 VERT_ATTRIB_SEVEN = 7,
169 VERT_ATTRIB_TEX0 = 8,
170 VERT_ATTRIB_TEX1 = 9,
171 VERT_ATTRIB_TEX2 = 10,
172 VERT_ATTRIB_TEX3 = 11,
173 VERT_ATTRIB_TEX4 = 12,
174 VERT_ATTRIB_TEX5 = 13,
175 VERT_ATTRIB_TEX6 = 14,
176 VERT_ATTRIB_TEX7 = 15,
177 VERT_ATTRIB_GENERIC0 = 16,
178 VERT_ATTRIB_GENERIC1 = 17,
179 VERT_ATTRIB_GENERIC2 = 18,
180 VERT_ATTRIB_GENERIC3 = 19,
181 VERT_ATTRIB_MAX = 16
182 };
183
184 /**
185 * Bitflags for vertex attributes.
186 * These are used in bitfields in many places.
187 */
188 /*@{*/
189 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
190 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
191 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
192 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
193 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
194 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
195 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
196 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
197 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
198 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
199 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
200 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
201 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
202 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
203 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
204 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
205 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
206 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
207 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
208 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
209
210 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
211 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
212 /*@}*/
213
214
215 /**
216 * Indexes for fragment program input attributes.
217 */
218 enum
219 {
220 FRAG_ATTRIB_WPOS = 0,
221 FRAG_ATTRIB_COL0 = 1,
222 FRAG_ATTRIB_COL1 = 2,
223 FRAG_ATTRIB_FOGC = 3,
224 FRAG_ATTRIB_TEX0 = 4,
225 FRAG_ATTRIB_TEX1 = 5,
226 FRAG_ATTRIB_TEX2 = 6,
227 FRAG_ATTRIB_TEX3 = 7,
228 FRAG_ATTRIB_TEX4 = 8,
229 FRAG_ATTRIB_TEX5 = 9,
230 FRAG_ATTRIB_TEX6 = 10,
231 FRAG_ATTRIB_TEX7 = 11
232 };
233
234 /*
235 * Bitflags for fragment attributes.
236 */
237 /*@{*/
238 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
239 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
240 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
241 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
242 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
243 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
244 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
245 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
246 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
247 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
248 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
249 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
250
251 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
252 FRAG_BIT_TEX1| \
253 FRAG_BIT_TEX2| \
254 FRAG_BIT_TEX3| \
255 FRAG_BIT_TEX4| \
256 FRAG_BIT_TEX5| \
257 FRAG_BIT_TEX6| \
258 FRAG_BIT_TEX7)
259 /*@}*/
260
261
262 /**
263 * Bits for each basic buffer in a complete framebuffer.
264 * When glDrawBuffer(GL_FRONT_AND_BACK) is called (non-stereo),
265 * _DrawDestMask will be set to (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT),
266 * for example. Also passed to ctx->Driver.Clear() to indicate which
267 * buffers to clear.
268 */
269 /*@{*/
270 #define DD_FRONT_LEFT_BIT 0x1
271 #define DD_FRONT_RIGHT_BIT 0x2
272 #define DD_BACK_LEFT_BIT 0x4
273 #define DD_BACK_RIGHT_BIT 0x8
274 #define DD_AUX0_BIT 0x10
275 #define DD_AUX1_BIT 0x20
276 #define DD_AUX2_BIT 0x40
277 #define DD_AUX3_BIT 0x80
278 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
279 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
280 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
281 /*@}*/
282
283
284 /**
285 * Data structure for color tables
286 */
287 struct gl_color_table
288 {
289 GLenum Format; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
290 GLenum IntFormat;
291 GLuint Size; /**< number of entries (rows) in table */
292 GLvoid *Table; /**< points to data of <Type> */
293 GLenum Type; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
294 GLubyte RedSize;
295 GLubyte GreenSize;
296 GLubyte BlueSize;
297 GLubyte AlphaSize;
298 GLubyte LuminanceSize;
299 GLubyte IntensitySize;
300 };
301
302
303 /**
304 * \name Bit flags used for updating material values.
305 */
306 /*@{*/
307 #define MAT_ATTRIB_FRONT_AMBIENT 0
308 #define MAT_ATTRIB_BACK_AMBIENT 1
309 #define MAT_ATTRIB_FRONT_DIFFUSE 2
310 #define MAT_ATTRIB_BACK_DIFFUSE 3
311 #define MAT_ATTRIB_FRONT_SPECULAR 4
312 #define MAT_ATTRIB_BACK_SPECULAR 5
313 #define MAT_ATTRIB_FRONT_EMISSION 6
314 #define MAT_ATTRIB_BACK_EMISSION 7
315 #define MAT_ATTRIB_FRONT_SHININESS 8
316 #define MAT_ATTRIB_BACK_SHININESS 9
317 #define MAT_ATTRIB_FRONT_INDEXES 10
318 #define MAT_ATTRIB_BACK_INDEXES 11
319 #define MAT_ATTRIB_MAX 12
320
321 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
322 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
323 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
324 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
325 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
326 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
327
328 #define MAT_INDEX_AMBIENT 0
329 #define MAT_INDEX_DIFFUSE 1
330 #define MAT_INDEX_SPECULAR 2
331
332 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
333 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
334 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
335 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
336 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
337 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
338 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
339 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
340 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
341 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
342 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
343 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
344
345
346 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
347 MAT_BIT_FRONT_AMBIENT | \
348 MAT_BIT_FRONT_DIFFUSE | \
349 MAT_BIT_FRONT_SPECULAR | \
350 MAT_BIT_FRONT_SHININESS | \
351 MAT_BIT_FRONT_INDEXES)
352
353 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
354 MAT_BIT_BACK_AMBIENT | \
355 MAT_BIT_BACK_DIFFUSE | \
356 MAT_BIT_BACK_SPECULAR | \
357 MAT_BIT_BACK_SHININESS | \
358 MAT_BIT_BACK_INDEXES)
359
360 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
361 /*@}*/
362
363
364 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
365 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
366
367 /**
368 * Material shininess lookup table.
369 */
370 struct gl_shine_tab
371 {
372 struct gl_shine_tab *next, *prev;
373 GLfloat tab[SHINE_TABLE_SIZE+1];
374 GLfloat shininess;
375 GLuint refcount;
376 };
377
378
379 /**
380 * Light source state.
381 */
382 struct gl_light
383 {
384 struct gl_light *next; /**< double linked list with sentinel */
385 struct gl_light *prev;
386
387 GLfloat Ambient[4]; /**< ambient color */
388 GLfloat Diffuse[4]; /**< diffuse color */
389 GLfloat Specular[4]; /**< specular color */
390 GLfloat EyePosition[4]; /**< position in eye coordinates */
391 GLfloat EyeDirection[4]; /**< spotlight dir in eye coordinates */
392 GLfloat SpotExponent;
393 GLfloat SpotCutoff; /**< in degrees */
394 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
395 GLfloat ConstantAttenuation;
396 GLfloat LinearAttenuation;
397 GLfloat QuadraticAttenuation;
398 GLboolean Enabled; /**< On/off flag */
399
400 /**
401 * \name Derived fields
402 */
403 /*@{*/
404 GLuint _Flags; /**< State */
405
406 GLfloat _Position[4]; /**< position in eye/obj coordinates */
407 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
408 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
409 GLfloat _NormDirection[4]; /**< normalized spotlight direction */
410 GLfloat _VP_inf_spot_attenuation;
411
412 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
413 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
414 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
415 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
416 GLfloat _dli; /**< CI diffuse light intensity */
417 GLfloat _sli; /**< CI specular light intensity */
418 /*@}*/
419 };
420
421
422 /**
423 * Light model state.
424 */
425 struct gl_lightmodel
426 {
427 GLfloat Ambient[4]; /**< ambient color */
428 GLboolean LocalViewer; /**< Local (or infinite) view point? */
429 GLboolean TwoSide; /**< Two (or one) sided lighting? */
430 GLenum ColorControl; /**< either GL_SINGLE_COLOR
431 * or GL_SEPARATE_SPECULAR_COLOR */
432 };
433
434
435 /**
436 * Material state.
437 */
438 struct gl_material
439 {
440 GLfloat Attrib[MAT_ATTRIB_MAX][4];
441 };
442
443
444 /**
445 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
446 */
447 struct gl_accum_attrib
448 {
449 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
450 };
451
452
453 /**
454 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
455 */
456 struct gl_colorbuffer_attrib
457 {
458 GLuint ClearIndex; /**< Index to use for glClear */
459 GLclampf ClearColor[4]; /**< Color to use for glClear */
460
461 GLuint IndexMask; /**< Color index write mask */
462 GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
463
464 GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
465 GLbitfield _DrawDestMask[MAX_DRAW_BUFFERS];/**< bitmask of DD_*_BIT bits */
466
467 /**
468 * \name alpha testing
469 */
470 /*@{*/
471 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
472 GLenum AlphaFunc; /**< Alpha test function */
473 GLclampf AlphaRef; /**< Alpha reference value */
474 /*@}*/
475
476 /**
477 * \name Blending
478 */
479 /*@{*/
480 GLboolean BlendEnabled; /**< Blending enabled flag */
481 GLenum BlendSrcRGB; /**< Blending source operator */
482 GLenum BlendDstRGB; /**< Blending destination operator */
483 GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
484 GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
485 GLenum BlendEquationRGB; /**< Blending equation */
486 GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
487 GLfloat BlendColor[4]; /**< Blending color */
488 /*@}*/
489
490 /**
491 * \name Logic op
492 */
493 /*@{*/
494 GLenum LogicOp; /**< Logic operator */
495 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
496 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
497 GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
498 /*@}*/
499
500 GLboolean DitherFlag; /**< Dither enable flag */
501 };
502
503
504 /**
505 * Current attribute group (GL_CURRENT_BIT).
506 */
507 struct gl_current_attrib
508 {
509 /**
510 * \name Values valid only when FLUSH_VERTICES has been called.
511 */
512 /*@{*/
513 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Current vertex attributes
514 * indexed by VERT_ATTRIB_* */
515 GLfloat Index; /**< Current color index */
516 GLboolean EdgeFlag; /**< Current edge flag */
517 /*@}*/
518
519 /**
520 * \name Values are always valid.
521 *
522 * \note BTW, note how similar this set of attributes is to the SWvertex
523 * data type in the software rasterizer...
524 */
525 /*@{*/
526 GLfloat RasterPos[4]; /**< Current raster position */
527 GLfloat RasterDistance; /**< Current raster distance */
528 GLfloat RasterColor[4]; /**< Current raster color */
529 GLfloat RasterSecondaryColor[4]; /**< Current raster secondary color */
530 GLfloat RasterIndex; /**< Current raster index */
531 GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];/**< Current raster texcoords */
532 GLboolean RasterPosValid; /**< Raster pos valid flag */
533 /*@}*/
534 };
535
536
537 /**
538 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
539 */
540 struct gl_depthbuffer_attrib
541 {
542 GLenum Func; /**< Function for depth buffer compare */
543 GLclampd Clear; /**< Value to clear depth buffer to */
544 GLboolean Test; /**< Depth buffering enabled flag */
545 GLboolean Mask; /**< Depth buffer writable? */
546 GLboolean OcclusionTest; /**< GL_HP_occlusion_test */
547 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
548 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
549 };
550
551
552 /**
553 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
554 */
555 struct gl_enable_attrib
556 {
557 GLboolean AlphaTest;
558 GLboolean AutoNormal;
559 GLboolean Blend;
560 GLuint ClipPlanes;
561 GLboolean ColorMaterial;
562 GLboolean ColorTable; /* SGI_color_table */
563 GLboolean PostColorMatrixColorTable; /* SGI_color_table */
564 GLboolean PostConvolutionColorTable; /* SGI_color_table */
565 GLboolean Convolution1D;
566 GLboolean Convolution2D;
567 GLboolean Separable2D;
568 GLboolean CullFace;
569 GLboolean DepthTest;
570 GLboolean Dither;
571 GLboolean Fog;
572 GLboolean Histogram;
573 GLboolean Light[MAX_LIGHTS];
574 GLboolean Lighting;
575 GLboolean LineSmooth;
576 GLboolean LineStipple;
577 GLboolean IndexLogicOp;
578 GLboolean ColorLogicOp;
579 GLboolean Map1Color4;
580 GLboolean Map1Index;
581 GLboolean Map1Normal;
582 GLboolean Map1TextureCoord1;
583 GLboolean Map1TextureCoord2;
584 GLboolean Map1TextureCoord3;
585 GLboolean Map1TextureCoord4;
586 GLboolean Map1Vertex3;
587 GLboolean Map1Vertex4;
588 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
589 GLboolean Map2Color4;
590 GLboolean Map2Index;
591 GLboolean Map2Normal;
592 GLboolean Map2TextureCoord1;
593 GLboolean Map2TextureCoord2;
594 GLboolean Map2TextureCoord3;
595 GLboolean Map2TextureCoord4;
596 GLboolean Map2Vertex3;
597 GLboolean Map2Vertex4;
598 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
599 GLboolean MinMax;
600 GLboolean Normalize;
601 GLboolean PixelTexture;
602 GLboolean PointSmooth;
603 GLboolean PolygonOffsetPoint;
604 GLboolean PolygonOffsetLine;
605 GLboolean PolygonOffsetFill;
606 GLboolean PolygonSmooth;
607 GLboolean PolygonStipple;
608 GLboolean RescaleNormals;
609 GLboolean Scissor;
610 GLboolean Stencil;
611 GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
612 GLboolean MultisampleEnabled; /* GL_ARB_multisample */
613 GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
614 GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
615 GLboolean SampleCoverage; /* GL_ARB_multisample */
616 GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
617 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
618 GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
619 GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
620 /* SGI_texture_color_table */
621 GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
622 /* GL_NV_vertex_program */
623 GLboolean VertexProgram;
624 GLboolean VertexProgramPointSize;
625 GLboolean VertexProgramTwoSide;
626 /* GL_ARB_point_sprite / GL_NV_point_sprite */
627 GLboolean PointSprite;
628 GLboolean FragmentShaderATI;
629 };
630
631
632 /**
633 * Evaluator attribute group (GL_EVAL_BIT).
634 */
635 struct gl_eval_attrib
636 {
637 /**
638 * \name Enable bits
639 */
640 /*@{*/
641 GLboolean Map1Color4;
642 GLboolean Map1Index;
643 GLboolean Map1Normal;
644 GLboolean Map1TextureCoord1;
645 GLboolean Map1TextureCoord2;
646 GLboolean Map1TextureCoord3;
647 GLboolean Map1TextureCoord4;
648 GLboolean Map1Vertex3;
649 GLboolean Map1Vertex4;
650 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
651 GLboolean Map2Color4;
652 GLboolean Map2Index;
653 GLboolean Map2Normal;
654 GLboolean Map2TextureCoord1;
655 GLboolean Map2TextureCoord2;
656 GLboolean Map2TextureCoord3;
657 GLboolean Map2TextureCoord4;
658 GLboolean Map2Vertex3;
659 GLboolean Map2Vertex4;
660 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
661 GLboolean AutoNormal;
662 /*@}*/
663
664 /**
665 * \name Map Grid endpoints and divisions and calculated du values
666 */
667 /*@{*/
668 GLint MapGrid1un;
669 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
670 GLint MapGrid2un, MapGrid2vn;
671 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
672 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
673 /*@}*/
674 };
675
676
677 /**
678 * Fog attribute group (GL_FOG_BIT).
679 */
680 struct gl_fog_attrib
681 {
682 GLboolean Enabled; /**< Fog enabled flag */
683 GLfloat Color[4]; /**< Fog color */
684 GLfloat Density; /**< Density >= 0.0 */
685 GLfloat Start; /**< Start distance in eye coords */
686 GLfloat End; /**< End distance in eye coords */
687 GLfloat Index; /**< Fog index */
688 GLenum Mode; /**< Fog mode */
689 GLboolean ColorSumEnabled;
690 GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
691 };
692
693
694 /**
695 * Hint attribute group (GL_HINT_BIT).
696 *
697 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
698 */
699 struct gl_hint_attrib
700 {
701 GLenum PerspectiveCorrection;
702 GLenum PointSmooth;
703 GLenum LineSmooth;
704 GLenum PolygonSmooth;
705 GLenum Fog;
706 GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
707 GLenum TextureCompression; /**< GL_ARB_texture_compression */
708 GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
709 };
710
711
712 /**
713 * Histogram attributes.
714 */
715 struct gl_histogram_attrib
716 {
717 GLuint Width; /**< number of table entries */
718 GLint Format; /**< GL_ALPHA, GL_RGB, etc */
719 GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
720 GLboolean Sink; /**< terminate image transfer? */
721 GLubyte RedSize; /**< Bits per counter */
722 GLubyte GreenSize;
723 GLubyte BlueSize;
724 GLubyte AlphaSize;
725 GLubyte LuminanceSize;
726 };
727
728
729 /**
730 * Color Min/max state.
731 */
732 struct gl_minmax_attrib
733 {
734 GLenum Format;
735 GLboolean Sink;
736 GLfloat Min[4], Max[4]; /**< RGBA */
737 };
738
739
740 /**
741 * Image convolution state.
742 */
743 struct gl_convolution_attrib
744 {
745 GLenum Format;
746 GLenum InternalFormat;
747 GLuint Width;
748 GLuint Height;
749 GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
750 };
751
752
753 /**
754 * Light state flags.
755 */
756 /*@{*/
757 #define LIGHT_SPOT 0x1
758 #define LIGHT_LOCAL_VIEWER 0x2
759 #define LIGHT_POSITIONAL 0x4
760 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
761 /*@}*/
762
763
764 /**
765 * Lighting attribute group (GL_LIGHT_BIT).
766 */
767 struct gl_light_attrib
768 {
769 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
770 struct gl_lightmodel Model; /**< Lighting model */
771
772 /**
773 * Must flush FLUSH_VERTICES before referencing:
774 */
775 /*@{*/
776 struct gl_material Material; /**< Includes front & back values */
777 /*@}*/
778
779 GLboolean Enabled; /**< Lighting enabled flag */
780 GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
781 GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
782 GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
783 GLuint ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
784 GLboolean ColorMaterialEnabled;
785
786 struct gl_light EnabledList; /**< List sentinel */
787
788 /**
789 * Derived state for optimizations:
790 */
791 /*@{*/
792 GLboolean _NeedEyeCoords;
793 GLboolean _NeedVertices; /**< Use fast shader? */
794 GLuint _Flags; /**< LIGHT_* flags, see above */
795 GLfloat _BaseColor[2][3];
796 /*@}*/
797 };
798
799
800 /**
801 * Line attribute group (GL_LINE_BIT).
802 */
803 struct gl_line_attrib
804 {
805 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
806 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
807 GLushort StipplePattern; /**< Stipple pattern */
808 GLint StippleFactor; /**< Stipple repeat factor */
809 GLfloat Width; /**< Line width */
810 GLfloat _Width; /**< Clamped Line width */
811 };
812
813
814 /**
815 * Display list attribute group (GL_LIST_BIT).
816 */
817 struct gl_list_attrib
818 {
819 GLuint ListBase;
820 };
821
822
823 /**
824 * Used by device drivers to hook new commands into display lists.
825 */
826 struct gl_list_instruction
827 {
828 GLuint Size;
829 void (*Execute)( GLcontext *ctx, void *data );
830 void (*Destroy)( GLcontext *ctx, void *data );
831 void (*Print)( GLcontext *ctx, void *data );
832 };
833
834 #define MAX_DLIST_EXT_OPCODES 16
835
836 /**
837 * Used by device drivers to hook new commands into display lists.
838 */
839 struct gl_list_extensions
840 {
841 struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
842 GLuint NumOpcodes;
843 };
844
845
846 /**
847 * Multisample attribute group (GL_MULTISAMPLE_BIT).
848 */
849 struct gl_multisample_attrib
850 {
851 GLboolean Enabled;
852 GLboolean SampleAlphaToCoverage;
853 GLboolean SampleAlphaToOne;
854 GLboolean SampleCoverage;
855 GLfloat SampleCoverageValue;
856 GLboolean SampleCoverageInvert;
857 };
858
859
860 /**
861 * Pixel attribute group (GL_PIXEL_MODE_BIT).
862 */
863 struct gl_pixel_attrib
864 {
865 GLenum ReadBuffer; /**< source buffer for glReadPixels()/glCopyPixels() */
866 GLubyte _ReadSrcMask; /**< Not really a mask, but like _DrawDestMask
867 *
868 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
869 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
870 GLfloat RedBias, RedScale;
871 GLfloat GreenBias, GreenScale;
872 GLfloat BlueBias, BlueScale;
873 GLfloat AlphaBias, AlphaScale;
874 GLfloat DepthBias, DepthScale;
875 GLint IndexShift, IndexOffset;
876 GLboolean MapColorFlag;
877 GLboolean MapStencilFlag;
878 GLfloat ZoomX, ZoomY;
879 /* XXX move these out of gl_pixel_attrib */
880 GLint MapStoSsize; /**< Size of each pixel map */
881 GLint MapItoIsize;
882 GLint MapItoRsize;
883 GLint MapItoGsize;
884 GLint MapItoBsize;
885 GLint MapItoAsize;
886 GLint MapRtoRsize;
887 GLint MapGtoGsize;
888 GLint MapBtoBsize;
889 GLint MapAtoAsize;
890 GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */
891 GLint MapItoI[MAX_PIXEL_MAP_TABLE];
892 GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
893 GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
894 GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
895 GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
896 GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
897 GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
898 GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
899 GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
900 GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
901 GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
902 GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
903 GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
904 /** GL_EXT_histogram */
905 GLboolean HistogramEnabled;
906 GLboolean MinMaxEnabled;
907 /** GL_SGIS_pixel_texture */
908 GLboolean PixelTextureEnabled;
909 GLenum FragmentRgbSource;
910 GLenum FragmentAlphaSource;
911 /** GL_SGI_color_matrix */
912 GLfloat PostColorMatrixScale[4]; /**< RGBA */
913 GLfloat PostColorMatrixBias[4]; /**< RGBA */
914 /** GL_SGI_color_table */
915 GLfloat ColorTableScale[4];
916 GLfloat ColorTableBias[4];
917 GLboolean ColorTableEnabled;
918 GLfloat PCCTscale[4];
919 GLfloat PCCTbias[4];
920 GLboolean PostConvolutionColorTableEnabled;
921 GLfloat PCMCTscale[4];
922 GLfloat PCMCTbias[4];
923 GLboolean PostColorMatrixColorTableEnabled;
924 /** GL_SGI_texture_color_table */
925 GLfloat TextureColorTableScale[4];
926 GLfloat TextureColorTableBias[4];
927 /** Convolution */
928 GLboolean Convolution1DEnabled;
929 GLboolean Convolution2DEnabled;
930 GLboolean Separable2DEnabled;
931 GLfloat ConvolutionBorderColor[3][4];
932 GLenum ConvolutionBorderMode[3];
933 GLfloat ConvolutionFilterScale[3][4];
934 GLfloat ConvolutionFilterBias[3][4];
935 GLfloat PostConvolutionScale[4]; /**< RGBA */
936 GLfloat PostConvolutionBias[4]; /**< RGBA */
937 };
938
939
940 /**
941 * Point attribute group (GL_POINT_BIT).
942 */
943 struct gl_point_attrib
944 {
945 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
946 GLfloat Size; /**< User-specified point size */
947 GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */
948 GLfloat Params[3]; /**< GL_EXT_point_parameters */
949 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
950 GLfloat Threshold; /**< GL_EXT_point_parameters */
951 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
952 GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
953 GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
954 GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
955 GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
956 };
957
958
959 /**
960 * Polygon attribute group (GL_POLYGON_BIT).
961 */
962 struct gl_polygon_attrib
963 {
964 GLenum FrontFace; /**< Either GL_CW or GL_CCW */
965 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
966 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
967 GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
968 GLboolean CullFlag; /**< Culling on/off flag */
969 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
970 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
971 GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
972 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
973 GLfloat OffsetUnits; /**< Polygon offset units, from user */
974 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
975 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
976 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
977 };
978
979
980 /**
981 * Scissor attributes (GL_SCISSOR_BIT).
982 */
983 struct gl_scissor_attrib
984 {
985 GLboolean Enabled; /**< Scissor test enabled? */
986 GLint X, Y; /**< Lower left corner of box */
987 GLsizei Width, Height; /**< Size of box */
988 };
989
990
991 /**
992 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
993 */
994 struct gl_stencil_attrib
995 {
996 GLboolean Enabled; /**< Enabled flag */
997 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
998 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 1) */
999 GLenum Function[2]; /**< Stencil function */
1000 GLenum FailFunc[2]; /**< Fail function */
1001 GLenum ZPassFunc[2]; /**< Depth buffer pass function */
1002 GLenum ZFailFunc[2]; /**< Depth buffer fail function */
1003 GLstencil Ref[2]; /**< Reference value */
1004 GLstencil ValueMask[2]; /**< Value mask */
1005 GLstencil WriteMask[2]; /**< Write mask */
1006 GLstencil Clear; /**< Clear value */
1007 };
1008
1009
1010 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1011
1012 /**
1013 * An index for each type of texture object
1014 */
1015 /*@{*/
1016 #define TEXTURE_1D_INDEX 0
1017 #define TEXTURE_2D_INDEX 1
1018 #define TEXTURE_3D_INDEX 2
1019 #define TEXTURE_CUBE_INDEX 3
1020 #define TEXTURE_RECT_INDEX 4
1021 /*@}*/
1022
1023 /**
1024 * Bit flags for each type of texture object
1025 * Used for Texture.Unit[]._ReallyEnabled flags.
1026 */
1027 /*@{*/
1028 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1029 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1030 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1031 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1032 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1033 /*@}*/
1034
1035
1036 /**
1037 * TexGenEnabled flags.
1038 */
1039 /*@{*/
1040 #define S_BIT 1
1041 #define T_BIT 2
1042 #define R_BIT 4
1043 #define Q_BIT 8
1044 /*@}*/
1045
1046
1047 /**
1048 * Bit flag versions of the corresponding GL_ constants.
1049 */
1050 /*@{*/
1051 #define TEXGEN_SPHERE_MAP 0x1
1052 #define TEXGEN_OBJ_LINEAR 0x2
1053 #define TEXGEN_EYE_LINEAR 0x4
1054 #define TEXGEN_REFLECTION_MAP_NV 0x8
1055 #define TEXGEN_NORMAL_MAP_NV 0x10
1056
1057 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1058 TEXGEN_REFLECTION_MAP_NV | \
1059 TEXGEN_NORMAL_MAP_NV)
1060 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1061 TEXGEN_REFLECTION_MAP_NV | \
1062 TEXGEN_NORMAL_MAP_NV | \
1063 TEXGEN_EYE_LINEAR)
1064 /*@}*/
1065
1066
1067 /* A selection of state flags to make driver and module's lives easier. */
1068 #define ENABLE_TEXGEN0 0x1
1069 #define ENABLE_TEXGEN1 0x2
1070 #define ENABLE_TEXGEN2 0x4
1071 #define ENABLE_TEXGEN3 0x8
1072 #define ENABLE_TEXGEN4 0x10
1073 #define ENABLE_TEXGEN5 0x20
1074 #define ENABLE_TEXGEN6 0x40
1075 #define ENABLE_TEXGEN7 0x80
1076
1077 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1078 #define ENABLE_TEXMAT1 0x2
1079 #define ENABLE_TEXMAT2 0x4
1080 #define ENABLE_TEXMAT3 0x8
1081 #define ENABLE_TEXMAT4 0x10
1082 #define ENABLE_TEXMAT5 0x20
1083 #define ENABLE_TEXMAT6 0x40
1084 #define ENABLE_TEXMAT7 0x80
1085
1086 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1087 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1088
1089
1090 /**
1091 * Texel fetch function prototype. We use texel fetch functions to
1092 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1093 * texture images. These functions help to isolate us from the gritty
1094 * details of all the various texture image encodings.
1095 *
1096 * \param texImage texture image.
1097 * \param col texel column.
1098 * \param row texel row.
1099 * \param img texel image level/layer.
1100 * \param texelOut output texel (up to 4 GLchans)
1101 */
1102 typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
1103 GLint col, GLint row, GLint img,
1104 GLchan *texelOut );
1105
1106 /**
1107 * As above, but returns floats.
1108 * Used for depth component images and for upcoming signed/float
1109 * texture images.
1110 */
1111 typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
1112 GLint col, GLint row, GLint img,
1113 GLfloat *texelOut );
1114
1115
1116 /**
1117 * TexImage store function. This is called by the glTex[Sub]Image
1118 * functions and is responsible for converting the user-specified texture
1119 * image into a specific (hardware) image format.
1120 */
1121 typedef GLboolean (*StoreTexImageFunc)(GLcontext *ctx, GLuint dims,
1122 GLenum baseInternalFormat,
1123 const struct gl_texture_format *dstFormat,
1124 GLvoid *dstAddr,
1125 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
1126 GLint dstRowStride, GLint dstImageStride,
1127 GLint srcWidth, GLint srcHeight, GLint srcDepth,
1128 GLenum srcFormat, GLenum srcType,
1129 const GLvoid *srcAddr,
1130 const struct gl_pixelstore_attrib *srcPacking);
1131
1132
1133
1134 /**
1135 * Texture format record
1136 */
1137 struct gl_texture_format
1138 {
1139 GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
1140
1141 GLenum BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1142 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1143 * GL_INTENSITY, GL_COLOR_INDEX or
1144 * GL_DEPTH_COMPONENT.
1145 */
1146 GLenum DataType; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1147 GLubyte RedBits; /**< Bits per texel component */
1148 GLubyte GreenBits; /**< These are just rough approximations for */
1149 GLubyte BlueBits; /**< compressed texture formats. */
1150 GLubyte AlphaBits;
1151 GLubyte LuminanceBits;
1152 GLubyte IntensityBits;
1153 GLubyte IndexBits;
1154 GLubyte DepthBits;
1155
1156 GLuint TexelBytes; /**< Bytes per texel, 0 if compressed format */
1157
1158 StoreTexImageFunc StoreImage;
1159
1160 /**
1161 * \name Texel fetch function pointers
1162 */
1163 /*@{*/
1164 FetchTexelFuncC FetchTexel1D;
1165 FetchTexelFuncC FetchTexel2D;
1166 FetchTexelFuncC FetchTexel3D;
1167 FetchTexelFuncF FetchTexel1Df;
1168 FetchTexelFuncF FetchTexel2Df;
1169 FetchTexelFuncF FetchTexel3Df;
1170 /*@}*/
1171 };
1172
1173
1174 /**
1175 * Texture image state. Describes the dimensions of a texture image,
1176 * the texel format and pointers to Texel Fetch functions.
1177 */
1178 struct gl_texture_image
1179 {
1180 GLenum Format; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1181 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1182 * GL_INTENSITY, GL_COLOR_INDEX or
1183 * GL_DEPTH_COMPONENT only.
1184 * Used for choosing TexEnv arithmetic.
1185 */
1186 GLint IntFormat; /**< Internal format as given by the user */
1187 GLuint Border; /**< 0 or 1 */
1188 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
1189 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
1190 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
1191 GLuint RowStride; /**< == Width unless IsClientData and padded */
1192 GLuint Width2; /**< = Width - 2*Border */
1193 GLuint Height2; /**< = Height - 2*Border */
1194 GLuint Depth2; /**< = Depth - 2*Border */
1195 GLuint WidthLog2; /**< = log2(Width2) */
1196 GLuint HeightLog2; /**< = log2(Height2) */
1197 GLuint DepthLog2; /**< = log2(Depth2) */
1198 GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
1199 GLfloat WidthScale; /**< used for mipmap LOD computation */
1200 GLfloat HeightScale; /**< used for mipmap LOD computation */
1201 GLfloat DepthScale; /**< used for mipmap LOD computation */
1202 GLvoid *Data; /**< Image data, accessed via FetchTexel() */
1203 GLboolean IsClientData; /**< Data owned by client? */
1204 GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
1205
1206 const struct gl_texture_format *TexFormat;
1207
1208 struct gl_texture_object *TexObject; /**< Pointer back to parent object */
1209
1210 FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
1211 FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
1212
1213 GLboolean IsCompressed; /**< GL_ARB_texture_compression */
1214 GLuint CompressedSize; /**< GL_ARB_texture_compression */
1215
1216 /**
1217 * \name For device driver:
1218 */
1219 /*@{*/
1220 void *DriverData; /**< Arbitrary device driver data */
1221 /*@}*/
1222 };
1223
1224
1225 /**
1226 * Indexes for cube map faces.
1227 */
1228 /*@{*/
1229 #define FACE_POS_X 0
1230 #define FACE_NEG_X 1
1231 #define FACE_POS_Y 2
1232 #define FACE_NEG_Y 3
1233 #define FACE_POS_Z 4
1234 #define FACE_NEG_Z 5
1235 #define MAX_FACES 6
1236 /*@}*/
1237
1238
1239 /**
1240 * Texture object state. Contains the array of mipmap images, border color,
1241 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1242 * color palette.
1243 */
1244 struct gl_texture_object
1245 {
1246 _glthread_Mutex Mutex; /**< for thread safety */
1247 GLint RefCount; /**< reference count */
1248 GLuint Name; /**< the user-visible texture object ID */
1249 GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1250 GLfloat Priority; /**< in [0,1] */
1251 GLfloat BorderColor[4]; /**< unclamped */
1252 GLchan _BorderChan[4]; /**< clamped, as GLchan */
1253 /** \name Wrap modes
1254 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1255 /*@{*/
1256 GLenum WrapS;
1257 GLenum WrapT;
1258 GLenum WrapR;
1259 /*@}*/
1260 GLenum MinFilter; /**< minification filter */
1261 GLenum MagFilter; /**< magnification filter */
1262 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
1263 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
1264 GLfloat LodBias; /**< OpenGL 1.4 */
1265 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
1266 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
1267 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1268 GLboolean CompareFlag; /**< GL_SGIX_shadow */
1269 GLenum CompareOperator; /**< GL_SGIX_shadow */
1270 GLfloat ShadowAmbient;
1271 GLenum CompareMode; /**< GL_ARB_shadow */
1272 GLenum CompareFunc; /**< GL_ARB_shadow */
1273 GLenum DepthMode; /**< GL_ARB_depth_texture */
1274 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
1275 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1276 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
1277 GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
1278
1279 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1280
1281 /** GL_EXT_paletted_texture */
1282 struct gl_color_table Palette;
1283
1284 GLboolean Complete; /**< Is texture object complete? */
1285 struct gl_texture_object *Next; /**< Next in linked list */
1286
1287 /**
1288 * \name For device driver
1289 */
1290 /*@{*/
1291 void *DriverData; /**< Arbitrary device driver data */
1292 /*@}*/
1293 };
1294
1295
1296 /**
1297 * Texture combine environment state.
1298 *
1299 * \todo
1300 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1301 * structure will need to be expanded for 4 elements.
1302 */
1303 struct gl_tex_env_combine_state
1304 {
1305 GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1306 GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1307 GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1308 GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1309 GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1310 GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1311 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1312 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1313 GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
1314 GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
1315 };
1316
1317
1318 /**
1319 * Texture unit state. Contains enable flags, texture environment/function/
1320 * combiners, texgen state, pointers to current texture objects and
1321 * post-filter color tables.
1322 */
1323 struct gl_texture_unit
1324 {
1325 GLuint Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1326 GLuint _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1327
1328 GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1329 GLfloat EnvColor[4];
1330 GLuint TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1331 /** \name Tex coord generation mode
1332 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1333 /*@{*/
1334 GLenum GenModeS;
1335 GLenum GenModeT;
1336 GLenum GenModeR;
1337 GLenum GenModeQ;
1338 /*@}*/
1339 GLuint _GenBitS;
1340 GLuint _GenBitT;
1341 GLuint _GenBitR;
1342 GLuint _GenBitQ;
1343 GLuint _GenFlags; /**< bitwise or of GenBit[STRQ] */
1344 GLfloat ObjectPlaneS[4];
1345 GLfloat ObjectPlaneT[4];
1346 GLfloat ObjectPlaneR[4];
1347 GLfloat ObjectPlaneQ[4];
1348 GLfloat EyePlaneS[4];
1349 GLfloat EyePlaneT[4];
1350 GLfloat EyePlaneR[4];
1351 GLfloat EyePlaneQ[4];
1352 GLfloat LodBias; /**< for biasing mipmap levels */
1353
1354 /**
1355 * \name GL_EXT_texture_env_combine
1356 */
1357 struct gl_tex_env_combine_state Combine;
1358
1359 /**
1360 * Derived state based on \c EnvMode and the \c BaseFormat of the
1361 * currently enabled texture.
1362 */
1363 struct gl_tex_env_combine_state _EnvMode;
1364
1365 /**
1366 * Currently enabled combiner state. This will point to either
1367 * \c Combine or \c _EnvMode.
1368 */
1369 struct gl_tex_env_combine_state *_CurrentCombine;
1370
1371 struct gl_texture_object *Current1D;
1372 struct gl_texture_object *Current2D;
1373 struct gl_texture_object *Current3D;
1374 struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
1375 struct gl_texture_object *CurrentRect; /**< GL_NV_texture_rectangle */
1376
1377 struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
1378
1379 struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */
1380 struct gl_texture_object Saved2D;
1381 struct gl_texture_object Saved3D;
1382 struct gl_texture_object SavedCubeMap;
1383 struct gl_texture_object SavedRect;
1384
1385 /* GL_SGI_texture_color_table */
1386 struct gl_color_table ColorTable;
1387 struct gl_color_table ProxyColorTable;
1388 GLboolean ColorTableEnabled;
1389 };
1390
1391
1392 /**
1393 * Texture attribute group (GL_TEXTURE_BIT).
1394 */
1395 struct gl_texture_attrib
1396 {
1397 /**
1398 * name multitexture
1399 */
1400 /**@{*/
1401 GLuint CurrentUnit; /**< Active texture unit */
1402 GLuint _EnabledUnits; /**< one bit set for each really-enabled unit */
1403 GLuint _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
1404 GLuint _GenFlags; /**< for texgen */
1405 GLuint _TexGenEnabled;
1406 GLuint _TexMatEnabled;
1407 /**@}*/
1408
1409 struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
1410
1411 struct gl_texture_object *Proxy1D;
1412 struct gl_texture_object *Proxy2D;
1413 struct gl_texture_object *Proxy3D;
1414 struct gl_texture_object *ProxyCubeMap;
1415 struct gl_texture_object *ProxyRect;
1416
1417 /** GL_EXT_shared_texture_palette */
1418 GLboolean SharedPalette;
1419 struct gl_color_table Palette;
1420 };
1421
1422
1423 /**
1424 * Transformation attribute group (GL_TRANSFORM_BIT).
1425 */
1426 struct gl_transform_attrib
1427 {
1428 GLenum MatrixMode; /**< Matrix mode */
1429 GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */
1430 GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */
1431 GLuint ClipPlanesEnabled; /**< on/off bitmask */
1432 GLboolean Normalize; /**< Normalize all normals? */
1433 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1434 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1435
1436 GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */
1437 GLfloat CullEyePos[4];
1438 GLfloat CullObjPos[4];
1439 };
1440
1441
1442 /**
1443 * Viewport attribute group (GL_VIEWPORT_BIT).
1444 */
1445 struct gl_viewport_attrib
1446 {
1447 GLint X, Y; /**< position */
1448 GLsizei Width, Height; /**< size */
1449 GLfloat Near, Far; /**< Depth buffer range */
1450 GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
1451 };
1452
1453
1454 /**
1455 * Node for the attribute stack.
1456 */
1457 struct gl_attrib_node
1458 {
1459 GLbitfield kind;
1460 void *data;
1461 struct gl_attrib_node *next;
1462 };
1463
1464
1465 /**
1466 * GL_ARB_vertex/pixel_buffer_object buffer object
1467 */
1468 struct gl_buffer_object
1469 {
1470 GLint RefCount;
1471 GLuint Name;
1472 GLenum Usage;
1473 GLenum Access;
1474 GLvoid *Pointer; /**< Only valid while buffer is mapped */
1475 GLuint Size; /**< Size of storage in bytes */
1476 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1477 GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
1478 GLboolean DeletePending; /**< Deleted by user but RefCount > 0? */
1479 };
1480
1481
1482
1483 /**
1484 * Client pixel packing/unpacking attributes
1485 */
1486 struct gl_pixelstore_attrib
1487 {
1488 GLint Alignment;
1489 GLint RowLength;
1490 GLint SkipPixels;
1491 GLint SkipRows;
1492 GLint ImageHeight; /**< for GL_EXT_texture3D */
1493 GLint SkipImages; /**< for GL_EXT_texture3D */
1494 GLboolean SwapBytes;
1495 GLboolean LsbFirst;
1496 GLboolean ClientStorage; /**< GL_APPLE_client_storage */
1497 GLboolean Invert; /**< GL_MESA_pack_invert */
1498 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
1499 };
1500
1501
1502 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1503
1504
1505 /**
1506 * Client vertex array attributes
1507 */
1508 struct gl_client_array
1509 {
1510 GLint Size; /**< components per element (1,2,3,4) */
1511 GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
1512 GLsizei Stride; /**< user-specified stride */
1513 GLsizei StrideB; /**< actual stride in bytes */
1514 const GLubyte *Ptr; /**< Points to array data */
1515 GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
1516 GLboolean Normalized; /**< GL_ARB_vertex_program */
1517
1518 /**< GL_ARB_vertex_buffer_object */
1519 struct gl_buffer_object *BufferObj;
1520 GLuint _MaxElement;
1521
1522 GLuint Flags;
1523 };
1524
1525
1526 /**
1527 * Vertex array state
1528 */
1529 struct gl_array_attrib
1530 {
1531 struct gl_client_array Vertex; /**< client data descriptors */
1532 struct gl_client_array Normal;
1533 struct gl_client_array Color;
1534 struct gl_client_array SecondaryColor;
1535 struct gl_client_array FogCoord;
1536 struct gl_client_array Index;
1537 struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
1538 struct gl_client_array EdgeFlag;
1539
1540 struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
1541
1542 GLint ActiveTexture; /**< Client Active Texture */
1543 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1544 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1545
1546 GLuint _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
1547 GLuint NewState; /**< _NEW_ARRAY_* */
1548
1549 #if FEATURE_ARB_vertex_buffer_object
1550 struct gl_buffer_object *NullBufferObj;
1551 struct gl_buffer_object *ArrayBufferObj;
1552 struct gl_buffer_object *ElementArrayBufferObj;
1553 #endif
1554 GLuint _MaxElement; /* Min of all enabled array's maxes */
1555 };
1556
1557
1558 /**
1559 * Feedback buffer state
1560 */
1561 struct gl_feedback
1562 {
1563 GLenum Type;
1564 GLuint _Mask; /* FB_* bits */
1565 GLfloat *Buffer;
1566 GLuint BufferSize;
1567 GLuint Count;
1568 };
1569
1570
1571 /**
1572 * Selection buffer state
1573 */
1574 struct gl_selection
1575 {
1576 GLuint *Buffer; /**< selection buffer */
1577 GLuint BufferSize; /**< size of the selection buffer */
1578 GLuint BufferCount; /**< number of values in the selection buffer */
1579 GLuint Hits; /**< number of records in the selection buffer */
1580 GLuint NameStackDepth; /**< name stack depth */
1581 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1582 GLboolean HitFlag; /**< hit flag */
1583 GLfloat HitMinZ; /**< minimum hit depth */
1584 GLfloat HitMaxZ; /**< maximum hit depth */
1585 };
1586
1587
1588 /**
1589 * 1-D Evaluator control points
1590 */
1591 struct gl_1d_map
1592 {
1593 GLuint Order; /**< Number of control points */
1594 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1595 GLfloat *Points; /**< Points to contiguous control points */
1596 };
1597
1598
1599 /**
1600 * 2-D Evaluator control points
1601 */
1602 struct gl_2d_map
1603 {
1604 GLuint Uorder; /**< Number of control points in U dimension */
1605 GLuint Vorder; /**< Number of control points in V dimension */
1606 GLfloat u1, u2, du;
1607 GLfloat v1, v2, dv;
1608 GLfloat *Points; /**< Points to contiguous control points */
1609 };
1610
1611
1612 /**
1613 * All evaluator control point state
1614 */
1615 struct gl_evaluators
1616 {
1617 /**
1618 * \name 1-D maps
1619 */
1620 /*@{*/
1621 struct gl_1d_map Map1Vertex3;
1622 struct gl_1d_map Map1Vertex4;
1623 struct gl_1d_map Map1Index;
1624 struct gl_1d_map Map1Color4;
1625 struct gl_1d_map Map1Normal;
1626 struct gl_1d_map Map1Texture1;
1627 struct gl_1d_map Map1Texture2;
1628 struct gl_1d_map Map1Texture3;
1629 struct gl_1d_map Map1Texture4;
1630 struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
1631 /*@}*/
1632
1633 /**
1634 * \name 2-D maps
1635 */
1636 /*@{*/
1637 struct gl_2d_map Map2Vertex3;
1638 struct gl_2d_map Map2Vertex4;
1639 struct gl_2d_map Map2Index;
1640 struct gl_2d_map Map2Color4;
1641 struct gl_2d_map Map2Normal;
1642 struct gl_2d_map Map2Texture1;
1643 struct gl_2d_map Map2Texture2;
1644 struct gl_2d_map Map2Texture3;
1645 struct gl_2d_map Map2Texture4;
1646 struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
1647 /*@}*/
1648 };
1649
1650
1651 /**
1652 * NV_fragment_program runtime state
1653 */
1654 struct fp_machine
1655 {
1656 GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
1657 GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
1658 GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
1659 GLuint CondCodes[4];
1660 };
1661
1662 /**
1663 * ATI_fragment_shader runtime state
1664 */
1665 #define ATI_FS_INPUT_PRIMARY 0
1666 #define ATI_FS_INPUT_SECONDARY 1
1667
1668 /* 6 register sets - 2 inputs (primary, secondary) */
1669 struct atifs_machine
1670 {
1671 GLfloat Registers[6][4];
1672 GLfloat PrevPassRegisters[6][4];
1673 GLfloat Inputs[2][4];
1674 GLuint pass;
1675 };
1676
1677
1678 /**
1679 * Names of the various vertex/fragment register files
1680 */
1681 enum register_file
1682 {
1683 PROGRAM_TEMPORARY = 10,
1684 PROGRAM_INPUT,
1685 PROGRAM_OUTPUT,
1686 PROGRAM_LOCAL_PARAM,
1687 PROGRAM_ENV_PARAM,
1688 PROGRAM_NAMED_PARAM,
1689 PROGRAM_STATE_VAR,
1690 PROGRAM_WRITE_ONLY,
1691 PROGRAM_ADDRESS
1692 };
1693
1694
1695 /** Vertex and fragment instructions */
1696 struct vp_instruction;
1697 struct fp_instruction;
1698 struct atifs_instruction;
1699 struct program_parameter_list;
1700
1701
1702 /**
1703 * Base class for any kind of program object
1704 */
1705 struct program
1706 {
1707 GLuint Id;
1708 GLubyte *String; /**< Null-terminated program text */
1709 GLboolean DeletePending; /**< User called glDeletePrograms? */
1710 GLint RefCount;
1711 GLenum Target;
1712 GLenum Format; /**< String encoding format */
1713 GLboolean Resident;
1714 GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
1715 GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */
1716 GLuint NumTemporaries;
1717 GLuint NumParameters;
1718 GLuint NumAttributes;
1719 GLuint NumAddressRegs;
1720 };
1721
1722
1723 /** Vertex program object */
1724 struct vertex_program
1725 {
1726 struct program Base; /* base class */
1727 struct vp_instruction *Instructions; /* Compiled instructions */
1728 GLboolean IsNVProgram; /* GL_NV_vertex_program ? */
1729 GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
1730 GLuint InputsRead; /* Bitmask of which input regs are read */
1731 GLuint OutputsWritten; /* Bitmask of which output regs are written to */
1732 struct program_parameter_list *Parameters; /**< array [NumParameters] */
1733 };
1734
1735
1736 /** Fragment program object */
1737 struct fragment_program
1738 {
1739 struct program Base; /**< base class */
1740 struct fp_instruction *Instructions; /**< Compiled instructions */
1741 GLuint InputsRead; /**< Bitmask of which input regs are read */
1742 GLuint OutputsWritten; /**< Bitmask of which output regs are written to */
1743 GLuint TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_INDEX bitmask */
1744 GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
1745 GLuint NumTexInstructions;
1746 GLuint NumTexIndirections;
1747 GLenum FogOption;
1748 struct program_parameter_list *Parameters; /**< array [NumParameters] */
1749
1750 #ifdef USE_TCC
1751 char c_str[4096]; /* experimental... */
1752 int c_strlen;
1753 #endif
1754 };
1755
1756 struct ati_fragment_shader
1757 {
1758 struct program Base;
1759 struct atifs_instruction *Instructions;
1760 GLfloat Constants[8][4];
1761 GLint cur_pass;
1762 };
1763
1764 /**
1765 * State common to vertex and fragment programs.
1766 */
1767 struct gl_program_state
1768 {
1769 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_NV */
1770 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_NV */
1771 };
1772
1773
1774 /**
1775 * State vars for GL_ARB/GL_NV_vertex_program
1776 */
1777 struct gl_vertex_program_state
1778 {
1779 GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */
1780 GLboolean _Enabled; /**< Really enabled? */
1781 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1782 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1783 struct vertex_program *Current; /**< ptr to currently bound program */
1784
1785 GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1786 GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1787
1788 GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
1789 /* Only used during program execution (may be moved someday): */
1790 GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
1791 GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
1792 GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
1793 GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
1794 GLint AddressReg[4];
1795
1796 #if FEATURE_MESA_program_debug
1797 GLprogramcallbackMESA Callback;
1798 GLvoid *CallbackData;
1799 GLboolean CallbackEnabled;
1800 GLuint CurrentPosition;
1801 #endif
1802 };
1803
1804
1805 /*
1806 * State for GL_ARB/NV_fragment_program
1807 */
1808 struct gl_fragment_program_state
1809 {
1810 GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
1811 GLboolean _Enabled; /* Really enabled? */
1812 struct fragment_program *Current; /* ptr to currently bound program */
1813 struct fp_machine Machine; /* machine state */
1814 GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
1815
1816 #if FEATURE_MESA_program_debug
1817 GLprogramcallbackMESA Callback;
1818 GLvoid *CallbackData;
1819 GLboolean CallbackEnabled;
1820 GLuint CurrentPosition;
1821 #endif
1822 };
1823
1824 /*
1825 * State for GL_fragment_shader
1826 */
1827 struct gl_ati_fragment_shader_state
1828 {
1829 GLboolean Enabled;
1830 GLboolean _Enabled;
1831 GLboolean Compiling;
1832 struct atifs_machine Machine; /* machine state */
1833 struct ati_fragment_shader *Current;
1834 };
1835
1836 /*
1837 * State for GL_ARB_occlusion_query
1838 */
1839 struct gl_occlusion_state
1840 {
1841 GLboolean Active;
1842 GLuint CurrentQueryObject;
1843 GLuint PassedCounter;
1844 struct _mesa_HashTable *QueryObjects;
1845 };
1846
1847 /**
1848 * gl2 unique interface identifier.
1849 * Each gl2 interface has its own interface id used for object queries.
1850 */
1851 enum gl2_uiid
1852 {
1853 UIID_UNKNOWN, /* supported by all objects */
1854 UIID_GENERIC, /* generic object */
1855 UIID_CONTAINER, /* contains generic objects */
1856 UIID_SHADER, /* shader object */
1857 UIID_FRAGMENT_SHADER, /* fragment shader */
1858 UIID_VERTEX_SHADER, /* vertex shader */
1859 UIID_PROGRAM, /* program object */
1860 UIID_3DLABS_SHHANDLE /* encapsulates 3dlabs' ShHandle */
1861 };
1862
1863 struct gl2_unknown_intf
1864 {
1865 GLvoid (* AddRef) (struct gl2_unknown_intf **);
1866 GLvoid (* Release) (struct gl2_unknown_intf **);
1867 struct gl2_unknown_intf **(* QueryInterface) (struct gl2_unknown_intf **, enum gl2_uiid uiid);
1868 };
1869
1870 struct gl2_generic_intf
1871 {
1872 struct gl2_unknown_intf _unknown;
1873 GLvoid (* Delete) (struct gl2_generic_intf **);
1874 GLenum (* GetType) (struct gl2_generic_intf **);
1875 GLhandleARB (* GetName) (struct gl2_generic_intf **);
1876 GLboolean (* GetDeleteStatus) (struct gl2_generic_intf **);
1877 const GLcharARB *(* GetInfoLog) (struct gl2_generic_intf **);
1878 };
1879
1880 struct gl2_container_intf
1881 {
1882 struct gl2_generic_intf _generic;
1883 GLboolean (* Attach) (struct gl2_container_intf **, struct gl2_generic_intf **);
1884 GLboolean (* Detach) (struct gl2_container_intf **, struct gl2_generic_intf **);
1885 GLsizei (* GetAttachedCount) (struct gl2_container_intf **);
1886 struct gl2_generic_intf **(* GetAttached) (struct gl2_container_intf **, GLuint);
1887 };
1888
1889 struct gl2_shader_intf
1890 {
1891 struct gl2_generic_intf _generic;
1892 GLenum (* GetSubType) (struct gl2_shader_intf **);
1893 GLboolean (* GetCompileStatus) (struct gl2_shader_intf **);
1894 GLvoid (* SetSource) (struct gl2_shader_intf **, GLcharARB *, GLint *, GLsizei);
1895 const GLcharARB *(* GetSource) (struct gl2_shader_intf **);
1896 GLvoid (* Compile) (struct gl2_shader_intf **);
1897 };
1898
1899 struct gl2_program_intf
1900 {
1901 struct gl2_container_intf _container;
1902 GLboolean (* GetLinkStatus) (struct gl2_program_intf **);
1903 GLboolean (* GetValidateStatus) (struct gl2_program_intf **);
1904 GLvoid (* Link) (struct gl2_program_intf **);
1905 GLvoid (* Validate) (struct gl2_program_intf **);
1906 };
1907
1908 struct gl2_fragment_shader_intf
1909 {
1910 struct gl2_shader_intf _shader;
1911 };
1912
1913 struct gl2_vertex_shader_intf
1914 {
1915 struct gl2_shader_intf _shader;
1916 };
1917
1918 struct gl2_3dlabs_shhandle_intf
1919 {
1920 struct gl2_unknown_intf _unknown;
1921 GLvoid *(* GetShHandle) (struct gl2_3dlabs_shhandle_intf **);
1922 };
1923
1924 struct gl_shader_objects_state
1925 {
1926 struct gl2_program_intf **current_program;
1927 };
1928
1929
1930 /**
1931 * State which can be shared by multiple contexts:
1932 */
1933 struct gl_shared_state
1934 {
1935 _glthread_Mutex Mutex; /**< for thread safety */
1936 GLint RefCount; /**< Reference count */
1937 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
1938 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
1939 struct gl_texture_object *TexObjectList;/**< Linked list of texture objects */
1940
1941 /**
1942 * \name Default texture objects (shared by all multi-texture units)
1943 */
1944 /*@{*/
1945 struct gl_texture_object *Default1D;
1946 struct gl_texture_object *Default2D;
1947 struct gl_texture_object *Default3D;
1948 struct gl_texture_object *DefaultCubeMap;
1949 struct gl_texture_object *DefaultRect;
1950 /*@}*/
1951
1952 /**
1953 * \name GL_NV_vertex/_program
1954 */
1955 /*@{*/
1956 struct _mesa_HashTable *Programs;
1957 #if FEATURE_ARB_vertex_program
1958 struct program *DefaultVertexProgram;
1959 #endif
1960 #if FEATURE_ARB_fragment_program
1961 struct program *DefaultFragmentProgram;
1962 #endif
1963 #if FEATURE_ATI_fragment_shader
1964 struct program *DefaultFragmentShader;
1965 #endif
1966 /*@}*/
1967
1968 #if FEATURE_ARB_vertex_buffer_object
1969 struct _mesa_HashTable *BufferObjects;
1970 #endif
1971
1972 struct _mesa_HashTable *GL2Objects;
1973
1974 void *DriverData; /**< Device driver shared state */
1975 };
1976
1977
1978 /**
1979 * Frame buffer.
1980 *
1981 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1982 * depth, accum, stencil, and software-simulated alpha buffers.
1983 * In C++ terms, think of this as a base class from which device drivers
1984 * will make derived classes.
1985 */
1986 struct gl_frame_buffer
1987 {
1988 GLvisual Visual; /**< The corresponding visual */
1989
1990 GLuint Width, Height; /**< size of frame buffer in pixels */
1991
1992 GLboolean Initialized;
1993
1994 GLboolean UseSoftwareDepthBuffer;
1995 GLboolean UseSoftwareAccumBuffer;
1996 GLboolean UseSoftwareStencilBuffer;
1997 GLboolean UseSoftwareAlphaBuffers;
1998 GLboolean UseSoftwareAuxBuffers;
1999
2000 /** \name Software depth (aka Z) buffer */
2001 /*@{*/
2002 GLvoid *DepthBuffer; /**< array [Width*Height] of GLushort or GLuint*/
2003 /*@}*/
2004
2005 /** \name Software stencil buffer */
2006 /*@{*/
2007 GLstencil *Stencil; /**< array [Width*Height] of GLstencil values */
2008 /*@}*/
2009
2010 /** \name Software accumulation buffer */
2011 /*@{*/
2012 GLaccum *Accum; /**< array [4*Width*Height] of GLaccum values */
2013 /*@}*/
2014
2015 /** \name Software alpha planes */
2016 /*@{*/
2017 GLchan *FrontLeftAlpha; /**< array [Width*Height] of GLchan */
2018 GLchan *BackLeftAlpha; /**< array [Width*Height] of GLchan */
2019 GLchan *FrontRightAlpha; /**< array [Width*Height] of GLchan */
2020 GLchan *BackRightAlpha; /**< array [Width*Height] of GLchan */
2021 /*@}*/
2022
2023 GLchan *AuxBuffers[MAX_AUX_BUFFERS];
2024
2025 /**
2026 * \name Drawing bounds
2027 *
2028 * Intersection of window size and scissor box
2029 */
2030 /*@{*/
2031 GLint _Xmin; /**< inclusive */
2032 GLint _Ymin; /**< inclusive */
2033 GLint _Xmax; /**< exclusive */
2034 GLint _Ymax; /**< exclusive */
2035 /*@}*/
2036 };
2037
2038
2039 /**
2040 * Constants which may be overridden by device driver during context creation
2041 * but are never changed after that.
2042 */
2043 struct gl_constants
2044 {
2045 GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
2046 GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2047 GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2048 GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
2049 GLuint MaxTextureCoordUnits;
2050 GLuint MaxTextureImageUnits;
2051 GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */
2052 GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
2053 GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
2054 GLuint MaxArrayLockSize;
2055 GLint SubPixelBits;
2056 GLfloat MinPointSize, MaxPointSize; /* aliased */
2057 GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
2058 GLfloat PointSizeGranularity;
2059 GLfloat MinLineWidth, MaxLineWidth; /* aliased */
2060 GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
2061 GLfloat LineWidthGranularity;
2062 GLuint MaxColorTableSize;
2063 GLuint MaxConvolutionWidth;
2064 GLuint MaxConvolutionHeight;
2065 GLuint MaxClipPlanes;
2066 GLuint MaxLights;
2067 GLfloat MaxShininess; /* GL_NV_light_max_exponent */
2068 GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
2069 GLuint MaxViewportWidth, MaxViewportHeight;
2070 /* GL_ARB_vertex_program */
2071 GLuint MaxVertexProgramInstructions;
2072 GLuint MaxVertexProgramAttribs;
2073 GLuint MaxVertexProgramTemps;
2074 GLuint MaxVertexProgramLocalParams;
2075 GLuint MaxVertexProgramEnvParams;
2076 GLuint MaxVertexProgramAddressRegs;
2077 /* GL_ARB_fragment_program */
2078 GLuint MaxFragmentProgramInstructions;
2079 GLuint MaxFragmentProgramAttribs;
2080 GLuint MaxFragmentProgramTemps;
2081 GLuint MaxFragmentProgramLocalParams;
2082 GLuint MaxFragmentProgramEnvParams;
2083 GLuint MaxFragmentProgramAddressRegs;
2084 GLuint MaxFragmentProgramAluInstructions;
2085 GLuint MaxFragmentProgramTexInstructions;
2086 GLuint MaxFragmentProgramTexIndirections;
2087 /* vertex or fragment program */
2088 GLuint MaxProgramMatrices;
2089 GLuint MaxProgramMatrixStackDepth;
2090 /* vertex array / buffer object bounds checking */
2091 GLboolean CheckArrayBounds;
2092 /* GL_ARB_draw_buffers */
2093 GLuint MaxDrawBuffers;
2094 /* GL_OES_read_format */
2095 GLenum ColorReadFormat;
2096 GLenum ColorReadType;
2097 };
2098
2099
2100 /**
2101 * Enable flag for each OpenGL extension. Different device drivers will
2102 * enable different extensions at runtime.
2103 */
2104 struct gl_extensions
2105 {
2106 /**
2107 * \name Flags to quickly test if certain extensions are available.
2108 *
2109 * Not every extension needs to have such a flag, but it's encouraged.
2110 */
2111 /*@{*/
2112 GLboolean dummy; /* don't remove this! */
2113 GLboolean ARB_depth_texture;
2114 GLboolean ARB_draw_buffers;
2115 GLboolean ARB_fragment_program;
2116 GLboolean ARB_fragment_shader;
2117 GLboolean ARB_half_float_pixel;
2118 GLboolean ARB_imaging;
2119 GLboolean ARB_multisample;
2120 GLboolean ARB_multitexture;
2121 GLboolean ARB_occlusion_query;
2122 GLboolean ARB_point_sprite;
2123 GLboolean ARB_shader_objects;
2124 GLboolean ARB_shadow;
2125 GLboolean ARB_texture_border_clamp;
2126 GLboolean ARB_texture_compression;
2127 GLboolean ARB_texture_cube_map;
2128 GLboolean ARB_texture_env_combine;
2129 GLboolean ARB_texture_env_crossbar;
2130 GLboolean ARB_texture_env_dot3;
2131 GLboolean ARB_texture_float;
2132 GLboolean ARB_texture_mirrored_repeat;
2133 GLboolean ARB_texture_non_power_of_two;
2134 GLboolean ARB_transpose_matrix;
2135 GLboolean ARB_vertex_buffer_object;
2136 GLboolean ARB_vertex_program;
2137 GLboolean ARB_vertex_shader;
2138 GLboolean ARB_window_pos;
2139 GLboolean EXT_abgr;
2140 GLboolean EXT_bgra;
2141 GLboolean EXT_blend_color;
2142 GLboolean EXT_blend_equation_separate;
2143 GLboolean EXT_blend_func_separate;
2144 GLboolean EXT_blend_logic_op;
2145 GLboolean EXT_blend_minmax;
2146 GLboolean EXT_blend_subtract;
2147 GLboolean EXT_clip_volume_hint;
2148 GLboolean EXT_cull_vertex;
2149 GLboolean EXT_convolution;
2150 GLboolean EXT_compiled_vertex_array;
2151 GLboolean EXT_copy_texture;
2152 GLboolean EXT_depth_bounds_test;
2153 GLboolean EXT_draw_range_elements;
2154 GLboolean EXT_fog_coord;
2155 GLboolean EXT_histogram;
2156 GLboolean EXT_multi_draw_arrays;
2157 GLboolean EXT_paletted_texture;
2158 GLboolean EXT_packed_pixels;
2159 GLboolean EXT_pixel_buffer_object;
2160 GLboolean EXT_point_parameters;
2161 GLboolean EXT_polygon_offset;
2162 GLboolean EXT_rescale_normal;
2163 GLboolean EXT_shadow_funcs;
2164 GLboolean EXT_secondary_color;
2165 GLboolean EXT_separate_specular_color;
2166 GLboolean EXT_shared_texture_palette;
2167 GLboolean EXT_stencil_wrap;
2168 GLboolean EXT_stencil_two_side;
2169 GLboolean EXT_subtexture;
2170 GLboolean EXT_texture;
2171 GLboolean EXT_texture_object;
2172 GLboolean EXT_texture3D;
2173 GLboolean EXT_texture_compression_s3tc;
2174 GLboolean EXT_texture_env_add;
2175 GLboolean EXT_texture_env_combine;
2176 GLboolean EXT_texture_env_dot3;
2177 GLboolean EXT_texture_filter_anisotropic;
2178 GLboolean EXT_texture_lod_bias;
2179 GLboolean EXT_texture_mirror_clamp;
2180 GLboolean EXT_vertex_array;
2181 GLboolean EXT_vertex_array_set;
2182 /* vendor extensions */
2183 GLboolean APPLE_client_storage;
2184 GLboolean APPLE_packed_pixels;
2185 GLboolean ATI_texture_mirror_once;
2186 GLboolean ATI_texture_env_combine3;
2187 GLboolean ATI_fragment_shader;
2188 GLboolean HP_occlusion_test;
2189 GLboolean IBM_rasterpos_clip;
2190 GLboolean IBM_multimode_draw_arrays;
2191 GLboolean MESA_pack_invert;
2192 GLboolean MESA_packed_depth_stencil;
2193 GLboolean MESA_program_debug;
2194 GLboolean MESA_resize_buffers;
2195 GLboolean MESA_ycbcr_texture;
2196 GLboolean NV_blend_square;
2197 GLboolean NV_fragment_program;
2198 GLboolean NV_light_max_exponent;
2199 GLboolean NV_point_sprite;
2200 GLboolean NV_texgen_reflection;
2201 GLboolean NV_texture_rectangle;
2202 GLboolean NV_vertex_program;
2203 GLboolean NV_vertex_program1_1;
2204 GLboolean OES_read_format;
2205 GLboolean SGI_color_matrix;
2206 GLboolean SGI_color_table;
2207 GLboolean SGI_texture_color_table;
2208 GLboolean SGIS_generate_mipmap;
2209 GLboolean SGIS_pixel_texture;
2210 GLboolean SGIS_texture_edge_clamp;
2211 GLboolean SGIS_texture_lod;
2212 GLboolean SGIX_depth_texture;
2213 GLboolean SGIX_pixel_texture;
2214 GLboolean SGIX_shadow;
2215 GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
2216 GLboolean TDFX_texture_compression_FXT1;
2217 GLboolean S3_s3tc;
2218 /*@}*/
2219 /* The extension string */
2220 const GLubyte *String;
2221 };
2222
2223
2224 /**
2225 * A stack of matrices (projection, modelview, color, texture, etc).
2226 */
2227 struct matrix_stack
2228 {
2229 GLmatrix *Top; /**< points into Stack */
2230 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
2231 GLuint Depth; /**< 0 <= Depth < MaxDepth */
2232 GLuint MaxDepth; /**< size of Stack[] array */
2233 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2234 };
2235
2236
2237 /**
2238 * \name Bits for image transfer operations
2239 *
2240 * \sa __GLcontextRec::ImageTransferState.
2241 */
2242 /*@{*/
2243 #define IMAGE_SCALE_BIAS_BIT 0x1
2244 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2245 #define IMAGE_MAP_COLOR_BIT 0x4
2246 #define IMAGE_COLOR_TABLE_BIT 0x8
2247 #define IMAGE_CONVOLUTION_BIT 0x10
2248 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2249 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2250 #define IMAGE_COLOR_MATRIX_BIT 0x80
2251 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2252 #define IMAGE_HISTOGRAM_BIT 0x200
2253 #define IMAGE_MIN_MAX_BIT 0x400
2254 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2255
2256
2257 /** Pixel Transfer ops up to convolution */
2258 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2259 IMAGE_SHIFT_OFFSET_BIT | \
2260 IMAGE_MAP_COLOR_BIT | \
2261 IMAGE_COLOR_TABLE_BIT)
2262
2263 /** Pixel transfer ops after convolution */
2264 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2265 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2266 IMAGE_COLOR_MATRIX_BIT | \
2267 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2268 IMAGE_HISTOGRAM_BIT | \
2269 IMAGE_MIN_MAX_BIT)
2270 /*@}*/
2271
2272
2273 /**
2274 * \name Bits to indicate what state has changed.
2275 *
2276 * 4 unused flags.
2277 */
2278 /*@{*/
2279 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2280 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2281 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2282 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2283 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2284 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2285 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2286 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2287 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2288 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2289 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2290 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2291 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2292 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2293 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2294 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2295 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2296 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2297 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2298 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2299 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2300 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2301 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2302 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2303 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2304 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2305 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2306 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2307 #define _NEW_ALL ~0
2308 /*@}*/
2309
2310
2311 /**
2312 * \name Bits to track array state changes
2313 *
2314 * Also used to summarize array enabled.
2315 */
2316 /*@{*/
2317 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2318 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2319 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2320 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2321 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2322 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2323 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2324 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2325 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2326 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2327 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2328 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2329 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2330 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2331 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2332 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2333 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2334 #define _NEW_ARRAY_ALL 0xffffffff
2335
2336
2337 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2338 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2339 /*@}*/
2340
2341
2342 /**
2343 * \name A bunch of flags that we think might be useful to drivers.
2344 *
2345 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2346 */
2347 /*@{*/
2348 #define DD_FLATSHADE 0x1
2349 #define DD_SEPARATE_SPECULAR 0x2
2350 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2351 #define DD_TRI_LIGHT_TWOSIDE 0x8
2352 #define DD_TRI_UNFILLED 0x10
2353 #define DD_TRI_SMOOTH 0x20
2354 #define DD_TRI_STIPPLE 0x40
2355 #define DD_TRI_OFFSET 0x80
2356 #define DD_LINE_SMOOTH 0x100
2357 #define DD_LINE_STIPPLE 0x200
2358 #define DD_LINE_WIDTH 0x400
2359 #define DD_POINT_SMOOTH 0x800
2360 #define DD_POINT_SIZE 0x1000
2361 #define DD_POINT_ATTEN 0x2000
2362 #define DD_TRI_TWOSTENCIL 0x4000
2363 /*@}*/
2364
2365
2366 /**
2367 * \name Define the state changes under which each of these bits might change
2368 */
2369 /*@{*/
2370 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2371 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2372 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2373 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2374 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2375 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2376 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2377 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2378 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2379 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2380 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2381 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2382 #define _DD_NEW_POINT_SIZE _NEW_POINT
2383 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2384 /*@}*/
2385
2386
2387 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2388 _NEW_TEXTURE | \
2389 _NEW_POINT | \
2390 _NEW_MODELVIEW)
2391
2392 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2393 _NEW_TEXTURE)
2394
2395 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2396
2397
2398
2399
2400 /*
2401 * Forward declaration of display list data types:
2402 */
2403 union node;
2404 typedef union node Node;
2405
2406
2407 /* This has to be included here. */
2408 #include "dd.h"
2409
2410
2411 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2412
2413 /**
2414 * Core Mesa's support for tnl modules:
2415 */
2416 struct gl_tnl_module
2417 {
2418 /**
2419 * Vertex format to be lazily swapped into current dispatch.
2420 */
2421 const GLvertexformat *Current;
2422
2423 /**
2424 * \name Record of functions swapped out.
2425 * On restore, only need to swap these functions back in.
2426 */
2427 /*@{*/
2428 void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
2429 GLuint SwapCount;
2430 /*@}*/
2431 };
2432
2433
2434 /**
2435 * State used during display list compilation and execution.
2436 */
2437 struct mesa_list_state
2438 {
2439 GLuint CallDepth; /**< Current recursion calling depth */
2440 Node *CurrentListPtr; /**< Head of list being compiled */
2441 GLuint CurrentListNum; /**< Number of the list being compiled */
2442 Node *CurrentBlock; /**< Pointer to current block of nodes */
2443 GLuint CurrentPos; /**< Index into current block of nodes */
2444 GLvertexformat ListVtxfmt;
2445
2446 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
2447 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
2448
2449 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
2450 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
2451
2452 GLubyte ActiveIndex;
2453 GLfloat CurrentIndex;
2454
2455 GLubyte ActiveEdgeFlag;
2456 GLboolean CurrentEdgeFlag;
2457 };
2458
2459
2460 /**
2461 * Mesa rendering context.
2462 *
2463 * This is the central context data structure for Mesa. Almost all
2464 * OpenGL state is contained in this structure.
2465 * Think of this as a base class from which device drivers will derive
2466 * sub classes.
2467 *
2468 * The GLcontext typedef names this structure.
2469 */
2470 struct __GLcontextRec
2471 {
2472 /**
2473 * \name OS related interfaces.
2474 *
2475 * These \b must be the first members of this structure, because they are
2476 * exposed to the outside world (i.e. GLX extension).
2477 */
2478 /*@{*/
2479 __GLimports imports;
2480 __GLexports exports;
2481 /*@}*/
2482
2483 /** State possibly shared with other contexts in the address space */
2484 struct gl_shared_state *Shared;
2485
2486 /** \name API function pointer tables */
2487 /*@{*/
2488 struct _glapi_table *Save; /**< Display list save functions */
2489 struct _glapi_table *Exec; /**< Execute functions */
2490 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
2491 /*@}*/
2492
2493 GLvisual Visual;
2494 GLframebuffer *DrawBuffer; /**< buffer for writing */
2495 GLframebuffer *ReadBuffer; /**< buffer for reading */
2496
2497 /**
2498 * Device driver function pointer table
2499 */
2500 struct dd_function_table Driver;
2501
2502 void *DriverCtx; /**< Points to device driver context/state */
2503 void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
2504
2505 /** Core/Driver constants */
2506 struct gl_constants Const;
2507
2508 /** \name The various 4x4 matrix stacks */
2509 /*@{*/
2510 struct matrix_stack ModelviewMatrixStack;
2511 struct matrix_stack ProjectionMatrixStack;
2512 struct matrix_stack ColorMatrixStack;
2513 struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
2514 struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
2515 struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
2516 /*@}*/
2517
2518 /** Combined modelview and projection matrix */
2519 GLmatrix _ModelProjectMatrix;
2520
2521 /** \name Display lists */
2522 struct mesa_list_state ListState;
2523
2524 GLboolean ExecuteFlag; /**< Execute GL commands? */
2525 GLboolean CompileFlag; /**< Compile GL commands into display list? */
2526
2527 /** Extensions */
2528 struct gl_extensions Extensions;
2529
2530 /** \name Renderer attribute stack */
2531 /*@{*/
2532 GLuint AttribStackDepth;
2533 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
2534 /*@}*/
2535
2536 /** \name Renderer attribute groups
2537 *
2538 * We define a struct for each attribute group to make pushing and popping
2539 * attributes easy. Also it's a good organization.
2540 */
2541 /*@{*/
2542 struct gl_accum_attrib Accum; /**< Accumulation buffer attributes */
2543 struct gl_colorbuffer_attrib Color; /**< Color buffers attributes */
2544 struct gl_current_attrib Current; /**< Current attributes */
2545 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
2546 struct gl_eval_attrib Eval; /**< Eval attributes */
2547 struct gl_fog_attrib Fog; /**< Fog attributes */
2548 struct gl_hint_attrib Hint; /**< Hint attributes */
2549 struct gl_light_attrib Light; /**< Light attributes */
2550 struct gl_line_attrib Line; /**< Line attributes */
2551 struct gl_list_attrib List; /**< List attributes */
2552 struct gl_multisample_attrib Multisample;
2553 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
2554 struct gl_point_attrib Point; /**< Point attributes */
2555 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
2556 GLuint PolygonStipple[32]; /**< Polygon stipple */
2557 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
2558 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
2559 struct gl_texture_attrib Texture; /**< Texture attributes */
2560 struct gl_transform_attrib Transform; /**< Transformation attributes */
2561 struct gl_viewport_attrib Viewport; /**< Viewport attributes */
2562 /*@}*/
2563
2564 /** \name Client attribute stack */
2565 /*@{*/
2566 GLuint ClientAttribStackDepth;
2567 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
2568 /*@}*/
2569
2570 /** \name Client attribute groups */
2571 /*@{*/
2572 struct gl_array_attrib Array; /**< Vertex arrays */
2573 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
2574 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
2575 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
2576 /*@}*/
2577
2578 /** \name Other assorted state (not pushed/popped on attribute stack) */
2579 /*@{*/
2580 struct gl_histogram_attrib Histogram;
2581 struct gl_minmax_attrib MinMax;
2582 struct gl_convolution_attrib Convolution1D;
2583 struct gl_convolution_attrib Convolution2D;
2584 struct gl_convolution_attrib Separable2D;
2585
2586 struct gl_evaluators EvalMap; /**< All evaluators */
2587 struct gl_feedback Feedback; /**< Feedback */
2588 struct gl_selection Select; /**< Selection */
2589
2590 struct gl_color_table ColorTable; /**< Pre-convolution */
2591 struct gl_color_table ProxyColorTable; /**< Pre-convolution */
2592 struct gl_color_table PostConvolutionColorTable;
2593 struct gl_color_table ProxyPostConvolutionColorTable;
2594 struct gl_color_table PostColorMatrixColorTable;
2595 struct gl_color_table ProxyPostColorMatrixColorTable;
2596
2597 struct gl_program_state Program; /**< for vertex or fragment progs */
2598 struct gl_vertex_program_state VertexProgram; /**< GL_NV_vertex_program */
2599 struct gl_fragment_program_state FragmentProgram; /**< GL_NV_fragment_program */
2600 struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
2601
2602 struct gl_occlusion_state Occlusion; /**< GL_ARB_occlusion_query */
2603
2604 struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
2605 /*@}*/
2606
2607 GLenum ErrorValue; /**< Last error code */
2608 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2609 GLuint NewState; /**< bitwise-or of _NEW_* flags */
2610
2611 /** \name Derived state */
2612 /*@{*/
2613 GLuint _TriangleCaps; /**< bitwise-or of DD_* flags */
2614 GLuint _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
2615 GLfloat _EyeZDir[3];
2616 GLfloat _ModelViewInvScale;
2617 GLuint _NeedEyeCoords;
2618 GLuint _ForceEyeCoords;
2619 GLboolean _RotateMode;
2620 GLenum _CurrentProgram; /* currently executing program */
2621
2622 struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
2623 struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
2624 /**@}*/
2625
2626 struct gl_list_extensions ListExt; /**< driver dlist extensions */
2627
2628
2629 GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
2630 GLboolean OcclusionResultSaved; /**< for GL_HP_occlusion_test */
2631 GLuint _Facing; /**< This is a hack for 2-sided stencil test.
2632 *
2633 * We don't have a better way to communicate this value from
2634 * swrast_setup to swrast. */
2635
2636
2637 /** \name Z buffer stuff */
2638 /*@{*/
2639 GLuint DepthMax; /**< Max depth buffer value */
2640 GLfloat DepthMaxF; /**< Float max depth buffer value */
2641 GLfloat MRD; /**< minimum resolvable difference in Z values */
2642 /*@}*/
2643
2644 /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
2645 /*@{*/
2646 GLboolean ClampFragmentColors;
2647 GLboolean ClampVertexColors;
2648 /*@}*/
2649
2650 /** \name For debugging/development only */
2651 /*@{*/
2652 GLboolean FirstTimeCurrent;
2653 /*@}*/
2654
2655 /** Dither disable via MESA_NO_DITHER env var */
2656 GLboolean NoDither;
2657
2658 /** software compression/decompression supported or not */
2659 GLboolean Mesa_DXTn;
2660
2661 /** Core tnl module support */
2662 struct gl_tnl_module TnlModule;
2663
2664 /**
2665 * \name Hooks for module contexts.
2666 *
2667 * These will eventually live in the driver or elsewhere.
2668 */
2669 /*@{*/
2670 void *swrast_context;
2671 void *swsetup_context;
2672 void *swtnl_context;
2673 void *swtnl_im;
2674 void *acache_context;
2675 void *aelt_context;
2676 /*@}*/
2677 };
2678
2679
2680 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2681 extern const char *_mesa_prim_name[GL_POLYGON+4];
2682
2683
2684 #ifdef MESA_DEBUG
2685 extern int MESA_VERBOSE;
2686 extern int MESA_DEBUG_FLAGS;
2687 # define MESA_FUNCTION __FUNCTION__
2688 #else
2689 # define MESA_VERBOSE 0
2690 # define MESA_DEBUG_FLAGS 0
2691 # define MESA_FUNCTION "a function"
2692 # ifndef NDEBUG
2693 # define NDEBUG
2694 # endif
2695 #endif
2696
2697
2698 enum _verbose
2699 {
2700 VERBOSE_VARRAY = 0x0001,
2701 VERBOSE_TEXTURE = 0x0002,
2702 VERBOSE_IMMEDIATE = 0x0004,
2703 VERBOSE_PIPELINE = 0x0008,
2704 VERBOSE_DRIVER = 0x0010,
2705 VERBOSE_STATE = 0x0020,
2706 VERBOSE_API = 0x0040,
2707 VERBOSE_DISPLAY_LIST = 0x0100,
2708 VERBOSE_LIGHTING = 0x0200,
2709 VERBOSE_PRIMS = 0x0400,
2710 VERBOSE_VERTS = 0x0800
2711 };
2712
2713
2714 enum _debug
2715 {
2716 DEBUG_ALWAYS_FLUSH = 0x1
2717 };
2718
2719
2720
2721 #define Elements(x) sizeof(x)/sizeof(*(x))
2722
2723
2724 #endif /* TYPES_H */