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