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