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