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 | \
389 * Data structure for color tables
391 struct gl_color_table
393 GLenum InternalFormat
; /**< The user-specified format */
394 GLenum _BaseFormat
; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
395 GLuint Size
; /**< number of entries in table */
396 GLfloat
*TableF
; /**< Color table, floating point values */
397 GLubyte
*TableUB
; /**< Color table, ubyte values */
402 GLubyte LuminanceSize
;
403 GLubyte IntensitySize
;
408 * \name Bit flags used for updating material values.
411 #define MAT_ATTRIB_FRONT_AMBIENT 0
412 #define MAT_ATTRIB_BACK_AMBIENT 1
413 #define MAT_ATTRIB_FRONT_DIFFUSE 2
414 #define MAT_ATTRIB_BACK_DIFFUSE 3
415 #define MAT_ATTRIB_FRONT_SPECULAR 4
416 #define MAT_ATTRIB_BACK_SPECULAR 5
417 #define MAT_ATTRIB_FRONT_EMISSION 6
418 #define MAT_ATTRIB_BACK_EMISSION 7
419 #define MAT_ATTRIB_FRONT_SHININESS 8
420 #define MAT_ATTRIB_BACK_SHININESS 9
421 #define MAT_ATTRIB_FRONT_INDEXES 10
422 #define MAT_ATTRIB_BACK_INDEXES 11
423 #define MAT_ATTRIB_MAX 12
425 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
426 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
427 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
428 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
429 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
430 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
432 #define MAT_INDEX_AMBIENT 0
433 #define MAT_INDEX_DIFFUSE 1
434 #define MAT_INDEX_SPECULAR 2
436 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
437 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
438 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
439 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
440 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
441 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
442 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
443 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
444 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
445 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
446 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
447 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
450 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
451 MAT_BIT_FRONT_AMBIENT | \
452 MAT_BIT_FRONT_DIFFUSE | \
453 MAT_BIT_FRONT_SPECULAR | \
454 MAT_BIT_FRONT_SHININESS | \
455 MAT_BIT_FRONT_INDEXES)
457 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
458 MAT_BIT_BACK_AMBIENT | \
459 MAT_BIT_BACK_DIFFUSE | \
460 MAT_BIT_BACK_SPECULAR | \
461 MAT_BIT_BACK_SHININESS | \
462 MAT_BIT_BACK_INDEXES)
464 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
468 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
469 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
472 * Material shininess lookup table.
476 struct gl_shine_tab
*next
, *prev
;
477 GLfloat tab
[SHINE_TABLE_SIZE
+1];
484 * Light source state.
488 struct gl_light
*next
; /**< double linked list with sentinel */
489 struct gl_light
*prev
;
491 GLfloat Ambient
[4]; /**< ambient color */
492 GLfloat Diffuse
[4]; /**< diffuse color */
493 GLfloat Specular
[4]; /**< specular color */
494 GLfloat EyePosition
[4]; /**< position in eye coordinates */
495 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
496 GLfloat SpotExponent
;
497 GLfloat SpotCutoff
; /**< in degrees */
498 GLfloat _CosCutoffNeg
; /**< = cos(SpotCutoff) */
499 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
500 GLfloat ConstantAttenuation
;
501 GLfloat LinearAttenuation
;
502 GLfloat QuadraticAttenuation
;
503 GLboolean Enabled
; /**< On/off flag */
506 * \name Derived fields
509 GLbitfield _Flags
; /**< State */
511 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
512 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
513 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
514 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
515 GLfloat _VP_inf_spot_attenuation
;
517 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
518 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
519 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
520 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
521 GLfloat _dli
; /**< CI diffuse light intensity */
522 GLfloat _sli
; /**< CI specular light intensity */
532 GLfloat Ambient
[4]; /**< ambient color */
533 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
534 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
535 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
536 * or GL_SEPARATE_SPECULAR_COLOR */
545 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
550 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
552 struct gl_accum_attrib
554 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
559 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
561 struct gl_colorbuffer_attrib
563 GLuint ClearIndex
; /**< Index to use for glClear */
564 GLclampf ClearColor
[4]; /**< Color to use for glClear */
566 GLuint IndexMask
; /**< Color index write mask */
567 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
569 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
572 * \name alpha testing
575 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
576 GLenum AlphaFunc
; /**< Alpha test function */
577 GLclampf AlphaRef
; /**< Alpha reference value */
584 GLboolean BlendEnabled
; /**< Blending enabled flag */
585 GLenum BlendSrcRGB
; /**< Blending source operator */
586 GLenum BlendDstRGB
; /**< Blending destination operator */
587 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
588 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
589 GLenum BlendEquationRGB
; /**< Blending equation */
590 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
591 GLfloat BlendColor
[4]; /**< Blending color */
598 GLenum LogicOp
; /**< Logic operator */
599 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
600 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
601 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
604 GLboolean DitherFlag
; /**< Dither enable flag */
606 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
607 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
612 * Current attribute group (GL_CURRENT_BIT).
614 struct gl_current_attrib
617 * \name Current vertex attributes.
618 * \note Values are valid only after FLUSH_VERTICES has been called.
619 * \note Index and Edgeflag current values are stored as floats in the
620 * SIX and SEVEN attribute slots.
623 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Position, color, texcoords, etc */
627 * \name Current raster position attributes (always valid).
628 * \note This set of attributes is very similar to the SWvertex struct.
631 GLfloat RasterPos
[4];
632 GLfloat RasterDistance
;
633 GLfloat RasterColor
[4];
634 GLfloat RasterSecondaryColor
[4];
636 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
637 GLboolean RasterPosValid
;
643 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
645 struct gl_depthbuffer_attrib
647 GLenum Func
; /**< Function for depth buffer compare */
648 GLclampd Clear
; /**< Value to clear depth buffer to */
649 GLboolean Test
; /**< Depth buffering enabled flag */
650 GLboolean Mask
; /**< Depth buffer writable? */
651 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
652 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
657 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
659 struct gl_enable_attrib
662 GLboolean AutoNormal
;
664 GLbitfield ClipPlanes
;
665 GLboolean ColorMaterial
;
666 GLboolean ColorTable
; /* SGI_color_table */
667 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
668 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
669 GLboolean Convolution1D
;
670 GLboolean Convolution2D
;
671 GLboolean Separable2D
;
677 GLboolean Light
[MAX_LIGHTS
];
679 GLboolean LineSmooth
;
680 GLboolean LineStipple
;
681 GLboolean IndexLogicOp
;
682 GLboolean ColorLogicOp
;
683 GLboolean Map1Color4
;
685 GLboolean Map1Normal
;
686 GLboolean Map1TextureCoord1
;
687 GLboolean Map1TextureCoord2
;
688 GLboolean Map1TextureCoord3
;
689 GLboolean Map1TextureCoord4
;
690 GLboolean Map1Vertex3
;
691 GLboolean Map1Vertex4
;
692 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
693 GLboolean Map2Color4
;
695 GLboolean Map2Normal
;
696 GLboolean Map2TextureCoord1
;
697 GLboolean Map2TextureCoord2
;
698 GLboolean Map2TextureCoord3
;
699 GLboolean Map2TextureCoord4
;
700 GLboolean Map2Vertex3
;
701 GLboolean Map2Vertex4
;
702 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
705 GLboolean PixelTexture
;
706 GLboolean PointSmooth
;
707 GLboolean PolygonOffsetPoint
;
708 GLboolean PolygonOffsetLine
;
709 GLboolean PolygonOffsetFill
;
710 GLboolean PolygonSmooth
;
711 GLboolean PolygonStipple
;
712 GLboolean RescaleNormals
;
715 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
716 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
717 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
718 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
719 GLboolean SampleCoverage
; /* GL_ARB_multisample */
720 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
721 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
722 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
723 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
724 /* SGI_texture_color_table */
725 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
726 /* GL_ARB_vertex_program / GL_NV_vertex_program */
727 GLboolean VertexProgram
;
728 GLboolean VertexProgramPointSize
;
729 GLboolean VertexProgramTwoSide
;
730 /* GL_ARB_point_sprite / GL_NV_point_sprite */
731 GLboolean PointSprite
;
732 GLboolean FragmentShaderATI
;
737 * Evaluator attribute group (GL_EVAL_BIT).
739 struct gl_eval_attrib
745 GLboolean Map1Color4
;
747 GLboolean Map1Normal
;
748 GLboolean Map1TextureCoord1
;
749 GLboolean Map1TextureCoord2
;
750 GLboolean Map1TextureCoord3
;
751 GLboolean Map1TextureCoord4
;
752 GLboolean Map1Vertex3
;
753 GLboolean Map1Vertex4
;
754 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
755 GLboolean Map2Color4
;
757 GLboolean Map2Normal
;
758 GLboolean Map2TextureCoord1
;
759 GLboolean Map2TextureCoord2
;
760 GLboolean Map2TextureCoord3
;
761 GLboolean Map2TextureCoord4
;
762 GLboolean Map2Vertex3
;
763 GLboolean Map2Vertex4
;
764 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
765 GLboolean AutoNormal
;
769 * \name Map Grid endpoints and divisions and calculated du values
773 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
774 GLint MapGrid2un
, MapGrid2vn
;
775 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
776 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
782 * Fog attribute group (GL_FOG_BIT).
786 GLboolean Enabled
; /**< Fog enabled flag */
787 GLfloat Color
[4]; /**< Fog color */
788 GLfloat Density
; /**< Density >= 0.0 */
789 GLfloat Start
; /**< Start distance in eye coords */
790 GLfloat End
; /**< End distance in eye coords */
791 GLfloat Index
; /**< Fog index */
792 GLenum Mode
; /**< Fog mode */
793 GLboolean ColorSumEnabled
;
794 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
795 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
800 * Hint attribute group (GL_HINT_BIT).
802 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
804 struct gl_hint_attrib
806 GLenum PerspectiveCorrection
;
809 GLenum PolygonSmooth
;
811 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
812 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
813 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
814 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
819 * Histogram attributes.
821 struct gl_histogram_attrib
823 GLuint Width
; /**< number of table entries */
824 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
825 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
826 GLboolean Sink
; /**< terminate image transfer? */
827 GLubyte RedSize
; /**< Bits per counter */
831 GLubyte LuminanceSize
;
836 * Color Min/max state.
838 struct gl_minmax_attrib
842 GLfloat Min
[4], Max
[4]; /**< RGBA */
847 * Image convolution state.
849 struct gl_convolution_attrib
852 GLenum InternalFormat
;
855 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
863 #define LIGHT_SPOT 0x1
864 #define LIGHT_LOCAL_VIEWER 0x2
865 #define LIGHT_POSITIONAL 0x4
866 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
871 * Lighting attribute group (GL_LIGHT_BIT).
873 struct gl_light_attrib
875 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
876 struct gl_lightmodel Model
; /**< Lighting model */
879 * Must flush FLUSH_VERTICES before referencing:
882 struct gl_material Material
; /**< Includes front & back values */
885 GLboolean Enabled
; /**< Lighting enabled flag */
886 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
887 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
888 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
889 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
890 GLboolean ColorMaterialEnabled
;
891 GLenum ClampVertexColor
;
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 * A pixelmap (see glPixelMap)
973 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
974 GLubyte Map8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
979 * Collection of all pixelmaps
983 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
984 struct gl_pixelmap GtoG
;
985 struct gl_pixelmap BtoB
;
986 struct gl_pixelmap AtoA
;
987 struct gl_pixelmap ItoR
;
988 struct gl_pixelmap ItoG
;
989 struct gl_pixelmap ItoB
;
990 struct gl_pixelmap ItoA
;
991 struct gl_pixelmap ItoI
;
992 struct gl_pixelmap StoS
;
997 * Pixel attribute group (GL_PIXEL_MODE_BIT).
999 struct gl_pixel_attrib
1001 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
1003 /*--- Begin Pixel Transfer State ---*/
1004 /* Fields are in the order in which they're applied... */
1006 /* Scale & Bias (index shift, offset) */
1007 GLfloat RedBias
, RedScale
;
1008 GLfloat GreenBias
, GreenScale
;
1009 GLfloat BlueBias
, BlueScale
;
1010 GLfloat AlphaBias
, AlphaScale
;
1011 GLfloat DepthBias
, DepthScale
;
1012 GLint IndexShift
, IndexOffset
;
1015 /* Note: actual pixel maps are not part of this attrib group */
1016 GLboolean MapColorFlag
;
1017 GLboolean MapStencilFlag
;
1019 /* Color table lookup (GL_SGI_color_table) */
1020 /* Note: actual table is not part of this attrib group */
1021 GLfloat ColorTableScale
[4];
1022 GLfloat ColorTableBias
[4];
1023 GLboolean ColorTableEnabled
;
1025 /* Convolution (GL_EXT_convolution) */
1026 GLboolean Convolution1DEnabled
;
1027 GLboolean Convolution2DEnabled
;
1028 GLboolean Separable2DEnabled
;
1029 GLfloat ConvolutionBorderColor
[3][4];
1030 GLenum ConvolutionBorderMode
[3];
1031 GLfloat ConvolutionFilterScale
[3][4]; /**< RGBA */
1032 GLfloat ConvolutionFilterBias
[3][4]; /**< RGBA */
1033 GLfloat PostConvolutionScale
[4]; /**< RGBA */
1034 GLfloat PostConvolutionBias
[4]; /**< RGBA */
1036 /* Post-convolution color table */
1037 /* Note: actual table is not part of this attrib group */
1038 GLboolean PostConvolutionColorTableEnabled
;
1039 GLfloat PCCTscale
[4]; /** Post Convolution Color Table scale */
1040 GLfloat PCCTbias
[4]; /** Post Convolution Color Table bias */
1042 /* Color matrix (GL_SGI_color_matrix) */
1043 /* Note: the color matrix is not part of this attrib group */
1044 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
1045 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
1047 /* Post color matrix color table */
1048 /* Note: actual table is not part of this attrib group */
1049 GLboolean PostColorMatrixColorTableEnabled
;
1050 GLfloat PCMCTscale
[4]; /** Post Color Matrix Color Table scale */
1051 GLfloat PCMCTbias
[4]; /** Post Color Matrix Color Table bias */
1053 /* Histogram & minmax (GL_EXT_histogram) */
1054 /* Note: histogram and minmax data are not part of this attrib group */
1055 GLboolean HistogramEnabled
;
1056 GLboolean MinMaxEnabled
;
1058 /*--- End Pixel Transfer State ---*/
1061 GLfloat ZoomX
, ZoomY
;
1063 /** GL_SGI_texture_color_table */
1064 GLfloat TextureColorTableScale
[4];
1065 GLfloat TextureColorTableBias
[4];
1070 * Point attribute group (GL_POINT_BIT).
1072 struct gl_point_attrib
1074 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
1075 GLfloat Size
; /**< User-specified point size */
1076 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
1077 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
1078 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
1079 GLfloat Threshold
; /**< GL_EXT_point_parameters */
1080 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
1081 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
1082 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite */
1083 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
1084 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
1089 * Polygon attribute group (GL_POLYGON_BIT).
1091 struct gl_polygon_attrib
1093 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1094 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1095 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1096 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1097 GLboolean CullFlag
; /**< Culling on/off flag */
1098 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1099 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1100 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1101 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1102 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1103 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1104 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1105 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1110 * Scissor attributes (GL_SCISSOR_BIT).
1112 struct gl_scissor_attrib
1114 GLboolean Enabled
; /**< Scissor test enabled? */
1115 GLint X
, Y
; /**< Lower left corner of box */
1116 GLsizei Width
, Height
; /**< Size of box */
1121 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1123 struct gl_stencil_attrib
1125 GLboolean Enabled
; /**< Enabled flag */
1126 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1127 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1128 GLboolean _TestTwoSide
;
1129 GLenum Function
[2]; /**< Stencil function */
1130 GLenum FailFunc
[2]; /**< Fail function */
1131 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1132 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1133 GLint Ref
[2]; /**< Reference value */
1134 GLuint ValueMask
[2]; /**< Value mask */
1135 GLuint WriteMask
[2]; /**< Write mask */
1136 GLuint Clear
; /**< Clear value */
1140 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1143 * An index for each type of texture object
1146 #define TEXTURE_1D_INDEX 0
1147 #define TEXTURE_2D_INDEX 1
1148 #define TEXTURE_3D_INDEX 2
1149 #define TEXTURE_CUBE_INDEX 3
1150 #define TEXTURE_RECT_INDEX 4
1154 * Bit flags for each type of texture object
1155 * Used for Texture.Unit[]._ReallyEnabled flags.
1158 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1159 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1160 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1161 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1162 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1167 * TexGenEnabled flags.
1178 * Bit flag versions of the corresponding GL_ constants.
1181 #define TEXGEN_SPHERE_MAP 0x1
1182 #define TEXGEN_OBJ_LINEAR 0x2
1183 #define TEXGEN_EYE_LINEAR 0x4
1184 #define TEXGEN_REFLECTION_MAP_NV 0x8
1185 #define TEXGEN_NORMAL_MAP_NV 0x10
1187 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1188 TEXGEN_REFLECTION_MAP_NV | \
1189 TEXGEN_NORMAL_MAP_NV)
1190 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1191 TEXGEN_REFLECTION_MAP_NV | \
1192 TEXGEN_NORMAL_MAP_NV | \
1197 /* A selection of state flags to make driver and module's lives easier. */
1198 #define ENABLE_TEXGEN0 0x1
1199 #define ENABLE_TEXGEN1 0x2
1200 #define ENABLE_TEXGEN2 0x4
1201 #define ENABLE_TEXGEN3 0x8
1202 #define ENABLE_TEXGEN4 0x10
1203 #define ENABLE_TEXGEN5 0x20
1204 #define ENABLE_TEXGEN6 0x40
1205 #define ENABLE_TEXGEN7 0x80
1207 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1208 #define ENABLE_TEXMAT1 0x2
1209 #define ENABLE_TEXMAT2 0x4
1210 #define ENABLE_TEXMAT3 0x8
1211 #define ENABLE_TEXMAT4 0x10
1212 #define ENABLE_TEXMAT5 0x20
1213 #define ENABLE_TEXMAT6 0x40
1214 #define ENABLE_TEXMAT7 0x80
1216 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1217 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1221 * Texel fetch function prototype. We use texel fetch functions to
1222 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1223 * texture images. These functions help to isolate us from the gritty
1224 * details of all the various texture image encodings.
1226 * \param texImage texture image.
1227 * \param col texel column.
1228 * \param row texel row.
1229 * \param img texel image level/layer.
1230 * \param texelOut output texel (up to 4 GLchans)
1232 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1233 GLint col
, GLint row
, GLint img
,
1237 * As above, but returns floats.
1238 * Used for depth component images and for upcoming signed/float
1241 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1242 GLint col
, GLint row
, GLint img
,
1243 GLfloat
*texelOut
);
1246 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1247 GLint col
, GLint row
, GLint img
,
1252 * This macro defines the (many) parameters to the texstore functions.
1253 * \param dims either 1 or 2 or 3
1254 * \param baseInternalFormat user-specified base internal format
1255 * \param dstFormat destination Mesa texture format
1256 * \param dstAddr destination image address
1257 * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
1258 * \param dstRowStride destination image row stride, in bytes
1259 * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
1260 * \param srcWidth/Height/Depth source image size, in pixels
1261 * \param srcFormat incoming image format
1262 * \param srcType incoming image data type
1263 * \param srcAddr source image address
1264 * \param srcPacking source image packing parameters
1266 #define TEXSTORE_PARAMS \
1267 GLcontext *ctx, GLuint dims, \
1268 GLenum baseInternalFormat, \
1269 const struct gl_texture_format *dstFormat, \
1271 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
1272 GLint dstRowStride, const GLuint *dstImageOffsets, \
1273 GLint srcWidth, GLint srcHeight, GLint srcDepth, \
1274 GLenum srcFormat, GLenum srcType, \
1275 const GLvoid *srcAddr, \
1276 const struct gl_pixelstore_attrib *srcPacking
1281 * Texture image storage function.
1283 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
1287 * Texture format record
1289 struct gl_texture_format
1291 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1293 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1294 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1295 * GL_INTENSITY, GL_COLOR_INDEX or
1296 * GL_DEPTH_COMPONENT.
1298 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1299 GLubyte RedBits
; /**< Bits per texel component */
1300 GLubyte GreenBits
; /**< These are just rough approximations for */
1301 GLubyte BlueBits
; /**< compressed texture formats. */
1303 GLubyte LuminanceBits
;
1304 GLubyte IntensityBits
;
1307 GLubyte StencilBits
; /**< GL_EXT_packed_depth_stencil */
1309 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1311 StoreTexImageFunc StoreImage
;
1314 * \name Texel fetch function pointers
1317 FetchTexelFuncC FetchTexel1D
;
1318 FetchTexelFuncC FetchTexel2D
;
1319 FetchTexelFuncC FetchTexel3D
;
1320 FetchTexelFuncF FetchTexel1Df
;
1321 FetchTexelFuncF FetchTexel2Df
;
1322 FetchTexelFuncF FetchTexel3Df
;
1325 StoreTexelFunc StoreTexel
;
1329 #define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
1332 * Texture image state. Describes the dimensions of a texture image,
1333 * the texel format and pointers to Texel Fetch functions.
1335 struct gl_texture_image
1337 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1338 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1339 * GL_INTENSITY, GL_COLOR_INDEX,
1340 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1341 * only. Used for choosing TexEnv arithmetic.
1343 GLint InternalFormat
; /**< Internal format as given by the user */
1344 GLuint Border
; /**< 0 or 1 */
1345 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1346 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1347 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1348 GLuint Width2
; /**< = Width - 2*Border */
1349 GLuint Height2
; /**< = Height - 2*Border */
1350 GLuint Depth2
; /**< = Depth - 2*Border */
1351 GLuint WidthLog2
; /**< = log2(Width2) */
1352 GLuint HeightLog2
; /**< = log2(Height2) */
1353 GLuint DepthLog2
; /**< = log2(Depth2) */
1354 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1355 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1356 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1357 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1358 GLboolean IsClientData
; /**< Data owned by client? */
1359 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1361 const struct gl_texture_format
*TexFormat
;
1363 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1365 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1366 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1368 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1369 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1371 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1372 GLuint
*ImageOffsets
; /**< if 3D texture: array [Depth] of offsets to
1373 each 2D slice in 'Data', in texels */
1374 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1377 * \name For device driver:
1380 void *DriverData
; /**< Arbitrary device driver data */
1386 * Indexes for cube map faces.
1389 #define FACE_POS_X 0
1390 #define FACE_NEG_X 1
1391 #define FACE_POS_Y 2
1392 #define FACE_NEG_Y 3
1393 #define FACE_POS_Z 4
1394 #define FACE_NEG_Z 5
1400 * Texture object state. Contains the array of mipmap images, border color,
1401 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1404 struct gl_texture_object
1406 _glthread_Mutex Mutex
; /**< for thread safety */
1407 GLint RefCount
; /**< reference count */
1408 GLuint Name
; /**< the user-visible texture object ID */
1409 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1410 GLfloat Priority
; /**< in [0,1] */
1411 GLfloat BorderColor
[4]; /**< unclamped */
1412 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1413 GLenum WrapS
; /**< S-axis texture image wrap mode */
1414 GLenum WrapT
; /**< T-axis texture image wrap mode */
1415 GLenum WrapR
; /**< R-axis texture image wrap mode */
1416 GLenum MinFilter
; /**< minification filter */
1417 GLenum MagFilter
; /**< magnification filter */
1418 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1419 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1420 GLfloat LodBias
; /**< OpenGL 1.4 */
1421 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1422 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1423 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1424 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1425 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1426 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1427 GLenum CompareMode
; /**< GL_ARB_shadow */
1428 GLenum CompareFunc
; /**< GL_ARB_shadow */
1429 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1430 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1431 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1432 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1433 GLboolean Complete
; /**< Is texture object complete? */
1435 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1436 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1438 /** GL_EXT_paletted_texture */
1439 struct gl_color_table Palette
;
1443 * \name For device driver.
1444 * Note: instead of attaching driver data to this pointer, it's preferable
1445 * to instead use this struct as a base class for your own texture object
1446 * class. Driver->NewTextureObject() can be used to implement the
1449 void *DriverData
; /**< Arbitrary device driver data */
1454 * Texture combine environment state.
1457 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1458 * structure will need to be expanded for 4 elements.
1460 struct gl_tex_env_combine_state
1462 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1463 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1464 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1465 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1466 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1467 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1468 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1469 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1470 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1471 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1476 * Texture unit state. Contains enable flags, texture environment/function/
1477 * combiners, texgen state, pointers to current texture objects and
1478 * post-filter color tables.
1480 struct gl_texture_unit
1482 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1483 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1485 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1486 GLfloat EnvColor
[4];
1487 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1488 /** \name Tex coord generation mode
1489 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1496 GLbitfield _GenBitS
;
1497 GLbitfield _GenBitT
;
1498 GLbitfield _GenBitR
;
1499 GLbitfield _GenBitQ
;
1500 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1501 GLfloat ObjectPlaneS
[4];
1502 GLfloat ObjectPlaneT
[4];
1503 GLfloat ObjectPlaneR
[4];
1504 GLfloat ObjectPlaneQ
[4];
1505 GLfloat EyePlaneS
[4];
1506 GLfloat EyePlaneT
[4];
1507 GLfloat EyePlaneR
[4];
1508 GLfloat EyePlaneQ
[4];
1509 GLfloat LodBias
; /**< for biasing mipmap levels */
1512 * \name GL_EXT_texture_env_combine
1514 struct gl_tex_env_combine_state Combine
;
1517 * Derived state based on \c EnvMode and the \c BaseFormat of the
1518 * currently enabled texture.
1520 struct gl_tex_env_combine_state _EnvMode
;
1523 * Currently enabled combiner state. This will point to either
1524 * \c Combine or \c _EnvMode.
1526 struct gl_tex_env_combine_state
*_CurrentCombine
;
1528 struct gl_texture_object
*Current1D
;
1529 struct gl_texture_object
*Current2D
;
1530 struct gl_texture_object
*Current3D
;
1531 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1532 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1534 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1536 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1537 struct gl_texture_object Saved2D
;
1538 struct gl_texture_object Saved3D
;
1539 struct gl_texture_object SavedCubeMap
;
1540 struct gl_texture_object SavedRect
;
1542 /* GL_SGI_texture_color_table */
1543 struct gl_color_table ColorTable
;
1544 struct gl_color_table ProxyColorTable
;
1545 GLboolean ColorTableEnabled
;
1548 struct texenvprog_cache_item
{
1551 struct gl_fragment_program
*data
;
1552 struct texenvprog_cache_item
*next
;
1555 struct texenvprog_cache
{
1556 struct texenvprog_cache_item
**items
;
1557 GLuint size
, n_items
;
1562 * Texture attribute group (GL_TEXTURE_BIT).
1564 struct gl_texture_attrib
1570 GLuint CurrentUnit
; /**< Active texture unit */
1571 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1572 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1573 GLbitfield _GenFlags
; /**< for texgen */
1574 GLbitfield _TexGenEnabled
;
1575 GLbitfield _TexMatEnabled
;
1578 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1580 struct gl_texture_object
*Proxy1D
;
1581 struct gl_texture_object
*Proxy2D
;
1582 struct gl_texture_object
*Proxy3D
;
1583 struct gl_texture_object
*ProxyCubeMap
;
1584 struct gl_texture_object
*ProxyRect
;
1586 /** GL_EXT_shared_texture_palette */
1587 GLboolean SharedPalette
;
1588 struct gl_color_table Palette
;
1590 /** Cached texenv fragment programs */
1591 struct texenvprog_cache env_fp_cache
;
1596 * Transformation attribute group (GL_TRANSFORM_BIT).
1598 struct gl_transform_attrib
1600 GLenum MatrixMode
; /**< Matrix mode */
1601 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1602 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1603 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1604 GLboolean Normalize
; /**< Normalize all normals? */
1605 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1606 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1608 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1609 GLfloat CullEyePos
[4];
1610 GLfloat CullObjPos
[4];
1615 * Viewport attribute group (GL_VIEWPORT_BIT).
1617 struct gl_viewport_attrib
1619 GLint X
, Y
; /**< position */
1620 GLsizei Width
, Height
; /**< size */
1621 GLfloat Near
, Far
; /**< Depth buffer range */
1622 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1627 * Node for the attribute stack.
1629 struct gl_attrib_node
1633 struct gl_attrib_node
*next
;
1638 * GL_ARB_vertex/pixel_buffer_object buffer object
1640 struct gl_buffer_object
1646 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1647 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1648 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1649 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1655 * Client pixel packing/unpacking attributes
1657 struct gl_pixelstore_attrib
1663 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1664 GLint SkipImages
; /**< for GL_EXT_texture3D */
1665 GLboolean SwapBytes
;
1667 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1668 GLboolean Invert
; /**< GL_MESA_pack_invert */
1669 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1675 * Client vertex array attributes
1677 struct gl_client_array
1679 GLint Size
; /**< components per element (1,2,3,4) */
1680 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1681 GLsizei Stride
; /**< user-specified stride */
1682 GLsizei StrideB
; /**< actual stride in bytes */
1683 const GLubyte
*Ptr
; /**< Points to array data */
1684 GLboolean Enabled
; /**< Enabled flag is a boolean */
1685 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1687 /**< GL_ARB_vertex_buffer_object */
1688 struct gl_buffer_object
*BufferObj
;
1694 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1695 * extension, but a nice encapsulation in any case.
1697 struct gl_array_object
1699 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1702 /** Conventional vertex arrays */
1704 struct gl_client_array Vertex
;
1705 struct gl_client_array Normal
;
1706 struct gl_client_array Color
;
1707 struct gl_client_array SecondaryColor
;
1708 struct gl_client_array FogCoord
;
1709 struct gl_client_array Index
;
1710 struct gl_client_array EdgeFlag
;
1711 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1714 /** Generic arrays for vertex programs/shaders */
1715 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1717 /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
1718 GLbitfield _Enabled
;
1723 * Vertex array state
1725 struct gl_array_attrib
1727 struct gl_array_object
*ArrayObj
;
1728 struct gl_array_object
*DefaultArrayObj
;
1730 GLint ActiveTexture
; /**< Client Active Texture */
1731 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1732 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1734 GLbitfield NewState
; /**< mask of _NEW_ARRAY_* values */
1736 #if FEATURE_ARB_vertex_buffer_object
1737 struct gl_buffer_object
*NullBufferObj
;
1738 struct gl_buffer_object
*ArrayBufferObj
;
1739 struct gl_buffer_object
*ElementArrayBufferObj
;
1741 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1746 * Feedback buffer state
1751 GLbitfield _Mask
; /* FB_* bits */
1759 * Selection buffer state
1763 GLuint
*Buffer
; /**< selection buffer */
1764 GLuint BufferSize
; /**< size of the selection buffer */
1765 GLuint BufferCount
; /**< number of values in the selection buffer */
1766 GLuint Hits
; /**< number of records in the selection buffer */
1767 GLuint NameStackDepth
; /**< name stack depth */
1768 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1769 GLboolean HitFlag
; /**< hit flag */
1770 GLfloat HitMinZ
; /**< minimum hit depth */
1771 GLfloat HitMaxZ
; /**< maximum hit depth */
1776 * 1-D Evaluator control points
1780 GLuint Order
; /**< Number of control points */
1781 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1782 GLfloat
*Points
; /**< Points to contiguous control points */
1787 * 2-D Evaluator control points
1791 GLuint Uorder
; /**< Number of control points in U dimension */
1792 GLuint Vorder
; /**< Number of control points in V dimension */
1795 GLfloat
*Points
; /**< Points to contiguous control points */
1800 * All evaluator control point state
1802 struct gl_evaluators
1808 struct gl_1d_map Map1Vertex3
;
1809 struct gl_1d_map Map1Vertex4
;
1810 struct gl_1d_map Map1Index
;
1811 struct gl_1d_map Map1Color4
;
1812 struct gl_1d_map Map1Normal
;
1813 struct gl_1d_map Map1Texture1
;
1814 struct gl_1d_map Map1Texture2
;
1815 struct gl_1d_map Map1Texture3
;
1816 struct gl_1d_map Map1Texture4
;
1817 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1824 struct gl_2d_map Map2Vertex3
;
1825 struct gl_2d_map Map2Vertex4
;
1826 struct gl_2d_map Map2Index
;
1827 struct gl_2d_map Map2Color4
;
1828 struct gl_2d_map Map2Normal
;
1829 struct gl_2d_map Map2Texture1
;
1830 struct gl_2d_map Map2Texture2
;
1831 struct gl_2d_map Map2Texture3
;
1832 struct gl_2d_map Map2Texture4
;
1833 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1839 * Names of the various vertex/fragment program register files, etc.
1840 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1841 * All values should fit in a 4-bit field.
1845 PROGRAM_TEMPORARY
= 0,
1846 PROGRAM_LOCAL_PARAM
= 1,
1847 PROGRAM_ENV_PARAM
= 2,
1848 PROGRAM_STATE_VAR
= 3,
1851 PROGRAM_NAMED_PARAM
= 6,
1852 PROGRAM_CONSTANT
= 7,
1853 PROGRAM_WRITE_ONLY
= 8,
1854 PROGRAM_ADDRESS
= 9,
1855 PROGRAM_UNDEFINED
= 10, /* invalid value */
1860 /** Vertex and fragment instructions */
1861 struct prog_instruction
;
1862 struct gl_program_parameter_list
;
1866 * Base class for any kind of program object
1871 GLubyte
*String
; /**< Null-terminated program text */
1874 GLenum Format
; /**< String encoding format */
1877 struct prog_instruction
*Instructions
;
1879 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1880 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1882 /** Named parameters, constants, etc. from program text */
1883 struct gl_program_parameter_list
*Parameters
;
1884 /** Numbered local parameters */
1885 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1887 /** Logical counts */
1889 GLuint NumInstructions
;
1890 GLuint NumTemporaries
;
1891 GLuint NumParameters
;
1892 GLuint NumAttributes
;
1893 GLuint NumAddressRegs
;
1895 /** Native, actual h/w counts */
1897 GLuint NumNativeInstructions
;
1898 GLuint NumNativeTemporaries
;
1899 GLuint NumNativeParameters
;
1900 GLuint NumNativeAttributes
;
1901 GLuint NumNativeAddressRegs
;
1906 /** Vertex program object */
1907 struct gl_vertex_program
1909 struct gl_program Base
; /**< base class */
1910 GLboolean IsNVProgram
; /**< is this a GL_NV_vertex_program program? */
1911 GLboolean IsPositionInvariant
;
1912 void *TnlData
; /**< should probably use Base.DriverData */
1916 /** Fragment program object */
1917 struct gl_fragment_program
1919 struct gl_program Base
; /**< base class */
1920 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
1921 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1922 GLuint NumTexInstructions
;
1923 GLuint NumTexIndirections
;
1924 GLuint NumNativeAluInstructions
; /**< GL_ARB_fragment_program */
1925 GLuint NumNativeTexInstructions
;
1926 GLuint NumNativeTexIndirections
;
1933 * State common to vertex and fragment programs.
1935 struct gl_program_state
1937 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1938 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1943 * Context state for vertex programs.
1945 struct gl_vertex_program_state
1947 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_ARB/NV */
1948 GLboolean _Enabled
; /**< Enabled and valid program? */
1949 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1950 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1951 struct gl_vertex_program
*Current
; /**< ptr to currently bound program */
1952 const struct gl_vertex_program
*_Current
; /**< ptr to currently bound
1953 program, including internal
1954 (t_vp_build.c) programs */
1956 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /**< Env params */
1958 /* For GL_NV_vertex_program only: */
1959 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1960 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1962 #if FEATURE_MESA_program_debug
1963 GLprogramcallbackMESA Callback
;
1964 GLvoid
*CallbackData
;
1965 GLboolean CallbackEnabled
;
1966 GLuint CurrentPosition
;
1972 * Context state for fragment programs.
1974 struct gl_fragment_program_state
1976 GLboolean Enabled
; /**< User-set fragment program enable flag */
1977 GLboolean _Enabled
; /**< Fragment program enabled and valid? */
1978 GLboolean _Active
; /**< Is a user program or internal program active? */
1979 struct gl_fragment_program
*Current
; /**< User-bound program */
1980 const struct gl_fragment_program
*_Current
; /**< currently active program
1981 (including internal programs) */
1982 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /**< Env params */
1984 #if FEATURE_MESA_program_debug
1985 GLprogramcallbackMESA Callback
;
1986 GLvoid
*CallbackData
;
1987 GLboolean CallbackEnabled
;
1988 GLuint CurrentPosition
;
1994 * ATI_fragment_shader runtime state
1996 #define ATI_FS_INPUT_PRIMARY 0
1997 #define ATI_FS_INPUT_SECONDARY 1
1999 struct atifs_instruction
;
2000 struct atifs_setupinst
;
2003 * ATI fragment shader
2005 struct ati_fragment_shader
2009 struct atifs_instruction
*Instructions
[2];
2010 struct atifs_setupinst
*SetupInst
[2];
2011 GLfloat Constants
[8][4];
2012 GLbitfield LocalConstDef
; /** Indicates which constants have been set */
2013 GLubyte numArithInstr
[2];
2014 GLubyte regsAssigned
[2];
2015 GLubyte NumPasses
; /** 1 or 2 */
2017 GLubyte last_optype
;
2018 GLboolean interpinp1
;
2024 * Context state for GL_ATI_fragment_shader
2026 struct gl_ati_fragment_shader_state
2029 GLboolean _Enabled
; /** enabled and valid shader? */
2030 GLboolean Compiling
;
2031 GLfloat GlobalConstants
[8][4];
2032 struct ati_fragment_shader
*Current
;
2037 * Occlusion/timer query object.
2039 struct gl_query_object
2042 GLuint64EXT Result
; /* the counter */
2043 GLboolean Active
; /* inside Begin/EndQuery */
2044 GLboolean Ready
; /* result is ready */
2049 * Context state for query objects.
2051 struct gl_query_state
2053 struct _mesa_HashTable
*QueryObjects
;
2054 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2055 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2060 * Context state for vertex/fragment shaders.
2062 struct gl_shader_objects_state
2064 struct gl2_program_intf
**CurrentProgram
;
2065 GLboolean _VertexShaderPresent
;
2066 GLboolean _FragmentShaderPresent
;
2071 * State which can be shared by multiple contexts:
2073 struct gl_shared_state
2075 _glthread_Mutex Mutex
; /**< for thread safety */
2076 GLint RefCount
; /**< Reference count */
2077 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2078 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2081 * \name Default texture objects (shared by all multi-texture units)
2084 struct gl_texture_object
*Default1D
;
2085 struct gl_texture_object
*Default2D
;
2086 struct gl_texture_object
*Default3D
;
2087 struct gl_texture_object
*DefaultCubeMap
;
2088 struct gl_texture_object
*DefaultRect
;
2092 * \name Thread safety and statechange notification for texture
2095 * \todo Improve the granularity of locking.
2098 _glthread_Mutex TexMutex
; /**< texobj thread safety */
2099 GLuint TextureStateStamp
; /**< state notification for shared tex */
2105 * \name Vertex/fragment programs
2108 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
2109 #if FEATURE_ARB_vertex_program
2110 struct gl_program
*DefaultVertexProgram
;
2112 #if FEATURE_ARB_fragment_program
2113 struct gl_program
*DefaultFragmentProgram
;
2117 #if FEATURE_ATI_fragment_shader
2118 struct _mesa_HashTable
*ATIShaders
;
2119 struct ati_fragment_shader
*DefaultFragmentShader
;
2122 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2123 struct _mesa_HashTable
*BufferObjects
;
2126 #if FEATURE_ARB_shader_objects
2127 struct _mesa_HashTable
*GL2Objects
;
2130 #if FEATURE_EXT_framebuffer_object
2131 struct _mesa_HashTable
*RenderBuffers
;
2132 struct _mesa_HashTable
*FrameBuffers
;
2135 /** Objects associated with the GL_APPLE_vertex_array_object extension. */
2136 struct _mesa_HashTable
*ArrayObjects
;
2138 void *DriverData
; /**< Device driver shared state */
2145 * A renderbuffer stores colors or depth values or stencil values.
2146 * A framebuffer object will have a collection of these.
2147 * Data are read/written to the buffer with a handful of Get/Put functions.
2149 * Instances of this object are allocated with the Driver's NewRenderbuffer
2150 * hook. Drivers will likely wrap this class inside a driver-specific
2151 * class to simulate inheritance.
2153 struct gl_renderbuffer
2155 _glthread_Mutex Mutex
; /**< for thread safety */
2156 GLuint ClassID
; /**< Useful for drivers */
2159 GLuint Width
, Height
;
2160 GLenum InternalFormat
; /**< The user-specified format */
2161 GLenum _ActualFormat
; /**< The driver-chosen format */
2162 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2163 GL_STENCIL_INDEX. */
2164 GLenum DataType
; /**< Type of values passed to the Get/Put functions */
2165 GLubyte RedBits
; /**< Bits of red per pixel */
2171 GLubyte StencilBits
;
2172 GLvoid
*Data
; /**< This may not be used by some kinds of RBs */
2174 /* Used to wrap one renderbuffer around another: */
2175 struct gl_renderbuffer
*Wrapped
;
2177 /* Delete this renderbuffer */
2178 void (*Delete
)(struct gl_renderbuffer
*rb
);
2180 /* Allocate new storage for this renderbuffer */
2181 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2182 GLenum internalFormat
,
2183 GLuint width
, GLuint height
);
2185 /* Lock/Unlock are called before/after calling the Get/Put functions.
2186 * Not sure this is the right place for these yet.
2187 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2188 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2191 /* Return a pointer to the element/pixel at (x,y).
2192 * Should return NULL if the buffer memory can't be directly addressed.
2194 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2197 /* Get/Read a row of values.
2198 * The values will be of format _BaseFormat and type DataType.
2200 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2201 GLint x
, GLint y
, void *values
);
2203 /* Get/Read values at arbitrary locations.
2204 * The values will be of format _BaseFormat and type DataType.
2206 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2207 const GLint x
[], const GLint y
[], void *values
);
2209 /* Put/Write a row of values.
2210 * The values will be of format _BaseFormat and type DataType.
2212 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2213 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2215 /* Put/Write a row of RGB values. This is a special-case routine that's
2216 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2217 * a common case for glDrawPixels and some triangle routines.
2218 * The values will be of format GL_RGB and type DataType.
2220 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2221 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2224 /* Put/Write a row of identical values.
2225 * The values will be of format _BaseFormat and type DataType.
2227 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2228 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2230 /* Put/Write values at arbitrary locations.
2231 * The values will be of format _BaseFormat and type DataType.
2233 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2234 const GLint x
[], const GLint y
[], const void *values
,
2235 const GLubyte
*mask
);
2236 /* Put/Write identical values at arbitrary locations.
2237 * The values will be of format _BaseFormat and type DataType.
2239 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2240 GLuint count
, const GLint x
[], const GLint y
[],
2241 const void *value
, const GLubyte
*mask
);
2246 * A renderbuffer attachment point points to either a texture object
2247 * (and specifies a mipmap level, cube face or 3D texture slice) or
2248 * points to a renderbuffer.
2250 struct gl_renderbuffer_attachment
2252 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2255 /* IF Type == GL_RENDERBUFFER_EXT: */
2256 struct gl_renderbuffer
*Renderbuffer
;
2258 /* IF Type == GL_TEXTURE: */
2259 struct gl_texture_object
*Texture
;
2260 GLuint TextureLevel
;
2261 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2262 GLuint Zoffset
; /* for 3D textures */
2267 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2268 * In C++ terms, think of this as a base class from which device drivers
2269 * will make derived classes.
2271 struct gl_framebuffer
2273 _glthread_Mutex Mutex
; /**< for thread safety */
2274 GLuint Name
; /* if zero, this is a window system framebuffer */
2276 GLboolean DeletePending
;
2278 GLvisual Visual
; /**< The framebuffer's visual.
2279 Immutable if this is a window system buffer.
2280 Computed from attachments if user-made FBO. */
2282 GLboolean Initialized
;
2284 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2286 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2288 GLint _Xmin
, _Xmax
; /**< inclusive */
2289 GLint _Ymin
, _Ymax
; /**< exclusive */
2292 /** \name Derived Z buffer stuff */
2294 GLuint _DepthMax
; /**< Max depth buffer value */
2295 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2296 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2299 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2301 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2302 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2304 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2305 * attribute group and GL_PIXEL attribute group, respectively.
2307 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2308 GLenum ColorReadBuffer
;
2310 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2311 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2312 GLint _ColorReadBufferIndex
; /* -1 = None */
2314 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2315 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2316 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2317 struct gl_renderbuffer
*_ColorReadBuffer
;
2319 /** The Actual depth/stencil buffers to use. May be wrappers around the
2320 * depth/stencil buffers attached above. */
2321 struct gl_renderbuffer
*_DepthBuffer
;
2322 struct gl_renderbuffer
*_StencilBuffer
;
2324 /** Delete this framebuffer */
2325 void (*Delete
)(struct gl_framebuffer
*fb
);
2330 * Limits for vertex and fragment programs.
2332 struct gl_program_constants
2334 /* logical limits */
2335 GLuint MaxInstructions
;
2336 GLuint MaxAluInstructions
; /* fragment programs only, for now */
2337 GLuint MaxTexInstructions
; /* fragment programs only, for now */
2338 GLuint MaxTexIndirections
; /* fragment programs only, for now */
2341 GLuint MaxAddressRegs
; /* vertex program only, for now */
2342 GLuint MaxParameters
;
2343 GLuint MaxLocalParams
;
2344 GLuint MaxEnvParams
;
2345 /* native/hardware limits */
2346 GLuint MaxNativeInstructions
;
2347 GLuint MaxNativeAluInstructions
; /* fragment programs only, for now */
2348 GLuint MaxNativeTexInstructions
; /* fragment programs only, for now */
2349 GLuint MaxNativeTexIndirections
; /* fragment programs only, for now */
2350 GLuint MaxNativeAttribs
;
2351 GLuint MaxNativeTemps
;
2352 GLuint MaxNativeAddressRegs
; /* vertex program only, for now */
2353 GLuint MaxNativeParameters
;
2355 GLuint MaxUniformComponents
;
2360 * Constants which may be overridden by device driver during context creation
2361 * but are never changed after that.
2365 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2366 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2367 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2368 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2369 GLuint MaxTextureCoordUnits
;
2370 GLuint MaxTextureImageUnits
;
2371 GLuint MaxTextureUnits
; /* = MIN(CoordUnits, ImageUnits) */
2372 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2373 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2374 GLuint MaxArrayLockSize
;
2376 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2377 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2378 GLfloat PointSizeGranularity
;
2379 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2380 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2381 GLfloat LineWidthGranularity
;
2382 GLuint MaxColorTableSize
;
2383 GLuint MaxConvolutionWidth
;
2384 GLuint MaxConvolutionHeight
;
2385 GLuint MaxClipPlanes
;
2387 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2388 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2389 GLuint MaxViewportWidth
, MaxViewportHeight
;
2390 struct gl_program_constants VertexProgram
; /* GL_ARB_vertex_program */
2391 struct gl_program_constants FragmentProgram
; /* GL_ARB_fragment_program */
2392 /* shared by vertex and fragment program: */
2393 GLuint MaxProgramMatrices
;
2394 GLuint MaxProgramMatrixStackDepth
;
2395 /* vertex array / buffer object bounds checking */
2396 GLboolean CheckArrayBounds
;
2397 /* GL_ARB_draw_buffers */
2398 GLuint MaxDrawBuffers
;
2399 /* GL_OES_read_format */
2400 GLenum ColorReadFormat
;
2401 GLenum ColorReadType
;
2402 /* GL_EXT_framebuffer_object */
2403 GLuint MaxColorAttachments
;
2404 GLuint MaxRenderbufferSize
;
2405 /* GL_ARB_vertex_shader */
2406 GLuint MaxVertexTextureImageUnits
;
2407 GLuint MaxVaryingFloats
;
2412 * Enable flag for each OpenGL extension. Different device drivers will
2413 * enable different extensions at runtime.
2415 struct gl_extensions
2418 * \name Flags to quickly test if certain extensions are available.
2420 * Not every extension needs to have such a flag, but it's encouraged.
2423 GLboolean dummy
; /* don't remove this! */
2424 GLboolean ARB_depth_texture
;
2425 GLboolean ARB_draw_buffers
;
2426 GLboolean ARB_fragment_program
;
2427 GLboolean ARB_fragment_shader
;
2428 GLboolean ARB_half_float_pixel
;
2429 GLboolean ARB_imaging
;
2430 GLboolean ARB_multisample
;
2431 GLboolean ARB_multitexture
;
2432 GLboolean ARB_occlusion_query
;
2433 GLboolean ARB_point_sprite
;
2434 GLboolean ARB_shader_objects
;
2435 GLboolean ARB_shading_language_100
;
2436 GLboolean ARB_shading_language_120
;
2437 GLboolean ARB_shadow
;
2438 GLboolean ARB_texture_border_clamp
;
2439 GLboolean ARB_texture_compression
;
2440 GLboolean ARB_texture_cube_map
;
2441 GLboolean ARB_texture_env_combine
;
2442 GLboolean ARB_texture_env_crossbar
;
2443 GLboolean ARB_texture_env_dot3
;
2444 GLboolean ARB_texture_float
;
2445 GLboolean ARB_texture_mirrored_repeat
;
2446 GLboolean ARB_texture_non_power_of_two
;
2447 GLboolean ARB_transpose_matrix
;
2448 GLboolean ARB_vertex_buffer_object
;
2449 GLboolean ARB_vertex_program
;
2450 GLboolean ARB_vertex_shader
;
2451 GLboolean ARB_window_pos
;
2454 GLboolean EXT_blend_color
;
2455 GLboolean EXT_blend_equation_separate
;
2456 GLboolean EXT_blend_func_separate
;
2457 GLboolean EXT_blend_logic_op
;
2458 GLboolean EXT_blend_minmax
;
2459 GLboolean EXT_blend_subtract
;
2460 GLboolean EXT_clip_volume_hint
;
2461 GLboolean EXT_cull_vertex
;
2462 GLboolean EXT_convolution
;
2463 GLboolean EXT_compiled_vertex_array
;
2464 GLboolean EXT_copy_texture
;
2465 GLboolean EXT_depth_bounds_test
;
2466 GLboolean EXT_draw_range_elements
;
2467 GLboolean EXT_framebuffer_object
;
2468 GLboolean EXT_fog_coord
;
2469 GLboolean EXT_framebuffer_blit
;
2470 GLboolean EXT_gpu_program_parameters
;
2471 GLboolean EXT_histogram
;
2472 GLboolean EXT_multi_draw_arrays
;
2473 GLboolean EXT_paletted_texture
;
2474 GLboolean EXT_packed_depth_stencil
;
2475 GLboolean EXT_packed_pixels
;
2476 GLboolean EXT_pixel_buffer_object
;
2477 GLboolean EXT_point_parameters
;
2478 GLboolean EXT_polygon_offset
;
2479 GLboolean EXT_rescale_normal
;
2480 GLboolean EXT_shadow_funcs
;
2481 GLboolean EXT_secondary_color
;
2482 GLboolean EXT_separate_specular_color
;
2483 GLboolean EXT_shared_texture_palette
;
2484 GLboolean EXT_stencil_wrap
;
2485 GLboolean EXT_stencil_two_side
;
2486 GLboolean EXT_subtexture
;
2487 GLboolean EXT_texture
;
2488 GLboolean EXT_texture_object
;
2489 GLboolean EXT_texture3D
;
2490 GLboolean EXT_texture_compression_s3tc
;
2491 GLboolean EXT_texture_env_add
;
2492 GLboolean EXT_texture_env_combine
;
2493 GLboolean EXT_texture_env_dot3
;
2494 GLboolean EXT_texture_filter_anisotropic
;
2495 GLboolean EXT_texture_lod_bias
;
2496 GLboolean EXT_texture_mirror_clamp
;
2497 GLboolean EXT_texture_sRGB
;
2498 GLboolean EXT_timer_query
;
2499 GLboolean EXT_vertex_array
;
2500 GLboolean EXT_vertex_array_set
;
2501 /* vendor extensions */
2502 GLboolean APPLE_client_storage
;
2503 GLboolean APPLE_packed_pixels
;
2504 GLboolean APPLE_vertex_array_object
;
2505 GLboolean ATI_texture_mirror_once
;
2506 GLboolean ATI_texture_env_combine3
;
2507 GLboolean ATI_fragment_shader
;
2508 GLboolean ATI_separate_stencil
;
2509 GLboolean IBM_rasterpos_clip
;
2510 GLboolean IBM_multimode_draw_arrays
;
2511 GLboolean MESA_pack_invert
;
2512 GLboolean MESA_packed_depth_stencil
;
2513 GLboolean MESA_program_debug
;
2514 GLboolean MESA_resize_buffers
;
2515 GLboolean MESA_ycbcr_texture
;
2516 GLboolean NV_blend_square
;
2517 GLboolean NV_fragment_program
;
2518 GLboolean NV_light_max_exponent
;
2519 GLboolean NV_point_sprite
;
2520 GLboolean NV_texgen_reflection
;
2521 GLboolean NV_texture_rectangle
;
2522 GLboolean NV_vertex_program
;
2523 GLboolean NV_vertex_program1_1
;
2524 GLboolean OES_read_format
;
2525 GLboolean SGI_color_matrix
;
2526 GLboolean SGI_color_table
;
2527 GLboolean SGI_texture_color_table
;
2528 GLboolean SGIS_generate_mipmap
;
2529 GLboolean SGIS_texture_edge_clamp
;
2530 GLboolean SGIS_texture_lod
;
2531 GLboolean SGIX_depth_texture
;
2532 GLboolean SGIX_shadow
;
2533 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2534 GLboolean TDFX_texture_compression_FXT1
;
2537 /* The extension string */
2538 const GLubyte
*String
;
2543 * A stack of matrices (projection, modelview, color, texture, etc).
2547 GLmatrix
*Top
; /**< points into Stack */
2548 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2549 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2550 GLuint MaxDepth
; /**< size of Stack[] array */
2551 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2556 * \name Bits for image transfer operations
2558 * \sa __GLcontextRec::ImageTransferState.
2561 #define IMAGE_SCALE_BIAS_BIT 0x1
2562 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2563 #define IMAGE_MAP_COLOR_BIT 0x4
2564 #define IMAGE_COLOR_TABLE_BIT 0x8
2565 #define IMAGE_CONVOLUTION_BIT 0x10
2566 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2567 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2568 #define IMAGE_COLOR_MATRIX_BIT 0x80
2569 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2570 #define IMAGE_HISTOGRAM_BIT 0x200
2571 #define IMAGE_MIN_MAX_BIT 0x400
2572 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2573 #define IMAGE_RED_TO_LUMINANCE 0x1000
2576 /** Pixel Transfer ops up to convolution */
2577 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2578 IMAGE_SHIFT_OFFSET_BIT | \
2579 IMAGE_MAP_COLOR_BIT | \
2580 IMAGE_COLOR_TABLE_BIT)
2582 /** Pixel transfer ops after convolution */
2583 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2584 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2585 IMAGE_COLOR_MATRIX_BIT | \
2586 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2587 IMAGE_HISTOGRAM_BIT | \
2593 * \name Bits to indicate what state has changed.
2598 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2599 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2600 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2601 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2602 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2603 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2604 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2605 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2606 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2607 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2608 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2609 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2610 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2611 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2612 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2613 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2614 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2615 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2616 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2617 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2618 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2619 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2620 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2621 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2622 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2623 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2624 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2625 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2631 * \name Bits to track array state changes
2633 * Also used to summarize array enabled.
2636 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2637 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2638 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2639 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2640 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2641 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2642 #define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
2643 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
2644 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2645 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2646 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2647 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2648 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2649 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2650 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2651 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2652 #define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
2653 #define _NEW_ARRAY_ALL 0xffffffff
2656 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2657 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2662 * \name A bunch of flags that we think might be useful to drivers.
2664 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2667 #define DD_FLATSHADE 0x1
2668 #define DD_SEPARATE_SPECULAR 0x2
2669 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2670 #define DD_TRI_LIGHT_TWOSIDE 0x8
2671 #define DD_TRI_UNFILLED 0x10
2672 #define DD_TRI_SMOOTH 0x20
2673 #define DD_TRI_STIPPLE 0x40
2674 #define DD_TRI_OFFSET 0x80
2675 #define DD_LINE_SMOOTH 0x100
2676 #define DD_LINE_STIPPLE 0x200
2677 #define DD_LINE_WIDTH 0x400
2678 #define DD_POINT_SMOOTH 0x800
2679 #define DD_POINT_SIZE 0x1000
2680 #define DD_POINT_ATTEN 0x2000
2681 #define DD_TRI_TWOSTENCIL 0x4000
2686 * \name Define the state changes under which each of these bits might change
2689 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2690 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2691 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2692 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2693 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2694 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2695 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2696 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2697 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2698 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2699 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2700 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2701 #define _DD_NEW_POINT_SIZE _NEW_POINT
2702 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2706 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2712 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2715 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2721 * Forward declaration of display list data types:
2724 typedef union node Node
;
2727 /* This has to be included here. */
2731 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2734 * Core Mesa's support for tnl modules:
2736 struct gl_tnl_module
2739 * Vertex format to be lazily swapped into current dispatch.
2741 const GLvertexformat
*Current
;
2744 * \name Record of functions swapped out.
2745 * On restore, only need to swap these functions back in.
2749 _glapi_proc
* location
;
2750 _glapi_proc function
;
2751 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2756 /* Strictly this is a tnl/ private concept, but it doesn't seem
2757 * worthwhile adding a tnl private structure just to hold this one bit
2760 #define MESA_DLIST_DANGLING_REFS 0x1
2762 /* Provide a location where information about a display list can be
2763 * collected. Could be extended with driverPrivate structures,
2764 * etc. in the future.
2766 struct mesa_display_list
2775 * State used during display list compilation and execution.
2777 struct mesa_list_state
2779 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2780 GLuint CallDepth
; /**< Current recursion calling depth */
2782 struct mesa_display_list
*CurrentList
;
2783 Node
*CurrentListPtr
; /**< Head of list being compiled */
2784 GLuint CurrentListNum
; /**< Number of the list being compiled */
2785 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2786 GLuint CurrentPos
; /**< Index into current block of nodes */
2788 GLvertexformat ListVtxfmt
;
2790 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2791 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2793 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2794 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2796 GLubyte ActiveIndex
;
2797 GLfloat CurrentIndex
;
2799 GLubyte ActiveEdgeFlag
;
2800 GLboolean CurrentEdgeFlag
;
2805 * Mesa rendering context.
2807 * This is the central context data structure for Mesa. Almost all
2808 * OpenGL state is contained in this structure.
2809 * Think of this as a base class from which device drivers will derive
2812 * The GLcontext typedef names this structure.
2814 struct __GLcontextRec
2817 * \name OS related interfaces.
2819 * These \b must be the first members of this structure, because they are
2820 * exposed to the outside world (i.e. GLX extension).
2823 __GLimports imports
;
2824 __GLexports exports
;
2827 /** State possibly shared with other contexts in the address space */
2828 struct gl_shared_state
*Shared
;
2830 /** \name API function pointer tables */
2832 struct _glapi_table
*Save
; /**< Display list save functions */
2833 struct _glapi_table
*Exec
; /**< Execute functions */
2834 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2838 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2839 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2840 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2841 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2844 * Device driver function pointer table
2846 struct dd_function_table Driver
;
2848 void *DriverCtx
; /**< Points to device driver context/state */
2849 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2851 /** Core/Driver constants */
2852 struct gl_constants Const
;
2854 /** \name The various 4x4 matrix stacks */
2856 struct matrix_stack ModelviewMatrixStack
;
2857 struct matrix_stack ProjectionMatrixStack
;
2858 struct matrix_stack ColorMatrixStack
;
2859 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2860 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2861 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2864 /** Combined modelview and projection matrix */
2865 GLmatrix _ModelProjectMatrix
;
2867 /** \name Display lists */
2868 struct mesa_list_state ListState
;
2870 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2871 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2873 /** Extension information */
2874 struct gl_extensions Extensions
;
2876 /** \name State attribute stack (for glPush/PopAttrib) */
2878 GLuint AttribStackDepth
;
2879 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2882 /** \name Renderer attribute groups
2884 * We define a struct for each attribute group to make pushing and popping
2885 * attributes easy. Also it's a good organization.
2888 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
2889 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
2890 struct gl_current_attrib Current
; /**< Current attributes */
2891 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2892 struct gl_eval_attrib Eval
; /**< Eval attributes */
2893 struct gl_fog_attrib Fog
; /**< Fog attributes */
2894 struct gl_hint_attrib Hint
; /**< Hint attributes */
2895 struct gl_light_attrib Light
; /**< Light attributes */
2896 struct gl_line_attrib Line
; /**< Line attributes */
2897 struct gl_list_attrib List
; /**< List attributes */
2898 struct gl_multisample_attrib Multisample
;
2899 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2900 struct gl_point_attrib Point
; /**< Point attributes */
2901 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2902 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2903 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2904 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2905 struct gl_texture_attrib Texture
; /**< Texture attributes */
2906 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2907 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2910 /** \name Client attribute stack */
2912 GLuint ClientAttribStackDepth
;
2913 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2916 /** \name Client attribute groups */
2918 struct gl_array_attrib Array
; /**< Vertex arrays */
2919 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2920 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2921 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2924 /** \name Other assorted state (not pushed/popped on attribute stack) */
2926 struct gl_pixelmaps PixelMaps
;
2927 struct gl_histogram_attrib Histogram
;
2928 struct gl_minmax_attrib MinMax
;
2929 struct gl_convolution_attrib Convolution1D
;
2930 struct gl_convolution_attrib Convolution2D
;
2931 struct gl_convolution_attrib Separable2D
;
2933 struct gl_evaluators EvalMap
; /**< All evaluators */
2934 struct gl_feedback Feedback
; /**< Feedback */
2935 struct gl_selection Select
; /**< Selection */
2937 struct gl_color_table ColorTable
; /**< Pre-convolution */
2938 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2939 struct gl_color_table PostConvolutionColorTable
;
2940 struct gl_color_table ProxyPostConvolutionColorTable
;
2941 struct gl_color_table PostColorMatrixColorTable
;
2942 struct gl_color_table ProxyPostColorMatrixColorTable
;
2944 struct gl_program_state Program
; /**< for vertex or fragment progs */
2945 struct gl_vertex_program_state VertexProgram
; /**< GL_ARB/NV_vertex_program */
2946 struct gl_fragment_program_state FragmentProgram
; /**< GL_ARB/NV_vertex_program */
2947 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2949 struct gl_fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2950 struct gl_vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2952 GLboolean _MaintainTnlProgram
;
2953 GLboolean _MaintainTexEnvProgram
;
2954 GLboolean _UseTexEnvProgram
;
2956 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2958 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2961 #if FEATURE_EXT_framebuffer_object
2962 struct gl_renderbuffer
*CurrentRenderbuffer
;
2965 GLenum ErrorValue
; /**< Last error code */
2966 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2967 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2969 /** \name Derived state */
2971 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2972 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2973 GLfloat _EyeZDir
[3];
2974 GLfloat _ModelViewInvScale
;
2975 GLboolean _NeedEyeCoords
;
2976 GLboolean _ForceEyeCoords
;
2977 GLenum _CurrentProgram
; /* currently executing program */
2979 GLuint TextureStateTimestamp
; /* detect changes to shared state */
2981 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2982 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2985 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2988 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2990 * We don't have a better way to communicate this value from
2991 * swrast_setup to swrast. */
2993 /** \name For debugging/development only */
2995 GLboolean FirstTimeCurrent
;
2998 /** Dither disable via MESA_NO_DITHER env var */
3001 /** software compression/decompression supported or not */
3002 GLboolean Mesa_DXTn
;
3004 /** Core tnl module support */
3005 struct gl_tnl_module TnlModule
;
3008 * \name Hooks for module contexts.
3010 * These will eventually live in the driver or elsewhere.
3013 void *swrast_context
;
3014 void *swsetup_context
;
3015 void *swtnl_context
;
3017 void *acache_context
;
3023 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
3024 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
3028 extern int MESA_VERBOSE
;
3029 extern int MESA_DEBUG_FLAGS
;
3030 # define MESA_FUNCTION __FUNCTION__
3032 # define MESA_VERBOSE 0
3033 # define MESA_DEBUG_FLAGS 0
3034 # define MESA_FUNCTION "a function"
3043 VERBOSE_VARRAY
= 0x0001,
3044 VERBOSE_TEXTURE
= 0x0002,
3045 VERBOSE_IMMEDIATE
= 0x0004,
3046 VERBOSE_PIPELINE
= 0x0008,
3047 VERBOSE_DRIVER
= 0x0010,
3048 VERBOSE_STATE
= 0x0020,
3049 VERBOSE_API
= 0x0040,
3050 VERBOSE_DISPLAY_LIST
= 0x0100,
3051 VERBOSE_LIGHTING
= 0x0200,
3052 VERBOSE_PRIMS
= 0x0400,
3053 VERBOSE_VERTS
= 0x0800,
3054 VERBOSE_DISASSEM
= 0x1000
3060 DEBUG_ALWAYS_FLUSH
= 0x1
3065 #define Elements(x) sizeof(x)/sizeof(*(x))
3068 #endif /* TYPES_H */