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