3 * Main Mesa data structures.
5 * Please try to mark derived values with a leading underscore ('_').
9 * Mesa 3-D graphics library
12 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #include <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
40 #include "config.h" /* Hardwired parameters */
41 #include "glapitable.h"
43 #include "math/m_matrix.h" /* GLmatrix */
48 * Color channel data type.
51 typedef GLubyte GLchan
;
53 #define CHAN_MAXF 255.0F
54 #define CHAN_TYPE GL_UNSIGNED_BYTE
56 typedef GLushort GLchan
;
57 #define CHAN_MAX 65535
58 #define CHAN_MAXF 65535.0F
59 #define CHAN_TYPE GL_UNSIGNED_SHORT
61 typedef GLfloat GLchan
;
63 #define CHAN_MAXF 1.0F
64 #define CHAN_TYPE GL_FLOAT
66 #error "illegal number of color channel bits"
71 * Stencil buffer data type.
74 typedef GLubyte GLstencil
;
75 #elif STENCIL_BITS==16
76 typedef GLushort GLstencil
;
78 # error "illegal number of stencil bits"
83 * Fixed point data type.
87 * Fixed point arithmetic macros
89 #ifndef FIXED_FRAC_BITS
90 #define FIXED_FRAC_BITS 11
93 #define FIXED_SHIFT FIXED_FRAC_BITS
94 #define FIXED_ONE (1 << FIXED_SHIFT)
95 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
96 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
97 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
98 #define FIXED_EPSILON 1
99 #define FIXED_SCALE ((float) FIXED_ONE)
100 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
101 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
102 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
103 #define IntToFixed(I) ((I) << FIXED_SHIFT)
104 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
105 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
106 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
107 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
108 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
109 #define PosFloatToFixed(X) FloatToFixed(X)
110 #define SignedFloatToFixed(X) FloatToFixed(X)
115 * \name Some forward type declarations
118 struct _mesa_HashTable
;
119 struct gl_pixelstore_attrib
;
120 struct gl_texture_format
;
121 struct gl_texture_image
;
122 struct gl_texture_object
;
123 typedef struct __GLcontextRec GLcontext
;
124 typedef struct __GLcontextModesRec GLvisual
;
125 typedef struct gl_framebuffer GLframebuffer
;
131 * Indexes for vertex program attributes.
132 * GL_NV_vertex_program aliases generic attributes over the conventional
133 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
134 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
135 * generic attributes are distinct/separate).
140 VERT_ATTRIB_WEIGHT
= 1,
141 VERT_ATTRIB_NORMAL
= 2,
142 VERT_ATTRIB_COLOR0
= 3,
143 VERT_ATTRIB_COLOR1
= 4,
146 VERT_ATTRIB_SEVEN
= 7,
147 VERT_ATTRIB_TEX0
= 8,
148 VERT_ATTRIB_TEX1
= 9,
149 VERT_ATTRIB_TEX2
= 10,
150 VERT_ATTRIB_TEX3
= 11,
151 VERT_ATTRIB_TEX4
= 12,
152 VERT_ATTRIB_TEX5
= 13,
153 VERT_ATTRIB_TEX6
= 14,
154 VERT_ATTRIB_TEX7
= 15,
155 VERT_ATTRIB_GENERIC0
= 16,
156 VERT_ATTRIB_GENERIC1
= 17,
157 VERT_ATTRIB_GENERIC2
= 18,
158 VERT_ATTRIB_GENERIC3
= 19,
159 VERT_ATTRIB_GENERIC4
= 20,
160 VERT_ATTRIB_GENERIC5
= 21,
161 VERT_ATTRIB_GENERIC6
= 22,
162 VERT_ATTRIB_GENERIC7
= 23,
163 VERT_ATTRIB_GENERIC8
= 24,
164 VERT_ATTRIB_GENERIC9
= 25,
165 VERT_ATTRIB_GENERIC10
= 26,
166 VERT_ATTRIB_GENERIC11
= 27,
167 VERT_ATTRIB_GENERIC12
= 28,
168 VERT_ATTRIB_GENERIC13
= 29,
169 VERT_ATTRIB_GENERIC14
= 30,
170 VERT_ATTRIB_GENERIC15
= 31,
175 * Bitflags for vertex attributes.
176 * These are used in bitfields in many places.
179 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
180 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
181 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
182 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
183 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
184 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
185 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
186 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
187 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
188 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
189 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
190 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
191 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
192 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
193 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
194 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
195 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
196 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
197 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
198 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
199 #define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4)
200 #define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5)
201 #define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6)
202 #define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7)
203 #define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8)
204 #define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9)
205 #define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10)
206 #define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11)
207 #define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12)
208 #define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13)
209 #define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14)
210 #define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15)
212 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
213 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
217 * GLSL allows shader writers to allocate vertex result attributes (varyings) in
218 * single float component granularity. This is in contrast to vertex / fragment
219 * programs, where result attributes (actually texcoords) were allocated
220 * in 4-component vectors of floats granularity.
221 * For performance reasons, it would be optimal to stick with this scheme on a scalar
222 * processor. Varyings will likely be allocated as 3-component vectors, so statistically
224 * The constant VARYINGS_PER_VECTOR tells us how much of float components we pack into
225 * one result vector. For scalar processor it would be 1, for vector processor - 4.
227 * NOTE: Currently we pack varyings into vertex attributes.
229 #define VARYINGS_PER_VECTOR 2
230 #define VARYING_EMIT_STYLE EMIT_2F
231 #define MAX_VARYING_VECTORS ((MAX_VARYING_FLOATS + VARYINGS_PER_VECTOR - 1) / VARYINGS_PER_VECTOR)
234 * Indexes for vertex program result attributes
237 #define VERT_RESULT_HPOS 0
238 #define VERT_RESULT_COL0 1
239 #define VERT_RESULT_COL1 2
240 #define VERT_RESULT_FOGC 3
241 #define VERT_RESULT_TEX0 4
242 #define VERT_RESULT_TEX1 5
243 #define VERT_RESULT_TEX2 6
244 #define VERT_RESULT_TEX3 7
245 #define VERT_RESULT_TEX4 8
246 #define VERT_RESULT_TEX5 9
247 #define VERT_RESULT_TEX6 10
248 #define VERT_RESULT_TEX7 11
249 #define VERT_RESULT_PSIZ 12
250 #define VERT_RESULT_BFC0 13
251 #define VERT_RESULT_BFC1 14
252 #define VERT_RESULT_MAX 15
257 * Indexes for fragment program input attributes.
261 FRAG_ATTRIB_WPOS
= 0,
262 FRAG_ATTRIB_COL0
= 1,
263 FRAG_ATTRIB_COL1
= 2,
264 FRAG_ATTRIB_FOGC
= 3,
265 FRAG_ATTRIB_TEX0
= 4,
266 FRAG_ATTRIB_TEX1
= 5,
267 FRAG_ATTRIB_TEX2
= 6,
268 FRAG_ATTRIB_TEX3
= 7,
269 FRAG_ATTRIB_TEX4
= 8,
270 FRAG_ATTRIB_TEX5
= 9,
271 FRAG_ATTRIB_TEX6
= 10,
272 FRAG_ATTRIB_TEX7
= 11,
277 * Bitflags for fragment program input attributes.
280 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
281 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
282 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
283 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
284 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
285 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
286 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
287 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
288 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
289 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
290 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
291 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
293 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
305 * Fragment program results
308 #define FRAG_RESULT_COLR 0
309 #define FRAG_RESULT_COLH 1
310 #define FRAG_RESULT_DEPR 2
311 #define FRAG_RESULT_MAX 3
316 * Indexes for all renderbuffers
319 BUFFER_FRONT_LEFT
= 0, /* the four standard color buffers */
320 BUFFER_BACK_LEFT
= 1,
321 BUFFER_FRONT_RIGHT
= 2,
322 BUFFER_BACK_RIGHT
= 3,
323 BUFFER_AUX0
= 4, /* optional aux buffer */
330 BUFFER_COLOR0
= 11, /* generic renderbuffers */
342 * Bit flags for all renderbuffers
344 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
345 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
346 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
347 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
348 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
349 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
350 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
351 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
352 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
353 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
354 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
355 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
356 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
357 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
358 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
359 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
360 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
361 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
362 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
365 * Mask of all the color buffer bits (but not accum).
367 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
368 BUFFER_BIT_BACK_LEFT | \
369 BUFFER_BIT_FRONT_RIGHT | \
370 BUFFER_BIT_BACK_RIGHT | \
375 BUFFER_BIT_COLOR0 | \
376 BUFFER_BIT_COLOR1 | \
377 BUFFER_BIT_COLOR2 | \
378 BUFFER_BIT_COLOR3 | \
379 BUFFER_BIT_COLOR4 | \
380 BUFFER_BIT_COLOR5 | \
381 BUFFER_BIT_COLOR6 | \
388 * Data structure for color tables
390 struct gl_color_table
392 GLenum InternalFormat
; /**< The user-specified format */
393 GLenum _BaseFormat
; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
394 GLuint Size
; /**< number of entries (rows) in table */
395 GLvoid
*Table
; /**< points to data of <Type> */
396 GLenum Type
; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
401 GLubyte LuminanceSize
;
402 GLubyte IntensitySize
;
407 * \name Bit flags used for updating material values.
410 #define MAT_ATTRIB_FRONT_AMBIENT 0
411 #define MAT_ATTRIB_BACK_AMBIENT 1
412 #define MAT_ATTRIB_FRONT_DIFFUSE 2
413 #define MAT_ATTRIB_BACK_DIFFUSE 3
414 #define MAT_ATTRIB_FRONT_SPECULAR 4
415 #define MAT_ATTRIB_BACK_SPECULAR 5
416 #define MAT_ATTRIB_FRONT_EMISSION 6
417 #define MAT_ATTRIB_BACK_EMISSION 7
418 #define MAT_ATTRIB_FRONT_SHININESS 8
419 #define MAT_ATTRIB_BACK_SHININESS 9
420 #define MAT_ATTRIB_FRONT_INDEXES 10
421 #define MAT_ATTRIB_BACK_INDEXES 11
422 #define MAT_ATTRIB_MAX 12
424 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
425 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
426 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
427 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
428 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
429 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
431 #define MAT_INDEX_AMBIENT 0
432 #define MAT_INDEX_DIFFUSE 1
433 #define MAT_INDEX_SPECULAR 2
435 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
436 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
437 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
438 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
439 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
440 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
441 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
442 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
443 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
444 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
445 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
446 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
449 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
450 MAT_BIT_FRONT_AMBIENT | \
451 MAT_BIT_FRONT_DIFFUSE | \
452 MAT_BIT_FRONT_SPECULAR | \
453 MAT_BIT_FRONT_SHININESS | \
454 MAT_BIT_FRONT_INDEXES)
456 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
457 MAT_BIT_BACK_AMBIENT | \
458 MAT_BIT_BACK_DIFFUSE | \
459 MAT_BIT_BACK_SPECULAR | \
460 MAT_BIT_BACK_SHININESS | \
461 MAT_BIT_BACK_INDEXES)
463 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
467 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
468 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
471 * Material shininess lookup table.
475 struct gl_shine_tab
*next
, *prev
;
476 GLfloat tab
[SHINE_TABLE_SIZE
+1];
483 * Light source state.
487 struct gl_light
*next
; /**< double linked list with sentinel */
488 struct gl_light
*prev
;
490 GLfloat Ambient
[4]; /**< ambient color */
491 GLfloat Diffuse
[4]; /**< diffuse color */
492 GLfloat Specular
[4]; /**< specular color */
493 GLfloat EyePosition
[4]; /**< position in eye coordinates */
494 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
495 GLfloat SpotExponent
;
496 GLfloat SpotCutoff
; /**< in degrees */
497 GLfloat _CosCutoffNeg
; /**< = cos(SpotCutoff) */
498 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
499 GLfloat ConstantAttenuation
;
500 GLfloat LinearAttenuation
;
501 GLfloat QuadraticAttenuation
;
502 GLboolean Enabled
; /**< On/off flag */
505 * \name Derived fields
508 GLbitfield _Flags
; /**< State */
510 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
511 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
512 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
513 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
514 GLfloat _VP_inf_spot_attenuation
;
516 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
517 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
518 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
519 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
520 GLfloat _dli
; /**< CI diffuse light intensity */
521 GLfloat _sli
; /**< CI specular light intensity */
531 GLfloat Ambient
[4]; /**< ambient color */
532 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
533 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
534 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
535 * or GL_SEPARATE_SPECULAR_COLOR */
544 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
549 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
551 struct gl_accum_attrib
553 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
558 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
560 struct gl_colorbuffer_attrib
562 GLuint ClearIndex
; /**< Index to use for glClear */
563 GLclampf ClearColor
[4]; /**< Color to use for glClear */
565 GLuint IndexMask
; /**< Color index write mask */
566 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
568 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
571 * \name alpha testing
574 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
575 GLenum AlphaFunc
; /**< Alpha test function */
576 GLclampf AlphaRef
; /**< Alpha reference value */
583 GLboolean BlendEnabled
; /**< Blending enabled flag */
584 GLenum BlendSrcRGB
; /**< Blending source operator */
585 GLenum BlendDstRGB
; /**< Blending destination operator */
586 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
587 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
588 GLenum BlendEquationRGB
; /**< Blending equation */
589 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
590 GLfloat BlendColor
[4]; /**< Blending color */
597 GLenum LogicOp
; /**< Logic operator */
598 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
599 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
600 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
603 GLboolean DitherFlag
; /**< Dither enable flag */
605 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
606 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
611 * Current attribute group (GL_CURRENT_BIT).
613 struct gl_current_attrib
616 * \name Values valid only when FLUSH_VERTICES has been called.
619 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
620 * indexed by VERT_ATTRIB_* */
621 GLfloat Index
; /**< Current color index */
622 GLboolean EdgeFlag
; /**< Current edge flag */
626 * \name Values are always valid.
628 * \note BTW, note how similar this set of attributes is to the SWvertex
629 * data type in the software rasterizer...
632 GLfloat RasterPos
[4]; /**< Current raster position */
633 GLfloat RasterDistance
; /**< Current raster distance */
634 GLfloat RasterColor
[4]; /**< Current raster color */
635 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
636 GLfloat RasterIndex
; /**< Current raster index */
637 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
638 GLboolean RasterPosValid
; /**< Raster pos valid flag */
644 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
646 struct gl_depthbuffer_attrib
648 GLenum Func
; /**< Function for depth buffer compare */
649 GLclampd Clear
; /**< Value to clear depth buffer to */
650 GLboolean Test
; /**< Depth buffering enabled flag */
651 GLboolean Mask
; /**< Depth buffer writable? */
652 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
653 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
658 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
660 struct gl_enable_attrib
663 GLboolean AutoNormal
;
665 GLbitfield ClipPlanes
;
666 GLboolean ColorMaterial
;
667 GLboolean ColorTable
; /* SGI_color_table */
668 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
669 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
670 GLboolean Convolution1D
;
671 GLboolean Convolution2D
;
672 GLboolean Separable2D
;
678 GLboolean Light
[MAX_LIGHTS
];
680 GLboolean LineSmooth
;
681 GLboolean LineStipple
;
682 GLboolean IndexLogicOp
;
683 GLboolean ColorLogicOp
;
684 GLboolean Map1Color4
;
686 GLboolean Map1Normal
;
687 GLboolean Map1TextureCoord1
;
688 GLboolean Map1TextureCoord2
;
689 GLboolean Map1TextureCoord3
;
690 GLboolean Map1TextureCoord4
;
691 GLboolean Map1Vertex3
;
692 GLboolean Map1Vertex4
;
693 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
694 GLboolean Map2Color4
;
696 GLboolean Map2Normal
;
697 GLboolean Map2TextureCoord1
;
698 GLboolean Map2TextureCoord2
;
699 GLboolean Map2TextureCoord3
;
700 GLboolean Map2TextureCoord4
;
701 GLboolean Map2Vertex3
;
702 GLboolean Map2Vertex4
;
703 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
706 GLboolean PixelTexture
;
707 GLboolean PointSmooth
;
708 GLboolean PolygonOffsetPoint
;
709 GLboolean PolygonOffsetLine
;
710 GLboolean PolygonOffsetFill
;
711 GLboolean PolygonSmooth
;
712 GLboolean PolygonStipple
;
713 GLboolean RescaleNormals
;
716 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
717 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
718 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
719 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
720 GLboolean SampleCoverage
; /* GL_ARB_multisample */
721 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
722 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
723 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
724 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
725 /* SGI_texture_color_table */
726 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
727 /* GL_ARB_vertex_program / GL_NV_vertex_program */
728 GLboolean VertexProgram
;
729 GLboolean VertexProgramPointSize
;
730 GLboolean VertexProgramTwoSide
;
731 /* GL_ARB_point_sprite / GL_NV_point_sprite */
732 GLboolean PointSprite
;
733 GLboolean FragmentShaderATI
;
738 * Evaluator attribute group (GL_EVAL_BIT).
740 struct gl_eval_attrib
746 GLboolean Map1Color4
;
748 GLboolean Map1Normal
;
749 GLboolean Map1TextureCoord1
;
750 GLboolean Map1TextureCoord2
;
751 GLboolean Map1TextureCoord3
;
752 GLboolean Map1TextureCoord4
;
753 GLboolean Map1Vertex3
;
754 GLboolean Map1Vertex4
;
755 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
756 GLboolean Map2Color4
;
758 GLboolean Map2Normal
;
759 GLboolean Map2TextureCoord1
;
760 GLboolean Map2TextureCoord2
;
761 GLboolean Map2TextureCoord3
;
762 GLboolean Map2TextureCoord4
;
763 GLboolean Map2Vertex3
;
764 GLboolean Map2Vertex4
;
765 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
766 GLboolean AutoNormal
;
770 * \name Map Grid endpoints and divisions and calculated du values
774 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
775 GLint MapGrid2un
, MapGrid2vn
;
776 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
777 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
783 * Fog attribute group (GL_FOG_BIT).
787 GLboolean Enabled
; /**< Fog enabled flag */
788 GLfloat Color
[4]; /**< Fog color */
789 GLfloat Density
; /**< Density >= 0.0 */
790 GLfloat Start
; /**< Start distance in eye coords */
791 GLfloat End
; /**< End distance in eye coords */
792 GLfloat Index
; /**< Fog index */
793 GLenum Mode
; /**< Fog mode */
794 GLboolean ColorSumEnabled
;
795 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
796 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
801 * Hint attribute group (GL_HINT_BIT).
803 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
805 struct gl_hint_attrib
807 GLenum PerspectiveCorrection
;
810 GLenum PolygonSmooth
;
812 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
813 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
814 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
815 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
820 * Histogram attributes.
822 struct gl_histogram_attrib
824 GLuint Width
; /**< number of table entries */
825 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
826 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
827 GLboolean Sink
; /**< terminate image transfer? */
828 GLubyte RedSize
; /**< Bits per counter */
832 GLubyte LuminanceSize
;
837 * Color Min/max state.
839 struct gl_minmax_attrib
843 GLfloat Min
[4], Max
[4]; /**< RGBA */
848 * Image convolution state.
850 struct gl_convolution_attrib
853 GLenum InternalFormat
;
856 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
864 #define LIGHT_SPOT 0x1
865 #define LIGHT_LOCAL_VIEWER 0x2
866 #define LIGHT_POSITIONAL 0x4
867 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
872 * Lighting attribute group (GL_LIGHT_BIT).
874 struct gl_light_attrib
876 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
877 struct gl_lightmodel Model
; /**< Lighting model */
880 * Must flush FLUSH_VERTICES before referencing:
883 struct gl_material Material
; /**< Includes front & back values */
886 GLboolean Enabled
; /**< Lighting enabled flag */
887 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
888 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
889 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
890 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
891 GLboolean ColorMaterialEnabled
;
893 struct gl_light EnabledList
; /**< List sentinel */
896 * Derived state for optimizations:
899 GLboolean _NeedEyeCoords
;
900 GLboolean _NeedVertices
; /**< Use fast shader? */
901 GLbitfield _Flags
; /**< LIGHT_* flags, see above */
902 GLfloat _BaseColor
[2][3];
908 * Line attribute group (GL_LINE_BIT).
910 struct gl_line_attrib
912 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
913 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
914 GLushort StipplePattern
; /**< Stipple pattern */
915 GLint StippleFactor
; /**< Stipple repeat factor */
916 GLfloat Width
; /**< Line width */
917 GLfloat _Width
; /**< Clamped Line width */
922 * Display list attribute group (GL_LIST_BIT).
924 struct gl_list_attrib
931 * Used by device drivers to hook new commands into display lists.
933 struct gl_list_instruction
936 void (*Execute
)( GLcontext
*ctx
, void *data
);
937 void (*Destroy
)( GLcontext
*ctx
, void *data
);
938 void (*Print
)( GLcontext
*ctx
, void *data
);
941 #define MAX_DLIST_EXT_OPCODES 16
944 * Used by device drivers to hook new commands into display lists.
946 struct gl_list_extensions
948 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
954 * Multisample attribute group (GL_MULTISAMPLE_BIT).
956 struct gl_multisample_attrib
959 GLboolean SampleAlphaToCoverage
;
960 GLboolean SampleAlphaToOne
;
961 GLboolean SampleCoverage
;
962 GLfloat SampleCoverageValue
;
963 GLboolean SampleCoverageInvert
;
968 * Pixel attribute group (GL_PIXEL_MODE_BIT).
970 struct gl_pixel_attrib
972 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
973 GLfloat RedBias
, RedScale
;
974 GLfloat GreenBias
, GreenScale
;
975 GLfloat BlueBias
, BlueScale
;
976 GLfloat AlphaBias
, AlphaScale
;
977 GLfloat DepthBias
, DepthScale
;
978 GLint IndexShift
, IndexOffset
;
979 GLboolean MapColorFlag
;
980 GLboolean MapStencilFlag
;
981 GLfloat ZoomX
, ZoomY
;
982 /* XXX move these out of gl_pixel_attrib */
983 GLint MapStoSsize
; /**< Size of each pixel map */
993 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
994 GLfloat MapItoI
[MAX_PIXEL_MAP_TABLE
];
995 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
996 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
997 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
998 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
999 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
1000 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
1001 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
1002 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
1003 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
1004 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
1005 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
1006 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
1007 /** GL_EXT_histogram */
1008 GLboolean HistogramEnabled
;
1009 GLboolean MinMaxEnabled
;
1010 /** GL_SGI_color_matrix */
1011 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
1012 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
1013 /** GL_SGI_color_table */
1014 GLfloat ColorTableScale
[4];
1015 GLfloat ColorTableBias
[4];
1016 GLboolean ColorTableEnabled
;
1017 GLfloat PCCTscale
[4];
1018 GLfloat PCCTbias
[4];
1019 GLboolean PostConvolutionColorTableEnabled
;
1020 GLfloat PCMCTscale
[4];
1021 GLfloat PCMCTbias
[4];
1022 GLboolean PostColorMatrixColorTableEnabled
;
1023 /** GL_SGI_texture_color_table */
1024 GLfloat TextureColorTableScale
[4];
1025 GLfloat TextureColorTableBias
[4];
1027 GLboolean Convolution1DEnabled
;
1028 GLboolean Convolution2DEnabled
;
1029 GLboolean Separable2DEnabled
;
1030 GLfloat ConvolutionBorderColor
[3][4];
1031 GLenum ConvolutionBorderMode
[3];
1032 GLfloat ConvolutionFilterScale
[3][4];
1033 GLfloat ConvolutionFilterBias
[3][4];
1034 GLfloat PostConvolutionScale
[4]; /**< RGBA */
1035 GLfloat PostConvolutionBias
[4]; /**< RGBA */
1040 * Point attribute group (GL_POINT_BIT).
1042 struct gl_point_attrib
1044 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
1045 GLfloat Size
; /**< User-specified point size */
1046 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
1047 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
1048 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
1049 GLfloat Threshold
; /**< GL_EXT_point_parameters */
1050 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
1051 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
1052 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite */
1053 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
1054 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
1059 * Polygon attribute group (GL_POLYGON_BIT).
1061 struct gl_polygon_attrib
1063 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1064 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1065 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1066 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1067 GLboolean CullFlag
; /**< Culling on/off flag */
1068 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1069 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1070 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1071 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1072 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1073 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1074 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1075 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1080 * Scissor attributes (GL_SCISSOR_BIT).
1082 struct gl_scissor_attrib
1084 GLboolean Enabled
; /**< Scissor test enabled? */
1085 GLint X
, Y
; /**< Lower left corner of box */
1086 GLsizei Width
, Height
; /**< Size of box */
1091 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1093 struct gl_stencil_attrib
1095 GLboolean Enabled
; /**< Enabled flag */
1096 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1097 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1098 GLboolean _TestTwoSide
;
1099 GLenum Function
[2]; /**< Stencil function */
1100 GLenum FailFunc
[2]; /**< Fail function */
1101 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1102 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1103 GLint Ref
[2]; /**< Reference value */
1104 GLuint ValueMask
[2]; /**< Value mask */
1105 GLuint WriteMask
[2]; /**< Write mask */
1106 GLuint Clear
; /**< Clear value */
1110 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1113 * An index for each type of texture object
1116 #define TEXTURE_1D_INDEX 0
1117 #define TEXTURE_2D_INDEX 1
1118 #define TEXTURE_3D_INDEX 2
1119 #define TEXTURE_CUBE_INDEX 3
1120 #define TEXTURE_RECT_INDEX 4
1124 * Bit flags for each type of texture object
1125 * Used for Texture.Unit[]._ReallyEnabled flags.
1128 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1129 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1130 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1131 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1132 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1137 * TexGenEnabled flags.
1148 * Bit flag versions of the corresponding GL_ constants.
1151 #define TEXGEN_SPHERE_MAP 0x1
1152 #define TEXGEN_OBJ_LINEAR 0x2
1153 #define TEXGEN_EYE_LINEAR 0x4
1154 #define TEXGEN_REFLECTION_MAP_NV 0x8
1155 #define TEXGEN_NORMAL_MAP_NV 0x10
1157 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1158 TEXGEN_REFLECTION_MAP_NV | \
1159 TEXGEN_NORMAL_MAP_NV)
1160 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1161 TEXGEN_REFLECTION_MAP_NV | \
1162 TEXGEN_NORMAL_MAP_NV | \
1167 /* A selection of state flags to make driver and module's lives easier. */
1168 #define ENABLE_TEXGEN0 0x1
1169 #define ENABLE_TEXGEN1 0x2
1170 #define ENABLE_TEXGEN2 0x4
1171 #define ENABLE_TEXGEN3 0x8
1172 #define ENABLE_TEXGEN4 0x10
1173 #define ENABLE_TEXGEN5 0x20
1174 #define ENABLE_TEXGEN6 0x40
1175 #define ENABLE_TEXGEN7 0x80
1177 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1178 #define ENABLE_TEXMAT1 0x2
1179 #define ENABLE_TEXMAT2 0x4
1180 #define ENABLE_TEXMAT3 0x8
1181 #define ENABLE_TEXMAT4 0x10
1182 #define ENABLE_TEXMAT5 0x20
1183 #define ENABLE_TEXMAT6 0x40
1184 #define ENABLE_TEXMAT7 0x80
1186 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1187 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1191 * Texel fetch function prototype. We use texel fetch functions to
1192 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1193 * texture images. These functions help to isolate us from the gritty
1194 * details of all the various texture image encodings.
1196 * \param texImage texture image.
1197 * \param col texel column.
1198 * \param row texel row.
1199 * \param img texel image level/layer.
1200 * \param texelOut output texel (up to 4 GLchans)
1202 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1203 GLint col
, GLint row
, GLint img
,
1207 * As above, but returns floats.
1208 * Used for depth component images and for upcoming signed/float
1211 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1212 GLint col
, GLint row
, GLint img
,
1213 GLfloat
*texelOut
);
1216 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1217 GLint col
, GLint row
, GLint img
,
1221 * TexImage store function. This is called by the glTex[Sub]Image
1222 * functions and is responsible for converting the user-specified texture
1223 * image into a specific (hardware) image format.
1225 typedef GLboolean (*StoreTexImageFunc
)(GLcontext
*ctx
, GLuint dims
,
1226 GLenum baseInternalFormat
,
1227 const struct gl_texture_format
*dstFormat
,
1229 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
1230 GLint dstRowStride
, GLint dstImageStride
,
1231 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
1232 GLenum srcFormat
, GLenum srcType
,
1233 const GLvoid
*srcAddr
,
1234 const struct gl_pixelstore_attrib
*srcPacking
);
1239 * Texture format record
1241 struct gl_texture_format
1243 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1245 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1246 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1247 * GL_INTENSITY, GL_COLOR_INDEX or
1248 * GL_DEPTH_COMPONENT.
1250 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1251 GLubyte RedBits
; /**< Bits per texel component */
1252 GLubyte GreenBits
; /**< These are just rough approximations for */
1253 GLubyte BlueBits
; /**< compressed texture formats. */
1255 GLubyte LuminanceBits
;
1256 GLubyte IntensityBits
;
1259 GLubyte StencilBits
; /**< GL_EXT_packed_depth_stencil */
1261 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1263 StoreTexImageFunc StoreImage
;
1266 * \name Texel fetch function pointers
1269 FetchTexelFuncC FetchTexel1D
;
1270 FetchTexelFuncC FetchTexel2D
;
1271 FetchTexelFuncC FetchTexel3D
;
1272 FetchTexelFuncF FetchTexel1Df
;
1273 FetchTexelFuncF FetchTexel2Df
;
1274 FetchTexelFuncF FetchTexel3Df
;
1277 StoreTexelFunc StoreTexel
;
1282 * Texture image state. Describes the dimensions of a texture image,
1283 * the texel format and pointers to Texel Fetch functions.
1285 struct gl_texture_image
1287 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1288 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1289 * GL_INTENSITY, GL_COLOR_INDEX,
1290 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1291 * only. Used for choosing TexEnv arithmetic.
1293 GLint InternalFormat
; /**< Internal format as given by the user */
1294 GLuint Border
; /**< 0 or 1 */
1295 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1296 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1297 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1298 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1299 GLuint ImageStride
; /**< Stride between images, in texels */
1300 GLuint Width2
; /**< = Width - 2*Border */
1301 GLuint Height2
; /**< = Height - 2*Border */
1302 GLuint Depth2
; /**< = Depth - 2*Border */
1303 GLuint WidthLog2
; /**< = log2(Width2) */
1304 GLuint HeightLog2
; /**< = log2(Height2) */
1305 GLuint DepthLog2
; /**< = log2(Depth2) */
1306 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1307 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1308 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1309 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1310 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1311 GLboolean IsClientData
; /**< Data owned by client? */
1312 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1314 const struct gl_texture_format
*TexFormat
;
1316 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1318 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1319 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1321 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1322 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1325 * \name For device driver:
1328 void *DriverData
; /**< Arbitrary device driver data */
1334 * Indexes for cube map faces.
1337 #define FACE_POS_X 0
1338 #define FACE_NEG_X 1
1339 #define FACE_POS_Y 2
1340 #define FACE_NEG_Y 3
1341 #define FACE_POS_Z 4
1342 #define FACE_NEG_Z 5
1348 * Texture object state. Contains the array of mipmap images, border color,
1349 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1352 struct gl_texture_object
1354 _glthread_Mutex Mutex
; /**< for thread safety */
1355 GLint RefCount
; /**< reference count */
1356 GLuint Name
; /**< the user-visible texture object ID */
1357 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1358 GLfloat Priority
; /**< in [0,1] */
1359 GLfloat BorderColor
[4]; /**< unclamped */
1360 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1361 GLenum WrapS
; /**< S-axis texture image wrap mode */
1362 GLenum WrapT
; /**< T-axis texture image wrap mode */
1363 GLenum WrapR
; /**< R-axis texture image wrap mode */
1364 GLenum MinFilter
; /**< minification filter */
1365 GLenum MagFilter
; /**< magnification filter */
1366 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1367 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1368 GLfloat LodBias
; /**< OpenGL 1.4 */
1369 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1370 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1371 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1372 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1373 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1374 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1375 GLenum CompareMode
; /**< GL_ARB_shadow */
1376 GLenum CompareFunc
; /**< GL_ARB_shadow */
1377 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1378 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1379 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1380 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1381 GLboolean Complete
; /**< Is texture object complete? */
1383 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1384 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1386 /** GL_EXT_paletted_texture */
1387 struct gl_color_table Palette
;
1391 * \name For device driver.
1392 * Note: instead of attaching driver data to this pointer, it's preferable
1393 * to instead use this struct as a base class for your own texture object
1394 * class. Driver->NewTextureObject() can be used to implement the
1397 void *DriverData
; /**< Arbitrary device driver data */
1402 * Texture combine environment state.
1405 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1406 * structure will need to be expanded for 4 elements.
1408 struct gl_tex_env_combine_state
1410 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1411 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1412 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1413 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1414 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1415 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1416 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1417 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1418 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1419 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1424 * Texture unit state. Contains enable flags, texture environment/function/
1425 * combiners, texgen state, pointers to current texture objects and
1426 * post-filter color tables.
1428 struct gl_texture_unit
1430 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1431 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1433 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1434 GLfloat EnvColor
[4];
1435 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1436 /** \name Tex coord generation mode
1437 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1444 GLbitfield _GenBitS
;
1445 GLbitfield _GenBitT
;
1446 GLbitfield _GenBitR
;
1447 GLbitfield _GenBitQ
;
1448 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1449 GLfloat ObjectPlaneS
[4];
1450 GLfloat ObjectPlaneT
[4];
1451 GLfloat ObjectPlaneR
[4];
1452 GLfloat ObjectPlaneQ
[4];
1453 GLfloat EyePlaneS
[4];
1454 GLfloat EyePlaneT
[4];
1455 GLfloat EyePlaneR
[4];
1456 GLfloat EyePlaneQ
[4];
1457 GLfloat LodBias
; /**< for biasing mipmap levels */
1460 * \name GL_EXT_texture_env_combine
1462 struct gl_tex_env_combine_state Combine
;
1465 * Derived state based on \c EnvMode and the \c BaseFormat of the
1466 * currently enabled texture.
1468 struct gl_tex_env_combine_state _EnvMode
;
1471 * Currently enabled combiner state. This will point to either
1472 * \c Combine or \c _EnvMode.
1474 struct gl_tex_env_combine_state
*_CurrentCombine
;
1476 struct gl_texture_object
*Current1D
;
1477 struct gl_texture_object
*Current2D
;
1478 struct gl_texture_object
*Current3D
;
1479 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1480 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1482 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1484 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1485 struct gl_texture_object Saved2D
;
1486 struct gl_texture_object Saved3D
;
1487 struct gl_texture_object SavedCubeMap
;
1488 struct gl_texture_object SavedRect
;
1490 /* GL_SGI_texture_color_table */
1491 struct gl_color_table ColorTable
;
1492 struct gl_color_table ProxyColorTable
;
1493 GLboolean ColorTableEnabled
;
1496 struct texenvprog_cache
{
1500 struct texenvprog_cache
*next
;
1504 * Texture attribute group (GL_TEXTURE_BIT).
1506 struct gl_texture_attrib
1512 GLuint CurrentUnit
; /**< Active texture unit */
1513 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1514 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1515 GLbitfield _GenFlags
; /**< for texgen */
1516 GLbitfield _TexGenEnabled
;
1517 GLbitfield _TexMatEnabled
;
1520 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1522 struct gl_texture_object
*Proxy1D
;
1523 struct gl_texture_object
*Proxy2D
;
1524 struct gl_texture_object
*Proxy3D
;
1525 struct gl_texture_object
*ProxyCubeMap
;
1526 struct gl_texture_object
*ProxyRect
;
1528 /** GL_EXT_shared_texture_palette */
1529 GLboolean SharedPalette
;
1530 struct gl_color_table Palette
;
1532 /** Cached texenv fragment programs */
1533 struct texenvprog_cache
*env_fp_cache
;
1538 * Transformation attribute group (GL_TRANSFORM_BIT).
1540 struct gl_transform_attrib
1542 GLenum MatrixMode
; /**< Matrix mode */
1543 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1544 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1545 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1546 GLboolean Normalize
; /**< Normalize all normals? */
1547 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1548 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1550 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1551 GLfloat CullEyePos
[4];
1552 GLfloat CullObjPos
[4];
1557 * Viewport attribute group (GL_VIEWPORT_BIT).
1559 struct gl_viewport_attrib
1561 GLint X
, Y
; /**< position */
1562 GLsizei Width
, Height
; /**< size */
1563 GLfloat Near
, Far
; /**< Depth buffer range */
1564 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1569 * Node for the attribute stack.
1571 struct gl_attrib_node
1575 struct gl_attrib_node
*next
;
1580 * GL_ARB_vertex/pixel_buffer_object buffer object
1582 struct gl_buffer_object
1588 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1589 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1590 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1591 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1597 * Client pixel packing/unpacking attributes
1599 struct gl_pixelstore_attrib
1605 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1606 GLint SkipImages
; /**< for GL_EXT_texture3D */
1607 GLboolean SwapBytes
;
1609 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1610 GLboolean Invert
; /**< GL_MESA_pack_invert */
1611 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1615 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1619 * Client vertex array attributes
1621 struct gl_client_array
1623 GLint Size
; /**< components per element (1,2,3,4) */
1624 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1625 GLsizei Stride
; /**< user-specified stride */
1626 GLsizei StrideB
; /**< actual stride in bytes */
1627 const GLubyte
*Ptr
; /**< Points to array data */
1628 GLbitfield Enabled
; /**< one of the _NEW_ARRAY_ bits */
1629 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1631 /**< GL_ARB_vertex_buffer_object */
1632 struct gl_buffer_object
*BufferObj
;
1640 * Vertex array state
1642 struct gl_array_attrib
1644 struct gl_client_array Vertex
; /**< client data descriptors */
1645 struct gl_client_array Normal
;
1646 struct gl_client_array Color
;
1647 struct gl_client_array SecondaryColor
;
1648 struct gl_client_array FogCoord
;
1649 struct gl_client_array Index
;
1650 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1651 struct gl_client_array EdgeFlag
;
1653 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1655 GLint ActiveTexture
; /**< Client Active Texture */
1656 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1657 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1659 GLbitfield _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1660 GLbitfield NewState
; /**< _NEW_ARRAY_* */
1662 #if FEATURE_ARB_vertex_buffer_object
1663 struct gl_buffer_object
*NullBufferObj
;
1664 struct gl_buffer_object
*ArrayBufferObj
;
1665 struct gl_buffer_object
*ElementArrayBufferObj
;
1667 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1672 * Feedback buffer state
1677 GLbitfield _Mask
; /* FB_* bits */
1685 * Selection buffer state
1689 GLuint
*Buffer
; /**< selection buffer */
1690 GLuint BufferSize
; /**< size of the selection buffer */
1691 GLuint BufferCount
; /**< number of values in the selection buffer */
1692 GLuint Hits
; /**< number of records in the selection buffer */
1693 GLuint NameStackDepth
; /**< name stack depth */
1694 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1695 GLboolean HitFlag
; /**< hit flag */
1696 GLfloat HitMinZ
; /**< minimum hit depth */
1697 GLfloat HitMaxZ
; /**< maximum hit depth */
1702 * 1-D Evaluator control points
1706 GLuint Order
; /**< Number of control points */
1707 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1708 GLfloat
*Points
; /**< Points to contiguous control points */
1713 * 2-D Evaluator control points
1717 GLuint Uorder
; /**< Number of control points in U dimension */
1718 GLuint Vorder
; /**< Number of control points in V dimension */
1721 GLfloat
*Points
; /**< Points to contiguous control points */
1726 * All evaluator control point state
1728 struct gl_evaluators
1734 struct gl_1d_map Map1Vertex3
;
1735 struct gl_1d_map Map1Vertex4
;
1736 struct gl_1d_map Map1Index
;
1737 struct gl_1d_map Map1Color4
;
1738 struct gl_1d_map Map1Normal
;
1739 struct gl_1d_map Map1Texture1
;
1740 struct gl_1d_map Map1Texture2
;
1741 struct gl_1d_map Map1Texture3
;
1742 struct gl_1d_map Map1Texture4
;
1743 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1750 struct gl_2d_map Map2Vertex3
;
1751 struct gl_2d_map Map2Vertex4
;
1752 struct gl_2d_map Map2Index
;
1753 struct gl_2d_map Map2Color4
;
1754 struct gl_2d_map Map2Normal
;
1755 struct gl_2d_map Map2Texture1
;
1756 struct gl_2d_map Map2Texture2
;
1757 struct gl_2d_map Map2Texture3
;
1758 struct gl_2d_map Map2Texture4
;
1759 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1765 * State used during execution of fragment programs.
1769 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1770 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1771 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1772 GLuint CondCodes
[4];
1777 * Names of the various vertex/fragment program register files, etc.
1778 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1779 * All values should fit in a 4-bit field.
1783 PROGRAM_TEMPORARY
= 0,
1784 PROGRAM_LOCAL_PARAM
= 1,
1785 PROGRAM_ENV_PARAM
= 2,
1786 PROGRAM_STATE_VAR
= 3,
1789 PROGRAM_NAMED_PARAM
= 6,
1790 PROGRAM_CONSTANT
= 7,
1791 PROGRAM_WRITE_ONLY
= 8,
1792 PROGRAM_ADDRESS
= 9,
1793 PROGRAM_UNDEFINED
= 15 /* invalid value */
1797 /** Vertex and fragment instructions */
1798 struct prog_instruction
;
1799 struct program_parameter_list
;
1803 * Base class for any kind of program object
1808 GLubyte
*String
; /**< Null-terminated program text */
1811 GLenum Format
; /**< String encoding format */
1814 struct prog_instruction
*Instructions
;
1816 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1817 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1819 /** Named parameters, constants, etc. from program text */
1820 struct program_parameter_list
*Parameters
;
1821 /** Numbered local parameters */
1822 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1824 /** Logical counts */
1826 GLuint NumInstructions
;
1827 GLuint NumTemporaries
;
1828 GLuint NumParameters
;
1829 GLuint NumAttributes
;
1830 GLuint NumAddressRegs
;
1832 /** Native, actual h/w counts */
1834 GLuint NumNativeInstructions
;
1835 GLuint NumNativeTemporaries
;
1836 GLuint NumNativeParameters
;
1837 GLuint NumNativeAttributes
;
1838 GLuint NumNativeAddressRegs
;
1843 /** Vertex program object */
1844 struct vertex_program
1846 struct program Base
; /* base class */
1847 GLboolean IsNVProgram
; /* GL_NV_vertex_program ? */
1848 GLboolean IsPositionInvariant
; /* GL_ARB_vertex_program / GL_NV_vertex_program1_1 */
1849 void *TnlData
; /* should probably use Base.DriverData */
1853 /** Fragment program object */
1854 struct fragment_program
1856 struct program Base
; /**< base class */
1857 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
1858 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1859 GLuint NumTexInstructions
;
1860 GLuint NumTexIndirections
;
1861 GLuint NumNativeAluInstructions
; /**< GL_ARB_fragment_program */
1862 GLuint NumNativeTexInstructions
;
1863 GLuint NumNativeTexIndirections
;
1870 * State common to vertex and fragment programs.
1872 struct gl_program_state
1874 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1875 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1880 * State vars for GL_ARB/GL_NV_vertex_program
1882 struct gl_vertex_program_state
1884 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_ARB/NV */
1885 GLboolean _Enabled
; /**< Enabled and valid program? */
1886 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1887 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1888 struct vertex_program
*Current
; /**< ptr to currently bound program */
1889 struct vertex_program
*_Current
; /**< ptr to currently bound
1890 program, including internal
1891 (t_vp_build.c) programs */
1893 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1894 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1896 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1897 /* Only used during program execution (may be moved someday): */
1898 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1899 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1900 GLuint InputsSize
[MAX_NV_VERTEX_PROGRAM_INPUTS
];
1901 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1902 GLint AddressReg
[4];
1904 #if FEATURE_MESA_program_debug
1905 GLprogramcallbackMESA Callback
;
1906 GLvoid
*CallbackData
;
1907 GLboolean CallbackEnabled
;
1908 GLuint CurrentPosition
;
1914 * Context state for GL_ARB/NV_fragment_program
1916 struct gl_fragment_program_state
1918 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1919 GLboolean _Enabled
; /* Enabled and valid program? */
1921 struct fragment_program
*Current
; /* ptr to currently bound program */
1922 struct fragment_program
*_Current
; /* ptr to currently active program
1923 (including internal programs) */
1924 struct fp_machine Machine
; /* machine state */
1925 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1927 #if FEATURE_MESA_program_debug
1928 GLprogramcallbackMESA Callback
;
1929 GLvoid
*CallbackData
;
1930 GLboolean CallbackEnabled
;
1931 GLuint CurrentPosition
;
1937 * ATI_fragment_shader runtime state
1939 #define ATI_FS_INPUT_PRIMARY 0
1940 #define ATI_FS_INPUT_SECONDARY 1
1942 struct atifs_instruction
;
1943 struct atifs_setupinst
;
1946 * State for executing ATI fragment shader.
1948 struct atifs_machine
1950 GLfloat Registers
[6][4]; /** six temporary registers */
1951 GLfloat PrevPassRegisters
[6][4];
1952 GLfloat Inputs
[2][4]; /** Primary, secondary input colors */
1957 * ATI fragment shader
1959 struct ati_fragment_shader
1963 struct atifs_instruction
*Instructions
[2];
1964 struct atifs_setupinst
*SetupInst
[2];
1965 GLfloat Constants
[8][4];
1966 GLbitfield LocalConstDef
; /** Indicates which constants have been set */
1967 GLubyte numArithInstr
[2];
1968 GLubyte regsAssigned
[2];
1969 GLubyte NumPasses
; /** 1 or 2 */
1971 GLubyte last_optype
;
1972 GLboolean interpinp1
;
1978 * Context state for GL_ATI_fragment_shader
1980 struct gl_ati_fragment_shader_state
1983 GLboolean _Enabled
; /** enabled and valid shader? */
1984 GLboolean Compiling
;
1985 GLfloat GlobalConstants
[8][4];
1986 struct atifs_machine Machine
; /* machine state */
1987 struct ati_fragment_shader
*Current
;
1992 * Occlusion/timer query object.
1994 struct gl_query_object
1997 GLuint64EXT Result
; /* the counter */
1998 GLboolean Active
; /* inside Begin/EndQuery */
1999 GLboolean Ready
; /* result is ready */
2004 * Context state for query objects.
2006 struct gl_query_state
2008 struct _mesa_HashTable
*QueryObjects
;
2009 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2010 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2015 * Context state for vertex/fragment shaders.
2017 struct gl_shader_objects_state
2019 struct gl2_program_intf
**CurrentProgram
;
2020 GLboolean _VertexShaderPresent
;
2021 GLboolean _FragmentShaderPresent
;
2026 * State which can be shared by multiple contexts:
2028 struct gl_shared_state
2030 _glthread_Mutex Mutex
; /**< for thread safety */
2031 GLint RefCount
; /**< Reference count */
2032 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2033 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2036 * \name Default texture objects (shared by all multi-texture units)
2039 struct gl_texture_object
*Default1D
;
2040 struct gl_texture_object
*Default2D
;
2041 struct gl_texture_object
*Default3D
;
2042 struct gl_texture_object
*DefaultCubeMap
;
2043 struct gl_texture_object
*DefaultRect
;
2047 * \name Vertex/fragment programs
2050 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
2051 #if FEATURE_ARB_vertex_program
2052 struct program
*DefaultVertexProgram
;
2054 #if FEATURE_ARB_fragment_program
2055 struct program
*DefaultFragmentProgram
;
2059 #if FEATURE_ATI_fragment_shader
2060 struct _mesa_HashTable
*ATIShaders
;
2061 struct ati_fragment_shader
*DefaultFragmentShader
;
2064 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2065 struct _mesa_HashTable
*BufferObjects
;
2068 struct _mesa_HashTable
*GL2Objects
;
2070 #if FEATURE_EXT_framebuffer_object
2071 struct _mesa_HashTable
*RenderBuffers
;
2072 struct _mesa_HashTable
*FrameBuffers
;
2075 void *DriverData
; /**< Device driver shared state */
2082 * A renderbuffer stores colors or depth values or stencil values.
2083 * A framebuffer object will have a collection of these.
2084 * Data are read/written to the buffer with a handful of Get/Put functions.
2086 * Instances of this object are allocated with the Driver's NewRenderbuffer
2087 * hook. Drivers will likely wrap this class inside a driver-specific
2088 * class to simulate inheritance.
2090 struct gl_renderbuffer
2092 _glthread_Mutex Mutex
; /**< for thread safety */
2093 GLuint ClassID
; /**< Useful for drivers */
2096 GLuint Width
, Height
;
2097 GLenum InternalFormat
; /**< The user-specified format */
2098 GLenum _ActualFormat
; /**< The driver-chosen format */
2099 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2100 GL_STENCIL_INDEX. */
2101 GLenum DataType
; /**< Type of values passed to the Get/Put functions */
2102 GLubyte RedBits
; /**< Bits of red per pixel */
2108 GLubyte StencilBits
;
2111 /* Used to wrap one renderbuffer around another: */
2112 struct gl_renderbuffer
*Wrapped
;
2114 /* Delete this renderbuffer */
2115 void (*Delete
)(struct gl_renderbuffer
*rb
);
2117 /* Allocate new storage for this renderbuffer */
2118 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2119 GLenum internalFormat
,
2120 GLuint width
, GLuint height
);
2122 /* Lock/Unlock are called before/after calling the Get/Put functions.
2123 * Not sure this is the right place for these yet.
2124 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2125 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2128 /* Return a pointer to the element/pixel at (x,y).
2129 * Should return NULL if the buffer memory can't be directly addressed.
2131 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2134 /* Get/Read a row of values.
2135 * The values will be of format _BaseFormat and type DataType.
2137 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2138 GLint x
, GLint y
, void *values
);
2140 /* Get/Read values at arbitrary locations.
2141 * The values will be of format _BaseFormat and type DataType.
2143 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2144 const GLint x
[], const GLint y
[], void *values
);
2146 /* Put/Write a row of values.
2147 * The values will be of format _BaseFormat and type DataType.
2149 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2150 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2152 /* Put/Write a row of RGB values. This is a special-case routine that's
2153 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2154 * a common case for glDrawPixels and some triangle routines.
2155 * The values will be of format GL_RGB and type DataType.
2157 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2158 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2161 /* Put/Write a row of identical values.
2162 * The values will be of format _BaseFormat and type DataType.
2164 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2165 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2167 /* Put/Write values at arbitrary locations.
2168 * The values will be of format _BaseFormat and type DataType.
2170 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2171 const GLint x
[], const GLint y
[], const void *values
,
2172 const GLubyte
*mask
);
2173 /* Put/Write identical values at arbitrary locations.
2174 * The values will be of format _BaseFormat and type DataType.
2176 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2177 GLuint count
, const GLint x
[], const GLint y
[],
2178 const void *value
, const GLubyte
*mask
);
2183 * A renderbuffer attachment point points to either a texture object
2184 * (and specifies a mipmap level, cube face or 3D texture slice) or
2185 * points to a renderbuffer.
2187 struct gl_renderbuffer_attachment
2189 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2192 /* IF Type == GL_RENDERBUFFER_EXT: */
2193 struct gl_renderbuffer
*Renderbuffer
;
2195 /* IF Type == GL_TEXTURE: */
2196 struct gl_texture_object
*Texture
;
2197 GLuint TextureLevel
;
2198 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2199 GLuint Zoffset
; /* for 3D textures */
2204 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2205 * In C++ terms, think of this as a base class from which device drivers
2206 * will make derived classes.
2208 struct gl_framebuffer
2210 _glthread_Mutex Mutex
; /**< for thread safety */
2211 GLuint Name
; /* if zero, this is a window system framebuffer */
2214 GLvisual Visual
; /**< The framebuffer's visual.
2215 Immutable if this is a window system buffer.
2216 Computed from attachments if user-made FBO. */
2218 GLboolean Initialized
;
2220 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2222 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2224 GLint _Xmin
, _Xmax
; /**< inclusive */
2225 GLint _Ymin
, _Ymax
; /**< exclusive */
2228 /** \name Derived Z buffer stuff */
2230 GLuint _DepthMax
; /**< Max depth buffer value */
2231 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2232 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2235 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2237 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2238 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2240 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2241 * attribute group and GL_PIXEL attribute group, respectively.
2243 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2244 GLenum ColorReadBuffer
;
2246 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2247 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2248 GLint _ColorReadBufferIndex
; /* -1 = None */
2250 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2251 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2252 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2253 struct gl_renderbuffer
*_ColorReadBuffer
;
2255 /** The Actual depth/stencil buffers to use. May be wrappers around the
2256 * depth/stencil buffers attached above. */
2257 struct gl_renderbuffer
*_DepthBuffer
;
2258 struct gl_renderbuffer
*_StencilBuffer
;
2260 /** Delete this framebuffer */
2261 void (*Delete
)(struct gl_framebuffer
*fb
);
2266 * Limits for vertex and fragment programs.
2268 struct gl_program_constants
2270 /* logical limits */
2271 GLuint MaxInstructions
;
2272 GLuint MaxAluInstructions
; /* fragment programs only, for now */
2273 GLuint MaxTexInstructions
; /* fragment programs only, for now */
2274 GLuint MaxTexIndirections
; /* fragment programs only, for now */
2277 GLuint MaxAddressRegs
; /* vertex program only, for now */
2278 GLuint MaxParameters
;
2279 GLuint MaxLocalParams
;
2280 GLuint MaxEnvParams
;
2281 /* native/hardware limits */
2282 GLuint MaxNativeInstructions
;
2283 GLuint MaxNativeAluInstructions
; /* fragment programs only, for now */
2284 GLuint MaxNativeTexInstructions
; /* fragment programs only, for now */
2285 GLuint MaxNativeTexIndirections
; /* fragment programs only, for now */
2286 GLuint MaxNativeAttribs
;
2287 GLuint MaxNativeTemps
;
2288 GLuint MaxNativeAddressRegs
; /* vertex program only, for now */
2289 GLuint MaxNativeParameters
;
2294 * Constants which may be overridden by device driver during context creation
2295 * but are never changed after that.
2299 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2300 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2301 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2302 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2303 GLuint MaxTextureCoordUnits
;
2304 GLuint MaxTextureImageUnits
;
2305 GLuint MaxTextureUnits
; /* = MIN(CoordUnits, ImageUnits) */
2306 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2307 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2308 GLuint MaxArrayLockSize
;
2310 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2311 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2312 GLfloat PointSizeGranularity
;
2313 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2314 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2315 GLfloat LineWidthGranularity
;
2316 GLuint MaxColorTableSize
;
2317 GLuint MaxConvolutionWidth
;
2318 GLuint MaxConvolutionHeight
;
2319 GLuint MaxClipPlanes
;
2321 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2322 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2323 GLuint MaxViewportWidth
, MaxViewportHeight
;
2324 struct gl_program_constants VertexProgram
; /* GL_ARB_vertex_program */
2325 struct gl_program_constants FragmentProgram
; /* GL_ARB_fragment_program */
2326 /* shared by vertex and fragment program: */
2327 GLuint MaxProgramMatrices
;
2328 GLuint MaxProgramMatrixStackDepth
;
2329 /* vertex array / buffer object bounds checking */
2330 GLboolean CheckArrayBounds
;
2331 /* GL_ARB_draw_buffers */
2332 GLuint MaxDrawBuffers
;
2333 /* GL_OES_read_format */
2334 GLenum ColorReadFormat
;
2335 GLenum ColorReadType
;
2336 /* GL_EXT_framebuffer_object */
2337 GLuint MaxColorAttachments
;
2338 GLuint MaxRenderbufferSize
;
2343 * Enable flag for each OpenGL extension. Different device drivers will
2344 * enable different extensions at runtime.
2346 struct gl_extensions
2349 * \name Flags to quickly test if certain extensions are available.
2351 * Not every extension needs to have such a flag, but it's encouraged.
2354 GLboolean dummy
; /* don't remove this! */
2355 GLboolean ARB_depth_texture
;
2356 GLboolean ARB_draw_buffers
;
2357 GLboolean ARB_fragment_program
;
2358 GLboolean ARB_fragment_shader
;
2359 GLboolean ARB_half_float_pixel
;
2360 GLboolean ARB_imaging
;
2361 GLboolean ARB_multisample
;
2362 GLboolean ARB_multitexture
;
2363 GLboolean ARB_occlusion_query
;
2364 GLboolean ARB_point_sprite
;
2365 GLboolean ARB_shader_objects
;
2366 GLboolean ARB_shading_language_100
;
2367 GLboolean ARB_shadow
;
2368 GLboolean ARB_texture_border_clamp
;
2369 GLboolean ARB_texture_compression
;
2370 GLboolean ARB_texture_cube_map
;
2371 GLboolean ARB_texture_env_combine
;
2372 GLboolean ARB_texture_env_crossbar
;
2373 GLboolean ARB_texture_env_dot3
;
2374 GLboolean ARB_texture_float
;
2375 GLboolean ARB_texture_mirrored_repeat
;
2376 GLboolean ARB_texture_non_power_of_two
;
2377 GLboolean ARB_transpose_matrix
;
2378 GLboolean ARB_vertex_buffer_object
;
2379 GLboolean ARB_vertex_program
;
2380 GLboolean ARB_vertex_shader
;
2381 GLboolean ARB_window_pos
;
2384 GLboolean EXT_blend_color
;
2385 GLboolean EXT_blend_equation_separate
;
2386 GLboolean EXT_blend_func_separate
;
2387 GLboolean EXT_blend_logic_op
;
2388 GLboolean EXT_blend_minmax
;
2389 GLboolean EXT_blend_subtract
;
2390 GLboolean EXT_clip_volume_hint
;
2391 GLboolean EXT_cull_vertex
;
2392 GLboolean EXT_convolution
;
2393 GLboolean EXT_compiled_vertex_array
;
2394 GLboolean EXT_copy_texture
;
2395 GLboolean EXT_depth_bounds_test
;
2396 GLboolean EXT_draw_range_elements
;
2397 GLboolean EXT_framebuffer_object
;
2398 GLboolean EXT_fog_coord
;
2399 GLboolean EXT_framebuffer_blit
;
2400 GLboolean EXT_histogram
;
2401 GLboolean EXT_multi_draw_arrays
;
2402 GLboolean EXT_paletted_texture
;
2403 GLboolean EXT_packed_depth_stencil
;
2404 GLboolean EXT_packed_pixels
;
2405 GLboolean EXT_pixel_buffer_object
;
2406 GLboolean EXT_point_parameters
;
2407 GLboolean EXT_polygon_offset
;
2408 GLboolean EXT_rescale_normal
;
2409 GLboolean EXT_shadow_funcs
;
2410 GLboolean EXT_secondary_color
;
2411 GLboolean EXT_separate_specular_color
;
2412 GLboolean EXT_shared_texture_palette
;
2413 GLboolean EXT_stencil_wrap
;
2414 GLboolean EXT_stencil_two_side
;
2415 GLboolean EXT_subtexture
;
2416 GLboolean EXT_texture
;
2417 GLboolean EXT_texture_object
;
2418 GLboolean EXT_texture3D
;
2419 GLboolean EXT_texture_compression_s3tc
;
2420 GLboolean EXT_texture_env_add
;
2421 GLboolean EXT_texture_env_combine
;
2422 GLboolean EXT_texture_env_dot3
;
2423 GLboolean EXT_texture_filter_anisotropic
;
2424 GLboolean EXT_texture_lod_bias
;
2425 GLboolean EXT_texture_mirror_clamp
;
2426 GLboolean EXT_timer_query
;
2427 GLboolean EXT_vertex_array
;
2428 GLboolean EXT_vertex_array_set
;
2429 /* vendor extensions */
2430 GLboolean APPLE_client_storage
;
2431 GLboolean APPLE_packed_pixels
;
2432 GLboolean ATI_texture_mirror_once
;
2433 GLboolean ATI_texture_env_combine3
;
2434 GLboolean ATI_fragment_shader
;
2435 GLboolean IBM_rasterpos_clip
;
2436 GLboolean IBM_multimode_draw_arrays
;
2437 GLboolean MESA_pack_invert
;
2438 GLboolean MESA_packed_depth_stencil
;
2439 GLboolean MESA_program_debug
;
2440 GLboolean MESA_resize_buffers
;
2441 GLboolean MESA_ycbcr_texture
;
2442 GLboolean NV_blend_square
;
2443 GLboolean NV_fragment_program
;
2444 GLboolean NV_light_max_exponent
;
2445 GLboolean NV_point_sprite
;
2446 GLboolean NV_texgen_reflection
;
2447 GLboolean NV_texture_rectangle
;
2448 GLboolean NV_vertex_program
;
2449 GLboolean NV_vertex_program1_1
;
2450 GLboolean OES_read_format
;
2451 GLboolean SGI_color_matrix
;
2452 GLboolean SGI_color_table
;
2453 GLboolean SGI_texture_color_table
;
2454 GLboolean SGIS_generate_mipmap
;
2455 GLboolean SGIS_texture_edge_clamp
;
2456 GLboolean SGIS_texture_lod
;
2457 GLboolean SGIX_depth_texture
;
2458 GLboolean SGIX_shadow
;
2459 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2460 GLboolean TDFX_texture_compression_FXT1
;
2463 /* The extension string */
2464 const GLubyte
*String
;
2469 * A stack of matrices (projection, modelview, color, texture, etc).
2473 GLmatrix
*Top
; /**< points into Stack */
2474 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2475 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2476 GLuint MaxDepth
; /**< size of Stack[] array */
2477 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2482 * \name Bits for image transfer operations
2484 * \sa __GLcontextRec::ImageTransferState.
2487 #define IMAGE_SCALE_BIAS_BIT 0x1
2488 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2489 #define IMAGE_MAP_COLOR_BIT 0x4
2490 #define IMAGE_COLOR_TABLE_BIT 0x8
2491 #define IMAGE_CONVOLUTION_BIT 0x10
2492 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2493 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2494 #define IMAGE_COLOR_MATRIX_BIT 0x80
2495 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2496 #define IMAGE_HISTOGRAM_BIT 0x200
2497 #define IMAGE_MIN_MAX_BIT 0x400
2498 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2501 /** Pixel Transfer ops up to convolution */
2502 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2503 IMAGE_SHIFT_OFFSET_BIT | \
2504 IMAGE_MAP_COLOR_BIT | \
2505 IMAGE_COLOR_TABLE_BIT)
2507 /** Pixel transfer ops after convolution */
2508 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2509 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2510 IMAGE_COLOR_MATRIX_BIT | \
2511 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2512 IMAGE_HISTOGRAM_BIT | \
2518 * \name Bits to indicate what state has changed.
2523 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2524 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2525 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2526 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2527 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2528 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2529 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2530 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2531 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2532 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2533 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2534 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2535 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2536 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2537 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2538 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2539 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2540 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2541 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2542 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2543 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2544 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2545 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2546 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2547 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2548 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2549 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2550 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2556 * \name Bits to track array state changes
2558 * Also used to summarize array enabled.
2561 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2562 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2563 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2564 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2565 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2566 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2567 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2568 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2569 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2570 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2571 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2572 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2573 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2574 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2575 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2576 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2577 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2578 #define _NEW_ARRAY_ALL 0xffffffff
2581 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2582 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2587 * \name A bunch of flags that we think might be useful to drivers.
2589 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2592 #define DD_FLATSHADE 0x1
2593 #define DD_SEPARATE_SPECULAR 0x2
2594 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2595 #define DD_TRI_LIGHT_TWOSIDE 0x8
2596 #define DD_TRI_UNFILLED 0x10
2597 #define DD_TRI_SMOOTH 0x20
2598 #define DD_TRI_STIPPLE 0x40
2599 #define DD_TRI_OFFSET 0x80
2600 #define DD_LINE_SMOOTH 0x100
2601 #define DD_LINE_STIPPLE 0x200
2602 #define DD_LINE_WIDTH 0x400
2603 #define DD_POINT_SMOOTH 0x800
2604 #define DD_POINT_SIZE 0x1000
2605 #define DD_POINT_ATTEN 0x2000
2606 #define DD_TRI_TWOSTENCIL 0x4000
2611 * \name Define the state changes under which each of these bits might change
2614 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2615 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2616 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2617 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2618 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2619 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2620 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2621 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2622 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2623 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2624 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2625 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2626 #define _DD_NEW_POINT_SIZE _NEW_POINT
2627 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2631 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2636 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2639 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2645 * Forward declaration of display list data types:
2648 typedef union node Node
;
2651 /* This has to be included here. */
2655 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2658 * Core Mesa's support for tnl modules:
2660 struct gl_tnl_module
2663 * Vertex format to be lazily swapped into current dispatch.
2665 const GLvertexformat
*Current
;
2668 * \name Record of functions swapped out.
2669 * On restore, only need to swap these functions back in.
2673 _glapi_proc
* location
;
2674 _glapi_proc function
;
2675 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2680 /* Strictly this is a tnl/ private concept, but it doesn't seem
2681 * worthwhile adding a tnl private structure just to hold this one bit
2684 #define MESA_DLIST_DANGLING_REFS 0x1
2686 /* Provide a location where information about a display list can be
2687 * collected. Could be extended with driverPrivate structures,
2688 * etc. in the future.
2690 struct mesa_display_list
2699 * State used during display list compilation and execution.
2701 struct mesa_list_state
2703 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2704 GLuint CallDepth
; /**< Current recursion calling depth */
2706 struct mesa_display_list
*CurrentList
;
2707 Node
*CurrentListPtr
; /**< Head of list being compiled */
2708 GLuint CurrentListNum
; /**< Number of the list being compiled */
2709 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2710 GLuint CurrentPos
; /**< Index into current block of nodes */
2712 GLvertexformat ListVtxfmt
;
2714 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2715 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2717 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2718 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2720 GLubyte ActiveIndex
;
2721 GLfloat CurrentIndex
;
2723 GLubyte ActiveEdgeFlag
;
2724 GLboolean CurrentEdgeFlag
;
2729 * Mesa rendering context.
2731 * This is the central context data structure for Mesa. Almost all
2732 * OpenGL state is contained in this structure.
2733 * Think of this as a base class from which device drivers will derive
2736 * The GLcontext typedef names this structure.
2738 struct __GLcontextRec
2741 * \name OS related interfaces.
2743 * These \b must be the first members of this structure, because they are
2744 * exposed to the outside world (i.e. GLX extension).
2747 __GLimports imports
;
2748 __GLexports exports
;
2751 /** State possibly shared with other contexts in the address space */
2752 struct gl_shared_state
*Shared
;
2754 /** \name API function pointer tables */
2756 struct _glapi_table
*Save
; /**< Display list save functions */
2757 struct _glapi_table
*Exec
; /**< Execute functions */
2758 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2762 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2763 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2764 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2765 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2768 * Device driver function pointer table
2770 struct dd_function_table Driver
;
2772 void *DriverCtx
; /**< Points to device driver context/state */
2773 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2775 /** Core/Driver constants */
2776 struct gl_constants Const
;
2778 /** \name The various 4x4 matrix stacks */
2780 struct matrix_stack ModelviewMatrixStack
;
2781 struct matrix_stack ProjectionMatrixStack
;
2782 struct matrix_stack ColorMatrixStack
;
2783 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2784 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2785 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2788 /** Combined modelview and projection matrix */
2789 GLmatrix _ModelProjectMatrix
;
2791 /** \name Display lists */
2792 struct mesa_list_state ListState
;
2794 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2795 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2797 /** Extension information */
2798 struct gl_extensions Extensions
;
2800 /** \name State attribute stack (for glPush/PopAttrib) */
2802 GLuint AttribStackDepth
;
2803 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2806 /** \name Renderer attribute groups
2808 * We define a struct for each attribute group to make pushing and popping
2809 * attributes easy. Also it's a good organization.
2812 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
2813 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
2814 struct gl_current_attrib Current
; /**< Current attributes */
2815 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2816 struct gl_eval_attrib Eval
; /**< Eval attributes */
2817 struct gl_fog_attrib Fog
; /**< Fog attributes */
2818 struct gl_hint_attrib Hint
; /**< Hint attributes */
2819 struct gl_light_attrib Light
; /**< Light attributes */
2820 struct gl_line_attrib Line
; /**< Line attributes */
2821 struct gl_list_attrib List
; /**< List attributes */
2822 struct gl_multisample_attrib Multisample
;
2823 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2824 struct gl_point_attrib Point
; /**< Point attributes */
2825 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2826 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2827 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2828 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2829 struct gl_texture_attrib Texture
; /**< Texture attributes */
2830 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2831 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2834 /** \name Client attribute stack */
2836 GLuint ClientAttribStackDepth
;
2837 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2840 /** \name Client attribute groups */
2842 struct gl_array_attrib Array
; /**< Vertex arrays */
2843 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2844 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2845 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2848 /** \name Other assorted state (not pushed/popped on attribute stack) */
2850 struct gl_histogram_attrib Histogram
;
2851 struct gl_minmax_attrib MinMax
;
2852 struct gl_convolution_attrib Convolution1D
;
2853 struct gl_convolution_attrib Convolution2D
;
2854 struct gl_convolution_attrib Separable2D
;
2856 struct gl_evaluators EvalMap
; /**< All evaluators */
2857 struct gl_feedback Feedback
; /**< Feedback */
2858 struct gl_selection Select
; /**< Selection */
2860 struct gl_color_table ColorTable
; /**< Pre-convolution */
2861 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2862 struct gl_color_table PostConvolutionColorTable
;
2863 struct gl_color_table ProxyPostConvolutionColorTable
;
2864 struct gl_color_table PostColorMatrixColorTable
;
2865 struct gl_color_table ProxyPostColorMatrixColorTable
;
2867 struct gl_program_state Program
; /**< for vertex or fragment progs */
2868 struct gl_vertex_program_state VertexProgram
; /**< GL_ARB/NV_vertex_program */
2869 struct gl_fragment_program_state FragmentProgram
; /**< GL_ARB/NV_vertex_program */
2870 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2872 struct fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2873 struct vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2875 GLboolean _MaintainTnlProgram
;
2876 GLboolean _MaintainTexEnvProgram
;
2877 GLboolean _UseTexEnvProgram
;
2879 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2881 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2884 #if FEATURE_EXT_framebuffer_object
2885 struct gl_renderbuffer
*CurrentRenderbuffer
;
2888 GLenum ErrorValue
; /**< Last error code */
2889 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2890 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2892 /** \name Derived state */
2894 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2895 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2896 GLfloat _EyeZDir
[3];
2897 GLfloat _ModelViewInvScale
;
2898 GLboolean _NeedEyeCoords
;
2899 GLboolean _ForceEyeCoords
;
2900 GLenum _CurrentProgram
; /* currently executing program */
2902 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2903 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2906 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2909 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2911 * We don't have a better way to communicate this value from
2912 * swrast_setup to swrast. */
2914 /** \name For debugging/development only */
2916 GLboolean FirstTimeCurrent
;
2919 /** Dither disable via MESA_NO_DITHER env var */
2922 /** software compression/decompression supported or not */
2923 GLboolean Mesa_DXTn
;
2925 /** Core tnl module support */
2926 struct gl_tnl_module TnlModule
;
2929 * \name Hooks for module contexts.
2931 * These will eventually live in the driver or elsewhere.
2934 void *swrast_context
;
2935 void *swsetup_context
;
2936 void *swtnl_context
;
2938 void *acache_context
;
2944 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2945 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2949 extern int MESA_VERBOSE
;
2950 extern int MESA_DEBUG_FLAGS
;
2951 # define MESA_FUNCTION __FUNCTION__
2953 # define MESA_VERBOSE 0
2954 # define MESA_DEBUG_FLAGS 0
2955 # define MESA_FUNCTION "a function"
2964 VERBOSE_VARRAY
= 0x0001,
2965 VERBOSE_TEXTURE
= 0x0002,
2966 VERBOSE_IMMEDIATE
= 0x0004,
2967 VERBOSE_PIPELINE
= 0x0008,
2968 VERBOSE_DRIVER
= 0x0010,
2969 VERBOSE_STATE
= 0x0020,
2970 VERBOSE_API
= 0x0040,
2971 VERBOSE_DISPLAY_LIST
= 0x0100,
2972 VERBOSE_LIGHTING
= 0x0200,
2973 VERBOSE_PRIMS
= 0x0400,
2974 VERBOSE_VERTS
= 0x0800,
2975 VERBOSE_DISASSEM
= 0x1000
2981 DEBUG_ALWAYS_FLUSH
= 0x1
2986 #define Elements(x) sizeof(x)/sizeof(*(x))
2989 #endif /* TYPES_H */