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