716bbfcf85cd803431cfef931fe139a42371148e
[mesa.git] / src / mesa / main / mtypes.h
1 /* $Id: mtypes.h,v 1.103 2003/02/16 23:07:34 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 4.1
6 *
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /**
28 * \file mtypes.h
29 * \brief Main Mesa data structures.
30 */
31
32 #ifndef TYPES_H
33 #define TYPES_H
34
35
36 #include "glheader.h"
37 #include "config.h" /* Hardwired parameters */
38 #include "glapitable.h"
39 #include "glthread.h"
40
41 #include "math/m_matrix.h" /* GLmatrix */
42
43 #if defined(MESA_TRACE)
44 #include "Trace/tr_context.h"
45 #endif
46
47
48 /* Please try to mark derived values with a leading underscore ('_').
49 */
50
51 /*
52 * Color channel data type:
53 */
54 #if CHAN_BITS == 8
55 typedef GLubyte GLchan;
56 #define CHAN_MAX 255
57 #define CHAN_MAXF 255.0F
58 #define CHAN_TYPE GL_UNSIGNED_BYTE
59 #elif CHAN_BITS == 16
60 typedef GLushort GLchan;
61 #define CHAN_MAX 65535
62 #define CHAN_MAXF 65535.0F
63 #define CHAN_TYPE GL_UNSIGNED_SHORT
64 #elif CHAN_BITS == 32
65 typedef GLfloat GLchan;
66 #define CHAN_MAX 1.0
67 #define CHAN_MAXF 1.0F
68 #define CHAN_TYPE GL_FLOAT
69 #else
70 #error "illegal number of color channel bits"
71 #endif
72
73
74 /**
75 * Accumulation buffer data type:
76 */
77 #if ACCUM_BITS==8
78 typedef GLbyte GLaccum;
79 #elif ACCUM_BITS==16
80 typedef GLshort GLaccum;
81 #elif ACCUM_BITS==32
82 typedef GLfloat GLaccum;
83 #else
84 # error "illegal number of accumulation bits"
85 #endif
86
87
88 /**
89 * Stencil buffer data type:
90 */
91 #if STENCIL_BITS==8
92 typedef GLubyte GLstencil;
93 # define STENCIL_MAX 0xff
94 #elif STENCIL_BITS==16
95 typedef GLushort GLstencil;
96 # define STENCIL_MAX 0xffff
97 #else
98 # error "illegal number of stencil bits"
99 #endif
100
101
102 /**
103 * Depth buffer data type:
104 */
105 typedef GLuint GLdepth; /* Must be 32-bits! */
106
107
108 /**
109 * Fixed point data type:
110 */
111 typedef int GLfixed;
112
113
114
115 /**
116 * Some forward type declarations
117 */
118 struct _mesa_HashTable;
119 struct gl_texture_image;
120 struct gl_texture_object;
121 typedef struct __GLcontextRec GLcontext;
122 typedef struct __GLcontextModesRec GLvisual;
123 typedef struct gl_frame_buffer GLframebuffer;
124
125
126
127 /* These define the aliases between numbered vertex attributes and
128 * conventional OpenGL vertex attributes. We use these values in
129 * quite a few places. New in Mesa 4.1.
130 */
131 #define VERT_ATTRIB_POS 0
132 #define VERT_ATTRIB_WEIGHT 1
133 #define VERT_ATTRIB_NORMAL 2
134 #define VERT_ATTRIB_COLOR0 3
135 #define VERT_ATTRIB_COLOR1 4
136 #define VERT_ATTRIB_FOG 5
137 #define VERT_ATTRIB_SIX 6
138 #define VERT_ATTRIB_SEVEN 7
139 #define VERT_ATTRIB_TEX0 8
140 #define VERT_ATTRIB_TEX1 9
141 #define VERT_ATTRIB_TEX2 10
142 #define VERT_ATTRIB_TEX3 11
143 #define VERT_ATTRIB_TEX4 12
144 #define VERT_ATTRIB_TEX5 13
145 #define VERT_ATTRIB_TEX6 14
146 #define VERT_ATTRIB_TEX7 15
147 #define VERT_ATTRIB_MAX 16
148
149 /* These are used in bitfields in many places */
150 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
151 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
152 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
153 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
154 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
155 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
156 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
157 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
158 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
159 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
160 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
161 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
162 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
163 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
164 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
165 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
166
167 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
168
169
170
171 /**
172 * Maximum number of temporary vertices required for clipping. (Used
173 * in array_cache and tnl modules).
174 */
175 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
176
177
178 /* Data structure for color tables */
179 struct gl_color_table {
180 GLenum Format; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
181 GLenum IntFormat;
182 GLuint Size; /* number of entries (rows) in table */
183 GLvoid *Table; /* either GLfloat * or GLchan * */
184 GLboolean FloatTable; /* are entries stored as floats? */
185 GLubyte RedSize;
186 GLubyte GreenSize;
187 GLubyte BlueSize;
188 GLubyte AlphaSize;
189 GLubyte LuminanceSize;
190 GLubyte IntensitySize;
191 };
192
193
194 /*
195 * Bit flags used for updating material values.
196 */
197 #define FRONT_AMBIENT_BIT 0x1
198 #define BACK_AMBIENT_BIT 0x2
199 #define FRONT_DIFFUSE_BIT 0x4
200 #define BACK_DIFFUSE_BIT 0x8
201 #define FRONT_SPECULAR_BIT 0x10
202 #define BACK_SPECULAR_BIT 0x20
203 #define FRONT_EMISSION_BIT 0x40
204 #define BACK_EMISSION_BIT 0x80
205 #define FRONT_SHININESS_BIT 0x100
206 #define BACK_SHININESS_BIT 0x200
207 #define FRONT_INDEXES_BIT 0x400
208 #define BACK_INDEXES_BIT 0x800
209
210 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
211 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
212 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
213
214 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
215 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
216 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
217
218 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
219
220
221
222 /*
223 * Specular exponent and material shininess lookup table sizes:
224 */
225 #define EXP_TABLE_SIZE 512
226 #define SHINE_TABLE_SIZE 256
227
228 struct gl_shine_tab {
229 struct gl_shine_tab *next, *prev;
230 GLfloat tab[SHINE_TABLE_SIZE+1];
231 GLfloat shininess;
232 GLuint refcount;
233 };
234
235
236 struct gl_light {
237 struct gl_light *next; /* double linked list with sentinel */
238 struct gl_light *prev;
239
240 GLfloat Ambient[4]; /* ambient color */
241 GLfloat Diffuse[4]; /* diffuse color */
242 GLfloat Specular[4]; /* specular color */
243 GLfloat EyePosition[4]; /* position in eye coordinates */
244 GLfloat EyeDirection[4]; /* spotlight dir in eye coordinates */
245 GLfloat SpotExponent;
246 GLfloat SpotCutoff; /* in degress */
247 GLfloat _CosCutoff; /* = MAX(0, cos(SpotCutoff)) */
248 GLfloat ConstantAttenuation;
249 GLfloat LinearAttenuation;
250 GLfloat QuadraticAttenuation;
251 GLboolean Enabled; /* On/off flag */
252
253 /* Derived fields */
254 GLuint _Flags; /* State */
255
256 GLfloat _Position[4]; /* position in eye/obj coordinates */
257 GLfloat _VP_inf_norm[3]; /* Norm direction to infinite light */
258 GLfloat _h_inf_norm[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
259 GLfloat _NormDirection[4]; /* normalized spotlight direction */
260 GLfloat _VP_inf_spot_attenuation;
261
262 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */
263 GLfloat _MatAmbient[2][3]; /* material ambient * light ambient */
264 GLfloat _MatDiffuse[2][3]; /* material diffuse * light diffuse */
265 GLfloat _MatSpecular[2][3]; /* material spec * light specular */
266 GLfloat _dli; /* CI diffuse light intensity */
267 GLfloat _sli; /* CI specular light intensity */
268 };
269
270
271 struct gl_lightmodel {
272 GLfloat Ambient[4]; /* ambient color */
273 GLboolean LocalViewer; /* Local (or infinite) view point? */
274 GLboolean TwoSide; /* Two (or one) sided lighting? */
275 GLenum ColorControl; /* either GL_SINGLE_COLOR */
276 /* or GL_SEPARATE_SPECULAR_COLOR */
277 };
278
279
280 struct gl_material
281 {
282 GLfloat Ambient[4];
283 GLfloat Diffuse[4];
284 GLfloat Specular[4];
285 GLfloat Emission[4];
286 GLfloat Shininess;
287 GLfloat AmbientIndex; /* for color index lighting */
288 GLfloat DiffuseIndex; /* for color index lighting */
289 GLfloat SpecularIndex; /* for color index lighting */
290 };
291
292
293 /*
294 * Attribute structures:
295 * We define a struct for each attribute group to make pushing and
296 * popping attributes easy. Also it's a good organization.
297 */
298 struct gl_accum_attrib {
299 GLfloat ClearColor[4]; /* Accumulation buffer clear color */
300 };
301
302
303 /*
304 * Used in _DrawDestMask and _ReadSrcMask below to identify color buffers.
305 */
306 #define FRONT_LEFT_BIT 0x1
307 #define FRONT_RIGHT_BIT 0x2
308 #define BACK_LEFT_BIT 0x4
309 #define BACK_RIGHT_BIT 0x8
310 #define AUX0_BIT 0x10
311 #define AUX1_BIT 0x20
312 #define AUX2_BIT 0x40
313 #define AUX3_BIT 0x80
314
315 struct gl_colorbuffer_attrib {
316 GLuint ClearIndex; /* Index to use for glClear */
317 GLclampf ClearColor[4]; /* Color to use for glClear */
318
319 GLuint IndexMask; /* Color index write mask */
320 GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */
321
322 GLenum DrawBuffer; /* Which buffer to draw into */
323 GLubyte _DrawDestMask; /* bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
324
325 /* alpha testing */
326 GLboolean AlphaEnabled; /* Alpha test enabled flag */
327 GLenum AlphaFunc; /* Alpha test function */
328 GLclampf AlphaRef;
329
330 /* blending */
331 GLboolean BlendEnabled; /* Blending enabled flag */
332 GLenum BlendSrcRGB; /* Blending source operator */
333 GLenum BlendDstRGB; /* Blending destination operator */
334 GLenum BlendSrcA; /* GL_INGR_blend_func_separate */
335 GLenum BlendDstA; /* GL_INGR_blend_func_separate */
336 GLenum BlendEquation;
337 GLfloat BlendColor[4];
338
339 /* logic op */
340 GLenum LogicOp; /* Logic operator */
341 GLboolean IndexLogicOpEnabled; /* Color index logic op enabled flag */
342 GLboolean ColorLogicOpEnabled; /* RGBA logic op enabled flag */
343
344 GLboolean DitherFlag; /* Dither enable flag */
345 };
346
347
348 struct gl_current_attrib {
349 /* These values valid only when FLUSH_VERTICES has been called.
350 */
351 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /* Current vertex attributes */
352 /* indexed by VERT_ATTRIB_* */
353 GLuint Index; /* Current color index */
354 GLboolean EdgeFlag; /* Current edge flag */
355
356 /* These values are always valid. BTW, note how similar this set of
357 * attributes is to the SWvertex datatype in the software rasterizer...
358 */
359 GLfloat RasterPos[4]; /* Current raster position */
360 GLfloat RasterDistance; /* Current raster distance */
361 GLfloat RasterColor[4]; /* Current raster color */
362 GLfloat RasterSecondaryColor[4]; /* Current rast 2ndary color */
363 GLuint RasterIndex; /* Current raster index */
364 GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
365 GLboolean RasterPosValid; /* Raster pos valid flag */
366 };
367
368
369 struct gl_depthbuffer_attrib {
370 GLenum Func; /* Function for depth buffer compare */
371 GLfloat Clear; /* Value to clear depth buffer to */
372 GLboolean Test; /* Depth buffering enabled flag */
373 GLboolean Mask; /* Depth buffer writable? */
374 GLboolean OcclusionTest; /* GL_HP_occlusion_test */
375 };
376
377
378 struct gl_enable_attrib {
379 GLboolean AlphaTest;
380 GLboolean AutoNormal;
381 GLboolean Blend;
382 GLuint ClipPlanes;
383 GLboolean ColorMaterial;
384 GLboolean ColorTable; /* SGI_color_table */
385 GLboolean PostColorMatrixColorTable; /* SGI_color_table */
386 GLboolean PostConvolutionColorTable; /* SGI_color_table */
387 GLboolean Convolution1D;
388 GLboolean Convolution2D;
389 GLboolean Separable2D;
390 GLboolean CullFace;
391 GLboolean DepthTest;
392 GLboolean Dither;
393 GLboolean Fog;
394 GLboolean Histogram;
395 GLboolean Light[MAX_LIGHTS];
396 GLboolean Lighting;
397 GLboolean LineSmooth;
398 GLboolean LineStipple;
399 GLboolean IndexLogicOp;
400 GLboolean ColorLogicOp;
401 GLboolean Map1Color4;
402 GLboolean Map1Index;
403 GLboolean Map1Normal;
404 GLboolean Map1TextureCoord1;
405 GLboolean Map1TextureCoord2;
406 GLboolean Map1TextureCoord3;
407 GLboolean Map1TextureCoord4;
408 GLboolean Map1Vertex3;
409 GLboolean Map1Vertex4;
410 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
411 GLboolean Map2Color4;
412 GLboolean Map2Index;
413 GLboolean Map2Normal;
414 GLboolean Map2TextureCoord1;
415 GLboolean Map2TextureCoord2;
416 GLboolean Map2TextureCoord3;
417 GLboolean Map2TextureCoord4;
418 GLboolean Map2Vertex3;
419 GLboolean Map2Vertex4;
420 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
421 GLboolean MinMax;
422 GLboolean Normalize;
423 GLboolean PixelTexture;
424 GLboolean PointSmooth;
425 GLboolean PolygonOffsetPoint;
426 GLboolean PolygonOffsetLine;
427 GLboolean PolygonOffsetFill;
428 GLboolean PolygonSmooth;
429 GLboolean PolygonStipple;
430 GLboolean RescaleNormals;
431 GLboolean Scissor;
432 GLboolean Stencil;
433 GLboolean MultisampleEnabled; /* GL_ARB_multisample */
434 GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
435 GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
436 GLboolean SampleCoverage; /* GL_ARB_multisample */
437 GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
438 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
439 GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
440 GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
441 /* SGI_texture_color_table */
442 GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
443 /* GL_NV_vertex_program */
444 GLboolean VertexProgram;
445 GLboolean VertexProgramPointSize;
446 GLboolean VertexProgramTwoSide;
447 /* GL_NV_point_sprite */
448 GLboolean PointSprite;
449 };
450
451
452 struct gl_eval_attrib {
453 /* Enable bits */
454 GLboolean Map1Color4;
455 GLboolean Map1Index;
456 GLboolean Map1Normal;
457 GLboolean Map1TextureCoord1;
458 GLboolean Map1TextureCoord2;
459 GLboolean Map1TextureCoord3;
460 GLboolean Map1TextureCoord4;
461 GLboolean Map1Vertex3;
462 GLboolean Map1Vertex4;
463 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
464 GLboolean Map2Color4;
465 GLboolean Map2Index;
466 GLboolean Map2Normal;
467 GLboolean Map2TextureCoord1;
468 GLboolean Map2TextureCoord2;
469 GLboolean Map2TextureCoord3;
470 GLboolean Map2TextureCoord4;
471 GLboolean Map2Vertex3;
472 GLboolean Map2Vertex4;
473 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
474 GLboolean AutoNormal;
475 /* Map Grid endpoints and divisions and calculated du values */
476 GLint MapGrid1un;
477 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
478 GLint MapGrid2un, MapGrid2vn;
479 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
480 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
481 };
482
483
484 struct gl_fog_attrib {
485 GLboolean Enabled; /* Fog enabled flag */
486 GLfloat Color[4]; /* Fog color */
487 GLfloat Density; /* Density >= 0.0 */
488 GLfloat Start; /* Start distance in eye coords */
489 GLfloat End; /* End distance in eye coords */
490 GLfloat Index; /* Fog index */
491 GLenum Mode; /* Fog mode */
492 GLboolean ColorSumEnabled;
493 GLenum FogCoordinateSource; /* GL_EXT_fog_coord */
494 };
495
496
497 struct gl_hint_attrib {
498 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
499 GLenum PerspectiveCorrection;
500 GLenum PointSmooth;
501 GLenum LineSmooth;
502 GLenum PolygonSmooth;
503 GLenum Fog;
504 GLenum ClipVolumeClipping; /* GL_EXT_clip_volume_hint */
505 GLenum TextureCompression; /* GL_ARB_texture_compression */
506 GLenum GenerateMipmap; /* GL_SGIS_generate_mipmap */
507 };
508
509
510 struct gl_histogram_attrib {
511 GLuint Width; /* number of table entries */
512 GLint Format; /* GL_ALPHA, GL_RGB, etc */
513 GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /* the histogram */
514 GLboolean Sink; /* terminate image transfer? */
515 GLubyte RedSize; /* Bits per counter */
516 GLubyte GreenSize;
517 GLubyte BlueSize;
518 GLubyte AlphaSize;
519 GLubyte LuminanceSize;
520 };
521
522
523 struct gl_minmax_attrib {
524 GLenum Format;
525 GLboolean Sink;
526 GLfloat Min[4], Max[4]; /* RGBA */
527 };
528
529
530 struct gl_convolution_attrib {
531 GLenum Format;
532 GLenum InternalFormat;
533 GLuint Width;
534 GLuint Height;
535 GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
536 };
537
538
539 #define LIGHT_SPOT 0x1
540 #define LIGHT_LOCAL_VIEWER 0x2
541 #define LIGHT_POSITIONAL 0x4
542 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
543
544 struct gl_light_attrib {
545 struct gl_light Light[MAX_LIGHTS]; /* Array of lights */
546 struct gl_lightmodel Model; /* Lighting model */
547
548 /* Must flush FLUSH_VERTICES before referencing:
549 */
550 struct gl_material Material[2]; /* Material 0=front, 1=back */
551
552 GLboolean Enabled; /* Lighting enabled flag */
553 GLenum ShadeModel; /* GL_FLAT or GL_SMOOTH */
554 GLenum ColorMaterialFace; /* GL_FRONT, BACK or FRONT_AND_BACK */
555 GLenum ColorMaterialMode; /* GL_AMBIENT, GL_DIFFUSE, etc */
556 GLuint ColorMaterialBitmask; /* bitmask formed from Face and Mode */
557 GLboolean ColorMaterialEnabled;
558
559 struct gl_light EnabledList; /* List sentinel */
560
561 /* Derived for optimizations: */
562 GLboolean _NeedVertices; /* Use fast shader? */
563 GLuint _Flags; /* LIGHT_* flags, see above */
564 GLfloat _BaseColor[2][3];
565 };
566
567
568 struct gl_line_attrib {
569 GLboolean SmoothFlag; /* GL_LINE_SMOOTH enabled? */
570 GLboolean StippleFlag; /* GL_LINE_STIPPLE enabled? */
571 GLushort StipplePattern; /* Stipple pattern */
572 GLint StippleFactor; /* Stipple repeat factor */
573 GLfloat Width; /* Line width */
574 GLfloat _Width; /* Clamped Line width */
575 };
576
577
578 struct gl_list_attrib {
579 GLuint ListBase;
580 };
581
582
583 struct gl_list_opcode {
584 GLuint size;
585 void (*execute)( GLcontext *ctx, void *data );
586 void (*destroy)( GLcontext *ctx, void *data );
587 void (*print)( GLcontext *ctx, void *data );
588 };
589
590 #define GL_MAX_EXT_OPCODES 16
591
592 struct gl_list_extensions {
593 struct gl_list_opcode opcode[GL_MAX_EXT_OPCODES];
594 GLuint nr_opcodes;
595 };
596
597
598 struct gl_multisample_attrib {
599 GLboolean Enabled;
600 GLboolean SampleAlphaToCoverage;
601 GLboolean SampleAlphaToOne;
602 GLboolean SampleCoverage;
603 GLfloat SampleCoverageValue;
604 GLboolean SampleCoverageInvert;
605 };
606
607
608 struct gl_pixel_attrib {
609 GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */
610 GLubyte _ReadSrcMask; /* Not really a mask, but like _DrawDestMask */
611 /* May be: FRONT_LEFT_BIT, BACK_LEFT_BIT, */
612 /* FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
613 GLfloat RedBias, RedScale;
614 GLfloat GreenBias, GreenScale;
615 GLfloat BlueBias, BlueScale;
616 GLfloat AlphaBias, AlphaScale;
617 GLfloat DepthBias, DepthScale;
618 GLint IndexShift, IndexOffset;
619 GLboolean MapColorFlag;
620 GLboolean MapStencilFlag;
621 GLfloat ZoomX, ZoomY;
622 /* XXX move these out of gl_pixel_attrib */
623 GLint MapStoSsize; /* Size of each pixel map */
624 GLint MapItoIsize;
625 GLint MapItoRsize;
626 GLint MapItoGsize;
627 GLint MapItoBsize;
628 GLint MapItoAsize;
629 GLint MapRtoRsize;
630 GLint MapGtoGsize;
631 GLint MapBtoBsize;
632 GLint MapAtoAsize;
633 GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /* Pixel map tables */
634 GLint MapItoI[MAX_PIXEL_MAP_TABLE];
635 GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
636 GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
637 GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
638 GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
639 GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /* converted to 8-bit color */
640 GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
641 GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
642 GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
643 GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
644 GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
645 GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
646 GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
647 /* GL_EXT_histogram */
648 GLboolean HistogramEnabled;
649 GLboolean MinMaxEnabled;
650 /* GL_SGIS_pixel_texture */
651 GLboolean PixelTextureEnabled;
652 GLenum FragmentRgbSource;
653 GLenum FragmentAlphaSource;
654 /* GL_SGI_color_matrix */
655 GLfloat PostColorMatrixScale[4]; /* RGBA */
656 GLfloat PostColorMatrixBias[4]; /* RGBA */
657 /* GL_SGI_color_table */
658 GLfloat ColorTableScale[4];
659 GLfloat ColorTableBias[4];
660 GLboolean ColorTableEnabled;
661 GLfloat PCCTscale[4];
662 GLfloat PCCTbias[4];
663 GLboolean PostConvolutionColorTableEnabled;
664 GLfloat PCMCTscale[4];
665 GLfloat PCMCTbias[4];
666 GLboolean PostColorMatrixColorTableEnabled;
667 /* GL_SGI_texture_color_table */
668 GLfloat TextureColorTableScale[4];
669 GLfloat TextureColorTableBias[4];
670 /* Convolution */
671 GLboolean Convolution1DEnabled;
672 GLboolean Convolution2DEnabled;
673 GLboolean Separable2DEnabled;
674 GLfloat ConvolutionBorderColor[3][4];
675 GLenum ConvolutionBorderMode[3];
676 GLfloat ConvolutionFilterScale[3][4];
677 GLfloat ConvolutionFilterBias[3][4];
678 GLfloat PostConvolutionScale[4]; /* RGBA */
679 GLfloat PostConvolutionBias[4]; /* RGBA */
680 };
681
682
683 struct gl_point_attrib {
684 GLboolean SmoothFlag; /* True if GL_POINT_SMOOTH is enabled */
685 GLfloat Size; /* User-specified point size */
686 GLfloat _Size; /* Size clamped to Const.Min/MaxPointSize */
687 GLfloat Params[3]; /* GL_EXT_point_parameters */
688 GLfloat MinSize, MaxSize; /* GL_EXT_point_parameters */
689 GLfloat Threshold; /* GL_EXT_point_parameters */
690 GLboolean _Attenuated; /* True if Params != [1, 0, 0] */
691 GLboolean PointSprite; /* GL_NV_point_sprite */
692 GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /* GL_NV_point_sprite */
693 GLenum SpriteRMode; /* GL_NV_point_sprite */
694 };
695
696
697 struct gl_polygon_attrib {
698 GLenum FrontFace; /* Either GL_CW or GL_CCW */
699 GLenum FrontMode; /* Either GL_POINT, GL_LINE or GL_FILL */
700 GLenum BackMode; /* Either GL_POINT, GL_LINE or GL_FILL */
701 GLboolean _FrontBit; /* 0=GL_CCW, 1=GL_CW */
702 GLboolean CullFlag; /* Culling on/off flag */
703 GLboolean SmoothFlag; /* True if GL_POLYGON_SMOOTH is enabled */
704 GLboolean StippleFlag; /* True if GL_POLYGON_STIPPLE is enabled */
705 GLenum CullFaceMode; /* Culling mode GL_FRONT or GL_BACK */
706 GLfloat OffsetFactor; /* Polygon offset factor, from user */
707 GLfloat OffsetUnits; /* Polygon offset units, from user */
708 GLboolean OffsetPoint; /* Offset in GL_POINT mode */
709 GLboolean OffsetLine; /* Offset in GL_LINE mode */
710 GLboolean OffsetFill; /* Offset in GL_FILL mode */
711 };
712
713
714 struct gl_scissor_attrib {
715 GLboolean Enabled; /* Scissor test enabled? */
716 GLint X, Y; /* Lower left corner of box */
717 GLsizei Width, Height; /* Size of box */
718 };
719
720
721 struct gl_stencil_attrib {
722 GLboolean Enabled; /* Enabled flag */
723 GLboolean TestTwoSide; /* GL_EXT_stencil_two_side */
724 GLubyte ActiveFace; /* GL_EXT_stencil_two_side (0 or 1) */
725 GLenum Function[2]; /* Stencil function */
726 GLenum FailFunc[2]; /* Fail function */
727 GLenum ZPassFunc[2]; /* Depth buffer pass function */
728 GLenum ZFailFunc[2]; /* Depth buffer fail function */
729 GLstencil Ref[2]; /* Reference value */
730 GLstencil ValueMask[2]; /* Value mask */
731 GLstencil WriteMask[2]; /* Write mask */
732 GLstencil Clear; /* Clear value */
733 };
734
735
736 /* TexGenEnabled flags */
737 #define S_BIT 1
738 #define T_BIT 2
739 #define R_BIT 4
740 #define Q_BIT 8
741
742 /* Texture.Unit[]._ReallyEnabled flags: */
743 #define TEXTURE_1D_BIT 0x01
744 #define TEXTURE_2D_BIT 0x02
745 #define TEXTURE_3D_BIT 0x04
746 #define TEXTURE_CUBE_BIT 0x08
747 #define TEXTURE_RECT_BIT 0x10
748
749 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
750
751
752 /* Bitmap versions of the GL_ constants. */
753 #define TEXGEN_SPHERE_MAP 0x1
754 #define TEXGEN_OBJ_LINEAR 0x2
755 #define TEXGEN_EYE_LINEAR 0x4
756 #define TEXGEN_REFLECTION_MAP_NV 0x8
757 #define TEXGEN_NORMAL_MAP_NV 0x10
758
759 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
760 TEXGEN_REFLECTION_MAP_NV | \
761 TEXGEN_NORMAL_MAP_NV)
762 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
763 TEXGEN_REFLECTION_MAP_NV | \
764 TEXGEN_NORMAL_MAP_NV | \
765 TEXGEN_EYE_LINEAR)
766
767
768
769 /* A selection of state flags to make driver and module's lives easier. */
770 #define ENABLE_TEXGEN0 0x1
771 #define ENABLE_TEXGEN1 0x2
772 #define ENABLE_TEXGEN2 0x4
773 #define ENABLE_TEXGEN3 0x8
774 #define ENABLE_TEXGEN4 0x10
775 #define ENABLE_TEXGEN5 0x20
776 #define ENABLE_TEXGEN6 0x40
777 #define ENABLE_TEXGEN7 0x80
778
779 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
780 #define ENABLE_TEXMAT1 0x2
781 #define ENABLE_TEXMAT2 0x4
782 #define ENABLE_TEXMAT3 0x8
783 #define ENABLE_TEXMAT4 0x10
784 #define ENABLE_TEXMAT5 0x20
785 #define ENABLE_TEXMAT6 0x40
786 #define ENABLE_TEXMAT7 0x80
787
788 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
789 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
790
791 /*
792 * If teximage is color-index, texelOut returns GLchan[1].
793 * If teximage is depth, texelOut returns GLfloat[1].
794 * Otherwise, texelOut returns GLchan[4].
795 */
796 typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage,
797 GLint col, GLint row, GLint img,
798 GLvoid *texelOut );
799
800 /* Texture format record */
801 struct gl_texture_format {
802 GLint MesaFormat; /* One of the MESA_FORMAT_* values */
803
804 GLenum BaseFormat; /* Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
805 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
806 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
807 */
808 GLubyte RedBits; /* Bits per texel component */
809 GLubyte GreenBits; /* These are just rough approximations for */
810 GLubyte BlueBits; /* compressed texture formats. */
811 GLubyte AlphaBits;
812 GLubyte LuminanceBits;
813 GLubyte IntensityBits;
814 GLubyte IndexBits;
815 GLubyte DepthBits;
816
817 GLint TexelBytes; /* Bytes per texel (0 for compressed formats */
818
819 FetchTexelFunc FetchTexel1D; /* Texel fetch function pointers */
820 FetchTexelFunc FetchTexel2D;
821 FetchTexelFunc FetchTexel3D;
822 };
823
824
825 /* Texture image record */
826 struct gl_texture_image {
827 GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
828 * GL_INTENSITY, GL_RGB, GL_RGBA,
829 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
830 * Used for choosing TexEnv arithmetic.
831 */
832 GLint IntFormat; /* Internal format as given by the user */
833 GLuint Border; /* 0 or 1 */
834 GLuint Width; /* = 2^WidthLog2 + 2*Border */
835 GLuint Height; /* = 2^HeightLog2 + 2*Border */
836 GLuint Depth; /* = 2^DepthLog2 + 2*Border */
837 GLuint RowStride; /* == Width unless IsClientData and padded */
838 GLuint Width2; /* = Width - 2*Border */
839 GLuint Height2; /* = Height - 2*Border */
840 GLuint Depth2; /* = Depth - 2*Border */
841 GLuint WidthLog2; /* = log2(Width2) */
842 GLuint HeightLog2; /* = log2(Height2) */
843 GLuint DepthLog2; /* = log2(Depth2) */
844 GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */
845 GLfloat WidthScale; /* used for mipmap lod computation */
846 GLfloat HeightScale; /* used for mipmap lod computation */
847 GLfloat DepthScale; /* used for mipmap lod computation */
848 GLvoid *Data; /* Image data, accessed via FetchTexel() */
849 GLboolean IsClientData; /* Data owned by client? */
850
851
852 const struct gl_texture_format *TexFormat;
853
854 FetchTexelFunc FetchTexel; /* Texel fetch function pointer */
855
856 GLboolean IsCompressed; /* GL_ARB_texture_compression */
857 GLuint CompressedSize; /* GL_ARB_texture_compression */
858
859 /* For device driver: */
860 void *DriverData; /* Arbitrary device driver data */
861 };
862
863
864 /* Texture object record */
865 struct gl_texture_object {
866 _glthread_Mutex Mutex; /* for thread safety */
867 GLint RefCount; /* reference count */
868 GLuint Name; /* an unsigned integer */
869 GLenum Target; /* GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
870 GLfloat Priority; /* in [0,1] */
871 GLfloat BorderColor[4]; /* unclamped */
872 GLchan _BorderChan[4]; /* clamped, as GLchan */
873 GLenum WrapS; /* Wrap modes are: GL_CLAMP, REPEAT */
874 GLenum WrapT; /* GL_CLAMP_TO_EDGE, and */
875 GLenum WrapR; /* GL_CLAMP_TO_BORDER_ARB */
876 GLenum MinFilter; /* minification filter */
877 GLenum MagFilter; /* magnification filter */
878 GLfloat MinLod; /* min lambda, OpenGL 1.2 */
879 GLfloat MaxLod; /* max lambda, OpenGL 1.2 */
880 GLint BaseLevel; /* min mipmap level, OpenGL 1.2 */
881 GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */
882 GLfloat MaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
883 GLboolean CompareFlag; /* GL_SGIX_shadow */
884 GLenum CompareOperator; /* GL_SGIX_shadow */
885 GLfloat ShadowAmbient;
886 GLenum CompareMode; /* GL_ARB_shadow */
887 GLenum CompareFunc; /* GL_ARB_shadow */
888 GLenum DepthMode; /* GL_ARB_depth_texture */
889 GLint _MaxLevel; /* actual max mipmap level (q in the spec) */
890 GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */
891 GLboolean GenerateMipmap; /* GL_SGIS_generate_mipmap */
892
893 struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
894
895 /* Texture cube faces */
896 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
897 struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS];
898 struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS];
899 struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS];
900 struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS];
901 struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS];
902
903 /* GL_EXT_paletted_texture */
904 struct gl_color_table Palette;
905
906 GLboolean Complete; /* Is texture object complete? */
907 struct gl_texture_object *Next; /* Next in linked list */
908
909 /* For device driver: */
910 void *DriverData; /* Arbitrary device driver data */
911 };
912
913
914 /* Texture unit record */
915 struct gl_texture_unit {
916 GLuint Enabled; /* bitmask of TEXTURE_*_BIT flags */
917 GLuint _ReallyEnabled; /* 0 or exactly one of TEXTURE_*_BIT flags */
918
919 GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
920 GLfloat EnvColor[4];
921 GLuint TexGenEnabled; /* Bitwise-OR of [STRQ]_BIT values */
922 GLenum GenModeS; /* Tex coord generation mode, either */
923 GLenum GenModeT; /* GL_OBJECT_LINEAR, or */
924 GLenum GenModeR; /* GL_EYE_LINEAR, or */
925 GLenum GenModeQ; /* GL_SPHERE_MAP */
926 GLuint _GenBitS;
927 GLuint _GenBitT;
928 GLuint _GenBitR;
929 GLuint _GenBitQ;
930 GLuint _GenFlags; /* bitwise or of GenBit[STRQ] */
931 GLfloat ObjectPlaneS[4];
932 GLfloat ObjectPlaneT[4];
933 GLfloat ObjectPlaneR[4];
934 GLfloat ObjectPlaneQ[4];
935 GLfloat EyePlaneS[4];
936 GLfloat EyePlaneT[4];
937 GLfloat EyePlaneR[4];
938 GLfloat EyePlaneQ[4];
939 GLfloat LodBias; /* for biasing mipmap levels */
940
941 /* GL_EXT_texture_env_combine */
942 GLenum CombineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
943 GLenum CombineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
944 GLenum CombineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
945 GLenum CombineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
946 GLenum CombineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
947 GLenum CombineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
948 GLuint CombineScaleShiftRGB; /* 0, 1 or 2 */
949 GLuint CombineScaleShiftA; /* 0, 1 or 2 */
950
951 struct gl_texture_object *Current1D;
952 struct gl_texture_object *Current2D;
953 struct gl_texture_object *Current3D;
954 struct gl_texture_object *CurrentCubeMap; /* GL_ARB_texture_cube_map */
955 struct gl_texture_object *CurrentRect; /* GL_NV_texture_rectangle */
956
957 struct gl_texture_object *_Current; /* Points to really enabled tex obj */
958
959 struct gl_texture_object Saved1D; /* only used by glPush/PopAttrib */
960 struct gl_texture_object Saved2D;
961 struct gl_texture_object Saved3D;
962 struct gl_texture_object SavedCubeMap;
963 struct gl_texture_object SavedRect;
964
965 /* GL_SGI_texture_color_table */
966 struct gl_color_table ColorTable;
967 struct gl_color_table ProxyColorTable;
968 GLboolean ColorTableEnabled;
969 };
970
971
972 /* The texture attribute group */
973 struct gl_texture_attrib {
974 /* multitexture */
975 GLuint CurrentUnit; /* Active texture unit */
976
977 GLuint _EnabledUnits; /* one bit set for each really-enabled unit */
978 GLuint _GenFlags; /* for texgen */
979 GLuint _TexGenEnabled;
980 GLuint _TexMatEnabled;
981
982 struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
983
984 struct gl_texture_object *Proxy1D;
985 struct gl_texture_object *Proxy2D;
986 struct gl_texture_object *Proxy3D;
987 struct gl_texture_object *ProxyCubeMap;
988 struct gl_texture_object *ProxyRect;
989
990 /* GL_EXT_shared_texture_palette */
991 GLboolean SharedPalette;
992 struct gl_color_table Palette;
993 };
994
995
996 struct gl_transform_attrib {
997 GLenum MatrixMode; /* Matrix mode */
998 GLfloat EyeUserPlane[MAX_CLIP_PLANES][4];
999 GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /* derived */
1000 GLuint ClipPlanesEnabled; /* on/off bitmask */
1001 GLboolean Normalize; /* Normalize all normals? */
1002 GLboolean RescaleNormals; /* GL_EXT_rescale_normal */
1003 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
1004 };
1005
1006
1007 struct gl_viewport_attrib {
1008 GLint X, Y; /* position */
1009 GLsizei Width, Height; /* size */
1010 GLfloat Near, Far; /* Depth buffer range */
1011 GLmatrix _WindowMap; /* Mapping transformation as a matrix. */
1012 };
1013
1014
1015 /* For the attribute stack: */
1016 struct gl_attrib_node {
1017 GLbitfield kind;
1018 void *data;
1019 struct gl_attrib_node *next;
1020 };
1021
1022
1023 /*
1024 * Client pixel packing/unpacking attributes
1025 */
1026 struct gl_pixelstore_attrib {
1027 GLint Alignment;
1028 GLint RowLength;
1029 GLint SkipPixels;
1030 GLint SkipRows;
1031 GLint ImageHeight; /* for GL_EXT_texture3D */
1032 GLint SkipImages; /* for GL_EXT_texture3D */
1033 GLboolean SwapBytes;
1034 GLboolean LsbFirst;
1035 GLboolean ClientStorage; /* GL_APPLE_client_storage */
1036 GLboolean Invert; /* GL_MESA_pack_invert */
1037 };
1038
1039
1040 #define CA_CLIENT_DATA 0x1 /* Data not alloced by mesa */
1041
1042
1043 /*
1044 * Client vertex array attributes
1045 */
1046 struct gl_client_array {
1047 GLint Size;
1048 GLenum Type;
1049 GLsizei Stride; /* user-specified stride */
1050 GLsizei StrideB; /* actual stride in bytes */
1051 void *Ptr;
1052 GLuint Flags;
1053 GLuint Enabled; /* one of the _NEW_ARRAY_ bits */
1054 };
1055
1056
1057 struct gl_array_attrib {
1058 struct gl_client_array Vertex; /* client data descriptors */
1059 struct gl_client_array Normal;
1060 struct gl_client_array Color;
1061 struct gl_client_array SecondaryColor;
1062 struct gl_client_array FogCoord;
1063 struct gl_client_array Index;
1064 struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
1065 struct gl_client_array EdgeFlag;
1066
1067 struct gl_client_array VertexAttrib[16]; /* GL_NV_vertex_program */
1068
1069 GLint TexCoordInterleaveFactor;
1070 GLint ActiveTexture; /* Client Active Texture */
1071 GLuint LockFirst;
1072 GLuint LockCount;
1073
1074 GLuint _Enabled; /* _NEW_ARRAY_* - bit set if array enabled */
1075 GLuint NewState; /* _NEW_ARRAY_* */
1076 };
1077
1078
1079 struct gl_feedback {
1080 GLenum Type;
1081 GLuint _Mask; /* FB_* bits */
1082 GLfloat *Buffer;
1083 GLuint BufferSize;
1084 GLuint Count;
1085 };
1086
1087
1088 struct gl_selection {
1089 GLuint *Buffer;
1090 GLuint BufferSize; /* size of SelectBuffer */
1091 GLuint BufferCount; /* number of values in SelectBuffer */
1092 GLuint Hits; /* number of records in SelectBuffer */
1093 GLuint NameStackDepth;
1094 GLuint NameStack[MAX_NAME_STACK_DEPTH];
1095 GLboolean HitFlag;
1096 GLfloat HitMinZ, HitMaxZ;
1097 };
1098
1099
1100 /*
1101 * 1-D Evaluator control points
1102 */
1103 struct gl_1d_map {
1104 GLuint Order; /* Number of control points */
1105 GLfloat u1, u2, du; /* u1, u2, 1.0/(u2-u1) */
1106 GLfloat *Points; /* Points to contiguous control points */
1107 };
1108
1109
1110 /*
1111 * 2-D Evaluator control points
1112 */
1113 struct gl_2d_map {
1114 GLuint Uorder; /* Number of control points in U dimension */
1115 GLuint Vorder; /* Number of control points in V dimension */
1116 GLfloat u1, u2, du;
1117 GLfloat v1, v2, dv;
1118 GLfloat *Points; /* Points to contiguous control points */
1119 };
1120
1121
1122 /*
1123 * All evalutator control points
1124 */
1125 struct gl_evaluators {
1126 /* 1-D maps */
1127 struct gl_1d_map Map1Vertex3;
1128 struct gl_1d_map Map1Vertex4;
1129 struct gl_1d_map Map1Index;
1130 struct gl_1d_map Map1Color4;
1131 struct gl_1d_map Map1Normal;
1132 struct gl_1d_map Map1Texture1;
1133 struct gl_1d_map Map1Texture2;
1134 struct gl_1d_map Map1Texture3;
1135 struct gl_1d_map Map1Texture4;
1136 struct gl_1d_map Map1Attrib[16]; /* GL_NV_vertex_program */
1137
1138 /* 2-D maps */
1139 struct gl_2d_map Map2Vertex3;
1140 struct gl_2d_map Map2Vertex4;
1141 struct gl_2d_map Map2Index;
1142 struct gl_2d_map Map2Color4;
1143 struct gl_2d_map Map2Normal;
1144 struct gl_2d_map Map2Texture1;
1145 struct gl_2d_map Map2Texture2;
1146 struct gl_2d_map Map2Texture3;
1147 struct gl_2d_map Map2Texture4;
1148 struct gl_2d_map Map2Attrib[16]; /* GL_NV_vertex_program */
1149 };
1150
1151
1152
1153 /* NV_vertex_program runtime state */
1154 struct vp_machine
1155 {
1156 GLfloat Registers[MAX_NV_VERTEX_PROGRAM_TEMPS
1157 + MAX_NV_VERTEX_PROGRAM_PARAMS
1158 + MAX_NV_VERTEX_PROGRAM_INPUTS
1159 + MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
1160 GLint AddressReg; /* might someday be a 4-vector */
1161 };
1162
1163
1164 /* NV_fragment_program runtime state */
1165 struct fp_machine
1166 {
1167 GLfloat Registers[MAX_NV_FRAGMENT_PROGRAM_TEMPS
1168 + MAX_NV_FRAGMENT_PROGRAM_PARAMS
1169 + MAX_NV_FRAGMENT_PROGRAM_INPUTS
1170 + MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
1171 + MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS][4];
1172 GLuint CondCodes[4];
1173 };
1174
1175
1176 /* Vertex and fragment instructions */
1177 struct vp_instruction;
1178 struct fp_instruction;
1179
1180 struct symbol_table
1181 {
1182 struct symbol *Head;
1183 };
1184
1185
1186 /* Base class for any kind of program object */
1187 struct program
1188 {
1189 GLuint Id;
1190 GLubyte *String; /* Null-terminated program text */
1191 GLenum Target;
1192 GLint RefCount;
1193 GLboolean Resident;
1194 };
1195
1196
1197 /* Vertex program object */
1198 struct vertex_program
1199 {
1200 struct program Base; /* base class */
1201 struct vp_instruction *Instructions; /* Compiled instructions */
1202 GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
1203 GLuint InputsRead; /* Bitmask of which input regs are read */
1204 GLuint OutputsWritten; /* Bitmask of which output regs are written to */
1205 };
1206
1207
1208 /* Fragment program object */
1209 struct fragment_program
1210 {
1211 struct program Base; /* base class */
1212 struct fp_instruction *Instructions; /* Compiled instructions */
1213 GLuint InputsRead; /* Bitmask of which input regs are read */
1214 GLuint OutputsWritten; /* Bitmask of which output regs are written to */
1215 GLfloat LocalParams[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4];
1216 struct symbol_table SymbolTable;
1217 };
1218
1219
1220 /*
1221 * State common to vertex and fragment programs.
1222 */
1223 struct program_state {
1224 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_NV */
1225 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_NV */
1226 };
1227
1228
1229 /*
1230 * State for GL_NV_vertex_program
1231 */
1232 struct vertex_program_state
1233 {
1234 GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
1235 GLboolean PointSizeEnabled; /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1236 GLboolean TwoSideEnabled; /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1237 struct vertex_program *Current; /* ptr to currently bound program */
1238 struct vp_machine Machine; /* machine state */
1239
1240 GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1241 GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
1242 };
1243
1244
1245 /*
1246 * State for GL_NV_fragment_program
1247 */
1248 struct fragment_program_state
1249 {
1250 GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
1251 struct fragment_program *Current; /* ptr to currently bound program */
1252 struct fp_machine Machine; /* machine state */
1253 };
1254
1255
1256 /*
1257 * State which can be shared by multiple contexts:
1258 */
1259 struct gl_shared_state {
1260 _glthread_Mutex Mutex; /* for thread safety */
1261 GLint RefCount; /* Reference count */
1262 struct _mesa_HashTable *DisplayList; /* Display lists hash table */
1263 struct _mesa_HashTable *TexObjects; /* Texture objects hash table */
1264 struct gl_texture_object *TexObjectList;/* Linked list of texture objects */
1265
1266 /* Default texture objects (shared by all multi-texture units) */
1267 struct gl_texture_object *Default1D;
1268 struct gl_texture_object *Default2D;
1269 struct gl_texture_object *Default3D;
1270 struct gl_texture_object *DefaultCubeMap;
1271 struct gl_texture_object *DefaultRect;
1272
1273 /* GL_NV_vertex/_program */
1274 struct _mesa_HashTable *Programs;
1275
1276 void *DriverData; /* Device driver shared state */
1277 };
1278
1279
1280 /*
1281 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1282 * depth, accum, stencil, and software-simulated alpha buffers.
1283 * In C++ terms, think of this as a base class from which device drivers
1284 * will make derived classes.
1285 */
1286 struct gl_frame_buffer {
1287 GLvisual Visual; /* The corresponding visual */
1288
1289 GLuint Width, Height; /* size of frame buffer in pixels */
1290
1291 GLboolean UseSoftwareDepthBuffer;
1292 GLboolean UseSoftwareAccumBuffer;
1293 GLboolean UseSoftwareStencilBuffer;
1294 GLboolean UseSoftwareAlphaBuffers;
1295
1296 /* Software depth (aka Z) buffer */
1297 GLvoid *DepthBuffer; /* array [Width*Height] of GLushort or GLuint*/
1298
1299 /* Software stencil buffer */
1300 GLstencil *Stencil; /* array [Width*Height] of GLstencil values */
1301
1302 /* Software accumulation buffer */
1303 GLaccum *Accum; /* array [4*Width*Height] of GLaccum values */
1304
1305 /* Software alpha planes */
1306 GLvoid *FrontLeftAlpha; /* array [Width*Height] of GLubyte */
1307 GLvoid *BackLeftAlpha; /* array [Width*Height] of GLubyte */
1308 GLvoid *FrontRightAlpha; /* array [Width*Height] of GLubyte */
1309 GLvoid *BackRightAlpha; /* array [Width*Height] of GLubyte */
1310
1311 /* Drawing bounds: intersection of window size and scissor box */
1312 GLint _Xmin, _Ymin; /* inclusive */
1313 GLint _Xmax, _Ymax; /* exclusive */
1314 };
1315
1316
1317 /*
1318 * Constants which may be overriden by device driver during context creation
1319 * but are never changed after that.
1320 */
1321 struct gl_constants {
1322 GLint MaxTextureLevels;
1323 GLint Max3DTextureLevels;
1324 GLint MaxCubeTextureLevels; /* GL_ARB_texture_cube_map */
1325 GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
1326 GLuint MaxTextureUnits;
1327 GLuint MaxTextureCoordUnits;
1328 GLuint MaxTextureImageUnits;
1329 GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
1330 GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
1331 GLuint MaxArrayLockSize;
1332 GLint SubPixelBits;
1333 GLfloat MinPointSize, MaxPointSize; /* aliased */
1334 GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
1335 GLfloat PointSizeGranularity;
1336 GLfloat MinLineWidth, MaxLineWidth; /* aliased */
1337 GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
1338 GLfloat LineWidthGranularity;
1339 GLuint NumAuxBuffers;
1340 GLuint MaxColorTableSize;
1341 GLuint MaxConvolutionWidth;
1342 GLuint MaxConvolutionHeight;
1343 GLuint MaxClipPlanes;
1344 GLuint MaxLights;
1345 };
1346
1347
1348 /*
1349 * List of extensions.
1350 */
1351 struct extension;
1352 struct gl_extensions {
1353 char *ext_string;
1354 struct extension *ext_list;
1355 /* Flags to quickly test if certain extensions are available.
1356 * Not every extension needs to have such a flag, but it's encouraged.
1357 */
1358 GLboolean ARB_depth_texture;
1359 GLboolean ARB_imaging;
1360 GLboolean ARB_multisample;
1361 GLboolean ARB_multitexture;
1362 GLboolean ARB_shadow;
1363 GLboolean ARB_texture_border_clamp;
1364 GLboolean ARB_texture_compression;
1365 GLboolean ARB_texture_cube_map;
1366 GLboolean ARB_texture_env_combine;
1367 GLboolean ARB_texture_env_crossbar;
1368 GLboolean ARB_texture_env_dot3;
1369 GLboolean ARB_texture_mirrored_repeat;
1370 GLboolean ARB_window_pos;
1371 GLboolean ATI_texture_mirror_once;
1372 GLboolean ATI_texture_env_combine3;
1373 GLboolean EXT_blend_color;
1374 GLboolean EXT_blend_func_separate;
1375 GLboolean EXT_blend_logic_op;
1376 GLboolean EXT_blend_minmax;
1377 GLboolean EXT_blend_subtract;
1378 GLboolean EXT_clip_volume_hint;
1379 GLboolean EXT_convolution;
1380 GLboolean EXT_compiled_vertex_array;
1381 GLboolean EXT_fog_coord;
1382 GLboolean EXT_histogram;
1383 GLboolean EXT_multi_draw_arrays;
1384 GLboolean EXT_packed_pixels;
1385 GLboolean EXT_paletted_texture;
1386 GLboolean EXT_point_parameters;
1387 GLboolean EXT_polygon_offset;
1388 GLboolean EXT_rescale_normal;
1389 GLboolean EXT_shadow_funcs;
1390 GLboolean EXT_secondary_color;
1391 GLboolean EXT_shared_texture_palette;
1392 GLboolean EXT_stencil_wrap;
1393 GLboolean EXT_stencil_two_side;
1394 GLboolean EXT_texture3D;
1395 GLboolean EXT_texture_compression_s3tc;
1396 GLboolean EXT_texture_env_add;
1397 GLboolean EXT_texture_env_combine;
1398 GLboolean EXT_texture_env_dot3;
1399 GLboolean EXT_texture_filter_anisotropic;
1400 GLboolean EXT_texture_object;
1401 GLboolean EXT_texture_lod_bias;
1402 GLboolean EXT_vertex_array_set;
1403 GLboolean HP_occlusion_test;
1404 GLboolean IBM_rasterpos_clip;
1405 GLboolean INGR_blend_func_separate;
1406 GLboolean MESA_pack_invert;
1407 GLboolean MESA_window_pos;
1408 GLboolean MESA_resize_buffers;
1409 GLboolean MESA_ycbcr_texture;
1410 GLboolean NV_blend_square;
1411 GLboolean NV_fragment_program;
1412 GLboolean NV_point_sprite;
1413 GLboolean NV_texture_rectangle;
1414 GLboolean NV_texgen_reflection;
1415 GLboolean NV_vertex_program;
1416 GLboolean NV_vertex_program1_1;
1417 GLboolean SGI_color_matrix;
1418 GLboolean SGI_color_table;
1419 GLboolean SGI_texture_color_table;
1420 GLboolean SGIS_generate_mipmap;
1421 GLboolean SGIS_pixel_texture;
1422 GLboolean SGIS_texture_edge_clamp;
1423 GLboolean SGIX_depth_texture;
1424 GLboolean SGIX_pixel_texture;
1425 GLboolean SGIX_shadow;
1426 GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
1427 GLboolean TDFX_texture_compression_FXT1;
1428 GLboolean APPLE_client_storage;
1429 };
1430
1431
1432 /*
1433 * A stack of matrices (projection, modelview, color, texture, etc).
1434 */
1435 struct matrix_stack
1436 {
1437 GLmatrix *Top; /* points into Stack */
1438 GLmatrix *Stack; /* array [MaxDepth] of GLmatrix */
1439 GLuint Depth; /* 0 <= Depth < MaxDepth */
1440 GLuint MaxDepth; /* size of Stack[] array */
1441 GLuint DirtyFlag; /* _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1442 };
1443
1444
1445 /*
1446 * Bits for image transfer operations (ctx->ImageTransferState).
1447 */
1448 #define IMAGE_SCALE_BIAS_BIT 0x1
1449 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1450 #define IMAGE_MAP_COLOR_BIT 0x4
1451 #define IMAGE_COLOR_TABLE_BIT 0x8
1452 #define IMAGE_CONVOLUTION_BIT 0x10
1453 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1454 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1455 #define IMAGE_COLOR_MATRIX_BIT 0x80
1456 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1457 #define IMAGE_HISTOGRAM_BIT 0x200
1458 #define IMAGE_MIN_MAX_BIT 0x400
1459
1460 /* transfer ops up to convolution: */
1461 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1462 IMAGE_SHIFT_OFFSET_BIT | \
1463 IMAGE_MAP_COLOR_BIT | \
1464 IMAGE_COLOR_TABLE_BIT)
1465
1466 /* transfer ops after convolution: */
1467 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1468 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1469 IMAGE_COLOR_MATRIX_BIT | \
1470 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1471 IMAGE_HISTOGRAM_BIT | \
1472 IMAGE_MIN_MAX_BIT)
1473
1474
1475 /*
1476 * Bits to indicate what state has changed. 6 unused flags.
1477 */
1478 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1479 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1480 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1481 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1482 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1483 #define _NEW_COLOR 0x20 /* ctx->Color */
1484 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1485 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1486 #define _NEW_FOG 0x100 /* ctx->Fog */
1487 #define _NEW_HINT 0x200 /* ctx->Hint */
1488 #define _NEW_LIGHT 0x400 /* ctx->Light */
1489 #define _NEW_LINE 0x800 /* ctx->Line */
1490 #define _NEW_PIXEL 0x1000 /* ctx->Pixel */
1491 #define _NEW_POINT 0x2000 /* ctx->Point */
1492 #define _NEW_POLYGON 0x4000 /* ctx->Polygon */
1493 #define _NEW_POLYGONSTIPPLE 0x8000 /* ctx->PolygonStipple */
1494 #define _NEW_SCISSOR 0x10000 /* ctx->Scissor */
1495 #define _NEW_STENCIL 0x20000 /* ctx->Stencil */
1496 #define _NEW_TEXTURE 0x40000 /* ctx->Texture */
1497 #define _NEW_TRANSFORM 0x80000 /* ctx->Transform */
1498 #define _NEW_VIEWPORT 0x100000 /* ctx->Viewport */
1499 #define _NEW_PACKUNPACK 0x200000 /* ctx->Pack, ctx->Unpack */
1500 #define _NEW_ARRAY 0x400000 /* ctx->Array */
1501 #define _NEW_RENDERMODE 0x800000 /* RenderMode, Feedback, Select */
1502 #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
1503 #define _NEW_MULTISAMPLE 0x2000000 /* ctx->Multisample */
1504 #define _NEW_TRACK_MATRIX 0x4000000 /* ctx->VertexProgram */
1505 #define _NEW_PROGRAM 0x8000000 /* ctx->VertexProgram */
1506 #define _NEW_ALL ~0
1507
1508
1509
1510 /* Bits to track array state changes (also used to summarize array enabled)
1511 */
1512 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1513 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1514 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1515 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1516 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1517 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1518 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1519 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1520 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1521 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1522 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1523 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1524 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1525 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1526 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1527 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1528 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
1529 #define _NEW_ARRAY_ALL 0xffffffff
1530
1531
1532 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1533 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1534
1535
1536 /* A bunch of flags that we think might be useful to drivers.
1537 * Set in the ctx->_TriangleCaps bitfield.
1538 */
1539 #define DD_FLATSHADE 0x1
1540 #define DD_SEPARATE_SPECULAR 0x2
1541 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1542 #define DD_TRI_LIGHT_TWOSIDE 0x8
1543 #define DD_TRI_UNFILLED 0x10
1544 #define DD_TRI_SMOOTH 0x20
1545 #define DD_TRI_STIPPLE 0x40
1546 #define DD_TRI_OFFSET 0x80
1547 #define DD_LINE_SMOOTH 0x100
1548 #define DD_LINE_STIPPLE 0x200
1549 #define DD_LINE_WIDTH 0x400
1550 #define DD_POINT_SMOOTH 0x800
1551 #define DD_POINT_SIZE 0x1000
1552 #define DD_POINT_ATTEN 0x2000
1553
1554
1555 /* Define the state changes under which each of these bits might change
1556 */
1557 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1558 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1559 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1560 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1561 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1562 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1563 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1564 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1565 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1566 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1567 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1568 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1569 #define _DD_NEW_POINT_SIZE _NEW_POINT
1570 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1571
1572 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1573 _NEW_TEXTURE | \
1574 _NEW_POINT | \
1575 _NEW_MODELVIEW)
1576
1577 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1578 _NEW_TEXTURE)
1579
1580 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1581
1582
1583 /* Bits for ctx->_NeedNormals */
1584 #define NEED_NORMALS_TEXGEN 0x1
1585 #define NEED_NORMALS_LIGHT 0x2
1586
1587 /* Bits for ctx->_NeedEyeCoords */
1588 #define NEED_EYE_TEXGEN 0x1
1589 #define NEED_EYE_LIGHT 0x2
1590 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1591 #define NEED_EYE_POINT_ATTEN 0x8
1592 #define NEED_EYE_DRIVER 0x10
1593
1594
1595 /*
1596 * Forward declaration of display list datatypes:
1597 */
1598 union node;
1599 typedef union node Node;
1600
1601
1602 /* This has to be included here. */
1603 #include "dd.h"
1604
1605
1606 /*
1607 * Core Mesa's support for tnl modules:
1608 */
1609 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1610
1611 struct gl_tnl_module {
1612 /* Vertex format to be lazily swapped into current dispatch.
1613 */
1614 GLvertexformat *Current;
1615
1616 /* Record of functions swapped out. On restore, only need to swap
1617 * these functions back in.
1618 */
1619 void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
1620 GLuint SwapCount;
1621 };
1622
1623
1624 /**
1625 * This is the central context data structure for Mesa. Almost all
1626 * OpenGL state is contained in this structure.
1627 * Think of this as a base class from which device drivers will derive
1628 * sub classes.
1629 */
1630 struct __GLcontextRec {
1631 /**
1632 * OS related interfaces; these *must* be the first members of this
1633 * structure, because they are exposed to the outside world (i.e. GLX
1634 * extension).
1635 */
1636 __GLimports imports;
1637 __GLexports exports;
1638
1639 /* State possibly shared with other contexts in the address space */
1640 struct gl_shared_state *Shared;
1641
1642 /* API function pointer tables */
1643 struct _glapi_table *Save; /**< Display list save funcs */
1644 struct _glapi_table *Exec; /**< Execute funcs */
1645 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
1646
1647 GLboolean ExecPrefersFloat; /**< What preference for color conversion? */
1648 GLboolean SavePrefersFloat;
1649
1650 GLvisual Visual;
1651 GLframebuffer *DrawBuffer; /**< buffer for writing */
1652 GLframebuffer *ReadBuffer; /**< buffer for reading */
1653
1654 /**
1655 * Device driver function pointer table
1656 */
1657 struct dd_function_table Driver;
1658
1659 void *DriverCtx; /**< Points to device driver context/state */
1660 void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
1661
1662 /* Core/Driver constants */
1663 struct gl_constants Const;
1664
1665 /* The various 4x4 matrix stacks */
1666 struct matrix_stack ModelviewMatrixStack;
1667 struct matrix_stack ProjectionMatrixStack;
1668 struct matrix_stack ColorMatrixStack;
1669 struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
1670 struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
1671 struct matrix_stack *CurrentStack; /* Points to one of the above stacks */
1672
1673 /* Combined modelview and projection matrix */
1674 GLmatrix _ModelProjectMatrix;
1675
1676 /* Display lists */
1677 GLuint CallDepth; /* Current recursion calling depth */
1678 GLboolean ExecuteFlag; /* Execute GL commands? */
1679 GLboolean CompileFlag; /* Compile GL commands into display list? */
1680 Node *CurrentListPtr; /* Head of list being compiled */
1681 GLuint CurrentListNum; /* Number of the list being compiled */
1682 Node *CurrentBlock; /* Pointer to current block of nodes */
1683 GLuint CurrentPos; /* Index into current block of nodes */
1684
1685 /* Extensions */
1686 struct gl_extensions Extensions;
1687
1688 /* Renderer attribute stack */
1689 GLuint AttribStackDepth;
1690 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
1691
1692 /* Renderer attribute groups */
1693 struct gl_accum_attrib Accum;
1694 struct gl_colorbuffer_attrib Color;
1695 struct gl_current_attrib Current;
1696 struct gl_depthbuffer_attrib Depth;
1697 struct gl_eval_attrib Eval;
1698 struct gl_fog_attrib Fog;
1699 struct gl_hint_attrib Hint;
1700 struct gl_light_attrib Light;
1701 struct gl_line_attrib Line;
1702 struct gl_list_attrib List;
1703 struct gl_multisample_attrib Multisample;
1704 struct gl_pixel_attrib Pixel;
1705 struct gl_point_attrib Point;
1706 struct gl_polygon_attrib Polygon;
1707 GLuint PolygonStipple[32];
1708 struct gl_scissor_attrib Scissor;
1709 struct gl_stencil_attrib Stencil;
1710 struct gl_texture_attrib Texture;
1711 struct gl_transform_attrib Transform;
1712 struct gl_viewport_attrib Viewport;
1713
1714 /* Other attribute groups */
1715 struct gl_histogram_attrib Histogram;
1716 struct gl_minmax_attrib MinMax;
1717 struct gl_convolution_attrib Convolution1D;
1718 struct gl_convolution_attrib Convolution2D;
1719 struct gl_convolution_attrib Separable2D;
1720
1721 /* Client attribute stack */
1722 GLuint ClientAttribStackDepth;
1723 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
1724
1725 /* Client attribute groups */
1726 struct gl_array_attrib Array; /* Vertex arrays */
1727 struct gl_pixelstore_attrib Pack; /* Pixel packing */
1728 struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */
1729
1730 struct gl_evaluators EvalMap; /* All evaluators */
1731 struct gl_feedback Feedback; /* Feedback */
1732 struct gl_selection Select; /* Selection */
1733
1734 struct gl_color_table ColorTable; /* Pre-convolution */
1735 struct gl_color_table ProxyColorTable; /* Pre-convolution */
1736 struct gl_color_table PostConvolutionColorTable;
1737 struct gl_color_table ProxyPostConvolutionColorTable;
1738 struct gl_color_table PostColorMatrixColorTable;
1739 struct gl_color_table ProxyPostColorMatrixColorTable;
1740
1741 struct program_state Program; /* for vertex or fragment progs */
1742 struct vertex_program_state VertexProgram; /* GL_NV_vertex_program */
1743 struct fragment_program_state FragmentProgram; /* GL_NV_fragment_program */
1744
1745 GLenum ErrorValue; /* Last error code */
1746 GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1747 GLuint NewState; /* bitwise-or of _NEW_* flags */
1748
1749 /* Derived */
1750 GLuint _TriangleCaps; /* bitwise-or of DD_* flags */
1751 GLuint _ImageTransferState;/* bitwise-or of IMAGE_*_BIT flags */
1752 GLfloat _EyeZDir[3];
1753 GLfloat _ModelViewInvScale;
1754 GLuint _NeedEyeCoords;
1755 GLuint _NeedNormals; /* Are vertex normal vectors needed? */
1756
1757 struct gl_shine_tab *_ShineTable[2]; /* Active shine tables */
1758 struct gl_shine_tab *_ShineTabList; /* Mru list of inactive shine tables */
1759
1760 struct gl_list_extensions listext; /* driver dlist extensions */
1761
1762
1763 GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
1764 GLboolean OcclusionResultSaved; /**< for GL_HP_occlusion_test */
1765 GLuint _Facing; /* This is a hack for 2-sided stencil test. We don't */
1766 /* have a better way to communicate this value from */
1767 /* swrast_setup to swrast. */
1768
1769
1770 /* Z buffer stuff */
1771 GLuint DepthMax; /**< Max depth buffer value */
1772 GLfloat DepthMaxF; /**< Float max depth buffer value */
1773 GLfloat MRD; /**< minimum resolvable difference in Z values */
1774
1775 /** Should 3Dfx Glide driver catch signals? */
1776 GLboolean CatchSignals;
1777
1778 /** For debugging/development only */
1779 GLboolean NoRaster;
1780 GLboolean FirstTimeCurrent;
1781
1782 /** Dither disable via MESA_NO_DITHER env var */
1783 GLboolean NoDither;
1784
1785 GLboolean Rendering;
1786
1787 #if defined(MESA_TRACE)
1788 struct _glapi_table *TraceDispatch;
1789 trace_context_t *TraceCtx;
1790 #else
1791 void *TraceDispatch;
1792 void *TraceCtx;
1793 #endif
1794
1795 /* Core tnl module support */
1796 struct gl_tnl_module TnlModule;
1797
1798 /* Hooks for module contexts. These will eventually live
1799 * in the driver or elsewhere.
1800 */
1801 void *swrast_context;
1802 void *swsetup_context;
1803 void *swtnl_context;
1804 void *swtnl_im;
1805 void *acache_context;
1806 void *aelt_context;
1807 };
1808
1809
1810 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1811 extern const char *_mesa_prim_name[GL_POLYGON+4];
1812
1813 #ifndef MESA_DEBUG
1814 #define MESA_DEBUG
1815 #endif
1816
1817 #ifdef MESA_DEBUG
1818 extern int MESA_VERBOSE;
1819 extern int MESA_DEBUG_FLAGS;
1820 #else
1821 # define MESA_VERBOSE 0
1822 # define MESA_DEBUG_FLAGS 0
1823 # ifndef NDEBUG
1824 # define NDEBUG
1825 # endif
1826 #endif
1827
1828
1829 enum _verbose {
1830 VERBOSE_VARRAY = 0x0001,
1831 VERBOSE_TEXTURE = 0x0002,
1832 VERBOSE_IMMEDIATE = 0x0004,
1833 VERBOSE_PIPELINE = 0x0008,
1834 VERBOSE_DRIVER = 0x0010,
1835 VERBOSE_STATE = 0x0020,
1836 VERBOSE_API = 0x0040,
1837 VERBOSE_DISPLAY_LIST = 0x0100,
1838 VERBOSE_LIGHTING = 0x0200,
1839 VERBOSE_PRIMS = 0x0400,
1840 VERBOSE_VERTS = 0x0800
1841 };
1842
1843
1844 enum _debug {
1845 DEBUG_ALWAYS_FLUSH = 0x1
1846 };
1847
1848
1849
1850 #define Elements(x) sizeof(x)/sizeof(*(x))
1851
1852
1853 /* Eventually let the driver specify what statechanges require a flush:
1854 */
1855 #define FLUSH_VERTICES(ctx, newstate) \
1856 do { \
1857 if (MESA_VERBOSE & VERBOSE_STATE) \
1858 _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
1859 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1860 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1861 ctx->NewState |= newstate; \
1862 } while (0)
1863
1864 #define FLUSH_CURRENT(ctx, newstate) \
1865 do { \
1866 if (MESA_VERBOSE & VERBOSE_STATE) \
1867 _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
1868 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1869 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1870 ctx->NewState |= newstate; \
1871 } while (0)
1872
1873 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1874 do { \
1875 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1876 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1877 return retval; \
1878 } \
1879 } while (0)
1880
1881 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1882 do { \
1883 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1884 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1885 return; \
1886 } \
1887 } while (0)
1888
1889 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1890 do { \
1891 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1892 FLUSH_VERTICES(ctx, 0); \
1893 } while (0)
1894
1895 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1896 do { \
1897 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1898 FLUSH_VERTICES(ctx, 0); \
1899 } while (0)
1900
1901
1902
1903
1904 #endif /* TYPES_H */