2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * \brief Main Mesa data structures.
35 #include "config.h" /* Hardwired parameters */
36 #include "glapitable.h"
39 #include "math/m_matrix.h" /* GLmatrix */
41 #if defined(MESA_TRACE)
42 #include "Trace/tr_context.h"
46 /* Please try to mark derived values with a leading underscore ('_').
50 * Color channel data type:
53 typedef GLubyte GLchan
;
55 #define CHAN_MAXF 255.0F
56 #define CHAN_TYPE GL_UNSIGNED_BYTE
58 typedef GLushort GLchan
;
59 #define CHAN_MAX 65535
60 #define CHAN_MAXF 65535.0F
61 #define CHAN_TYPE GL_UNSIGNED_SHORT
63 typedef GLfloat GLchan
;
65 #define CHAN_MAXF 1.0F
66 #define CHAN_TYPE GL_FLOAT
68 #error "illegal number of color channel bits"
73 * Accumulation buffer data type:
76 typedef GLbyte GLaccum
;
78 typedef GLshort GLaccum
;
80 typedef GLfloat GLaccum
;
82 # error "illegal number of accumulation bits"
87 * Stencil buffer data type:
90 typedef GLubyte GLstencil
;
91 # define STENCIL_MAX 0xff
92 #elif STENCIL_BITS==16
93 typedef GLushort GLstencil
;
94 # define STENCIL_MAX 0xffff
96 # error "illegal number of stencil bits"
101 * Depth buffer data type:
103 typedef GLuint GLdepth
; /* Must be 32-bits! */
107 * Fixed point data type:
111 * Fixed point arithmetic macros
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
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
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)
141 * Some forward type declarations
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
;
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.
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
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)
192 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
197 * Maximum number of temporary vertices required for clipping. (Used
198 * in array_cache and tnl modules).
200 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
203 /* Data structure for color tables */
204 struct gl_color_table
{
205 GLenum Format
; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
207 GLuint Size
; /* number of entries (rows) in table */
208 GLvoid
*Table
; /* either GLfloat * or GLchan * */
209 GLboolean FloatTable
; /* are entries stored as floats? */
214 GLubyte LuminanceSize
;
215 GLubyte IntensitySize
;
220 * Bit flags used for updating material values.
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
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)
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)
243 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
248 * Specular exponent and material shininess lookup table sizes:
250 #define EXP_TABLE_SIZE 512
251 #define SHINE_TABLE_SIZE 256
253 struct gl_shine_tab
{
254 struct gl_shine_tab
*next
, *prev
;
255 GLfloat tab
[SHINE_TABLE_SIZE
+1];
262 struct gl_light
*next
; /* double linked list with sentinel */
263 struct gl_light
*prev
;
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 */
279 GLuint _Flags
; /* State */
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
;
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 */
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 */
312 GLfloat AmbientIndex
; /* for color index lighting */
313 GLfloat DiffuseIndex
; /* for color index lighting */
314 GLfloat SpecularIndex
; /* for color index lighting */
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.
323 struct gl_accum_attrib
{
324 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
329 * Used in _DrawDestMask and _ReadSrcMask below to identify color buffers.
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
340 struct gl_colorbuffer_attrib
{
341 GLuint ClearIndex
; /* Index to use for glClear */
342 GLclampf ClearColor
[4]; /* Color to use for glClear */
344 GLuint IndexMask
; /* Color index write mask */
345 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
347 GLenum DrawBuffer
; /* Which buffer to draw into */
348 GLubyte _DrawDestMask
; /* bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
351 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
352 GLenum AlphaFunc
; /* Alpha test function */
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];
365 GLenum LogicOp
; /* Logic operator */
366 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
367 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
369 GLboolean DitherFlag
; /* Dither enable flag */
373 struct gl_current_attrib
{
374 /* These values valid only when FLUSH_VERTICES has been called.
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 */
381 /* These values are always valid. BTW, note how similar this set of
382 * attributes is to the SWvertex datatype in the software rasterizer...
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 */
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 */
405 struct gl_enable_attrib
{
407 GLboolean AutoNormal
;
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
;
422 GLboolean Light
[MAX_LIGHTS
];
424 GLboolean LineSmooth
;
425 GLboolean LineStipple
;
426 GLboolean IndexLogicOp
;
427 GLboolean ColorLogicOp
;
428 GLboolean Map1Color4
;
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
;
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 */
450 GLboolean PixelTexture
;
451 GLboolean PointSmooth
;
452 GLboolean PolygonOffsetPoint
;
453 GLboolean PolygonOffsetLine
;
454 GLboolean PolygonOffsetFill
;
455 GLboolean PolygonSmooth
;
456 GLboolean PolygonStipple
;
457 GLboolean RescaleNormals
;
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
;
479 struct gl_eval_attrib
{
481 GLboolean Map1Color4
;
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
;
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 */
504 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
505 GLint MapGrid2un
, MapGrid2vn
;
506 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
507 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
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 */
524 struct gl_hint_attrib
{
525 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
526 GLenum PerspectiveCorrection
;
529 GLenum PolygonSmooth
;
531 GLenum ClipVolumeClipping
; /* GL_EXT_clip_volume_hint */
532 GLenum TextureCompression
; /* GL_ARB_texture_compression */
533 GLenum GenerateMipmap
; /* GL_SGIS_generate_mipmap */
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 */
546 GLubyte LuminanceSize
;
550 struct gl_minmax_attrib
{
553 GLfloat Min
[4], Max
[4]; /* RGBA */
557 struct gl_convolution_attrib
{
559 GLenum InternalFormat
;
562 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
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)
571 struct gl_light_attrib
{
572 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
573 struct gl_lightmodel Model
; /* Lighting model */
575 /* Must flush FLUSH_VERTICES before referencing:
577 struct gl_material Material
[2]; /* Material 0=front, 1=back */
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
;
586 struct gl_light EnabledList
; /* List sentinel */
588 /* Derived for optimizations: */
589 GLboolean _NeedVertices
; /* Use fast shader? */
590 GLuint _Flags
; /* LIGHT_* flags, see above */
591 GLfloat _BaseColor
[2][3];
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 */
605 struct gl_list_attrib
{
610 struct gl_list_opcode
{
612 void (*execute
)( GLcontext
*ctx
, void *data
);
613 void (*destroy
)( GLcontext
*ctx
, void *data
);
614 void (*print
)( GLcontext
*ctx
, void *data
);
617 #define GL_MAX_EXT_OPCODES 16
619 struct gl_list_extensions
{
620 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
625 struct gl_multisample_attrib
{
627 GLboolean SampleAlphaToCoverage
;
628 GLboolean SampleAlphaToOne
;
629 GLboolean SampleCoverage
;
630 GLfloat SampleCoverageValue
;
631 GLboolean SampleCoverageInvert
;
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 */
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];
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];
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 */
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 */
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 */
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 */
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 */
763 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
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
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)
779 /* TexGenEnabled flags */
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
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 | \
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
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
819 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
820 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
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].
827 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
828 GLint col
, GLint row
, GLint img
,
831 /* Texture format record */
832 struct gl_texture_format
{
833 GLint MesaFormat
; /* One of the MESA_FORMAT_* values */
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.
839 GLubyte RedBits
; /* Bits per texel component */
840 GLubyte GreenBits
; /* These are just rough approximations for */
841 GLubyte BlueBits
; /* compressed texture formats. */
843 GLubyte LuminanceBits
;
844 GLubyte IntensityBits
;
848 GLint TexelBytes
; /* Bytes per texel (0 for compressed formats */
850 FetchTexelFunc FetchTexel1D
; /* Texel fetch function pointers */
851 FetchTexelFunc FetchTexel2D
;
852 FetchTexelFunc FetchTexel3D
;
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.
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 GLboolean _IsPowerOfTwo
; /* Are all dimensions powers of two? */
883 const struct gl_texture_format
*TexFormat
;
885 FetchTexelFunc FetchTexel
; /* Texel fetch function pointer */
887 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
888 GLuint CompressedSize
; /* GL_ARB_texture_compression */
890 /* For device driver: */
891 void *DriverData
; /* Arbitrary device driver data */
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 GLboolean _IsPowerOfTwo
; /* Are all image dimensions powers of two? */
925 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
927 /* Texture cube faces */
928 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
929 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
930 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
931 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
932 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
933 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
935 /* GL_EXT_paletted_texture */
936 struct gl_color_table Palette
;
938 GLboolean Complete
; /* Is texture object complete? */
939 struct gl_texture_object
*Next
; /* Next in linked list */
941 /* For device driver: */
942 void *DriverData
; /* Arbitrary device driver data */
946 /* Texture unit record */
947 struct gl_texture_unit
{
948 GLuint Enabled
; /* bitmask of TEXTURE_*_BIT flags */
949 GLuint _ReallyEnabled
; /* 0 or exactly one of TEXTURE_*_BIT flags */
951 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
953 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
954 GLenum GenModeS
; /* Tex coord generation mode, either */
955 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
956 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
957 GLenum GenModeQ
; /* GL_SPHERE_MAP */
962 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
963 GLfloat ObjectPlaneS
[4];
964 GLfloat ObjectPlaneT
[4];
965 GLfloat ObjectPlaneR
[4];
966 GLfloat ObjectPlaneQ
[4];
967 GLfloat EyePlaneS
[4];
968 GLfloat EyePlaneT
[4];
969 GLfloat EyePlaneR
[4];
970 GLfloat EyePlaneQ
[4];
971 GLfloat LodBias
; /* for biasing mipmap levels */
973 /* GL_EXT_texture_env_combine */
974 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
975 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
976 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
977 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
978 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
979 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
980 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
981 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
983 struct gl_texture_object
*Current1D
;
984 struct gl_texture_object
*Current2D
;
985 struct gl_texture_object
*Current3D
;
986 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
987 struct gl_texture_object
*CurrentRect
; /* GL_NV_texture_rectangle */
989 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
991 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
992 struct gl_texture_object Saved2D
;
993 struct gl_texture_object Saved3D
;
994 struct gl_texture_object SavedCubeMap
;
995 struct gl_texture_object SavedRect
;
997 /* GL_SGI_texture_color_table */
998 struct gl_color_table ColorTable
;
999 struct gl_color_table ProxyColorTable
;
1000 GLboolean ColorTableEnabled
;
1004 /* The texture attribute group */
1005 struct gl_texture_attrib
{
1007 GLuint CurrentUnit
; /* Active texture unit */
1009 GLuint _EnabledUnits
; /* one bit set for each really-enabled unit */
1010 GLuint _EnabledCoordUnits
; /* one bit per enabled coordinate unit */
1011 GLuint _GenFlags
; /* for texgen */
1012 GLuint _TexGenEnabled
;
1013 GLuint _TexMatEnabled
;
1015 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1017 struct gl_texture_object
*Proxy1D
;
1018 struct gl_texture_object
*Proxy2D
;
1019 struct gl_texture_object
*Proxy3D
;
1020 struct gl_texture_object
*ProxyCubeMap
;
1021 struct gl_texture_object
*ProxyRect
;
1023 /* GL_EXT_shared_texture_palette */
1024 GLboolean SharedPalette
;
1025 struct gl_color_table Palette
;
1029 struct gl_transform_attrib
{
1030 GLenum MatrixMode
; /* Matrix mode */
1031 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
1032 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
1033 GLuint ClipPlanesEnabled
; /* on/off bitmask */
1034 GLboolean Normalize
; /* Normalize all normals? */
1035 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
1036 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
1040 struct gl_viewport_attrib
{
1041 GLint X
, Y
; /* position */
1042 GLsizei Width
, Height
; /* size */
1043 GLfloat Near
, Far
; /* Depth buffer range */
1044 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
1048 /* For the attribute stack: */
1049 struct gl_attrib_node
{
1052 struct gl_attrib_node
*next
;
1057 * Client pixel packing/unpacking attributes
1059 struct gl_pixelstore_attrib
{
1064 GLint ImageHeight
; /* for GL_EXT_texture3D */
1065 GLint SkipImages
; /* for GL_EXT_texture3D */
1066 GLboolean SwapBytes
;
1068 GLboolean ClientStorage
; /* GL_APPLE_client_storage */
1069 GLboolean Invert
; /* GL_MESA_pack_invert */
1073 #define CA_CLIENT_DATA 0x1 /* Data not alloced by mesa */
1077 * Client vertex array attributes
1079 struct gl_client_array
{
1082 GLsizei Stride
; /* user-specified stride */
1083 GLsizei StrideB
; /* actual stride in bytes */
1086 GLuint Enabled
; /* one of the _NEW_ARRAY_ bits */
1087 GLboolean Normalized
; /* GL_ARB_vertex_program */
1091 struct gl_array_attrib
{
1092 struct gl_client_array Vertex
; /* client data descriptors */
1093 struct gl_client_array Normal
;
1094 struct gl_client_array Color
;
1095 struct gl_client_array SecondaryColor
;
1096 struct gl_client_array FogCoord
;
1097 struct gl_client_array Index
;
1098 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1099 struct gl_client_array EdgeFlag
;
1100 /* GL_NV_vertex_program */
1101 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1103 GLint TexCoordInterleaveFactor
;
1104 GLint ActiveTexture
; /* Client Active Texture */
1108 GLuint _Enabled
; /* _NEW_ARRAY_* - bit set if array enabled */
1109 GLuint NewState
; /* _NEW_ARRAY_* */
1111 /* GL_ARB_vertex_buffer_object */
1112 GLuint ArrayBufferBinding
;
1113 GLuint VertexArrayBufferBinding
;
1114 GLuint NormalArrayBufferBinding
;
1115 GLuint ColorArrayBufferBinding
;
1116 GLuint IndexArrayBufferBinding
;
1117 GLuint TextureArrayBufferBinding
;
1118 GLuint EdgeFlagArrayBufferBinding
;
1119 GLuint SecondaryColorArrayBufferBinding
;
1120 GLuint FogCoordArrayBufferBinding
;
1121 GLuint WeightArrayBufferBinding
;
1122 GLuint ElementArrayBufferBinding
;
1123 GLuint VertexAttribArrayBufferBinding
[VERT_ATTRIB_MAX
];
1127 struct gl_feedback
{
1129 GLuint _Mask
; /* FB_* bits */
1136 struct gl_selection
{
1138 GLuint BufferSize
; /* size of SelectBuffer */
1139 GLuint BufferCount
; /* number of values in SelectBuffer */
1140 GLuint Hits
; /* number of records in SelectBuffer */
1141 GLuint NameStackDepth
;
1142 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1144 GLfloat HitMinZ
, HitMaxZ
;
1149 * 1-D Evaluator control points
1152 GLuint Order
; /* Number of control points */
1153 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1154 GLfloat
*Points
; /* Points to contiguous control points */
1159 * 2-D Evaluator control points
1162 GLuint Uorder
; /* Number of control points in U dimension */
1163 GLuint Vorder
; /* Number of control points in V dimension */
1166 GLfloat
*Points
; /* Points to contiguous control points */
1171 * All evalutator control points
1173 struct gl_evaluators
{
1175 struct gl_1d_map Map1Vertex3
;
1176 struct gl_1d_map Map1Vertex4
;
1177 struct gl_1d_map Map1Index
;
1178 struct gl_1d_map Map1Color4
;
1179 struct gl_1d_map Map1Normal
;
1180 struct gl_1d_map Map1Texture1
;
1181 struct gl_1d_map Map1Texture2
;
1182 struct gl_1d_map Map1Texture3
;
1183 struct gl_1d_map Map1Texture4
;
1184 struct gl_1d_map Map1Attrib
[16]; /* GL_NV_vertex_program */
1187 struct gl_2d_map Map2Vertex3
;
1188 struct gl_2d_map Map2Vertex4
;
1189 struct gl_2d_map Map2Index
;
1190 struct gl_2d_map Map2Color4
;
1191 struct gl_2d_map Map2Normal
;
1192 struct gl_2d_map Map2Texture1
;
1193 struct gl_2d_map Map2Texture2
;
1194 struct gl_2d_map Map2Texture3
;
1195 struct gl_2d_map Map2Texture4
;
1196 struct gl_2d_map Map2Attrib
[16]; /* GL_NV_vertex_program */
1201 /* NV_vertex_program runtime state */
1204 GLfloat Registers
[MAX_NV_VERTEX_PROGRAM_TEMPS
1205 + MAX_NV_VERTEX_PROGRAM_PARAMS
1206 + MAX_NV_VERTEX_PROGRAM_INPUTS
1207 + MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1208 GLint AddressReg
; /* might someday be a 4-vector */
1212 /* NV_fragment_program runtime state */
1215 GLfloat Registers
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
1216 + MAX_NV_FRAGMENT_PROGRAM_PARAMS
1217 + MAX_NV_FRAGMENT_PROGRAM_INPUTS
1218 + MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
1219 + MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS
][4];
1220 GLuint CondCodes
[4];
1224 /* Vertex and fragment instructions */
1225 struct vp_instruction
;
1226 struct fp_instruction
;
1228 /* Program parameters */
1229 struct program_parameter
1237 /* Base class for any kind of program object */
1241 GLubyte
*String
; /* Null-terminated program text */
1243 GLenum Format
; /* String encoding format */
1246 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1247 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1248 GLuint NumTemporaries
;
1249 GLuint NumParameters
;
1250 GLuint NumAttributes
;
1251 GLuint NumAddressRegs
;
1255 /* Vertex program object */
1256 struct vertex_program
1258 struct program Base
; /* base class */
1259 struct vp_instruction
*Instructions
; /* Compiled instructions */
1260 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1261 GLuint InputsRead
; /* Bitmask of which input regs are read */
1262 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1266 /* Fragment program object */
1267 struct fragment_program
1269 struct program Base
; /* base class */
1270 struct fp_instruction
*Instructions
; /* Compiled instructions */
1271 GLuint InputsRead
; /* Bitmask of which input regs are read */
1272 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1273 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /* TEXTURE_x_INDEX bitmask */
1274 GLuint NumAluInstructions
; /* GL_ARB_fragment_program */
1275 GLuint NumTexInstructions
;
1276 GLuint NumTexIndirections
;
1277 struct program_parameter
*Parameters
; /* array [NumParameters] */
1278 GLuint NumParameters
;
1283 * State common to vertex and fragment programs.
1285 struct program_state
{
1286 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1287 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1292 * State for GL_ARB/NV_vertex_program
1294 struct vertex_program_state
1296 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1297 GLboolean PointSizeEnabled
; /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1298 GLboolean TwoSideEnabled
; /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1299 struct vertex_program
*Current
; /* ptr to currently bound program */
1300 struct vp_machine Machine
; /* machine state */
1302 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1303 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1308 * State for GL_ARB/NV_fragment_program
1310 struct fragment_program_state
1312 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1313 struct fragment_program
*Current
; /* ptr to currently bound program */
1314 struct fp_machine Machine
; /* machine state */
1319 * State for GL_ARB_occlusion_query
1321 struct occlusion_state
1324 GLuint CurrentQueryObject
;
1325 GLuint PassedCounter
;
1326 struct _mesa_HashTable
*QueryObjects
;
1331 * State which can be shared by multiple contexts:
1333 struct gl_shared_state
{
1334 _glthread_Mutex Mutex
; /* for thread safety */
1335 GLint RefCount
; /* Reference count */
1336 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1337 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1338 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1340 /* Default texture objects (shared by all multi-texture units) */
1341 struct gl_texture_object
*Default1D
;
1342 struct gl_texture_object
*Default2D
;
1343 struct gl_texture_object
*Default3D
;
1344 struct gl_texture_object
*DefaultCubeMap
;
1345 struct gl_texture_object
*DefaultRect
;
1347 /* GL_NV_vertex/_program */
1348 struct _mesa_HashTable
*Programs
;
1349 #if FEATURE_ARB_vertex_program
1350 struct program
*DefaultVertexProgram
;
1352 #if FEATURE_ARB_fragment_program
1353 struct program
*DefaultFragmentProgram
;
1356 void *DriverData
; /* Device driver shared state */
1361 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1362 * depth, accum, stencil, and software-simulated alpha buffers.
1363 * In C++ terms, think of this as a base class from which device drivers
1364 * will make derived classes.
1366 struct gl_frame_buffer
{
1367 GLvisual Visual
; /* The corresponding visual */
1369 GLuint Width
, Height
; /* size of frame buffer in pixels */
1371 GLboolean UseSoftwareDepthBuffer
;
1372 GLboolean UseSoftwareAccumBuffer
;
1373 GLboolean UseSoftwareStencilBuffer
;
1374 GLboolean UseSoftwareAlphaBuffers
;
1376 /* Software depth (aka Z) buffer */
1377 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1379 /* Software stencil buffer */
1380 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1382 /* Software accumulation buffer */
1383 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1385 /* Software alpha planes */
1386 GLvoid
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1387 GLvoid
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1388 GLvoid
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1389 GLvoid
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1391 /* Drawing bounds: intersection of window size and scissor box */
1392 GLint _Xmin
, _Ymin
; /* inclusive */
1393 GLint _Xmax
, _Ymax
; /* exclusive */
1398 * Constants which may be overriden by device driver during context creation
1399 * but are never changed after that.
1401 struct gl_constants
{
1402 GLint MaxTextureLevels
;
1403 GLint Max3DTextureLevels
;
1404 GLint MaxCubeTextureLevels
; /* GL_ARB_texture_cube_map */
1405 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1406 GLuint MaxTextureCoordUnits
;
1407 GLuint MaxTextureImageUnits
;
1408 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1409 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1410 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1411 GLuint MaxArrayLockSize
;
1413 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1414 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1415 GLfloat PointSizeGranularity
;
1416 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1417 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1418 GLfloat LineWidthGranularity
;
1419 GLuint NumAuxBuffers
;
1420 GLuint MaxColorTableSize
;
1421 GLuint MaxConvolutionWidth
;
1422 GLuint MaxConvolutionHeight
;
1423 GLuint MaxClipPlanes
;
1425 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1426 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1427 /* GL_ARB_vertex_program */
1428 GLuint MaxVertexProgramInstructions
;
1429 GLuint MaxVertexProgramAttribs
;
1430 GLuint MaxVertexProgramTemps
;
1431 GLuint MaxVertexProgramLocalParams
;
1432 GLuint MaxVertexProgramEnvParams
;
1433 GLuint MaxVertexProgramAddressRegs
;
1434 /* GL_ARB_fragment_program */
1435 GLuint MaxFragmentProgramInstructions
;
1436 GLuint MaxFragmentProgramAttribs
;
1437 GLuint MaxFragmentProgramTemps
;
1438 GLuint MaxFragmentProgramLocalParams
;
1439 GLuint MaxFragmentProgramEnvParams
;
1440 GLuint MaxFragmentProgramAddressRegs
;
1441 GLuint MaxFragmentProgramAluInstructions
;
1442 GLuint MaxFragmentProgramTexInstructions
;
1443 GLuint MaxFragmentProgramTexIndirections
;
1444 /* vertex or fragment program */
1445 GLuint MaxProgramMatrices
;
1446 GLuint MaxProgramMatrixStackDepth
;
1451 * List of extensions.
1453 struct gl_extensions
{
1454 /* Flags to quickly test if certain extensions are available.
1455 * Not every extension needs to have such a flag, but it's encouraged.
1457 GLboolean dummy
; /* don't remove this! */
1458 GLboolean ARB_depth_texture
;
1459 GLboolean ARB_fragment_program
;
1460 GLboolean ARB_imaging
;
1461 GLboolean ARB_multisample
;
1462 GLboolean ARB_multitexture
;
1463 GLboolean ARB_occlusion_query
;
1464 GLboolean ARB_shadow
;
1465 GLboolean ARB_texture_border_clamp
;
1466 GLboolean ARB_texture_compression
;
1467 GLboolean ARB_texture_cube_map
;
1468 GLboolean ARB_texture_env_combine
;
1469 GLboolean ARB_texture_env_crossbar
;
1470 GLboolean ARB_texture_env_dot3
;
1471 GLboolean ARB_texture_mirrored_repeat
;
1472 GLboolean ARB_texture_non_power_of_two
;
1473 GLboolean ARB_vertex_buffer_object
;
1474 GLboolean ARB_vertex_program
;
1475 GLboolean ARB_window_pos
;
1476 GLboolean ATI_texture_mirror_once
;
1477 GLboolean ATI_texture_env_combine3
;
1478 GLboolean EXT_blend_color
;
1479 GLboolean EXT_blend_func_separate
;
1480 GLboolean EXT_blend_logic_op
;
1481 GLboolean EXT_blend_minmax
;
1482 GLboolean EXT_blend_subtract
;
1483 GLboolean EXT_convolution
;
1484 GLboolean EXT_compiled_vertex_array
;
1485 GLboolean EXT_depth_bounds_test
;
1486 GLboolean EXT_fog_coord
;
1487 GLboolean EXT_histogram
;
1488 GLboolean EXT_multi_draw_arrays
;
1489 GLboolean EXT_paletted_texture
;
1490 GLboolean EXT_point_parameters
;
1491 GLboolean EXT_shadow_funcs
;
1492 GLboolean EXT_secondary_color
;
1493 GLboolean EXT_shared_texture_palette
;
1494 GLboolean EXT_stencil_wrap
;
1495 GLboolean EXT_stencil_two_side
;
1496 GLboolean EXT_texture3D
;
1497 GLboolean EXT_texture_compression_s3tc
;
1498 GLboolean EXT_texture_env_add
;
1499 GLboolean EXT_texture_env_combine
;
1500 GLboolean EXT_texture_env_dot3
;
1501 GLboolean EXT_texture_filter_anisotropic
;
1502 GLboolean EXT_texture_lod_bias
;
1503 GLboolean EXT_vertex_array_set
;
1504 GLboolean HP_occlusion_test
;
1505 GLboolean IBM_rasterpos_clip
;
1506 GLboolean MESA_pack_invert
;
1507 GLboolean MESA_packed_depth_stencil
;
1508 GLboolean MESA_resize_buffers
;
1509 GLboolean MESA_ycbcr_texture
;
1510 GLboolean NV_blend_square
;
1511 GLboolean NV_fragment_program
;
1512 GLboolean NV_point_sprite
;
1513 GLboolean NV_texture_rectangle
;
1514 GLboolean NV_vertex_program
;
1515 GLboolean NV_vertex_program1_1
;
1516 GLboolean SGI_color_matrix
;
1517 GLboolean SGI_color_table
;
1518 GLboolean SGI_texture_color_table
;
1519 GLboolean SGIS_generate_mipmap
;
1520 GLboolean SGIS_pixel_texture
;
1521 GLboolean SGIS_texture_edge_clamp
;
1522 GLboolean SGIX_depth_texture
;
1523 GLboolean SGIX_pixel_texture
;
1524 GLboolean SGIX_shadow
;
1525 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1526 GLboolean TDFX_texture_compression_FXT1
;
1527 GLboolean APPLE_client_storage
;
1528 /* The extension string */
1529 const GLubyte
*String
;
1534 * A stack of matrices (projection, modelview, color, texture, etc).
1538 GLmatrix
*Top
; /* points into Stack */
1539 GLmatrix
*Stack
; /* array [MaxDepth] of GLmatrix */
1540 GLuint Depth
; /* 0 <= Depth < MaxDepth */
1541 GLuint MaxDepth
; /* size of Stack[] array */
1542 GLuint DirtyFlag
; /* _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1547 * Bits for image transfer operations (ctx->ImageTransferState).
1549 #define IMAGE_SCALE_BIAS_BIT 0x1
1550 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1551 #define IMAGE_MAP_COLOR_BIT 0x4
1552 #define IMAGE_COLOR_TABLE_BIT 0x8
1553 #define IMAGE_CONVOLUTION_BIT 0x10
1554 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1555 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1556 #define IMAGE_COLOR_MATRIX_BIT 0x80
1557 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1558 #define IMAGE_HISTOGRAM_BIT 0x200
1559 #define IMAGE_MIN_MAX_BIT 0x400
1561 /* transfer ops up to convolution: */
1562 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1563 IMAGE_SHIFT_OFFSET_BIT | \
1564 IMAGE_MAP_COLOR_BIT | \
1565 IMAGE_COLOR_TABLE_BIT)
1567 /* transfer ops after convolution: */
1568 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1569 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1570 IMAGE_COLOR_MATRIX_BIT | \
1571 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1572 IMAGE_HISTOGRAM_BIT | \
1577 * Bits to indicate what state has changed. 6 unused flags.
1579 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1580 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1581 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1582 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1583 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1584 #define _NEW_COLOR 0x20 /* ctx->Color */
1585 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1586 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1587 #define _NEW_FOG 0x100 /* ctx->Fog */
1588 #define _NEW_HINT 0x200 /* ctx->Hint */
1589 #define _NEW_LIGHT 0x400 /* ctx->Light */
1590 #define _NEW_LINE 0x800 /* ctx->Line */
1591 #define _NEW_PIXEL 0x1000 /* ctx->Pixel */
1592 #define _NEW_POINT 0x2000 /* ctx->Point */
1593 #define _NEW_POLYGON 0x4000 /* ctx->Polygon */
1594 #define _NEW_POLYGONSTIPPLE 0x8000 /* ctx->PolygonStipple */
1595 #define _NEW_SCISSOR 0x10000 /* ctx->Scissor */
1596 #define _NEW_STENCIL 0x20000 /* ctx->Stencil */
1597 #define _NEW_TEXTURE 0x40000 /* ctx->Texture */
1598 #define _NEW_TRANSFORM 0x80000 /* ctx->Transform */
1599 #define _NEW_VIEWPORT 0x100000 /* ctx->Viewport */
1600 #define _NEW_PACKUNPACK 0x200000 /* ctx->Pack, ctx->Unpack */
1601 #define _NEW_ARRAY 0x400000 /* ctx->Array */
1602 #define _NEW_RENDERMODE 0x800000 /* RenderMode, Feedback, Select */
1603 #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
1604 #define _NEW_MULTISAMPLE 0x2000000 /* ctx->Multisample */
1605 #define _NEW_TRACK_MATRIX 0x4000000 /* ctx->VertexProgram */
1606 #define _NEW_PROGRAM 0x8000000 /* ctx->VertexProgram */
1611 /* Bits to track array state changes (also used to summarize array enabled)
1613 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1614 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1615 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1616 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1617 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1618 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1619 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1620 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1621 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1622 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1623 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1624 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1625 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1626 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1627 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1628 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1629 #define _NEW_ARRAY_ATTRIB_0 0x1 /* alias conventional arrays */
1630 #define _NEW_ARRAY_ALL 0xffffffff
1633 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1634 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1637 /* A bunch of flags that we think might be useful to drivers.
1638 * Set in the ctx->_TriangleCaps bitfield.
1640 #define DD_FLATSHADE 0x1
1641 #define DD_SEPARATE_SPECULAR 0x2
1642 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1643 #define DD_TRI_LIGHT_TWOSIDE 0x8
1644 #define DD_TRI_UNFILLED 0x10
1645 #define DD_TRI_SMOOTH 0x20
1646 #define DD_TRI_STIPPLE 0x40
1647 #define DD_TRI_OFFSET 0x80
1648 #define DD_LINE_SMOOTH 0x100
1649 #define DD_LINE_STIPPLE 0x200
1650 #define DD_LINE_WIDTH 0x400
1651 #define DD_POINT_SMOOTH 0x800
1652 #define DD_POINT_SIZE 0x1000
1653 #define DD_POINT_ATTEN 0x2000
1656 /* Define the state changes under which each of these bits might change
1658 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1659 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1660 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1661 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1662 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1663 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1664 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1665 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1666 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1667 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1668 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1669 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1670 #define _DD_NEW_POINT_SIZE _NEW_POINT
1671 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1673 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1678 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1681 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1684 /* Bits for ctx->_NeedNormals */
1685 #define NEED_NORMALS_TEXGEN 0x1
1686 #define NEED_NORMALS_LIGHT 0x2
1688 /* Bits for ctx->_NeedEyeCoords */
1689 #define NEED_EYE_TEXGEN 0x1
1690 #define NEED_EYE_LIGHT 0x2
1691 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1692 #define NEED_EYE_POINT_ATTEN 0x8
1693 #define NEED_EYE_DRIVER 0x10
1697 * Forward declaration of display list datatypes:
1700 typedef union node Node
;
1703 /* This has to be included here. */
1708 * Core Mesa's support for tnl modules:
1710 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1712 struct gl_tnl_module
{
1713 /* Vertex format to be lazily swapped into current dispatch.
1715 GLvertexformat
*Current
;
1717 /* Record of functions swapped out. On restore, only need to swap
1718 * these functions back in.
1720 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
1726 * This is the central context data structure for Mesa. Almost all
1727 * OpenGL state is contained in this structure.
1728 * Think of this as a base class from which device drivers will derive
1731 struct __GLcontextRec
{
1733 * OS related interfaces; these *must* be the first members of this
1734 * structure, because they are exposed to the outside world (i.e. GLX
1737 __GLimports imports
;
1738 __GLexports exports
;
1740 /* State possibly shared with other contexts in the address space */
1741 struct gl_shared_state
*Shared
;
1743 /* API function pointer tables */
1744 struct _glapi_table
*Save
; /**< Display list save funcs */
1745 struct _glapi_table
*Exec
; /**< Execute funcs */
1746 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
1748 GLboolean ExecPrefersFloat
; /**< What preference for color conversion? */
1749 GLboolean SavePrefersFloat
;
1752 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
1753 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
1756 * Device driver function pointer table
1758 struct dd_function_table Driver
;
1760 void *DriverCtx
; /**< Points to device driver context/state */
1761 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
1763 /* Core/Driver constants */
1764 struct gl_constants Const
;
1766 /* The various 4x4 matrix stacks */
1767 struct matrix_stack ModelviewMatrixStack
;
1768 struct matrix_stack ProjectionMatrixStack
;
1769 struct matrix_stack ColorMatrixStack
;
1770 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
1771 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
1772 struct matrix_stack
*CurrentStack
; /* Points to one of the above stacks */
1774 /* Combined modelview and projection matrix */
1775 GLmatrix _ModelProjectMatrix
;
1778 GLuint CallDepth
; /* Current recursion calling depth */
1779 GLboolean ExecuteFlag
; /* Execute GL commands? */
1780 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1781 Node
*CurrentListPtr
; /* Head of list being compiled */
1782 GLuint CurrentListNum
; /* Number of the list being compiled */
1783 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1784 GLuint CurrentPos
; /* Index into current block of nodes */
1787 struct gl_extensions Extensions
;
1789 /* Renderer attribute stack */
1790 GLuint AttribStackDepth
;
1791 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1793 /* Renderer attribute groups */
1794 struct gl_accum_attrib Accum
;
1795 struct gl_colorbuffer_attrib Color
;
1796 struct gl_current_attrib Current
;
1797 struct gl_depthbuffer_attrib Depth
;
1798 struct gl_eval_attrib Eval
;
1799 struct gl_fog_attrib Fog
;
1800 struct gl_hint_attrib Hint
;
1801 struct gl_light_attrib Light
;
1802 struct gl_line_attrib Line
;
1803 struct gl_list_attrib List
;
1804 struct gl_multisample_attrib Multisample
;
1805 struct gl_pixel_attrib Pixel
;
1806 struct gl_point_attrib Point
;
1807 struct gl_polygon_attrib Polygon
;
1808 GLuint PolygonStipple
[32];
1809 struct gl_scissor_attrib Scissor
;
1810 struct gl_stencil_attrib Stencil
;
1811 struct gl_texture_attrib Texture
;
1812 struct gl_transform_attrib Transform
;
1813 struct gl_viewport_attrib Viewport
;
1815 /* Other attribute groups */
1816 struct gl_histogram_attrib Histogram
;
1817 struct gl_minmax_attrib MinMax
;
1818 struct gl_convolution_attrib Convolution1D
;
1819 struct gl_convolution_attrib Convolution2D
;
1820 struct gl_convolution_attrib Separable2D
;
1822 /* Client attribute stack */
1823 GLuint ClientAttribStackDepth
;
1824 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1826 /* Client attribute groups */
1827 struct gl_array_attrib Array
; /* Vertex arrays */
1828 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1829 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1831 struct gl_evaluators EvalMap
; /* All evaluators */
1832 struct gl_feedback Feedback
; /* Feedback */
1833 struct gl_selection Select
; /* Selection */
1835 struct gl_color_table ColorTable
; /* Pre-convolution */
1836 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1837 struct gl_color_table PostConvolutionColorTable
;
1838 struct gl_color_table ProxyPostConvolutionColorTable
;
1839 struct gl_color_table PostColorMatrixColorTable
;
1840 struct gl_color_table ProxyPostColorMatrixColorTable
;
1842 struct program_state Program
; /* for vertex or fragment progs */
1843 struct vertex_program_state VertexProgram
; /* GL_NV_vertex_program */
1844 struct fragment_program_state FragmentProgram
; /* GL_NV_fragment_program */
1846 struct occlusion_state Occlusion
; /* GL_ARB_occlusion_query */
1848 GLenum ErrorValue
; /* Last error code */
1849 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1850 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1853 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1854 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1855 GLfloat _EyeZDir
[3];
1856 GLfloat _ModelViewInvScale
;
1857 GLuint _NeedEyeCoords
;
1858 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1860 struct gl_shine_tab
*_ShineTable
[2]; /* Active shine tables */
1861 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1863 struct gl_list_extensions listext
; /* driver dlist extensions */
1866 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
1867 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
1868 GLuint _Facing
; /* This is a hack for 2-sided stencil test. We don't */
1869 /* have a better way to communicate this value from */
1870 /* swrast_setup to swrast. */
1873 /* Z buffer stuff */
1874 GLuint DepthMax
; /**< Max depth buffer value */
1875 GLfloat DepthMaxF
; /**< Float max depth buffer value */
1876 GLfloat MRD
; /**< minimum resolvable difference in Z values */
1878 /** Should 3Dfx Glide driver catch signals? */
1879 GLboolean CatchSignals
;
1881 /** For debugging/development only */
1883 GLboolean FirstTimeCurrent
;
1885 /** Dither disable via MESA_NO_DITHER env var */
1888 GLboolean Rendering
;
1890 #if defined(MESA_TRACE)
1891 struct _glapi_table
*TraceDispatch
;
1892 trace_context_t
*TraceCtx
;
1894 void *TraceDispatch
;
1898 /* Core tnl module support */
1899 struct gl_tnl_module TnlModule
;
1901 /* Hooks for module contexts. These will eventually live
1902 * in the driver or elsewhere.
1904 void *swrast_context
;
1905 void *swsetup_context
;
1906 void *swtnl_context
;
1908 void *acache_context
;
1913 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1914 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
1918 extern int MESA_VERBOSE
;
1919 extern int MESA_DEBUG_FLAGS
;
1921 # define MESA_VERBOSE 0
1922 # define MESA_DEBUG_FLAGS 0
1930 VERBOSE_VARRAY
= 0x0001,
1931 VERBOSE_TEXTURE
= 0x0002,
1932 VERBOSE_IMMEDIATE
= 0x0004,
1933 VERBOSE_PIPELINE
= 0x0008,
1934 VERBOSE_DRIVER
= 0x0010,
1935 VERBOSE_STATE
= 0x0020,
1936 VERBOSE_API
= 0x0040,
1937 VERBOSE_DISPLAY_LIST
= 0x0100,
1938 VERBOSE_LIGHTING
= 0x0200,
1939 VERBOSE_PRIMS
= 0x0400,
1940 VERBOSE_VERTS
= 0x0800
1945 DEBUG_ALWAYS_FLUSH
= 0x1
1950 #define Elements(x) sizeof(x)/sizeof(*(x))
1953 /* Eventually let the driver specify what statechanges require a flush:
1955 #define FLUSH_VERTICES(ctx, newstate) \
1957 if (MESA_VERBOSE & VERBOSE_STATE) \
1958 _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
1959 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1960 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1961 ctx->NewState |= newstate; \
1964 #define FLUSH_CURRENT(ctx, newstate) \
1966 if (MESA_VERBOSE & VERBOSE_STATE) \
1967 _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
1968 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1969 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1970 ctx->NewState |= newstate; \
1973 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1975 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1976 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1981 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1983 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1984 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1989 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1991 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1992 FLUSH_VERTICES(ctx, 0); \
1995 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1997 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1998 FLUSH_VERTICES(ctx, 0); \
2004 #endif /* TYPES_H */