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