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