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