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,
145 VERT_ATTRIB_COLOR_INDEX
= 6,
146 VERT_ATTRIB_EDGEFLAG
= 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_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
186 #define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG)
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_EDGE 15
253 #define VERT_RESULT_MAX 16
258 * Indexes for fragment program input attributes.
262 FRAG_ATTRIB_WPOS
= 0,
263 FRAG_ATTRIB_COL0
= 1,
264 FRAG_ATTRIB_COL1
= 2,
265 FRAG_ATTRIB_FOGC
= 3,
266 FRAG_ATTRIB_TEX0
= 4,
267 FRAG_ATTRIB_TEX1
= 5,
268 FRAG_ATTRIB_TEX2
= 6,
269 FRAG_ATTRIB_TEX3
= 7,
270 FRAG_ATTRIB_TEX4
= 8,
271 FRAG_ATTRIB_TEX5
= 9,
272 FRAG_ATTRIB_TEX6
= 10,
273 FRAG_ATTRIB_TEX7
= 11,
278 * Bitflags for fragment program input attributes.
281 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
282 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
283 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
284 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
285 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
286 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
287 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
288 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
289 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
290 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
291 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
292 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
294 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
306 * Fragment program results
309 #define FRAG_RESULT_COLR 0
310 #define FRAG_RESULT_COLH 1
311 #define FRAG_RESULT_DEPR 2
312 #define FRAG_RESULT_MAX 3
317 * Indexes for all renderbuffers
320 BUFFER_FRONT_LEFT
= 0, /* the four standard color buffers */
321 BUFFER_BACK_LEFT
= 1,
322 BUFFER_FRONT_RIGHT
= 2,
323 BUFFER_BACK_RIGHT
= 3,
324 BUFFER_AUX0
= 4, /* optional aux buffer */
331 BUFFER_COLOR0
= 11, /* generic renderbuffers */
343 * Bit flags for all renderbuffers
345 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
346 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
347 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
348 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
349 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
350 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
351 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
352 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
353 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
354 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
355 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
356 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
357 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
358 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
359 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
360 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
361 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
362 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
363 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
366 * Mask of all the color buffer bits (but not accum).
368 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
369 BUFFER_BIT_BACK_LEFT | \
370 BUFFER_BIT_FRONT_RIGHT | \
371 BUFFER_BIT_BACK_RIGHT | \
376 BUFFER_BIT_COLOR0 | \
377 BUFFER_BIT_COLOR1 | \
378 BUFFER_BIT_COLOR2 | \
379 BUFFER_BIT_COLOR3 | \
380 BUFFER_BIT_COLOR4 | \
381 BUFFER_BIT_COLOR5 | \
382 BUFFER_BIT_COLOR6 | \
386 /** The pixel transfer path has three color tables: */
388 #define COLORTABLE_PRECONVOLUTION 0
389 #define COLORTABLE_POSTCONVOLUTION 1
390 #define COLORTABLE_POSTCOLORMATRIX 2
391 #define COLORTABLE_MAX 3
396 * Data structure for color tables
398 struct gl_color_table
400 GLenum InternalFormat
; /**< The user-specified format */
401 GLenum _BaseFormat
; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
402 GLuint Size
; /**< number of entries in table */
403 GLfloat
*TableF
; /**< Color table, floating point values */
404 GLubyte
*TableUB
; /**< Color table, ubyte values */
409 GLubyte LuminanceSize
;
410 GLubyte IntensitySize
;
415 * \name Bit flags used for updating material values.
418 #define MAT_ATTRIB_FRONT_AMBIENT 0
419 #define MAT_ATTRIB_BACK_AMBIENT 1
420 #define MAT_ATTRIB_FRONT_DIFFUSE 2
421 #define MAT_ATTRIB_BACK_DIFFUSE 3
422 #define MAT_ATTRIB_FRONT_SPECULAR 4
423 #define MAT_ATTRIB_BACK_SPECULAR 5
424 #define MAT_ATTRIB_FRONT_EMISSION 6
425 #define MAT_ATTRIB_BACK_EMISSION 7
426 #define MAT_ATTRIB_FRONT_SHININESS 8
427 #define MAT_ATTRIB_BACK_SHININESS 9
428 #define MAT_ATTRIB_FRONT_INDEXES 10
429 #define MAT_ATTRIB_BACK_INDEXES 11
430 #define MAT_ATTRIB_MAX 12
432 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
433 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
434 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
435 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
436 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
437 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
439 #define MAT_INDEX_AMBIENT 0
440 #define MAT_INDEX_DIFFUSE 1
441 #define MAT_INDEX_SPECULAR 2
443 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
444 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
445 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
446 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
447 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
448 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
449 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
450 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
451 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
452 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
453 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
454 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
457 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
458 MAT_BIT_FRONT_AMBIENT | \
459 MAT_BIT_FRONT_DIFFUSE | \
460 MAT_BIT_FRONT_SPECULAR | \
461 MAT_BIT_FRONT_SHININESS | \
462 MAT_BIT_FRONT_INDEXES)
464 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
465 MAT_BIT_BACK_AMBIENT | \
466 MAT_BIT_BACK_DIFFUSE | \
467 MAT_BIT_BACK_SPECULAR | \
468 MAT_BIT_BACK_SHININESS | \
469 MAT_BIT_BACK_INDEXES)
471 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
475 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
476 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
479 * Material shininess lookup table.
483 struct gl_shine_tab
*next
, *prev
;
484 GLfloat tab
[SHINE_TABLE_SIZE
+1];
491 * Light source state.
495 struct gl_light
*next
; /**< double linked list with sentinel */
496 struct gl_light
*prev
;
498 GLfloat Ambient
[4]; /**< ambient color */
499 GLfloat Diffuse
[4]; /**< diffuse color */
500 GLfloat Specular
[4]; /**< specular color */
501 GLfloat EyePosition
[4]; /**< position in eye coordinates */
502 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
503 GLfloat SpotExponent
;
504 GLfloat SpotCutoff
; /**< in degrees */
505 GLfloat _CosCutoffNeg
; /**< = cos(SpotCutoff) */
506 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
507 GLfloat ConstantAttenuation
;
508 GLfloat LinearAttenuation
;
509 GLfloat QuadraticAttenuation
;
510 GLboolean Enabled
; /**< On/off flag */
513 * \name Derived fields
516 GLbitfield _Flags
; /**< State */
518 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
519 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
520 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
521 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
522 GLfloat _VP_inf_spot_attenuation
;
524 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
525 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
526 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
527 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
528 GLfloat _dli
; /**< CI diffuse light intensity */
529 GLfloat _sli
; /**< CI specular light intensity */
539 GLfloat Ambient
[4]; /**< ambient color */
540 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
541 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
542 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
543 * or GL_SEPARATE_SPECULAR_COLOR */
552 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
557 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
559 struct gl_accum_attrib
561 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
566 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
568 struct gl_colorbuffer_attrib
570 GLuint ClearIndex
; /**< Index to use for glClear */
571 GLclampf ClearColor
[4]; /**< Color to use for glClear */
573 GLuint IndexMask
; /**< Color index write mask */
574 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
576 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
579 * \name alpha testing
582 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
583 GLenum AlphaFunc
; /**< Alpha test function */
584 GLclampf AlphaRef
; /**< Alpha reference value */
591 GLboolean BlendEnabled
; /**< Blending enabled flag */
592 GLenum BlendSrcRGB
; /**< Blending source operator */
593 GLenum BlendDstRGB
; /**< Blending destination operator */
594 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
595 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
596 GLenum BlendEquationRGB
; /**< Blending equation */
597 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
598 GLfloat BlendColor
[4]; /**< Blending color */
605 GLenum LogicOp
; /**< Logic operator */
606 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
607 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
608 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
611 GLboolean DitherFlag
; /**< Dither enable flag */
613 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
614 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
619 * Current attribute group (GL_CURRENT_BIT).
621 struct gl_current_attrib
624 * \name Current vertex attributes.
625 * \note Values are valid only after FLUSH_VERTICES has been called.
626 * \note Index and Edgeflag current values are stored as floats in the
627 * SIX and SEVEN attribute slots.
630 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Position, color, texcoords, etc */
634 * \name Current raster position attributes (always valid).
635 * \note This set of attributes is very similar to the SWvertex struct.
638 GLfloat RasterPos
[4];
639 GLfloat RasterDistance
;
640 GLfloat RasterColor
[4];
641 GLfloat RasterSecondaryColor
[4];
643 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
644 GLboolean RasterPosValid
;
650 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
652 struct gl_depthbuffer_attrib
654 GLenum Func
; /**< Function for depth buffer compare */
655 GLclampd Clear
; /**< Value to clear depth buffer to */
656 GLboolean Test
; /**< Depth buffering enabled flag */
657 GLboolean Mask
; /**< Depth buffer writable? */
658 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
659 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
664 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
666 struct gl_enable_attrib
669 GLboolean AutoNormal
;
671 GLbitfield ClipPlanes
;
672 GLboolean ColorMaterial
;
673 GLboolean ColorTable
[COLORTABLE_MAX
];
674 GLboolean Convolution1D
;
675 GLboolean Convolution2D
;
676 GLboolean Separable2D
;
682 GLboolean Light
[MAX_LIGHTS
];
684 GLboolean LineSmooth
;
685 GLboolean LineStipple
;
686 GLboolean IndexLogicOp
;
687 GLboolean ColorLogicOp
;
688 GLboolean Map1Color4
;
690 GLboolean Map1Normal
;
691 GLboolean Map1TextureCoord1
;
692 GLboolean Map1TextureCoord2
;
693 GLboolean Map1TextureCoord3
;
694 GLboolean Map1TextureCoord4
;
695 GLboolean Map1Vertex3
;
696 GLboolean Map1Vertex4
;
697 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
698 GLboolean Map2Color4
;
700 GLboolean Map2Normal
;
701 GLboolean Map2TextureCoord1
;
702 GLboolean Map2TextureCoord2
;
703 GLboolean Map2TextureCoord3
;
704 GLboolean Map2TextureCoord4
;
705 GLboolean Map2Vertex3
;
706 GLboolean Map2Vertex4
;
707 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
710 GLboolean PixelTexture
;
711 GLboolean PointSmooth
;
712 GLboolean PolygonOffsetPoint
;
713 GLboolean PolygonOffsetLine
;
714 GLboolean PolygonOffsetFill
;
715 GLboolean PolygonSmooth
;
716 GLboolean PolygonStipple
;
717 GLboolean RescaleNormals
;
720 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
721 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
722 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
723 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
724 GLboolean SampleCoverage
; /* GL_ARB_multisample */
725 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
726 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
727 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
728 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
729 /* SGI_texture_color_table */
730 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
731 /* GL_ARB_vertex_program / GL_NV_vertex_program */
732 GLboolean VertexProgram
;
733 GLboolean VertexProgramPointSize
;
734 GLboolean VertexProgramTwoSide
;
735 /* GL_ARB_point_sprite / GL_NV_point_sprite */
736 GLboolean PointSprite
;
737 GLboolean FragmentShaderATI
;
742 * Evaluator attribute group (GL_EVAL_BIT).
744 struct gl_eval_attrib
750 GLboolean Map1Color4
;
752 GLboolean Map1Normal
;
753 GLboolean Map1TextureCoord1
;
754 GLboolean Map1TextureCoord2
;
755 GLboolean Map1TextureCoord3
;
756 GLboolean Map1TextureCoord4
;
757 GLboolean Map1Vertex3
;
758 GLboolean Map1Vertex4
;
759 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
760 GLboolean Map2Color4
;
762 GLboolean Map2Normal
;
763 GLboolean Map2TextureCoord1
;
764 GLboolean Map2TextureCoord2
;
765 GLboolean Map2TextureCoord3
;
766 GLboolean Map2TextureCoord4
;
767 GLboolean Map2Vertex3
;
768 GLboolean Map2Vertex4
;
769 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
770 GLboolean AutoNormal
;
774 * \name Map Grid endpoints and divisions and calculated du values
778 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
779 GLint MapGrid2un
, MapGrid2vn
;
780 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
781 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
787 * Fog attribute group (GL_FOG_BIT).
791 GLboolean Enabled
; /**< Fog enabled flag */
792 GLfloat Color
[4]; /**< Fog color */
793 GLfloat Density
; /**< Density >= 0.0 */
794 GLfloat Start
; /**< Start distance in eye coords */
795 GLfloat End
; /**< End distance in eye coords */
796 GLfloat Index
; /**< Fog index */
797 GLenum Mode
; /**< Fog mode */
798 GLboolean ColorSumEnabled
;
799 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
800 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
805 * Hint attribute group (GL_HINT_BIT).
807 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
809 struct gl_hint_attrib
811 GLenum PerspectiveCorrection
;
814 GLenum PolygonSmooth
;
816 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
817 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
818 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
819 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
824 * Histogram attributes.
826 struct gl_histogram_attrib
828 GLuint Width
; /**< number of table entries */
829 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
830 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
831 GLboolean Sink
; /**< terminate image transfer? */
832 GLubyte RedSize
; /**< Bits per counter */
836 GLubyte LuminanceSize
;
841 * Color Min/max state.
843 struct gl_minmax_attrib
847 GLfloat Min
[4], Max
[4]; /**< RGBA */
852 * Image convolution state.
854 struct gl_convolution_attrib
857 GLenum InternalFormat
;
860 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
868 #define LIGHT_SPOT 0x1
869 #define LIGHT_LOCAL_VIEWER 0x2
870 #define LIGHT_POSITIONAL 0x4
871 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
876 * Lighting attribute group (GL_LIGHT_BIT).
878 struct gl_light_attrib
880 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
881 struct gl_lightmodel Model
; /**< Lighting model */
884 * Must flush FLUSH_VERTICES before referencing:
887 struct gl_material Material
; /**< Includes front & back values */
890 GLboolean Enabled
; /**< Lighting enabled flag */
891 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
892 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
893 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
894 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
895 GLboolean ColorMaterialEnabled
;
896 GLenum ClampVertexColor
;
898 struct gl_light EnabledList
; /**< List sentinel */
901 * Derived state for optimizations:
904 GLboolean _NeedEyeCoords
;
905 GLboolean _NeedVertices
; /**< Use fast shader? */
906 GLbitfield _Flags
; /**< LIGHT_* flags, see above */
907 GLfloat _BaseColor
[2][3];
913 * Line attribute group (GL_LINE_BIT).
915 struct gl_line_attrib
917 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
918 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
919 GLushort StipplePattern
; /**< Stipple pattern */
920 GLint StippleFactor
; /**< Stipple repeat factor */
921 GLfloat Width
; /**< Line width */
922 GLfloat _Width
; /**< Clamped Line width */
927 * Display list attribute group (GL_LIST_BIT).
929 struct gl_list_attrib
936 * Used by device drivers to hook new commands into display lists.
938 struct gl_list_instruction
941 void (*Execute
)( GLcontext
*ctx
, void *data
);
942 void (*Destroy
)( GLcontext
*ctx
, void *data
);
943 void (*Print
)( GLcontext
*ctx
, void *data
);
946 #define MAX_DLIST_EXT_OPCODES 16
949 * Used by device drivers to hook new commands into display lists.
951 struct gl_list_extensions
953 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
959 * Multisample attribute group (GL_MULTISAMPLE_BIT).
961 struct gl_multisample_attrib
964 GLboolean SampleAlphaToCoverage
;
965 GLboolean SampleAlphaToOne
;
966 GLboolean SampleCoverage
;
967 GLfloat SampleCoverageValue
;
968 GLboolean SampleCoverageInvert
;
973 * A pixelmap (see glPixelMap)
978 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
979 GLubyte Map8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
984 * Collection of all pixelmaps
988 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
989 struct gl_pixelmap GtoG
;
990 struct gl_pixelmap BtoB
;
991 struct gl_pixelmap AtoA
;
992 struct gl_pixelmap ItoR
;
993 struct gl_pixelmap ItoG
;
994 struct gl_pixelmap ItoB
;
995 struct gl_pixelmap ItoA
;
996 struct gl_pixelmap ItoI
;
997 struct gl_pixelmap StoS
;
1002 * Pixel attribute group (GL_PIXEL_MODE_BIT).
1004 struct gl_pixel_attrib
1006 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
1008 /*--- Begin Pixel Transfer State ---*/
1009 /* Fields are in the order in which they're applied... */
1011 /* Scale & Bias (index shift, offset) */
1012 GLfloat RedBias
, RedScale
;
1013 GLfloat GreenBias
, GreenScale
;
1014 GLfloat BlueBias
, BlueScale
;
1015 GLfloat AlphaBias
, AlphaScale
;
1016 GLfloat DepthBias
, DepthScale
;
1017 GLint IndexShift
, IndexOffset
;
1020 /* Note: actual pixel maps are not part of this attrib group */
1021 GLboolean MapColorFlag
;
1022 GLboolean MapStencilFlag
;
1024 /* There are multiple color table stages: */
1025 GLboolean ColorTableEnabled
[COLORTABLE_MAX
];
1026 GLfloat ColorTableScale
[COLORTABLE_MAX
][4]; /**< RGBA */
1027 GLfloat ColorTableBias
[COLORTABLE_MAX
][4]; /**< RGBA */
1029 /* Convolution (GL_EXT_convolution) */
1030 GLboolean Convolution1DEnabled
;
1031 GLboolean Convolution2DEnabled
;
1032 GLboolean Separable2DEnabled
;
1033 GLfloat ConvolutionBorderColor
[3][4];
1034 GLenum ConvolutionBorderMode
[3];
1035 GLfloat ConvolutionFilterScale
[3][4]; /**< RGBA */
1036 GLfloat ConvolutionFilterBias
[3][4]; /**< RGBA */
1037 GLfloat PostConvolutionScale
[4]; /**< RGBA */
1038 GLfloat PostConvolutionBias
[4]; /**< RGBA */
1040 /* Color matrix (GL_SGI_color_matrix) */
1041 /* Note: the color matrix is not part of this attrib group */
1042 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
1043 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
1045 /* Histogram & minmax (GL_EXT_histogram) */
1046 /* Note: histogram and minmax data are not part of this attrib group */
1047 GLboolean HistogramEnabled
;
1048 GLboolean MinMaxEnabled
;
1050 /*--- End Pixel Transfer State ---*/
1053 GLfloat ZoomX
, ZoomY
;
1055 /** GL_SGI_texture_color_table */
1056 GLfloat TextureColorTableScale
[4];
1057 GLfloat TextureColorTableBias
[4];
1062 * Point attribute group (GL_POINT_BIT).
1064 struct gl_point_attrib
1066 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
1067 GLfloat Size
; /**< User-specified point size */
1068 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
1069 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
1070 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
1071 GLfloat Threshold
; /**< GL_EXT_point_parameters */
1072 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
1073 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
1074 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite */
1075 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
1076 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
1081 * Polygon attribute group (GL_POLYGON_BIT).
1083 struct gl_polygon_attrib
1085 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1086 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1087 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1088 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1089 GLboolean CullFlag
; /**< Culling on/off flag */
1090 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1091 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1092 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1093 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1094 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1095 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1096 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1097 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1102 * Scissor attributes (GL_SCISSOR_BIT).
1104 struct gl_scissor_attrib
1106 GLboolean Enabled
; /**< Scissor test enabled? */
1107 GLint X
, Y
; /**< Lower left corner of box */
1108 GLsizei Width
, Height
; /**< Size of box */
1113 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1115 struct gl_stencil_attrib
1117 GLboolean Enabled
; /**< Enabled flag */
1118 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1119 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1120 GLboolean _TestTwoSide
;
1121 GLenum Function
[2]; /**< Stencil function */
1122 GLenum FailFunc
[2]; /**< Fail function */
1123 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1124 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1125 GLint Ref
[2]; /**< Reference value */
1126 GLuint ValueMask
[2]; /**< Value mask */
1127 GLuint WriteMask
[2]; /**< Write mask */
1128 GLuint Clear
; /**< Clear value */
1132 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1135 * An index for each type of texture object
1138 #define TEXTURE_1D_INDEX 0
1139 #define TEXTURE_2D_INDEX 1
1140 #define TEXTURE_3D_INDEX 2
1141 #define TEXTURE_CUBE_INDEX 3
1142 #define TEXTURE_RECT_INDEX 4
1146 * Bit flags for each type of texture object
1147 * Used for Texture.Unit[]._ReallyEnabled flags.
1150 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1151 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1152 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1153 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1154 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1159 * TexGenEnabled flags.
1170 * Bit flag versions of the corresponding GL_ constants.
1173 #define TEXGEN_SPHERE_MAP 0x1
1174 #define TEXGEN_OBJ_LINEAR 0x2
1175 #define TEXGEN_EYE_LINEAR 0x4
1176 #define TEXGEN_REFLECTION_MAP_NV 0x8
1177 #define TEXGEN_NORMAL_MAP_NV 0x10
1179 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1180 TEXGEN_REFLECTION_MAP_NV | \
1181 TEXGEN_NORMAL_MAP_NV)
1182 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1183 TEXGEN_REFLECTION_MAP_NV | \
1184 TEXGEN_NORMAL_MAP_NV | \
1189 /* A selection of state flags to make driver and module's lives easier. */
1190 #define ENABLE_TEXGEN0 0x1
1191 #define ENABLE_TEXGEN1 0x2
1192 #define ENABLE_TEXGEN2 0x4
1193 #define ENABLE_TEXGEN3 0x8
1194 #define ENABLE_TEXGEN4 0x10
1195 #define ENABLE_TEXGEN5 0x20
1196 #define ENABLE_TEXGEN6 0x40
1197 #define ENABLE_TEXGEN7 0x80
1199 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1200 #define ENABLE_TEXMAT1 0x2
1201 #define ENABLE_TEXMAT2 0x4
1202 #define ENABLE_TEXMAT3 0x8
1203 #define ENABLE_TEXMAT4 0x10
1204 #define ENABLE_TEXMAT5 0x20
1205 #define ENABLE_TEXMAT6 0x40
1206 #define ENABLE_TEXMAT7 0x80
1208 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1209 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1213 * Texel fetch function prototype. We use texel fetch functions to
1214 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1215 * texture images. These functions help to isolate us from the gritty
1216 * details of all the various texture image encodings.
1218 * \param texImage texture image.
1219 * \param col texel column.
1220 * \param row texel row.
1221 * \param img texel image level/layer.
1222 * \param texelOut output texel (up to 4 GLchans)
1224 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1225 GLint col
, GLint row
, GLint img
,
1229 * As above, but returns floats.
1230 * Used for depth component images and for upcoming signed/float
1233 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1234 GLint col
, GLint row
, GLint img
,
1235 GLfloat
*texelOut
);
1238 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1239 GLint col
, GLint row
, GLint img
,
1244 * This macro defines the (many) parameters to the texstore functions.
1245 * \param dims either 1 or 2 or 3
1246 * \param baseInternalFormat user-specified base internal format
1247 * \param dstFormat destination Mesa texture format
1248 * \param dstAddr destination image address
1249 * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
1250 * \param dstRowStride destination image row stride, in bytes
1251 * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
1252 * \param srcWidth/Height/Depth source image size, in pixels
1253 * \param srcFormat incoming image format
1254 * \param srcType incoming image data type
1255 * \param srcAddr source image address
1256 * \param srcPacking source image packing parameters
1258 #define TEXSTORE_PARAMS \
1259 GLcontext *ctx, GLuint dims, \
1260 GLenum baseInternalFormat, \
1261 const struct gl_texture_format *dstFormat, \
1263 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
1264 GLint dstRowStride, const GLuint *dstImageOffsets, \
1265 GLint srcWidth, GLint srcHeight, GLint srcDepth, \
1266 GLenum srcFormat, GLenum srcType, \
1267 const GLvoid *srcAddr, \
1268 const struct gl_pixelstore_attrib *srcPacking
1273 * Texture image storage function.
1275 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
1279 * Texture format record
1281 struct gl_texture_format
1283 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1285 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1286 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1287 * GL_INTENSITY, GL_COLOR_INDEX or
1288 * GL_DEPTH_COMPONENT.
1290 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1291 GLubyte RedBits
; /**< Bits per texel component */
1292 GLubyte GreenBits
; /**< These are just rough approximations for */
1293 GLubyte BlueBits
; /**< compressed texture formats. */
1295 GLubyte LuminanceBits
;
1296 GLubyte IntensityBits
;
1299 GLubyte StencilBits
; /**< GL_EXT_packed_depth_stencil */
1301 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1303 StoreTexImageFunc StoreImage
;
1306 * \name Texel fetch function pointers
1309 FetchTexelFuncC FetchTexel1D
;
1310 FetchTexelFuncC FetchTexel2D
;
1311 FetchTexelFuncC FetchTexel3D
;
1312 FetchTexelFuncF FetchTexel1Df
;
1313 FetchTexelFuncF FetchTexel2Df
;
1314 FetchTexelFuncF FetchTexel3Df
;
1317 StoreTexelFunc StoreTexel
;
1321 #define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
1324 * Texture image state. Describes the dimensions of a texture image,
1325 * the texel format and pointers to Texel Fetch functions.
1327 struct gl_texture_image
1329 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1330 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1331 * GL_INTENSITY, GL_COLOR_INDEX,
1332 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1333 * only. Used for choosing TexEnv arithmetic.
1335 GLint InternalFormat
; /**< Internal format as given by the user */
1336 GLuint Border
; /**< 0 or 1 */
1337 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1338 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1339 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1340 GLuint Width2
; /**< = Width - 2*Border */
1341 GLuint Height2
; /**< = Height - 2*Border */
1342 GLuint Depth2
; /**< = Depth - 2*Border */
1343 GLuint WidthLog2
; /**< = log2(Width2) */
1344 GLuint HeightLog2
; /**< = log2(Height2) */
1345 GLuint DepthLog2
; /**< = log2(Depth2) */
1346 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1347 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1348 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1349 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1350 GLboolean IsClientData
; /**< Data owned by client? */
1351 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1353 const struct gl_texture_format
*TexFormat
;
1355 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1357 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1358 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1360 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1361 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1363 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1364 GLuint
*ImageOffsets
; /**< if 3D texture: array [Depth] of offsets to
1365 each 2D slice in 'Data', in texels */
1366 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1369 * \name For device driver:
1372 void *DriverData
; /**< Arbitrary device driver data */
1378 * Indexes for cube map faces.
1381 #define FACE_POS_X 0
1382 #define FACE_NEG_X 1
1383 #define FACE_POS_Y 2
1384 #define FACE_NEG_Y 3
1385 #define FACE_POS_Z 4
1386 #define FACE_NEG_Z 5
1392 * Texture object state. Contains the array of mipmap images, border color,
1393 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1396 struct gl_texture_object
1398 _glthread_Mutex Mutex
; /**< for thread safety */
1399 GLint RefCount
; /**< reference count */
1400 GLuint Name
; /**< the user-visible texture object ID */
1401 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1402 GLfloat Priority
; /**< in [0,1] */
1403 GLfloat BorderColor
[4]; /**< unclamped */
1404 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1405 GLenum WrapS
; /**< S-axis texture image wrap mode */
1406 GLenum WrapT
; /**< T-axis texture image wrap mode */
1407 GLenum WrapR
; /**< R-axis texture image wrap mode */
1408 GLenum MinFilter
; /**< minification filter */
1409 GLenum MagFilter
; /**< magnification filter */
1410 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1411 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1412 GLfloat LodBias
; /**< OpenGL 1.4 */
1413 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1414 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1415 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1416 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1417 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1418 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1419 GLenum CompareMode
; /**< GL_ARB_shadow */
1420 GLenum CompareFunc
; /**< GL_ARB_shadow */
1421 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1422 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1423 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1424 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1425 GLboolean Complete
; /**< Is texture object complete? */
1427 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1428 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1430 /** GL_EXT_paletted_texture */
1431 struct gl_color_table Palette
;
1435 * \name For device driver.
1436 * Note: instead of attaching driver data to this pointer, it's preferable
1437 * to instead use this struct as a base class for your own texture object
1438 * class. Driver->NewTextureObject() can be used to implement the
1441 void *DriverData
; /**< Arbitrary device driver data */
1446 * Texture combine environment state.
1449 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1450 * structure will need to be expanded for 4 elements.
1452 struct gl_tex_env_combine_state
1454 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1455 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1456 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1457 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1458 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1459 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1460 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1461 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1462 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1463 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1468 * Texture unit state. Contains enable flags, texture environment/function/
1469 * combiners, texgen state, pointers to current texture objects and
1470 * post-filter color tables.
1472 struct gl_texture_unit
1474 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1475 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1477 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1478 GLfloat EnvColor
[4];
1479 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1480 /** \name Tex coord generation mode
1481 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1488 GLbitfield _GenBitS
;
1489 GLbitfield _GenBitT
;
1490 GLbitfield _GenBitR
;
1491 GLbitfield _GenBitQ
;
1492 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1493 GLfloat ObjectPlaneS
[4];
1494 GLfloat ObjectPlaneT
[4];
1495 GLfloat ObjectPlaneR
[4];
1496 GLfloat ObjectPlaneQ
[4];
1497 GLfloat EyePlaneS
[4];
1498 GLfloat EyePlaneT
[4];
1499 GLfloat EyePlaneR
[4];
1500 GLfloat EyePlaneQ
[4];
1501 GLfloat LodBias
; /**< for biasing mipmap levels */
1504 * \name GL_EXT_texture_env_combine
1506 struct gl_tex_env_combine_state Combine
;
1509 * Derived state based on \c EnvMode and the \c BaseFormat of the
1510 * currently enabled texture.
1512 struct gl_tex_env_combine_state _EnvMode
;
1515 * Currently enabled combiner state. This will point to either
1516 * \c Combine or \c _EnvMode.
1518 struct gl_tex_env_combine_state
*_CurrentCombine
;
1520 struct gl_texture_object
*Current1D
;
1521 struct gl_texture_object
*Current2D
;
1522 struct gl_texture_object
*Current3D
;
1523 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1524 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1526 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1528 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1529 struct gl_texture_object Saved2D
;
1530 struct gl_texture_object Saved3D
;
1531 struct gl_texture_object SavedCubeMap
;
1532 struct gl_texture_object SavedRect
;
1534 /* GL_SGI_texture_color_table */
1535 struct gl_color_table ColorTable
;
1536 struct gl_color_table ProxyColorTable
;
1537 GLboolean ColorTableEnabled
;
1540 struct texenvprog_cache_item
{
1543 struct gl_fragment_program
*data
;
1544 struct texenvprog_cache_item
*next
;
1547 struct texenvprog_cache
{
1548 struct texenvprog_cache_item
**items
;
1549 GLuint size
, n_items
;
1554 * Texture attribute group (GL_TEXTURE_BIT).
1556 struct gl_texture_attrib
1562 GLuint CurrentUnit
; /**< Active texture unit */
1563 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1564 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1565 GLbitfield _GenFlags
; /**< for texgen */
1566 GLbitfield _TexGenEnabled
;
1567 GLbitfield _TexMatEnabled
;
1570 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1572 struct gl_texture_object
*Proxy1D
;
1573 struct gl_texture_object
*Proxy2D
;
1574 struct gl_texture_object
*Proxy3D
;
1575 struct gl_texture_object
*ProxyCubeMap
;
1576 struct gl_texture_object
*ProxyRect
;
1578 /** GL_EXT_shared_texture_palette */
1579 GLboolean SharedPalette
;
1580 struct gl_color_table Palette
;
1582 /** Cached texenv fragment programs */
1583 struct texenvprog_cache env_fp_cache
;
1588 * Transformation attribute group (GL_TRANSFORM_BIT).
1590 struct gl_transform_attrib
1592 GLenum MatrixMode
; /**< Matrix mode */
1593 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1594 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1595 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1596 GLboolean Normalize
; /**< Normalize all normals? */
1597 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1598 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1600 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1601 GLfloat CullEyePos
[4];
1602 GLfloat CullObjPos
[4];
1607 * Viewport attribute group (GL_VIEWPORT_BIT).
1609 struct gl_viewport_attrib
1611 GLint X
, Y
; /**< position */
1612 GLsizei Width
, Height
; /**< size */
1613 GLfloat Near
, Far
; /**< Depth buffer range */
1614 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1619 * Node for the attribute stack.
1621 struct gl_attrib_node
1625 struct gl_attrib_node
*next
;
1630 * GL_ARB_vertex/pixel_buffer_object buffer object
1632 struct gl_buffer_object
1638 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1639 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1640 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1641 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1647 * Client pixel packing/unpacking attributes
1649 struct gl_pixelstore_attrib
1655 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1656 GLint SkipImages
; /**< for GL_EXT_texture3D */
1657 GLboolean SwapBytes
;
1659 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1660 GLboolean Invert
; /**< GL_MESA_pack_invert */
1661 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1667 * Client vertex array attributes
1669 struct gl_client_array
1671 GLint Size
; /**< components per element (1,2,3,4) */
1672 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1673 GLsizei Stride
; /**< user-specified stride */
1674 GLsizei StrideB
; /**< actual stride in bytes */
1675 const GLubyte
*Ptr
; /**< Points to array data */
1676 GLboolean Enabled
; /**< Enabled flag is a boolean */
1677 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1679 /**< GL_ARB_vertex_buffer_object */
1680 struct gl_buffer_object
*BufferObj
;
1686 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1687 * extension, but a nice encapsulation in any case.
1689 struct gl_array_object
1691 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1694 /** Conventional vertex arrays */
1696 struct gl_client_array Vertex
;
1697 struct gl_client_array Normal
;
1698 struct gl_client_array Color
;
1699 struct gl_client_array SecondaryColor
;
1700 struct gl_client_array FogCoord
;
1701 struct gl_client_array Index
;
1702 struct gl_client_array EdgeFlag
;
1703 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1706 /** Generic arrays for vertex programs/shaders */
1707 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1709 /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
1710 GLbitfield _Enabled
;
1715 * Vertex array state
1717 struct gl_array_attrib
1719 struct gl_array_object
*ArrayObj
;
1720 struct gl_array_object
*DefaultArrayObj
;
1722 GLint ActiveTexture
; /**< Client Active Texture */
1723 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1724 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1726 GLbitfield NewState
; /**< mask of _NEW_ARRAY_* values */
1728 #if FEATURE_ARB_vertex_buffer_object
1729 struct gl_buffer_object
*NullBufferObj
;
1730 struct gl_buffer_object
*ArrayBufferObj
;
1731 struct gl_buffer_object
*ElementArrayBufferObj
;
1733 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1738 * Feedback buffer state
1743 GLbitfield _Mask
; /* FB_* bits */
1751 * Selection buffer state
1755 GLuint
*Buffer
; /**< selection buffer */
1756 GLuint BufferSize
; /**< size of the selection buffer */
1757 GLuint BufferCount
; /**< number of values in the selection buffer */
1758 GLuint Hits
; /**< number of records in the selection buffer */
1759 GLuint NameStackDepth
; /**< name stack depth */
1760 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1761 GLboolean HitFlag
; /**< hit flag */
1762 GLfloat HitMinZ
; /**< minimum hit depth */
1763 GLfloat HitMaxZ
; /**< maximum hit depth */
1768 * 1-D Evaluator control points
1772 GLuint Order
; /**< Number of control points */
1773 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1774 GLfloat
*Points
; /**< Points to contiguous control points */
1779 * 2-D Evaluator control points
1783 GLuint Uorder
; /**< Number of control points in U dimension */
1784 GLuint Vorder
; /**< Number of control points in V dimension */
1787 GLfloat
*Points
; /**< Points to contiguous control points */
1792 * All evaluator control point state
1794 struct gl_evaluators
1800 struct gl_1d_map Map1Vertex3
;
1801 struct gl_1d_map Map1Vertex4
;
1802 struct gl_1d_map Map1Index
;
1803 struct gl_1d_map Map1Color4
;
1804 struct gl_1d_map Map1Normal
;
1805 struct gl_1d_map Map1Texture1
;
1806 struct gl_1d_map Map1Texture2
;
1807 struct gl_1d_map Map1Texture3
;
1808 struct gl_1d_map Map1Texture4
;
1809 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1816 struct gl_2d_map Map2Vertex3
;
1817 struct gl_2d_map Map2Vertex4
;
1818 struct gl_2d_map Map2Index
;
1819 struct gl_2d_map Map2Color4
;
1820 struct gl_2d_map Map2Normal
;
1821 struct gl_2d_map Map2Texture1
;
1822 struct gl_2d_map Map2Texture2
;
1823 struct gl_2d_map Map2Texture3
;
1824 struct gl_2d_map Map2Texture4
;
1825 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1831 * Names of the various vertex/fragment program register files, etc.
1832 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1833 * All values should fit in a 4-bit field.
1837 PROGRAM_TEMPORARY
= 0,
1838 PROGRAM_LOCAL_PARAM
= 1,
1839 PROGRAM_ENV_PARAM
= 2,
1840 PROGRAM_STATE_VAR
= 3,
1843 PROGRAM_NAMED_PARAM
= 6,
1844 PROGRAM_CONSTANT
= 7,
1845 PROGRAM_WRITE_ONLY
= 8,
1846 PROGRAM_ADDRESS
= 9,
1847 PROGRAM_UNDEFINED
= 10, /* invalid value */
1852 /** Vertex and fragment instructions */
1853 struct prog_instruction
;
1854 struct gl_program_parameter_list
;
1858 * Base class for any kind of program object
1863 GLubyte
*String
; /**< Null-terminated program text */
1866 GLenum Format
; /**< String encoding format */
1869 struct prog_instruction
*Instructions
;
1871 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1872 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1874 /** Named parameters, constants, etc. from program text */
1875 struct gl_program_parameter_list
*Parameters
;
1876 /** Numbered local parameters */
1877 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1879 /** Logical counts */
1881 GLuint NumInstructions
;
1882 GLuint NumTemporaries
;
1883 GLuint NumParameters
;
1884 GLuint NumAttributes
;
1885 GLuint NumAddressRegs
;
1887 /** Native, actual h/w counts */
1889 GLuint NumNativeInstructions
;
1890 GLuint NumNativeTemporaries
;
1891 GLuint NumNativeParameters
;
1892 GLuint NumNativeAttributes
;
1893 GLuint NumNativeAddressRegs
;
1898 /** Vertex program object */
1899 struct gl_vertex_program
1901 struct gl_program Base
; /**< base class */
1902 GLboolean IsNVProgram
; /**< is this a GL_NV_vertex_program program? */
1903 GLboolean IsPositionInvariant
;
1904 void *TnlData
; /**< should probably use Base.DriverData */
1908 /** Fragment program object */
1909 struct gl_fragment_program
1911 struct gl_program Base
; /**< base class */
1912 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
1913 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1914 GLuint NumTexInstructions
;
1915 GLuint NumTexIndirections
;
1916 GLuint NumNativeAluInstructions
; /**< GL_ARB_fragment_program */
1917 GLuint NumNativeTexInstructions
;
1918 GLuint NumNativeTexIndirections
;
1925 * State common to vertex and fragment programs.
1927 struct gl_program_state
1929 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1930 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1935 * Context state for vertex programs.
1937 struct gl_vertex_program_state
1939 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_ARB/NV */
1940 GLboolean _Enabled
; /**< Enabled and valid program? */
1941 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1942 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1943 struct gl_vertex_program
*Current
; /**< ptr to currently bound program */
1944 const struct gl_vertex_program
*_Current
; /**< ptr to currently bound
1945 program, including internal
1946 (t_vp_build.c) programs */
1948 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /**< Env params */
1950 /* For GL_NV_vertex_program only: */
1951 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1952 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1954 #if FEATURE_MESA_program_debug
1955 GLprogramcallbackMESA Callback
;
1956 GLvoid
*CallbackData
;
1957 GLboolean CallbackEnabled
;
1958 GLuint CurrentPosition
;
1964 * Context state for fragment programs.
1966 struct gl_fragment_program_state
1968 GLboolean Enabled
; /**< User-set fragment program enable flag */
1969 GLboolean _Enabled
; /**< Fragment program enabled and valid? */
1970 GLboolean _Active
; /**< Is a user program or internal program active? */
1971 struct gl_fragment_program
*Current
; /**< User-bound program */
1972 const struct gl_fragment_program
*_Current
; /**< currently active program
1973 (including internal programs) */
1974 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /**< Env params */
1976 #if FEATURE_MESA_program_debug
1977 GLprogramcallbackMESA Callback
;
1978 GLvoid
*CallbackData
;
1979 GLboolean CallbackEnabled
;
1980 GLuint CurrentPosition
;
1986 * ATI_fragment_shader runtime state
1988 #define ATI_FS_INPUT_PRIMARY 0
1989 #define ATI_FS_INPUT_SECONDARY 1
1991 struct atifs_instruction
;
1992 struct atifs_setupinst
;
1995 * ATI fragment shader
1997 struct ati_fragment_shader
2001 struct atifs_instruction
*Instructions
[2];
2002 struct atifs_setupinst
*SetupInst
[2];
2003 GLfloat Constants
[8][4];
2004 GLbitfield LocalConstDef
; /** Indicates which constants have been set */
2005 GLubyte numArithInstr
[2];
2006 GLubyte regsAssigned
[2];
2007 GLubyte NumPasses
; /** 1 or 2 */
2009 GLubyte last_optype
;
2010 GLboolean interpinp1
;
2016 * Context state for GL_ATI_fragment_shader
2018 struct gl_ati_fragment_shader_state
2021 GLboolean _Enabled
; /** enabled and valid shader? */
2022 GLboolean Compiling
;
2023 GLfloat GlobalConstants
[8][4];
2024 struct ati_fragment_shader
*Current
;
2029 * Occlusion/timer query object.
2031 struct gl_query_object
2034 GLuint64EXT Result
; /* the counter */
2035 GLboolean Active
; /* inside Begin/EndQuery */
2036 GLboolean Ready
; /* result is ready */
2041 * Context state for query objects.
2043 struct gl_query_state
2045 struct _mesa_HashTable
*QueryObjects
;
2046 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2047 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2052 * Context state for vertex/fragment shaders.
2054 struct gl_shader_objects_state
2056 struct gl2_program_intf
**CurrentProgram
;
2057 GLboolean _VertexShaderPresent
;
2058 GLboolean _FragmentShaderPresent
;
2063 * State which can be shared by multiple contexts:
2065 struct gl_shared_state
2067 _glthread_Mutex Mutex
; /**< for thread safety */
2068 GLint RefCount
; /**< Reference count */
2069 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2070 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2073 * \name Default texture objects (shared by all multi-texture units)
2076 struct gl_texture_object
*Default1D
;
2077 struct gl_texture_object
*Default2D
;
2078 struct gl_texture_object
*Default3D
;
2079 struct gl_texture_object
*DefaultCubeMap
;
2080 struct gl_texture_object
*DefaultRect
;
2084 * \name Thread safety and statechange notification for texture
2087 * \todo Improve the granularity of locking.
2090 _glthread_Mutex TexMutex
; /**< texobj thread safety */
2091 GLuint TextureStateStamp
; /**< state notification for shared tex */
2097 * \name Vertex/fragment programs
2100 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
2101 #if FEATURE_ARB_vertex_program
2102 struct gl_program
*DefaultVertexProgram
;
2104 #if FEATURE_ARB_fragment_program
2105 struct gl_program
*DefaultFragmentProgram
;
2109 #if FEATURE_ATI_fragment_shader
2110 struct _mesa_HashTable
*ATIShaders
;
2111 struct ati_fragment_shader
*DefaultFragmentShader
;
2114 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2115 struct _mesa_HashTable
*BufferObjects
;
2118 #if FEATURE_ARB_shader_objects
2119 struct _mesa_HashTable
*GL2Objects
;
2122 #if FEATURE_EXT_framebuffer_object
2123 struct _mesa_HashTable
*RenderBuffers
;
2124 struct _mesa_HashTable
*FrameBuffers
;
2127 /** Objects associated with the GL_APPLE_vertex_array_object extension. */
2128 struct _mesa_HashTable
*ArrayObjects
;
2130 void *DriverData
; /**< Device driver shared state */
2137 * A renderbuffer stores colors or depth values or stencil values.
2138 * A framebuffer object will have a collection of these.
2139 * Data are read/written to the buffer with a handful of Get/Put functions.
2141 * Instances of this object are allocated with the Driver's NewRenderbuffer
2142 * hook. Drivers will likely wrap this class inside a driver-specific
2143 * class to simulate inheritance.
2145 struct gl_renderbuffer
2147 _glthread_Mutex Mutex
; /**< for thread safety */
2148 GLuint ClassID
; /**< Useful for drivers */
2151 GLuint Width
, Height
;
2152 GLenum InternalFormat
; /**< The user-specified format */
2153 GLenum _ActualFormat
; /**< The driver-chosen format */
2154 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2155 GL_STENCIL_INDEX. */
2156 GLenum DataType
; /**< Type of values passed to the Get/Put functions */
2157 GLubyte RedBits
; /**< Bits of red per pixel */
2163 GLubyte StencilBits
;
2164 GLvoid
*Data
; /**< This may not be used by some kinds of RBs */
2166 /* Used to wrap one renderbuffer around another: */
2167 struct gl_renderbuffer
*Wrapped
;
2169 /* Delete this renderbuffer */
2170 void (*Delete
)(struct gl_renderbuffer
*rb
);
2172 /* Allocate new storage for this renderbuffer */
2173 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2174 GLenum internalFormat
,
2175 GLuint width
, GLuint height
);
2177 /* Lock/Unlock are called before/after calling the Get/Put functions.
2178 * Not sure this is the right place for these yet.
2179 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2180 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2183 /* Return a pointer to the element/pixel at (x,y).
2184 * Should return NULL if the buffer memory can't be directly addressed.
2186 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2189 /* Get/Read a row of values.
2190 * The values will be of format _BaseFormat and type DataType.
2192 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2193 GLint x
, GLint y
, void *values
);
2195 /* Get/Read values at arbitrary locations.
2196 * The values will be of format _BaseFormat and type DataType.
2198 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2199 const GLint x
[], const GLint y
[], void *values
);
2201 /* Put/Write a row of values.
2202 * The values will be of format _BaseFormat and type DataType.
2204 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2205 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2207 /* Put/Write a row of RGB values. This is a special-case routine that's
2208 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2209 * a common case for glDrawPixels and some triangle routines.
2210 * The values will be of format GL_RGB and type DataType.
2212 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2213 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2216 /* Put/Write a row of identical values.
2217 * The values will be of format _BaseFormat and type DataType.
2219 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2220 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2222 /* Put/Write values at arbitrary locations.
2223 * The values will be of format _BaseFormat and type DataType.
2225 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2226 const GLint x
[], const GLint y
[], const void *values
,
2227 const GLubyte
*mask
);
2228 /* Put/Write identical values at arbitrary locations.
2229 * The values will be of format _BaseFormat and type DataType.
2231 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2232 GLuint count
, const GLint x
[], const GLint y
[],
2233 const void *value
, const GLubyte
*mask
);
2238 * A renderbuffer attachment point points to either a texture object
2239 * (and specifies a mipmap level, cube face or 3D texture slice) or
2240 * points to a renderbuffer.
2242 struct gl_renderbuffer_attachment
2244 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2247 /* IF Type == GL_RENDERBUFFER_EXT: */
2248 struct gl_renderbuffer
*Renderbuffer
;
2250 /* IF Type == GL_TEXTURE: */
2251 struct gl_texture_object
*Texture
;
2252 GLuint TextureLevel
;
2253 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2254 GLuint Zoffset
; /* for 3D textures */
2259 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2260 * In C++ terms, think of this as a base class from which device drivers
2261 * will make derived classes.
2263 struct gl_framebuffer
2265 _glthread_Mutex Mutex
; /**< for thread safety */
2266 GLuint Name
; /* if zero, this is a window system framebuffer */
2268 GLboolean DeletePending
;
2270 GLvisual Visual
; /**< The framebuffer's visual.
2271 Immutable if this is a window system buffer.
2272 Computed from attachments if user-made FBO. */
2274 GLboolean Initialized
;
2276 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2278 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2280 GLint _Xmin
, _Xmax
; /**< inclusive */
2281 GLint _Ymin
, _Ymax
; /**< exclusive */
2284 /** \name Derived Z buffer stuff */
2286 GLuint _DepthMax
; /**< Max depth buffer value */
2287 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2288 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2291 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2293 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2294 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2296 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2297 * attribute group and GL_PIXEL attribute group, respectively.
2299 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2300 GLenum ColorReadBuffer
;
2302 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2303 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2304 GLint _ColorReadBufferIndex
; /* -1 = None */
2306 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2307 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2308 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2309 struct gl_renderbuffer
*_ColorReadBuffer
;
2311 /** The Actual depth/stencil buffers to use. May be wrappers around the
2312 * depth/stencil buffers attached above. */
2313 struct gl_renderbuffer
*_DepthBuffer
;
2314 struct gl_renderbuffer
*_StencilBuffer
;
2316 /** Delete this framebuffer */
2317 void (*Delete
)(struct gl_framebuffer
*fb
);
2322 * Limits for vertex and fragment programs.
2324 struct gl_program_constants
2326 /* logical limits */
2327 GLuint MaxInstructions
;
2328 GLuint MaxAluInstructions
; /* fragment programs only, for now */
2329 GLuint MaxTexInstructions
; /* fragment programs only, for now */
2330 GLuint MaxTexIndirections
; /* fragment programs only, for now */
2333 GLuint MaxAddressRegs
; /* vertex program only, for now */
2334 GLuint MaxParameters
;
2335 GLuint MaxLocalParams
;
2336 GLuint MaxEnvParams
;
2337 /* native/hardware limits */
2338 GLuint MaxNativeInstructions
;
2339 GLuint MaxNativeAluInstructions
; /* fragment programs only, for now */
2340 GLuint MaxNativeTexInstructions
; /* fragment programs only, for now */
2341 GLuint MaxNativeTexIndirections
; /* fragment programs only, for now */
2342 GLuint MaxNativeAttribs
;
2343 GLuint MaxNativeTemps
;
2344 GLuint MaxNativeAddressRegs
; /* vertex program only, for now */
2345 GLuint MaxNativeParameters
;
2347 GLuint MaxUniformComponents
;
2352 * Constants which may be overridden by device driver during context creation
2353 * but are never changed after that.
2357 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2358 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2359 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2360 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2361 GLuint MaxTextureCoordUnits
;
2362 GLuint MaxTextureImageUnits
;
2363 GLuint MaxTextureUnits
; /* = MIN(CoordUnits, ImageUnits) */
2364 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2365 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2366 GLuint MaxArrayLockSize
;
2368 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2369 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2370 GLfloat PointSizeGranularity
;
2371 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2372 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2373 GLfloat LineWidthGranularity
;
2374 GLuint MaxColorTableSize
;
2375 GLuint MaxConvolutionWidth
;
2376 GLuint MaxConvolutionHeight
;
2377 GLuint MaxClipPlanes
;
2379 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2380 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2381 GLuint MaxViewportWidth
, MaxViewportHeight
;
2382 struct gl_program_constants VertexProgram
; /* GL_ARB_vertex_program */
2383 struct gl_program_constants FragmentProgram
; /* GL_ARB_fragment_program */
2384 /* shared by vertex and fragment program: */
2385 GLuint MaxProgramMatrices
;
2386 GLuint MaxProgramMatrixStackDepth
;
2387 /* vertex array / buffer object bounds checking */
2388 GLboolean CheckArrayBounds
;
2389 /* GL_ARB_draw_buffers */
2390 GLuint MaxDrawBuffers
;
2391 /* GL_OES_read_format */
2392 GLenum ColorReadFormat
;
2393 GLenum ColorReadType
;
2394 /* GL_EXT_framebuffer_object */
2395 GLuint MaxColorAttachments
;
2396 GLuint MaxRenderbufferSize
;
2397 /* GL_ARB_vertex_shader */
2398 GLuint MaxVertexTextureImageUnits
;
2399 GLuint MaxVaryingFloats
;
2404 * Enable flag for each OpenGL extension. Different device drivers will
2405 * enable different extensions at runtime.
2407 struct gl_extensions
2410 * \name Flags to quickly test if certain extensions are available.
2412 * Not every extension needs to have such a flag, but it's encouraged.
2415 GLboolean dummy
; /* don't remove this! */
2416 GLboolean ARB_depth_texture
;
2417 GLboolean ARB_draw_buffers
;
2418 GLboolean ARB_fragment_program
;
2419 GLboolean ARB_fragment_shader
;
2420 GLboolean ARB_half_float_pixel
;
2421 GLboolean ARB_imaging
;
2422 GLboolean ARB_multisample
;
2423 GLboolean ARB_multitexture
;
2424 GLboolean ARB_occlusion_query
;
2425 GLboolean ARB_point_sprite
;
2426 GLboolean ARB_shader_objects
;
2427 GLboolean ARB_shading_language_100
;
2428 GLboolean ARB_shading_language_120
;
2429 GLboolean ARB_shadow
;
2430 GLboolean ARB_texture_border_clamp
;
2431 GLboolean ARB_texture_compression
;
2432 GLboolean ARB_texture_cube_map
;
2433 GLboolean ARB_texture_env_combine
;
2434 GLboolean ARB_texture_env_crossbar
;
2435 GLboolean ARB_texture_env_dot3
;
2436 GLboolean ARB_texture_float
;
2437 GLboolean ARB_texture_mirrored_repeat
;
2438 GLboolean ARB_texture_non_power_of_two
;
2439 GLboolean ARB_transpose_matrix
;
2440 GLboolean ARB_vertex_buffer_object
;
2441 GLboolean ARB_vertex_program
;
2442 GLboolean ARB_vertex_shader
;
2443 GLboolean ARB_window_pos
;
2446 GLboolean EXT_blend_color
;
2447 GLboolean EXT_blend_equation_separate
;
2448 GLboolean EXT_blend_func_separate
;
2449 GLboolean EXT_blend_logic_op
;
2450 GLboolean EXT_blend_minmax
;
2451 GLboolean EXT_blend_subtract
;
2452 GLboolean EXT_clip_volume_hint
;
2453 GLboolean EXT_cull_vertex
;
2454 GLboolean EXT_convolution
;
2455 GLboolean EXT_compiled_vertex_array
;
2456 GLboolean EXT_copy_texture
;
2457 GLboolean EXT_depth_bounds_test
;
2458 GLboolean EXT_draw_range_elements
;
2459 GLboolean EXT_framebuffer_object
;
2460 GLboolean EXT_fog_coord
;
2461 GLboolean EXT_framebuffer_blit
;
2462 GLboolean EXT_gpu_program_parameters
;
2463 GLboolean EXT_histogram
;
2464 GLboolean EXT_multi_draw_arrays
;
2465 GLboolean EXT_paletted_texture
;
2466 GLboolean EXT_packed_depth_stencil
;
2467 GLboolean EXT_packed_pixels
;
2468 GLboolean EXT_pixel_buffer_object
;
2469 GLboolean EXT_point_parameters
;
2470 GLboolean EXT_polygon_offset
;
2471 GLboolean EXT_rescale_normal
;
2472 GLboolean EXT_shadow_funcs
;
2473 GLboolean EXT_secondary_color
;
2474 GLboolean EXT_separate_specular_color
;
2475 GLboolean EXT_shared_texture_palette
;
2476 GLboolean EXT_stencil_wrap
;
2477 GLboolean EXT_stencil_two_side
;
2478 GLboolean EXT_subtexture
;
2479 GLboolean EXT_texture
;
2480 GLboolean EXT_texture_object
;
2481 GLboolean EXT_texture3D
;
2482 GLboolean EXT_texture_compression_s3tc
;
2483 GLboolean EXT_texture_env_add
;
2484 GLboolean EXT_texture_env_combine
;
2485 GLboolean EXT_texture_env_dot3
;
2486 GLboolean EXT_texture_filter_anisotropic
;
2487 GLboolean EXT_texture_lod_bias
;
2488 GLboolean EXT_texture_mirror_clamp
;
2489 GLboolean EXT_texture_sRGB
;
2490 GLboolean EXT_timer_query
;
2491 GLboolean EXT_vertex_array
;
2492 GLboolean EXT_vertex_array_set
;
2493 /* vendor extensions */
2494 GLboolean APPLE_client_storage
;
2495 GLboolean APPLE_packed_pixels
;
2496 GLboolean APPLE_vertex_array_object
;
2497 GLboolean ATI_texture_mirror_once
;
2498 GLboolean ATI_texture_env_combine3
;
2499 GLboolean ATI_fragment_shader
;
2500 GLboolean ATI_separate_stencil
;
2501 GLboolean IBM_rasterpos_clip
;
2502 GLboolean IBM_multimode_draw_arrays
;
2503 GLboolean MESA_pack_invert
;
2504 GLboolean MESA_packed_depth_stencil
;
2505 GLboolean MESA_program_debug
;
2506 GLboolean MESA_resize_buffers
;
2507 GLboolean MESA_ycbcr_texture
;
2508 GLboolean NV_blend_square
;
2509 GLboolean NV_fragment_program
;
2510 GLboolean NV_light_max_exponent
;
2511 GLboolean NV_point_sprite
;
2512 GLboolean NV_texgen_reflection
;
2513 GLboolean NV_texture_rectangle
;
2514 GLboolean NV_vertex_program
;
2515 GLboolean NV_vertex_program1_1
;
2516 GLboolean OES_read_format
;
2517 GLboolean SGI_color_matrix
;
2518 GLboolean SGI_color_table
;
2519 GLboolean SGI_texture_color_table
;
2520 GLboolean SGIS_generate_mipmap
;
2521 GLboolean SGIS_texture_edge_clamp
;
2522 GLboolean SGIS_texture_lod
;
2523 GLboolean SGIX_depth_texture
;
2524 GLboolean SGIX_shadow
;
2525 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2526 GLboolean TDFX_texture_compression_FXT1
;
2529 /* The extension string */
2530 const GLubyte
*String
;
2535 * A stack of matrices (projection, modelview, color, texture, etc).
2539 GLmatrix
*Top
; /**< points into Stack */
2540 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2541 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2542 GLuint MaxDepth
; /**< size of Stack[] array */
2543 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2548 * \name Bits for image transfer operations
2550 * \sa __GLcontextRec::ImageTransferState.
2553 #define IMAGE_SCALE_BIAS_BIT 0x1
2554 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2555 #define IMAGE_MAP_COLOR_BIT 0x4
2556 #define IMAGE_COLOR_TABLE_BIT 0x8
2557 #define IMAGE_CONVOLUTION_BIT 0x10
2558 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2559 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2560 #define IMAGE_COLOR_MATRIX_BIT 0x80
2561 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2562 #define IMAGE_HISTOGRAM_BIT 0x200
2563 #define IMAGE_MIN_MAX_BIT 0x400
2564 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2567 /** Pixel Transfer ops up to convolution */
2568 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2569 IMAGE_SHIFT_OFFSET_BIT | \
2570 IMAGE_MAP_COLOR_BIT | \
2571 IMAGE_COLOR_TABLE_BIT)
2573 /** Pixel transfer ops after convolution */
2574 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2575 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2576 IMAGE_COLOR_MATRIX_BIT | \
2577 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2578 IMAGE_HISTOGRAM_BIT | \
2584 * \name Bits to indicate what state has changed.
2589 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2590 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2591 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2592 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2593 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2594 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2595 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2596 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2597 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2598 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2599 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2600 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2601 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2602 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2603 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2604 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2605 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2606 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2607 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2608 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2609 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2610 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2611 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2612 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2613 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2614 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2615 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2616 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2622 * \name Bits to track array state changes
2624 * Also used to summarize array enabled.
2627 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2628 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2629 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2630 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2631 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2632 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2633 #define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
2634 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
2635 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2636 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2637 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2638 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2639 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2640 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2641 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2642 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2643 #define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
2644 #define _NEW_ARRAY_ALL 0xffffffff
2647 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2648 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2653 * \name A bunch of flags that we think might be useful to drivers.
2655 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2658 #define DD_FLATSHADE 0x1
2659 #define DD_SEPARATE_SPECULAR 0x2
2660 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2661 #define DD_TRI_LIGHT_TWOSIDE 0x8
2662 #define DD_TRI_UNFILLED 0x10
2663 #define DD_TRI_SMOOTH 0x20
2664 #define DD_TRI_STIPPLE 0x40
2665 #define DD_TRI_OFFSET 0x80
2666 #define DD_LINE_SMOOTH 0x100
2667 #define DD_LINE_STIPPLE 0x200
2668 #define DD_LINE_WIDTH 0x400
2669 #define DD_POINT_SMOOTH 0x800
2670 #define DD_POINT_SIZE 0x1000
2671 #define DD_POINT_ATTEN 0x2000
2672 #define DD_TRI_TWOSTENCIL 0x4000
2677 * \name Define the state changes under which each of these bits might change
2680 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2681 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2682 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2683 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2684 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2685 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2686 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2687 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2688 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2689 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2690 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2691 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2692 #define _DD_NEW_POINT_SIZE _NEW_POINT
2693 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2697 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2703 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2706 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2712 * Forward declaration of display list data types:
2715 typedef union node Node
;
2718 /* This has to be included here. */
2722 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2725 * Core Mesa's support for tnl modules:
2727 struct gl_tnl_module
2730 * Vertex format to be lazily swapped into current dispatch.
2732 const GLvertexformat
*Current
;
2735 * \name Record of functions swapped out.
2736 * On restore, only need to swap these functions back in.
2740 _glapi_proc
* location
;
2741 _glapi_proc function
;
2742 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2747 /* Strictly this is a tnl/ private concept, but it doesn't seem
2748 * worthwhile adding a tnl private structure just to hold this one bit
2751 #define MESA_DLIST_DANGLING_REFS 0x1
2753 /* Provide a location where information about a display list can be
2754 * collected. Could be extended with driverPrivate structures,
2755 * etc. in the future.
2757 struct mesa_display_list
2766 * State used during display list compilation and execution.
2768 struct mesa_list_state
2770 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2771 GLuint CallDepth
; /**< Current recursion calling depth */
2773 struct mesa_display_list
*CurrentList
;
2774 Node
*CurrentListPtr
; /**< Head of list being compiled */
2775 GLuint CurrentListNum
; /**< Number of the list being compiled */
2776 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2777 GLuint CurrentPos
; /**< Index into current block of nodes */
2779 GLvertexformat ListVtxfmt
;
2781 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2782 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2784 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2785 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2787 GLubyte ActiveIndex
;
2788 GLfloat CurrentIndex
;
2790 GLubyte ActiveEdgeFlag
;
2791 GLboolean CurrentEdgeFlag
;
2796 * Mesa rendering context.
2798 * This is the central context data structure for Mesa. Almost all
2799 * OpenGL state is contained in this structure.
2800 * Think of this as a base class from which device drivers will derive
2803 * The GLcontext typedef names this structure.
2805 struct __GLcontextRec
2808 * \name OS related interfaces.
2810 * These \b must be the first members of this structure, because they are
2811 * exposed to the outside world (i.e. GLX extension).
2814 __GLimports imports
;
2815 __GLexports exports
;
2818 /** State possibly shared with other contexts in the address space */
2819 struct gl_shared_state
*Shared
;
2821 /** \name API function pointer tables */
2823 struct _glapi_table
*Save
; /**< Display list save functions */
2824 struct _glapi_table
*Exec
; /**< Execute functions */
2825 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2829 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2830 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2831 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2832 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2835 * Device driver function pointer table
2837 struct dd_function_table Driver
;
2839 void *DriverCtx
; /**< Points to device driver context/state */
2840 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2842 /** Core/Driver constants */
2843 struct gl_constants Const
;
2845 /** \name The various 4x4 matrix stacks */
2847 struct matrix_stack ModelviewMatrixStack
;
2848 struct matrix_stack ProjectionMatrixStack
;
2849 struct matrix_stack ColorMatrixStack
;
2850 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2851 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2852 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2855 /** Combined modelview and projection matrix */
2856 GLmatrix _ModelProjectMatrix
;
2858 /** \name Display lists */
2859 struct mesa_list_state ListState
;
2861 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2862 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2864 /** Extension information */
2865 struct gl_extensions Extensions
;
2867 /** \name State attribute stack (for glPush/PopAttrib) */
2869 GLuint AttribStackDepth
;
2870 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2873 /** \name Renderer attribute groups
2875 * We define a struct for each attribute group to make pushing and popping
2876 * attributes easy. Also it's a good organization.
2879 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
2880 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
2881 struct gl_current_attrib Current
; /**< Current attributes */
2882 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2883 struct gl_eval_attrib Eval
; /**< Eval attributes */
2884 struct gl_fog_attrib Fog
; /**< Fog attributes */
2885 struct gl_hint_attrib Hint
; /**< Hint attributes */
2886 struct gl_light_attrib Light
; /**< Light attributes */
2887 struct gl_line_attrib Line
; /**< Line attributes */
2888 struct gl_list_attrib List
; /**< List attributes */
2889 struct gl_multisample_attrib Multisample
;
2890 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2891 struct gl_point_attrib Point
; /**< Point attributes */
2892 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2893 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2894 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2895 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2896 struct gl_texture_attrib Texture
; /**< Texture attributes */
2897 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2898 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2901 /** \name Client attribute stack */
2903 GLuint ClientAttribStackDepth
;
2904 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2907 /** \name Client attribute groups */
2909 struct gl_array_attrib Array
; /**< Vertex arrays */
2910 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2911 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2912 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2915 /** \name Other assorted state (not pushed/popped on attribute stack) */
2917 struct gl_pixelmaps PixelMaps
;
2918 struct gl_histogram_attrib Histogram
;
2919 struct gl_minmax_attrib MinMax
;
2920 struct gl_convolution_attrib Convolution1D
;
2921 struct gl_convolution_attrib Convolution2D
;
2922 struct gl_convolution_attrib Separable2D
;
2924 struct gl_evaluators EvalMap
; /**< All evaluators */
2925 struct gl_feedback Feedback
; /**< Feedback */
2926 struct gl_selection Select
; /**< Selection */
2928 struct gl_color_table ColorTable
[COLORTABLE_MAX
];
2929 struct gl_color_table ProxyColorTable
[COLORTABLE_MAX
];
2931 struct gl_color_table PostConvolutionColorTable
;
2932 struct gl_color_table ProxyPostConvolutionColorTable
;
2933 struct gl_color_table PostColorMatrixColorTable
;
2934 struct gl_color_table ProxyPostColorMatrixColorTable
;
2937 struct gl_program_state Program
; /**< for vertex or fragment progs */
2938 struct gl_vertex_program_state VertexProgram
; /**< GL_ARB/NV_vertex_program */
2939 struct gl_fragment_program_state FragmentProgram
; /**< GL_ARB/NV_vertex_program */
2940 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2942 struct gl_fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2943 struct gl_vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2945 GLboolean _MaintainTnlProgram
;
2946 GLboolean _MaintainTexEnvProgram
;
2947 GLboolean _UseTexEnvProgram
;
2949 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2951 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2954 #if FEATURE_EXT_framebuffer_object
2955 struct gl_renderbuffer
*CurrentRenderbuffer
;
2958 GLenum ErrorValue
; /**< Last error code */
2959 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2960 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2962 /** \name Derived state */
2964 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2965 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2966 GLfloat _EyeZDir
[3];
2967 GLfloat _ModelViewInvScale
;
2968 GLboolean _NeedEyeCoords
;
2969 GLboolean _ForceEyeCoords
;
2970 GLenum _CurrentProgram
; /* currently executing program */
2972 GLuint TextureStateTimestamp
; /* detect changes to shared state */
2974 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2975 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2978 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2981 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2983 * We don't have a better way to communicate this value from
2984 * swrast_setup to swrast. */
2986 /** \name For debugging/development only */
2988 GLboolean FirstTimeCurrent
;
2991 /** Dither disable via MESA_NO_DITHER env var */
2994 /** software compression/decompression supported or not */
2995 GLboolean Mesa_DXTn
;
2997 /** Core tnl module support */
2998 struct gl_tnl_module TnlModule
;
3001 * \name Hooks for module contexts.
3003 * These will eventually live in the driver or elsewhere.
3006 void *swrast_context
;
3007 void *swsetup_context
;
3008 void *swtnl_context
;
3010 void *acache_context
;
3016 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
3017 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
3021 extern int MESA_VERBOSE
;
3022 extern int MESA_DEBUG_FLAGS
;
3023 # define MESA_FUNCTION __FUNCTION__
3025 # define MESA_VERBOSE 0
3026 # define MESA_DEBUG_FLAGS 0
3027 # define MESA_FUNCTION "a function"
3036 VERBOSE_VARRAY
= 0x0001,
3037 VERBOSE_TEXTURE
= 0x0002,
3038 VERBOSE_IMMEDIATE
= 0x0004,
3039 VERBOSE_PIPELINE
= 0x0008,
3040 VERBOSE_DRIVER
= 0x0010,
3041 VERBOSE_STATE
= 0x0020,
3042 VERBOSE_API
= 0x0040,
3043 VERBOSE_DISPLAY_LIST
= 0x0100,
3044 VERBOSE_LIGHTING
= 0x0200,
3045 VERBOSE_PRIMS
= 0x0400,
3046 VERBOSE_VERTS
= 0x0800,
3047 VERBOSE_DISASSEM
= 0x1000
3053 DEBUG_ALWAYS_FLUSH
= 0x1
3058 #define Elements(x) sizeof(x)/sizeof(*(x))
3061 #endif /* TYPES_H */