2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * Main Mesa data structures.
30 * Please try to mark derived values with a leading underscore ('_').
37 #include "main/glheader.h"
38 #include "main/config.h"
39 #include "main/mfeatures.h"
40 #include "math/m_matrix.h" /* GLmatrix */
41 #include "main/simple_list.h" /* struct simple_node */
42 #include "main/formats.h" /* MESA_FORMAT_COUNT */
51 * \name 64-bit extension of GLbitfield.
54 typedef GLuint64 GLbitfield64
;
56 /** Set a single bit */
57 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
58 /** Set all bits up to excluding bit b */
59 #define BITFIELD64_MASK(b) \
60 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
61 /** Set count bits starting from bit b */
62 #define BITFIELD64_RANGE(b, count) \
63 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
67 * \name Some forward type declarations
70 struct _mesa_HashTable
;
71 struct gl_attrib_node
;
72 struct gl_list_extensions
;
74 struct gl_texture_object
;
80 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
81 #define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1)
82 #define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2)
83 #define PRIM_UNKNOWN (GL_POLYGON+3)
88 * Indexes for vertex program attributes.
89 * GL_NV_vertex_program aliases generic attributes over the conventional
90 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
91 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
92 * generic attributes are distinct/separate).
97 VERT_ATTRIB_WEIGHT
= 1,
98 VERT_ATTRIB_NORMAL
= 2,
99 VERT_ATTRIB_COLOR0
= 3,
100 VERT_ATTRIB_COLOR1
= 4,
102 VERT_ATTRIB_COLOR_INDEX
= 6,
103 VERT_ATTRIB_EDGEFLAG
= 7,
105 VERT_ATTRIB_POINT_SIZE
= 9,
110 * Symbolic constats to help iterating over
111 * specific blocks of vertex attributes.
114 #define VERT_ATTRIB(i) (VERT_ATTRIB_POS + (i))
117 * Bitflags for vertex attributes.
118 * These are used in bitfields in many places.
121 #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
122 #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
123 #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
124 #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
125 #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
126 #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
127 #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
128 #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
129 #define VERT_BIT_TEX BITFIELD64_BIT(VERT_ATTRIB_TEX)
130 #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
132 #define VERT_BIT(i) BITFIELD64_BIT(i)
133 #define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1)
139 * Indexes for fragment program input attributes. Note that
140 * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make
141 * assumptions about the layout of this enum.
145 FRAG_ATTRIB_WPOS
= 0,
146 FRAG_ATTRIB_COL0
= 1,
147 FRAG_ATTRIB_COL1
= 2,
148 FRAG_ATTRIB_FOGC
= 3,
150 FRAG_ATTRIB_FACE
= 5, /**< front/back face */
151 FRAG_ATTRIB_PNTC
= 6, /**< sprite/point coord */
152 FRAG_ATTRIB_CLIP_DIST0
= 7,
153 FRAG_ATTRIB_CLIP_DIST1
= 8,
158 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
159 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
160 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
161 #define FRAG_BIT_TEX (1 << FRAG_ATTRIB_TEX)
164 * Indexes for all renderbuffers
168 /* the four standard color buffers */
176 /* optional aux buffer */
182 * Bit flags for all renderbuffers
184 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
185 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
186 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
187 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
188 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
189 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
190 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
191 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
192 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
193 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
194 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
197 * Mask of all the color buffer bits (but not accum).
199 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
200 BUFFER_BIT_BACK_LEFT | \
201 BUFFER_BIT_FRONT_RIGHT | \
202 BUFFER_BIT_BACK_RIGHT | \
207 * Framebuffer configuration (aka visual / pixelformat)
208 * Note: some of these fields should be boolean, but it appears that
209 * code in drivers/dri/common/util.c requires int-sized fields.
214 GLboolean colorIndexMode
; /* XXX is this used anywhere? */
215 GLuint doubleBufferMode
;
218 GLboolean haveAccumBuffer
;
219 GLboolean haveDepthBuffer
;
220 GLboolean haveStencilBuffer
;
222 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
223 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
224 GLint rgbBits
; /* total bits for rgb */
225 GLint indexBits
; /* total bits for colorindex */
227 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
235 /* EXT_visual_rating / GLX 1.2 */
238 /* EXT_visual_info / GLX 1.2 */
239 GLint transparentPixel
;
240 /* colors are floats scaled to ints */
241 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
242 GLint transparentIndex
;
244 /* SGIX_pbuffer / GLX 1.3 */
245 GLint maxPbufferWidth
;
246 GLint maxPbufferHeight
;
247 GLint maxPbufferPixels
;
248 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
249 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
251 /* OML_swap_method */
254 /* EXT_texture_from_pixmap */
255 GLint bindToTextureRgb
;
256 GLint bindToTextureRgba
;
257 GLint bindToMipmapTexture
;
258 GLint bindToTextureTargets
;
264 * \name Bit flags used for updating material values.
267 #define MAT_ATTRIB_FRONT_AMBIENT 0
268 #define MAT_ATTRIB_BACK_AMBIENT 1
269 #define MAT_ATTRIB_FRONT_DIFFUSE 2
270 #define MAT_ATTRIB_BACK_DIFFUSE 3
271 #define MAT_ATTRIB_FRONT_SPECULAR 4
272 #define MAT_ATTRIB_BACK_SPECULAR 5
273 #define MAT_ATTRIB_FRONT_EMISSION 6
274 #define MAT_ATTRIB_BACK_EMISSION 7
275 #define MAT_ATTRIB_FRONT_SHININESS 8
276 #define MAT_ATTRIB_BACK_SHININESS 9
277 #define MAT_ATTRIB_FRONT_INDEXES 10
278 #define MAT_ATTRIB_BACK_INDEXES 11
279 #define MAT_ATTRIB_MAX 12
281 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
282 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
283 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
284 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
285 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
286 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
288 #define MAT_INDEX_AMBIENT 0
289 #define MAT_INDEX_DIFFUSE 1
290 #define MAT_INDEX_SPECULAR 2
292 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
293 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
294 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
295 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
296 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
297 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
298 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
299 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
300 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
301 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
302 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
303 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
306 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
307 MAT_BIT_FRONT_AMBIENT | \
308 MAT_BIT_FRONT_DIFFUSE | \
309 MAT_BIT_FRONT_SPECULAR | \
310 MAT_BIT_FRONT_SHININESS | \
311 MAT_BIT_FRONT_INDEXES)
313 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
314 MAT_BIT_BACK_AMBIENT | \
315 MAT_BIT_BACK_DIFFUSE | \
316 MAT_BIT_BACK_SPECULAR | \
317 MAT_BIT_BACK_SHININESS | \
318 MAT_BIT_BACK_INDEXES)
320 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
324 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
325 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
328 * Material shininess lookup table.
332 struct gl_shine_tab
*next
, *prev
;
333 GLfloat tab
[SHINE_TABLE_SIZE
+1];
340 * Light source state.
344 struct gl_light
*next
; /**< double linked list with sentinel */
345 struct gl_light
*prev
;
347 GLfloat Ambient
[4]; /**< ambient color */
348 GLfloat Diffuse
[4]; /**< diffuse color */
349 GLfloat Specular
[4]; /**< specular color */
350 GLfloat EyePosition
[4]; /**< position in eye coordinates */
351 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
352 GLfloat SpotExponent
;
353 GLfloat SpotCutoff
; /**< in degrees */
354 GLfloat _CosCutoffNeg
; /**< = cos(SpotCutoff) */
355 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
356 GLfloat ConstantAttenuation
;
357 GLfloat LinearAttenuation
;
358 GLfloat QuadraticAttenuation
;
359 GLboolean Enabled
; /**< On/off flag */
362 * \name Derived fields
365 GLbitfield _Flags
; /**< State */
367 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
368 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
369 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
370 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
371 GLfloat _VP_inf_spot_attenuation
;
373 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
374 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
375 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
376 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
386 GLfloat Ambient
[4]; /**< ambient color */
387 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
388 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
389 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
390 * or GL_SEPARATE_SPECULAR_COLOR */
399 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
404 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
406 struct gl_accum_attrib
408 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
413 * Used for storing clear color, texture border color, etc.
414 * The float values are typically unclamped.
425 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
427 struct gl_colorbuffer_attrib
429 GLuint ClearIndex
; /**< Index for glClear */
430 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
431 GLuint IndexMask
; /**< Color index write mask */
432 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
434 GLenum DrawBuffer
; /**< Which buffer to draw into */
437 * \name alpha testing
440 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
441 GLenum AlphaFunc
; /**< Alpha test function */
442 GLclampf AlphaRef
; /**< Alpha reference value */
449 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
451 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
452 * control, only on the fixed-pointness of the render target.
453 * The query does however depend on fragment color clamping.
455 GLfloat BlendColor
[4]; /**< Blending color */
457 GLenum SrcRGB
; /**< RGB blend source term */
458 GLenum DstRGB
; /**< RGB blend dest term */
459 GLenum SrcA
; /**< Alpha blend source term */
460 GLenum DstA
; /**< Alpha blend dest term */
461 GLenum EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
462 GLenum EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
469 GLenum LogicOp
; /**< Logic operator */
470 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
471 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
474 GLboolean DitherFlag
; /**< Dither enable flag */
479 * Current attribute group (GL_CURRENT_BIT).
481 struct gl_current_attrib
484 * \name Current vertex attributes.
485 * \note Values are valid only after FLUSH_VERTICES has been called.
486 * \note Index and Edgeflag current values are stored as floats in the
487 * SIX and SEVEN attribute slots.
489 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Position, color, texcoords, etc */
492 * \name Current raster position attributes (always valid).
493 * \note This set of attributes is very similar to the SWvertex struct.
496 GLfloat RasterPos
[4];
497 GLfloat RasterDistance
;
498 GLfloat RasterColor
[4];
499 GLfloat RasterSecondaryColor
[4];
500 GLfloat RasterTexCoords
[4];
501 GLboolean RasterPosValid
;
507 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
509 struct gl_depthbuffer_attrib
511 GLenum Func
; /**< Function for depth buffer compare */
512 GLclampd Clear
; /**< Value to clear depth buffer to */
513 GLboolean Test
; /**< Depth buffering enabled flag */
514 GLboolean Mask
; /**< Depth buffer writable? */
515 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
516 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
521 * Evaluator attribute group (GL_EVAL_BIT).
523 struct gl_eval_attrib
529 GLboolean Map1Color4
;
531 GLboolean Map1Normal
;
532 GLboolean Map1TextureCoord1
;
533 GLboolean Map1TextureCoord2
;
534 GLboolean Map1TextureCoord3
;
535 GLboolean Map1TextureCoord4
;
536 GLboolean Map1Vertex3
;
537 GLboolean Map1Vertex4
;
538 GLboolean Map2Color4
;
540 GLboolean Map2Normal
;
541 GLboolean Map2TextureCoord1
;
542 GLboolean Map2TextureCoord2
;
543 GLboolean Map2TextureCoord3
;
544 GLboolean Map2TextureCoord4
;
545 GLboolean Map2Vertex3
;
546 GLboolean Map2Vertex4
;
547 GLboolean AutoNormal
;
551 * \name Map Grid endpoints and divisions and calculated du values
555 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
556 GLint MapGrid2un
, MapGrid2vn
;
557 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
558 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
564 * Fog attribute group (GL_FOG_BIT).
568 GLboolean Enabled
; /**< Fog enabled flag */
569 GLfloat Color
[4]; /**< Fog color */
570 GLfloat Density
; /**< Density >= 0.0 */
571 GLfloat Start
; /**< Start distance in eye coords */
572 GLfloat End
; /**< End distance in eye coords */
573 GLfloat Index
; /**< Fog index */
574 GLenum Mode
; /**< Fog mode */
575 GLboolean ColorSumEnabled
;
576 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
577 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
578 GLenum FogDistanceMode
; /**< GL_NV_fog_distance */
583 * \brief Layout qualifiers for gl_FragDepth.
585 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
586 * a layout qualifier.
588 * \see enum ir_depth_layout
590 enum gl_frag_depth_layout
{
591 FRAG_DEPTH_LAYOUT_NONE
, /**< No layout is specified. */
592 FRAG_DEPTH_LAYOUT_ANY
,
593 FRAG_DEPTH_LAYOUT_GREATER
,
594 FRAG_DEPTH_LAYOUT_LESS
,
595 FRAG_DEPTH_LAYOUT_UNCHANGED
600 * Hint attribute group (GL_HINT_BIT).
602 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
604 struct gl_hint_attrib
606 GLenum PerspectiveCorrection
;
609 GLenum PolygonSmooth
;
611 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
618 #define LIGHT_SPOT 0x1
619 #define LIGHT_LOCAL_VIEWER 0x2
620 #define LIGHT_POSITIONAL 0x4
621 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
626 * Lighting attribute group (GL_LIGHT_BIT).
628 struct gl_light_attrib
630 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
631 struct gl_lightmodel Model
; /**< Lighting model */
634 * Must flush FLUSH_VERTICES before referencing:
637 struct gl_material Material
; /**< Includes front & back values */
640 GLboolean Enabled
; /**< Lighting enabled flag */
641 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
642 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
643 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
644 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
645 GLboolean ColorMaterialEnabled
;
647 struct gl_light EnabledList
; /**< List sentinel */
650 * Derived state for optimizations:
653 GLboolean _NeedEyeCoords
;
654 GLboolean _NeedVertices
; /**< Use fast shader? */
655 GLbitfield _Flags
; /**< LIGHT_* flags, see above */
656 GLfloat _BaseColor
[2][3];
662 * Line attribute group (GL_LINE_BIT).
664 struct gl_line_attrib
666 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
667 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
668 GLushort StipplePattern
; /**< Stipple pattern */
669 GLint StippleFactor
; /**< Stipple repeat factor */
670 GLfloat Width
; /**< Line width */
675 * Display list attribute group (GL_LIST_BIT).
677 struct gl_list_attrib
684 * Multisample attribute group (GL_MULTISAMPLE_BIT).
686 struct gl_multisample_attrib
689 GLboolean _Enabled
; /**< true if Enabled and multisample buffer */
690 GLboolean SampleAlphaToCoverage
;
691 GLboolean SampleAlphaToOne
;
692 GLboolean SampleCoverage
;
693 GLfloat SampleCoverageValue
;
694 GLboolean SampleCoverageInvert
;
699 * A pixelmap (see glPixelMap)
704 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
705 GLubyte Map8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
710 * Collection of all pixelmaps
714 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
715 struct gl_pixelmap GtoG
;
716 struct gl_pixelmap BtoB
;
717 struct gl_pixelmap AtoA
;
718 struct gl_pixelmap ItoR
;
719 struct gl_pixelmap ItoG
;
720 struct gl_pixelmap ItoB
;
721 struct gl_pixelmap ItoA
;
722 struct gl_pixelmap ItoI
;
723 struct gl_pixelmap StoS
;
728 * Pixel attribute group (GL_PIXEL_MODE_BIT).
730 struct gl_pixel_attrib
732 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
734 /*--- Begin Pixel Transfer State ---*/
735 /* Fields are in the order in which they're applied... */
737 /** Scale & Bias (index shift, offset) */
739 GLfloat RedBias
, RedScale
;
740 GLfloat GreenBias
, GreenScale
;
741 GLfloat BlueBias
, BlueScale
;
742 GLfloat AlphaBias
, AlphaScale
;
743 GLfloat DepthBias
, DepthScale
;
744 GLint IndexShift
, IndexOffset
;
748 /* Note: actual pixel maps are not part of this attrib group */
749 GLboolean MapColorFlag
;
750 GLboolean MapStencilFlag
;
752 /*--- End Pixel Transfer State ---*/
755 GLfloat ZoomX
, ZoomY
;
760 * Point attribute group (GL_POINT_BIT).
762 struct gl_point_attrib
764 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
765 GLfloat Size
; /**< User-specified point size */
766 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
767 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
768 GLfloat Threshold
; /**< GL_EXT_point_parameters */
769 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
770 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
771 GLboolean CoordReplace
; /**< GL_ARB_point_sprite*/
772 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
773 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
778 * Polygon attribute group (GL_POLYGON_BIT).
780 struct gl_polygon_attrib
782 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
783 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
784 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
785 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
786 GLboolean CullFlag
; /**< Culling on/off flag */
787 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
788 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
789 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
790 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
791 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
792 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
793 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
794 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
799 * Scissor attributes (GL_SCISSOR_BIT).
801 struct gl_scissor_attrib
803 GLboolean Enabled
; /**< Scissor test enabled? */
804 GLint X
, Y
; /**< Lower left corner of box */
805 GLsizei Width
, Height
; /**< Size of box */
810 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
813 struct gl_stencil_attrib
815 GLboolean Enabled
; /**< Enabled flag */
816 GLboolean _Enabled
; /**< Enabled and stencil buffer present */
817 GLenum Function
; /**< Stencil function */
818 GLenum FailFunc
; /**< Fail function */
819 GLenum ZPassFunc
; /**< Depth buffer pass function */
820 GLenum ZFailFunc
; /**< Depth buffer fail function */
821 GLint Ref
; /**< Reference value */
822 GLuint ValueMask
; /**< Value mask */
823 GLuint WriteMask
; /**< Write mask */
824 GLuint Clear
; /**< Clear value */
829 * An index for each type of texture object. These correspond to the GL
830 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
831 * Note: the order is from highest priority to lowest priority.
843 * Bit flags for each type of texture object
844 * Used for Texture.Unit[]._ReallyEnabled flags.
847 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
848 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
849 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
854 * TexGenEnabled flags.
861 #define STR_BITS (S_BIT | T_BIT | R_BIT)
866 * Bit flag versions of the corresponding GL_ constants.
869 #define TEXGEN_SPHERE_MAP 0x1
870 #define TEXGEN_OBJ_LINEAR 0x2
871 #define TEXGEN_EYE_LINEAR 0x4
872 #define TEXGEN_REFLECTION_MAP_NV 0x8
873 #define TEXGEN_NORMAL_MAP_NV 0x10
875 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
876 TEXGEN_REFLECTION_MAP_NV | \
877 TEXGEN_NORMAL_MAP_NV)
878 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
879 TEXGEN_REFLECTION_MAP_NV | \
880 TEXGEN_NORMAL_MAP_NV | \
886 /** Tex-gen enabled for texture unit? */
887 #define ENABLE_TEXGEN(unit) (1 << (unit))
889 /** Non-identity texture matrix for texture unit? */
890 #define ENABLE_TEXMAT(unit) (1 << (unit))
894 * Texture image state. Drivers will typically create a subclass of this
895 * with extra fields for memory buffers, etc.
897 struct gl_texture_image
899 GLint InternalFormat
; /**< Internal format as given by the user */
900 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
901 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
902 * GL_INTENSITY, GL_DEPTH_COMPONENT or
903 * GL_DEPTH_STENCIL_EXT only. Used for
904 * choosing TexEnv arithmetic.
906 gl_format TexFormat
; /**< The actual texture memory format */
908 GLuint Border
; /**< 0 or 1 */
909 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
910 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
911 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
912 GLuint Width2
; /**< = Width - 2*Border */
913 GLuint Height2
; /**< = Height - 2*Border */
914 GLuint Depth2
; /**< = Depth - 2*Border */
915 GLuint WidthLog2
; /**< = log2(Width2) */
916 GLuint HeightLog2
; /**< = log2(Height2) */
917 GLuint DepthLog2
; /**< = log2(Depth2) */
918 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
920 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
921 GLuint Level
; /**< Which mipmap level am I? */
922 /** Cube map face: index into gl_texture_object::Image[] array */
928 * Indexes for cube map faces.
942 * Sampler object state. These objects are new with GL_ARB_sampler_objects
943 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
945 struct gl_sampler_object
950 GLenum WrapS
; /**< S-axis texture image wrap mode */
951 GLenum WrapT
; /**< T-axis texture image wrap mode */
952 GLenum WrapR
; /**< R-axis texture image wrap mode */
953 GLenum MinFilter
; /**< minification filter */
954 GLenum MagFilter
; /**< magnification filter */
955 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
956 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
962 * Texture object state. Contains the array of mipmap images, border color,
963 * wrap modes, filter modes, and shadow/texcompare state.
965 struct gl_texture_object
967 _glthread_Mutex Mutex
; /**< for thread safety */
968 GLint RefCount
; /**< reference count */
969 GLuint Name
; /**< the user-visible texture object ID */
970 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
972 struct gl_sampler_object Sampler
;
974 GLfloat Priority
; /**< in [0,1] */
975 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
976 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
977 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
978 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
979 GLboolean _Complete
; /**< Is texture object complete? */
980 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
981 GLboolean Immutable
; /**< GL_ARB_texture_storage */
983 /** Actual texture images, indexed by [cube face] and [mipmap level] */
984 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
988 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
989 #define MAX_COMBINER_TERMS 4
993 * Texture combine environment state.
995 struct gl_tex_env_combine_state
997 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
998 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
999 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1000 GLenum SourceRGB
[MAX_COMBINER_TERMS
];
1001 GLenum SourceA
[MAX_COMBINER_TERMS
];
1002 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1003 GLenum OperandRGB
[MAX_COMBINER_TERMS
];
1004 GLenum OperandA
[MAX_COMBINER_TERMS
];
1005 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1006 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1007 GLuint _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1008 GLuint _NumArgsA
; /**< Number of inputs used for the A combiner */
1013 * Texture coord generation state.
1017 GLenum Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1018 GLbitfield _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1019 GLfloat ObjectPlane
[4];
1020 GLfloat EyePlane
[4];
1025 * Texture unit state. Contains enable flags, texture environment/function/
1026 * combiners, texgen state, and pointers to current texture objects.
1028 struct gl_texture_unit
1030 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1031 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1033 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1034 GLclampf EnvColor
[4];
1036 struct gl_texgen GenS
;
1037 struct gl_texgen GenT
;
1038 struct gl_texgen GenR
;
1039 struct gl_texgen GenQ
;
1040 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1041 GLbitfield _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1043 GLfloat LodBias
; /**< for biasing mipmap levels */
1046 * \name GL_EXT_texture_env_combine
1048 struct gl_tex_env_combine_state Combine
;
1051 * Derived state based on \c EnvMode and the \c BaseFormat of the
1052 * currently enabled texture.
1054 struct gl_tex_env_combine_state _EnvMode
;
1057 * Currently enabled combiner state. This will point to either
1058 * \c Combine or \c _EnvMode.
1060 struct gl_tex_env_combine_state
*_CurrentCombine
;
1062 /** Current texture object pointers */
1063 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1065 /** Points to highest priority, complete and enabled texture object */
1066 struct gl_texture_object
*_Current
;
1071 * Texture attribute group (GL_TEXTURE_BIT).
1073 struct gl_texture_attrib
1075 struct gl_texture_unit Unit
;
1077 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1081 /** Texture coord units/sets used for fragment texturing */
1082 GLboolean _EnabledCoord
;
1084 /** Texture coord units that have texgen enabled */
1085 GLboolean _TexGenEnabled
;
1087 /** Texture coord units that have non-identity matrices */
1088 GLboolean _TexMatEnabled
;
1090 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1091 GLbitfield _GenFlags
;
1096 * Data structure representing a single clip plane (e.g. one of the elements
1097 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1099 typedef GLfloat gl_clip_plane
[4];
1103 * Transformation attribute group (GL_TRANSFORM_BIT).
1105 struct gl_transform_attrib
1107 GLenum MatrixMode
; /**< Matrix mode */
1108 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1109 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1110 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1111 GLboolean Normalize
; /**< Normalize all normals? */
1112 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1113 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1115 GLfloat CullEyePos
[4];
1116 GLfloat CullObjPos
[4];
1121 * Viewport attribute group (GL_VIEWPORT_BIT).
1123 struct gl_viewport_attrib
1125 GLint X
, Y
; /**< position */
1126 GLsizei Width
, Height
; /**< size */
1127 GLfloat Near
, Far
; /**< Depth buffer range */
1128 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1133 * GL_ARB_vertex/pixel_buffer_object buffer object
1135 struct gl_buffer_object
1137 _glthread_Mutex Mutex
;
1140 GLenum Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1141 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1142 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1143 /** Fields describing a mapped buffer */
1145 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1146 GLvoid
*Pointer
; /**< User-space address of mapping */
1147 GLintptr Offset
; /**< Mapped offset */
1148 GLsizeiptr Length
; /**< Mapped length */
1150 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1151 GLboolean Written
; /**< Ever written to? (for debugging) */
1152 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1157 * Client pixel packing/unpacking attributes
1159 struct gl_pixelstore_attrib
1167 GLboolean SwapBytes
;
1169 GLboolean Invert
; /**< GL_MESA_pack_invert */
1174 * Client vertex array attributes
1176 struct gl_client_array
1178 GLint Size
; /**< components per element (1,2,3,4) */
1179 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1180 GLsizei Stride
; /**< user-specified stride */
1181 GLsizei StrideB
; /**< actual stride in bytes */
1182 const GLubyte
*Ptr
; /**< Points to array data */
1183 GLboolean Enabled
; /**< Enabled flag is a boolean */
1184 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1185 GLboolean Integer
; /**< Integer-valued? */
1186 GLuint _ElementSize
; /**< size of each element in bytes */
1188 struct gl_buffer_object
*BufferObj
;/**< GL_ARB_vertex_buffer_object */
1189 GLuint _MaxElement
; /**< max element index into array buffer + 1 */
1194 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1195 * extension, but a nice encapsulation in any case.
1197 struct gl_array_object
1199 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1203 _glthread_Mutex Mutex
;
1206 * Does the VAO use ARB semantics or Apple semantics?
1208 * There are several ways in which ARB_vertex_array_object and
1209 * APPLE_vertex_array_object VAOs have differing semantics. At the very
1212 * - ARB VAOs require that all array data be sourced from vertex buffer
1213 * objects, but Apple VAOs do not.
1215 * - ARB VAOs require that names come from GenVertexArrays.
1217 * This flag notes which behavior governs this VAO.
1219 GLboolean ARBsemantics
;
1222 * Has this array object been bound?
1226 /** Vertex attribute arrays */
1227 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1229 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1230 GLbitfield64 _Enabled
;
1233 * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs
1234 * we can determine the max legal (in bounds) glDrawElements array index.
1238 struct gl_buffer_object
*ElementArrayBufferObj
;
1243 * Vertex array state
1245 struct gl_array_attrib
1247 /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
1248 struct gl_array_object
*ArrayObj
;
1250 /** The default vertex array object */
1251 struct gl_array_object
*DefaultArrayObj
;
1253 /** Array objects (GL_ARB/APPLE_vertex_array_object) */
1254 struct _mesa_HashTable
*Objects
;
1256 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1257 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1259 GLbitfield64 NewState
; /**< mask of VERT_BIT_* values */
1260 GLboolean RebindArrays
; /**< whether the VBO module should rebind arrays */
1262 /* GL_ARB_vertex_buffer_object */
1263 struct gl_buffer_object
*ArrayBufferObj
;
1268 * Feedback buffer state
1273 GLbitfield _Mask
; /**< FB_* bits */
1281 * Selection buffer state
1285 GLuint
*Buffer
; /**< selection buffer */
1286 GLuint BufferSize
; /**< size of the selection buffer */
1287 GLuint BufferCount
; /**< number of values in the selection buffer */
1288 GLuint Hits
; /**< number of records in the selection buffer */
1289 GLuint NameStackDepth
; /**< name stack depth */
1290 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1291 GLboolean HitFlag
; /**< hit flag */
1292 GLfloat HitMinZ
; /**< minimum hit depth */
1293 GLfloat HitMaxZ
; /**< maximum hit depth */
1298 * 1-D Evaluator control points
1302 GLuint Order
; /**< Number of control points */
1303 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1304 GLfloat
*Points
; /**< Points to contiguous control points */
1309 * 2-D Evaluator control points
1313 GLuint Uorder
; /**< Number of control points in U dimension */
1314 GLuint Vorder
; /**< Number of control points in V dimension */
1317 GLfloat
*Points
; /**< Points to contiguous control points */
1322 * All evaluator control point state
1324 struct gl_evaluators
1330 struct gl_1d_map Map1Vertex3
;
1331 struct gl_1d_map Map1Vertex4
;
1332 struct gl_1d_map Map1Index
;
1333 struct gl_1d_map Map1Color4
;
1334 struct gl_1d_map Map1Normal
;
1335 struct gl_1d_map Map1Texture1
;
1336 struct gl_1d_map Map1Texture2
;
1337 struct gl_1d_map Map1Texture3
;
1338 struct gl_1d_map Map1Texture4
;
1345 struct gl_2d_map Map2Vertex3
;
1346 struct gl_2d_map Map2Vertex4
;
1347 struct gl_2d_map Map2Index
;
1348 struct gl_2d_map Map2Color4
;
1349 struct gl_2d_map Map2Normal
;
1350 struct gl_2d_map Map2Texture1
;
1351 struct gl_2d_map Map2Texture2
;
1352 struct gl_2d_map Map2Texture3
;
1353 struct gl_2d_map Map2Texture4
;
1359 * State which can be shared by multiple contexts:
1361 struct gl_shared_state
1363 _glthread_Mutex Mutex
; /**< for thread safety */
1364 GLint RefCount
; /**< Reference count */
1365 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1366 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1368 /** Default texture objects (shared by all texture units) */
1369 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
1371 /** Fallback texture used when a bound texture is incomplete */
1372 struct gl_texture_object
*FallbackTex
;
1375 * \name Thread safety and statechange notification for texture
1378 * \todo Improve the granularity of locking.
1381 _glthread_Mutex TexMutex
; /**< texobj thread safety */
1382 GLuint TextureStateStamp
; /**< state notification for shared tex */
1385 /** Default buffer object for vertex arrays that aren't in VBOs */
1386 struct gl_buffer_object
*NullBufferObj
;
1388 struct _mesa_HashTable
*BufferObjects
;
1390 void *DriverData
; /**< Device driver shared state */
1396 * Renderbuffers represent drawing surfaces such as color, depth and/or
1397 * stencil. A framebuffer object has a set of renderbuffers.
1398 * Drivers will typically derive subclasses of this type.
1400 struct gl_renderbuffer
1402 _glthread_Mutex Mutex
; /**< for thread safety */
1403 GLuint ClassID
; /**< Useful for drivers */
1405 GLuint Width
, Height
;
1406 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1407 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
1408 GLenum InternalFormat
; /**< The user-specified format */
1409 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
1410 GL_STENCIL_INDEX. */
1411 gl_format Format
; /**< The actual renderbuffer memory format */
1413 /** Delete this renderbuffer */
1414 void (*Delete
)(struct gl_renderbuffer
*rb
);
1416 /** Allocate new storage for this renderbuffer */
1417 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
1418 struct gl_renderbuffer
*rb
,
1419 GLenum internalFormat
,
1420 GLuint width
, GLuint height
);
1425 * A renderbuffer attachment points to either a texture object (and specifies
1426 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
1428 struct gl_renderbuffer_attachment
1431 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
1432 * application supplied renderbuffer object.
1434 struct gl_renderbuffer
*Renderbuffer
;
1439 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
1440 * In C++ terms, think of this as a base class from which device drivers
1441 * will make derived classes.
1443 struct gl_framebuffer
1445 _glthread_Mutex Mutex
; /**< for thread safety */
1448 GLboolean DeletePending
;
1451 * The framebuffer's visual. Immutable if this is a window system buffer.
1452 * Computed from attachments if user-made FBO.
1454 struct gl_config Visual
;
1456 GLboolean Initialized
;
1458 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1460 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
1462 GLint _Xmin
, _Xmax
; /**< inclusive */
1463 GLint _Ymin
, _Ymax
; /**< exclusive */
1466 /** \name Derived Z buffer stuff */
1468 GLuint _DepthMax
; /**< Max depth buffer value */
1469 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
1470 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
1473 /** Integer color values */
1474 GLboolean _IntegerColor
;
1476 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
1477 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
1479 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
1480 * attribute group and GL_PIXEL attribute group, respectively.
1482 GLenum ColorDrawBuffer
;
1483 GLenum ColorReadBuffer
;
1485 /** Computed from ColorDraw/ReadBuffer above */
1486 GLint _ColorDrawBufferIndex
; /**< BUFFER_x or -1 */
1487 GLint _ColorReadBufferIndex
; /* -1 = None */
1488 struct gl_renderbuffer
*_ColorDrawBuffer
;
1489 struct gl_renderbuffer
*_ColorReadBuffer
;
1491 /** Delete this framebuffer */
1492 void (*Delete
)(struct gl_framebuffer
*fb
);
1497 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
1501 GLushort RangeMin
; /**< min value exponent */
1502 GLushort RangeMax
; /**< max value exponent */
1503 GLushort Precision
; /**< number of mantissa bits */
1507 * Constants which may be overridden by device driver during context creation
1508 * but are never changed after that.
1512 GLint MaxTextureMbytes
; /**< Max memory per image, in MB */
1513 GLint MaxTextureLevels
; /**< Max mipmap levels. */
1514 GLint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
1515 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1517 GLuint MaxArrayLockSize
;
1521 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
1522 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
1523 GLfloat PointSizeGranularity
;
1524 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
1525 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
1526 GLfloat LineWidthGranularity
;
1528 GLuint MaxColorTableSize
;
1530 GLuint MaxClipPlanes
;
1532 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
1533 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
1535 GLuint MaxViewportWidth
, MaxViewportHeight
;
1537 /** vertex array / buffer object bounds checking */
1538 GLboolean CheckArrayBounds
;
1541 * Does the driver support real 32-bit integers? (Otherwise, integers are
1542 * simulated via floats.)
1544 GLboolean NativeIntegers
;
1546 /** OpenGL version 3.0 */
1547 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
1549 /** OpenGL version 3.2 */
1550 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
1553 * Whether the implementation strips out and ignores texture borders.
1555 * Many GPU hardware implementations don't support rendering with texture
1556 * borders and mipmapped textures. (Note: not static border color, but the
1557 * old 1-pixel border around each edge). Implementations then have to do
1558 * slow fallbacks to be correct, or just ignore the border and be fast but
1559 * wrong. Setting the flag stripts the border off of TexImage calls,
1560 * providing "fast but wrong" at significantly reduced driver complexity.
1562 * Texture borders are deprecated in GL 3.0.
1564 GLboolean StripTextureBorder
;
1569 * Enable flag for each OpenGL extension. Different device drivers will
1570 * enable different extensions at runtime.
1572 struct gl_extensions
1574 GLboolean dummy
; /* don't remove this! */
1575 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
1576 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
1577 GLboolean ARB_map_buffer_range
;
1578 GLboolean ARB_point_sprite
;
1579 GLboolean ARB_texture_cube_map
;
1580 GLboolean ARB_texture_env_combine
;
1581 GLboolean ARB_texture_env_crossbar
;
1582 GLboolean ARB_texture_env_dot3
;
1583 GLboolean ARB_texture_storage
;
1584 GLboolean ARB_transpose_matrix
;
1585 GLboolean ARB_vertex_array_object
;
1586 GLboolean ARB_window_pos
;
1587 GLboolean EXT_blend_color
;
1588 GLboolean EXT_blend_equation_separate
;
1589 GLboolean EXT_blend_func_separate
;
1590 GLboolean EXT_blend_minmax
;
1591 GLboolean EXT_clip_volume_hint
;
1592 GLboolean EXT_compiled_vertex_array
;
1593 GLboolean EXT_depth_bounds_test
;
1594 GLboolean EXT_draw_range_elements
;
1595 GLboolean EXT_fog_coord
;
1596 GLboolean EXT_packed_pixels
;
1597 GLboolean EXT_point_parameters
;
1598 GLboolean EXT_rescale_normal
;
1599 GLboolean EXT_shadow_funcs
;
1600 GLboolean EXT_secondary_color
;
1601 GLboolean EXT_separate_shader_objects
;
1602 GLboolean EXT_separate_specular_color
;
1603 GLboolean EXT_texture3D
;
1604 GLboolean EXT_texture_env_dot3
;
1605 GLboolean EXT_texture_filter_anisotropic
;
1606 GLboolean EXT_texture_integer
;
1607 /* vendor extensions */
1608 GLboolean APPLE_packed_pixels
;
1609 GLboolean APPLE_vertex_array_object
;
1610 GLboolean APPLE_object_purgeable
;
1611 GLboolean ATI_texture_env_combine3
;
1612 GLboolean IBM_rasterpos_clip
;
1613 GLboolean IBM_multimode_draw_arrays
;
1614 GLboolean MESA_pack_invert
;
1615 GLboolean MESA_resize_buffers
;
1616 GLboolean MESA_ycbcr_texture
;
1617 GLboolean NV_blend_square
;
1618 GLboolean NV_fog_distance
;
1619 GLboolean NV_light_max_exponent
;
1620 GLboolean NV_point_sprite
;
1621 GLboolean NV_texture_barrier
;
1622 GLboolean NV_texgen_reflection
;
1623 GLboolean NV_texture_env_combine4
;
1624 GLboolean extension_sentinel
;
1625 /** The extension string */
1626 const GLubyte
*String
;
1627 /** Number of supported extensions */
1633 * A stack of matrices (projection, modelview, color, texture, etc).
1635 struct gl_matrix_stack
1637 GLmatrix
*Top
; /**< points into Stack */
1638 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1639 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1640 GLuint MaxDepth
; /**< size of Stack[] array */
1641 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1646 * \name Bits for image transfer operations
1647 * \sa __struct gl_contextRec::ImageTransferState.
1650 #define IMAGE_SCALE_BIAS_BIT 0x1
1651 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1652 #define IMAGE_MAP_COLOR_BIT 0x4
1653 #define IMAGE_CLAMP_BIT 0x800
1656 /** Pixel Transfer ops */
1657 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
1658 IMAGE_SHIFT_OFFSET_BIT | \
1659 IMAGE_MAP_COLOR_BIT)
1662 * \name Bits to indicate what state has changed.
1665 #define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */
1666 #define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */
1667 #define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */
1668 #define _NEW_COLOR (1 << 3) /**< gl_context::Color */
1669 #define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */
1670 #define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */
1671 #define _NEW_FOG (1 << 6) /**< gl_context::Fog */
1672 #define _NEW_HINT (1 << 7) /**< gl_context::Hint */
1673 #define _NEW_LIGHT (1 << 8) /**< gl_context::Light */
1674 #define _NEW_LINE (1 << 9) /**< gl_context::Line */
1675 #define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */
1676 #define _NEW_POINT (1 << 11) /**< gl_context::Point */
1677 #define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */
1678 #define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */
1679 #define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */
1680 #define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */
1681 #define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */
1682 #define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */
1683 #define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */
1684 #define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */
1685 #define _NEW_ARRAY (1 << 20) /**< gl_context::Array */
1686 #define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */
1687 #define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */
1688 #define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */
1689 #define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */
1690 #define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */
1691 #define _NEW_BUFFER_OBJECT (1 << 26)
1695 * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for
1698 #define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM
1703 * \name A bunch of flags that we think might be useful to drivers.
1705 * Set in the __struct gl_contextRec::_TriangleCaps bitfield.
1708 #define DD_FLATSHADE 0x1
1709 #define DD_SEPARATE_SPECULAR 0x2
1710 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1711 #define DD_TRI_LIGHT_TWOSIDE 0x8
1712 #define DD_TRI_UNFILLED 0x10
1713 #define DD_TRI_SMOOTH 0x20
1714 #define DD_TRI_STIPPLE 0x40
1715 #define DD_TRI_OFFSET 0x80
1716 #define DD_LINE_SMOOTH 0x100
1717 #define DD_LINE_STIPPLE 0x200
1718 #define DD_POINT_SMOOTH 0x400
1719 #define DD_POINT_ATTEN 0x800
1724 * \name Define the state changes under which each of these bits might change
1727 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1728 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1729 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1730 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1731 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1732 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1733 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1734 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1735 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1736 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1737 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1738 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1739 #define _DD_NEW_POINT_SIZE _NEW_POINT
1740 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1745 * Composite state flags
1748 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1757 /* This has to be included here. */
1762 * Display list flags.
1763 * Strictly this is a tnl-private concept, but it doesn't seem
1764 * worthwhile adding a tnl private structure just to hold this one bit
1767 #define DLIST_DANGLING_REFS 0x1
1770 /** Opaque declaration of display list payload data type */
1771 union gl_dlist_node
;
1775 * Provide a location where information about a display list can be
1776 * collected. Could be extended with driverPrivate structures,
1777 * etc. in the future.
1779 struct gl_display_list
1782 GLbitfield Flags
; /**< DLIST_x flags */
1783 /** The dlist commands are in a linked list of nodes */
1784 union gl_dlist_node
*Head
;
1789 * State used during display list compilation and execution.
1791 struct gl_dlist_state
1793 GLuint CallDepth
; /**< Current recursion calling depth */
1795 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
1796 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
1797 GLuint CurrentPos
; /**< Index into current block of nodes */
1799 GLvertexformat ListVtxfmt
;
1801 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
1802 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
1804 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
1805 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
1807 GLubyte ActiveIndex
;
1808 GLfloat CurrentIndex
;
1810 GLubyte ActiveEdgeFlag
;
1811 GLboolean CurrentEdgeFlag
;
1814 /* State known to have been set by the currently-compiling display
1815 * list. Used to eliminate some redundant state changes.
1823 * Mesa rendering context.
1825 * This is the central context data structure for Mesa. Almost all
1826 * OpenGL state is contained in this structure.
1827 * Think of this as a base class from which device drivers will derive
1830 * The struct gl_context typedef names this structure.
1834 /** State possibly shared with other contexts in the address space */
1835 struct gl_shared_state
*Shared
;
1837 /** \name API function pointer tables */
1839 struct _glapi_table
*Save
; /**< Display list save functions */
1840 struct _glapi_table
*Exec
; /**< Execute functions */
1841 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
1844 struct gl_config Visual
;
1845 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
1846 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
1847 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
1848 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
1851 * Device driver function pointer table
1853 struct dd_function_table Driver
;
1855 void *DriverCtx
; /**< Points to device driver context/state */
1857 /** Core/Driver constants */
1858 struct gl_constants Const
;
1860 /** \name The various 4x4 matrix stacks */
1862 struct gl_matrix_stack ModelviewMatrixStack
;
1863 struct gl_matrix_stack ProjectionMatrixStack
;
1864 struct gl_matrix_stack TextureMatrixStack
;
1865 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
1868 /** Combined modelview and projection matrix */
1869 GLmatrix _ModelProjectMatrix
;
1871 /** \name Display lists */
1872 struct gl_dlist_state ListState
;
1874 GLboolean ExecuteFlag
; /**< Execute GL commands? */
1875 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
1877 /** Extension information */
1878 struct gl_extensions Extensions
;
1881 GLuint VersionMajor
, VersionMinor
;
1882 char *VersionString
;
1884 /** \name State attribute stack (for glPush/PopAttrib) */
1886 GLuint AttribStackDepth
;
1887 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1890 /** \name Renderer attribute groups
1892 * We define a struct for each attribute group to make pushing and popping
1893 * attributes easy. Also it's a good organization.
1896 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
1897 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
1898 struct gl_current_attrib Current
; /**< Current attributes */
1899 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
1900 struct gl_eval_attrib Eval
; /**< Eval attributes */
1901 struct gl_fog_attrib Fog
; /**< Fog attributes */
1902 struct gl_hint_attrib Hint
; /**< Hint attributes */
1903 struct gl_light_attrib Light
; /**< Light attributes */
1904 struct gl_line_attrib Line
; /**< Line attributes */
1905 struct gl_list_attrib List
; /**< List attributes */
1906 struct gl_multisample_attrib Multisample
;
1907 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
1908 struct gl_point_attrib Point
; /**< Point attributes */
1909 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
1910 GLuint PolygonStipple
[32]; /**< Polygon stipple */
1911 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
1912 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
1913 struct gl_texture_attrib Texture
; /**< Texture attributes */
1914 struct gl_transform_attrib Transform
; /**< Transformation attributes */
1915 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
1918 /** \name Client attribute stack */
1920 GLuint ClientAttribStackDepth
;
1921 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1924 /** \name Client attribute groups */
1926 struct gl_array_attrib Array
; /**< Vertex arrays */
1927 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
1928 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
1929 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
1932 /** \name Other assorted state (not pushed/popped on attribute stack) */
1934 struct gl_pixelmaps PixelMaps
;
1936 struct gl_evaluators EvalMap
; /**< All evaluators */
1937 struct gl_feedback Feedback
; /**< Feedback */
1938 struct gl_selection Select
; /**< Selection */
1941 struct gl_meta_state
*Meta
; /**< for "meta" operations */
1943 /* GL_EXT_framebuffer_object */
1944 struct gl_renderbuffer
*CurrentRenderbuffer
;
1946 GLenum ErrorValue
; /**< Last error code */
1949 * Recognize and silence repeated error debug messages in buggy apps.
1951 const char *ErrorDebugFmtString
;
1952 GLuint ErrorDebugCount
;
1954 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1955 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
1957 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
1959 /** \name Derived state */
1961 /** Bitwise-or of DD_* flags. Note that this bitfield may be used before
1962 * state validation so they need to always be current.
1964 GLbitfield _TriangleCaps
;
1965 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
1966 GLfloat _EyeZDir
[3];
1967 GLfloat _ModelViewInvScale
;
1968 GLboolean _NeedEyeCoords
;
1969 GLboolean _ForceEyeCoords
;
1971 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
1973 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
1974 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
1977 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
1979 /** \name For debugging/development only */
1981 GLboolean FirstTimeCurrent
;
1984 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
1987 * Use dp4 (rather than mul/mad) instructions for position
1990 GLboolean mvp_with_dp4
;
1992 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
1995 * \name Hooks for module contexts.
1997 * These will eventually live in the driver or elsewhere.
2000 void *swrast_context
;
2001 void *swsetup_context
;
2002 void *swtnl_context
;
2004 struct st_context
*st
;
2011 extern int MESA_VERBOSE
;
2012 extern int MESA_DEBUG_FLAGS
;
2013 # define MESA_FUNCTION __FUNCTION__
2015 # define MESA_VERBOSE 0
2016 # define MESA_DEBUG_FLAGS 0
2017 # define MESA_FUNCTION "a function"
2024 /** The MESA_VERBOSE var is a bitmask of these flags */
2027 VERBOSE_VARRAY
= 0x0001,
2028 VERBOSE_TEXTURE
= 0x0002,
2029 VERBOSE_MATERIAL
= 0x0004,
2030 VERBOSE_PIPELINE
= 0x0008,
2031 VERBOSE_DRIVER
= 0x0010,
2032 VERBOSE_STATE
= 0x0020,
2033 VERBOSE_API
= 0x0040,
2034 VERBOSE_DISPLAY_LIST
= 0x0100,
2035 VERBOSE_LIGHTING
= 0x0200,
2036 VERBOSE_PRIMS
= 0x0400,
2037 VERBOSE_VERTS
= 0x0800,
2038 VERBOSE_DISASSEM
= 0x1000,
2039 VERBOSE_DRAW
= 0x2000,
2040 VERBOSE_SWAPBUFFERS
= 0x4000
2044 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
2047 DEBUG_ALWAYS_FLUSH
= 0x1
2056 #endif /* MTYPES_H */