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