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