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