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