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