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_SEVEN
= 7,
147 VERT_ATTRIB_TEX0
= 8,
148 VERT_ATTRIB_TEX1
= 9,
149 VERT_ATTRIB_TEX2
= 10,
150 VERT_ATTRIB_TEX3
= 11,
151 VERT_ATTRIB_TEX4
= 12,
152 VERT_ATTRIB_TEX5
= 13,
153 VERT_ATTRIB_TEX6
= 14,
154 VERT_ATTRIB_TEX7
= 15,
155 VERT_ATTRIB_GENERIC0
= 16,
156 VERT_ATTRIB_GENERIC1
= 17,
157 VERT_ATTRIB_GENERIC2
= 18,
158 VERT_ATTRIB_GENERIC3
= 19,
159 VERT_ATTRIB_GENERIC4
= 20,
160 VERT_ATTRIB_GENERIC5
= 21,
161 VERT_ATTRIB_GENERIC6
= 22,
162 VERT_ATTRIB_GENERIC7
= 23,
163 VERT_ATTRIB_GENERIC8
= 24,
164 VERT_ATTRIB_GENERIC9
= 25,
165 VERT_ATTRIB_GENERIC10
= 26,
166 VERT_ATTRIB_GENERIC11
= 27,
167 VERT_ATTRIB_GENERIC12
= 28,
168 VERT_ATTRIB_GENERIC13
= 29,
169 VERT_ATTRIB_GENERIC14
= 30,
170 VERT_ATTRIB_GENERIC15
= 31,
175 * Bitflags for vertex attributes.
176 * These are used in bitfields in many places.
179 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
180 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
181 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
182 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
183 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
184 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
185 #define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
186 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
187 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
188 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
189 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
190 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
191 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
192 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
193 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
194 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
195 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
196 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
197 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
198 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
199 #define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4)
200 #define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5)
201 #define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6)
202 #define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7)
203 #define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8)
204 #define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9)
205 #define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10)
206 #define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11)
207 #define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12)
208 #define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13)
209 #define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14)
210 #define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15)
212 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
213 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
217 * GLSL allows shader writers to allocate vertex result attributes (varyings) in
218 * single float component granularity. This is in contrast to vertex / fragment
219 * programs, where result attributes (actually texcoords) were allocated
220 * in 4-component vectors of floats granularity.
221 * For performance reasons, it would be optimal to stick with this scheme on a scalar
222 * processor. Varyings will likely be allocated as 3-component vectors, so statistically
224 * The constant VARYINGS_PER_VECTOR tells us how much of float components we pack into
225 * one result vector. For scalar processor it would be 1, for vector processor - 4.
227 * NOTE: Currently we pack varyings into vertex attributes.
229 #define VARYINGS_PER_VECTOR 2
230 #define VARYING_EMIT_STYLE EMIT_2F
231 #define MAX_VARYING_VECTORS ((MAX_VARYING_FLOATS + VARYINGS_PER_VECTOR - 1) / VARYINGS_PER_VECTOR)
234 * Indexes for vertex program result attributes
237 #define VERT_RESULT_HPOS 0
238 #define VERT_RESULT_COL0 1
239 #define VERT_RESULT_COL1 2
240 #define VERT_RESULT_FOGC 3
241 #define VERT_RESULT_TEX0 4
242 #define VERT_RESULT_TEX1 5
243 #define VERT_RESULT_TEX2 6
244 #define VERT_RESULT_TEX3 7
245 #define VERT_RESULT_TEX4 8
246 #define VERT_RESULT_TEX5 9
247 #define VERT_RESULT_TEX6 10
248 #define VERT_RESULT_TEX7 11
249 #define VERT_RESULT_PSIZ 12
250 #define VERT_RESULT_BFC0 13
251 #define VERT_RESULT_BFC1 14
252 #define VERT_RESULT_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.
621 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Position, color, texcoords, etc */
622 GLfloat Index
; /**< Current color index */
623 GLboolean EdgeFlag
; /**< Current edge flag */
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 * Pixel attribute group (GL_PIXEL_MODE_BIT).
970 struct gl_pixel_attrib
972 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
973 GLfloat RedBias
, RedScale
;
974 GLfloat GreenBias
, GreenScale
;
975 GLfloat BlueBias
, BlueScale
;
976 GLfloat AlphaBias
, AlphaScale
;
977 GLfloat DepthBias
, DepthScale
;
978 GLint IndexShift
, IndexOffset
;
979 GLboolean MapColorFlag
;
980 GLboolean MapStencilFlag
;
981 GLfloat ZoomX
, ZoomY
;
982 /* XXX move these out of gl_pixel_attrib */
983 GLint MapStoSsize
; /**< Size of each pixel map */
993 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
994 GLfloat MapItoI
[MAX_PIXEL_MAP_TABLE
];
995 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
996 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
997 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
998 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
999 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
1000 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
1001 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
1002 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
1003 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
1004 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
1005 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
1006 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
1007 /** GL_EXT_histogram */
1008 GLboolean HistogramEnabled
;
1009 GLboolean MinMaxEnabled
;
1010 /** GL_SGI_color_matrix */
1011 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
1012 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
1013 /** GL_SGI_color_table */
1014 GLfloat ColorTableScale
[4];
1015 GLfloat ColorTableBias
[4];
1016 GLboolean ColorTableEnabled
;
1017 GLfloat PCCTscale
[4];
1018 GLfloat PCCTbias
[4];
1019 GLboolean PostConvolutionColorTableEnabled
;
1020 GLfloat PCMCTscale
[4];
1021 GLfloat PCMCTbias
[4];
1022 GLboolean PostColorMatrixColorTableEnabled
;
1023 /** GL_SGI_texture_color_table */
1024 GLfloat TextureColorTableScale
[4];
1025 GLfloat TextureColorTableBias
[4];
1027 GLboolean Convolution1DEnabled
;
1028 GLboolean Convolution2DEnabled
;
1029 GLboolean Separable2DEnabled
;
1030 GLfloat ConvolutionBorderColor
[3][4];
1031 GLenum ConvolutionBorderMode
[3];
1032 GLfloat ConvolutionFilterScale
[3][4];
1033 GLfloat ConvolutionFilterBias
[3][4];
1034 GLfloat PostConvolutionScale
[4]; /**< RGBA */
1035 GLfloat PostConvolutionBias
[4]; /**< RGBA */
1040 * Point attribute group (GL_POINT_BIT).
1042 struct gl_point_attrib
1044 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
1045 GLfloat Size
; /**< User-specified point size */
1046 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
1047 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
1048 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
1049 GLfloat Threshold
; /**< GL_EXT_point_parameters */
1050 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
1051 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
1052 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite */
1053 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
1054 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
1059 * Polygon attribute group (GL_POLYGON_BIT).
1061 struct gl_polygon_attrib
1063 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1064 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1065 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1066 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1067 GLboolean CullFlag
; /**< Culling on/off flag */
1068 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1069 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1070 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1071 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1072 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1073 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1074 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1075 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1080 * Scissor attributes (GL_SCISSOR_BIT).
1082 struct gl_scissor_attrib
1084 GLboolean Enabled
; /**< Scissor test enabled? */
1085 GLint X
, Y
; /**< Lower left corner of box */
1086 GLsizei Width
, Height
; /**< Size of box */
1091 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1093 struct gl_stencil_attrib
1095 GLboolean Enabled
; /**< Enabled flag */
1096 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1097 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1098 GLboolean _TestTwoSide
;
1099 GLenum Function
[2]; /**< Stencil function */
1100 GLenum FailFunc
[2]; /**< Fail function */
1101 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1102 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1103 GLint Ref
[2]; /**< Reference value */
1104 GLuint ValueMask
[2]; /**< Value mask */
1105 GLuint WriteMask
[2]; /**< Write mask */
1106 GLuint Clear
; /**< Clear value */
1110 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1113 * An index for each type of texture object
1116 #define TEXTURE_1D_INDEX 0
1117 #define TEXTURE_2D_INDEX 1
1118 #define TEXTURE_3D_INDEX 2
1119 #define TEXTURE_CUBE_INDEX 3
1120 #define TEXTURE_RECT_INDEX 4
1124 * Bit flags for each type of texture object
1125 * Used for Texture.Unit[]._ReallyEnabled flags.
1128 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1129 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1130 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1131 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1132 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1137 * TexGenEnabled flags.
1148 * Bit flag versions of the corresponding GL_ constants.
1151 #define TEXGEN_SPHERE_MAP 0x1
1152 #define TEXGEN_OBJ_LINEAR 0x2
1153 #define TEXGEN_EYE_LINEAR 0x4
1154 #define TEXGEN_REFLECTION_MAP_NV 0x8
1155 #define TEXGEN_NORMAL_MAP_NV 0x10
1157 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1158 TEXGEN_REFLECTION_MAP_NV | \
1159 TEXGEN_NORMAL_MAP_NV)
1160 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1161 TEXGEN_REFLECTION_MAP_NV | \
1162 TEXGEN_NORMAL_MAP_NV | \
1167 /* A selection of state flags to make driver and module's lives easier. */
1168 #define ENABLE_TEXGEN0 0x1
1169 #define ENABLE_TEXGEN1 0x2
1170 #define ENABLE_TEXGEN2 0x4
1171 #define ENABLE_TEXGEN3 0x8
1172 #define ENABLE_TEXGEN4 0x10
1173 #define ENABLE_TEXGEN5 0x20
1174 #define ENABLE_TEXGEN6 0x40
1175 #define ENABLE_TEXGEN7 0x80
1177 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1178 #define ENABLE_TEXMAT1 0x2
1179 #define ENABLE_TEXMAT2 0x4
1180 #define ENABLE_TEXMAT3 0x8
1181 #define ENABLE_TEXMAT4 0x10
1182 #define ENABLE_TEXMAT5 0x20
1183 #define ENABLE_TEXMAT6 0x40
1184 #define ENABLE_TEXMAT7 0x80
1186 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1187 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1191 * Texel fetch function prototype. We use texel fetch functions to
1192 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1193 * texture images. These functions help to isolate us from the gritty
1194 * details of all the various texture image encodings.
1196 * \param texImage texture image.
1197 * \param col texel column.
1198 * \param row texel row.
1199 * \param img texel image level/layer.
1200 * \param texelOut output texel (up to 4 GLchans)
1202 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1203 GLint col
, GLint row
, GLint img
,
1207 * As above, but returns floats.
1208 * Used for depth component images and for upcoming signed/float
1211 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1212 GLint col
, GLint row
, GLint img
,
1213 GLfloat
*texelOut
);
1216 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1217 GLint col
, GLint row
, GLint img
,
1222 * This macro defines the (many) parameters to the texstore functions.
1223 * \param dims either 1 or 2 or 3
1224 * \param baseInternalFormat user-specified base internal format
1225 * \param dstFormat destination Mesa texture format
1226 * \param dstAddr destination image address
1227 * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
1228 * \param dstRowStride destination image row stride, in bytes
1229 * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
1230 * \param srcWidth/Height/Depth source image size, in pixels
1231 * \param srcFormat incoming image format
1232 * \param srcType incoming image data type
1233 * \param srcAddr source image address
1234 * \param srcPacking source image packing parameters
1236 #define TEXSTORE_PARAMS \
1237 GLcontext *ctx, GLuint dims, \
1238 GLenum baseInternalFormat, \
1239 const struct gl_texture_format *dstFormat, \
1241 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
1242 GLint dstRowStride, const GLuint *dstImageOffsets, \
1243 GLint srcWidth, GLint srcHeight, GLint srcDepth, \
1244 GLenum srcFormat, GLenum srcType, \
1245 const GLvoid *srcAddr, \
1246 const struct gl_pixelstore_attrib *srcPacking
1251 * Texture image storage function.
1253 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
1257 * Texture format record
1259 struct gl_texture_format
1261 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1263 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1264 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1265 * GL_INTENSITY, GL_COLOR_INDEX or
1266 * GL_DEPTH_COMPONENT.
1268 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1269 GLubyte RedBits
; /**< Bits per texel component */
1270 GLubyte GreenBits
; /**< These are just rough approximations for */
1271 GLubyte BlueBits
; /**< compressed texture formats. */
1273 GLubyte LuminanceBits
;
1274 GLubyte IntensityBits
;
1277 GLubyte StencilBits
; /**< GL_EXT_packed_depth_stencil */
1279 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1281 StoreTexImageFunc StoreImage
;
1284 * \name Texel fetch function pointers
1287 FetchTexelFuncC FetchTexel1D
;
1288 FetchTexelFuncC FetchTexel2D
;
1289 FetchTexelFuncC FetchTexel3D
;
1290 FetchTexelFuncF FetchTexel1Df
;
1291 FetchTexelFuncF FetchTexel2Df
;
1292 FetchTexelFuncF FetchTexel3Df
;
1295 StoreTexelFunc StoreTexel
;
1299 #define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
1302 * Texture image state. Describes the dimensions of a texture image,
1303 * the texel format and pointers to Texel Fetch functions.
1305 struct gl_texture_image
1307 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1308 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1309 * GL_INTENSITY, GL_COLOR_INDEX,
1310 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1311 * only. Used for choosing TexEnv arithmetic.
1313 GLint InternalFormat
; /**< Internal format as given by the user */
1314 GLuint Border
; /**< 0 or 1 */
1315 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1316 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1317 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1318 GLuint Width2
; /**< = Width - 2*Border */
1319 GLuint Height2
; /**< = Height - 2*Border */
1320 GLuint Depth2
; /**< = Depth - 2*Border */
1321 GLuint WidthLog2
; /**< = log2(Width2) */
1322 GLuint HeightLog2
; /**< = log2(Height2) */
1323 GLuint DepthLog2
; /**< = log2(Depth2) */
1324 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1325 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1326 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1327 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1328 GLboolean IsClientData
; /**< Data owned by client? */
1329 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1331 const struct gl_texture_format
*TexFormat
;
1333 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1335 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1336 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1338 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1339 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1341 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1342 GLuint
*ImageOffsets
; /**< if 3D texture: array [Depth] of offsets to
1343 each 2D slice in 'Data', in texels */
1344 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1347 * \name For device driver:
1350 void *DriverData
; /**< Arbitrary device driver data */
1356 * Indexes for cube map faces.
1359 #define FACE_POS_X 0
1360 #define FACE_NEG_X 1
1361 #define FACE_POS_Y 2
1362 #define FACE_NEG_Y 3
1363 #define FACE_POS_Z 4
1364 #define FACE_NEG_Z 5
1370 * Texture object state. Contains the array of mipmap images, border color,
1371 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1374 struct gl_texture_object
1376 _glthread_Mutex Mutex
; /**< for thread safety */
1377 GLint RefCount
; /**< reference count */
1378 GLuint Name
; /**< the user-visible texture object ID */
1379 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1380 GLfloat Priority
; /**< in [0,1] */
1381 GLfloat BorderColor
[4]; /**< unclamped */
1382 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1383 GLenum WrapS
; /**< S-axis texture image wrap mode */
1384 GLenum WrapT
; /**< T-axis texture image wrap mode */
1385 GLenum WrapR
; /**< R-axis texture image wrap mode */
1386 GLenum MinFilter
; /**< minification filter */
1387 GLenum MagFilter
; /**< magnification filter */
1388 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1389 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1390 GLfloat LodBias
; /**< OpenGL 1.4 */
1391 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1392 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1393 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1394 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1395 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1396 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1397 GLenum CompareMode
; /**< GL_ARB_shadow */
1398 GLenum CompareFunc
; /**< GL_ARB_shadow */
1399 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1400 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1401 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1402 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1403 GLboolean Complete
; /**< Is texture object complete? */
1405 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1406 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1408 /** GL_EXT_paletted_texture */
1409 struct gl_color_table Palette
;
1413 * \name For device driver.
1414 * Note: instead of attaching driver data to this pointer, it's preferable
1415 * to instead use this struct as a base class for your own texture object
1416 * class. Driver->NewTextureObject() can be used to implement the
1419 void *DriverData
; /**< Arbitrary device driver data */
1424 * Texture combine environment state.
1427 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1428 * structure will need to be expanded for 4 elements.
1430 struct gl_tex_env_combine_state
1432 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1433 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1434 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1435 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1436 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1437 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1438 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1439 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1440 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1441 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1446 * Texture unit state. Contains enable flags, texture environment/function/
1447 * combiners, texgen state, pointers to current texture objects and
1448 * post-filter color tables.
1450 struct gl_texture_unit
1452 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1453 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1455 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1456 GLfloat EnvColor
[4];
1457 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1458 /** \name Tex coord generation mode
1459 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1466 GLbitfield _GenBitS
;
1467 GLbitfield _GenBitT
;
1468 GLbitfield _GenBitR
;
1469 GLbitfield _GenBitQ
;
1470 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1471 GLfloat ObjectPlaneS
[4];
1472 GLfloat ObjectPlaneT
[4];
1473 GLfloat ObjectPlaneR
[4];
1474 GLfloat ObjectPlaneQ
[4];
1475 GLfloat EyePlaneS
[4];
1476 GLfloat EyePlaneT
[4];
1477 GLfloat EyePlaneR
[4];
1478 GLfloat EyePlaneQ
[4];
1479 GLfloat LodBias
; /**< for biasing mipmap levels */
1482 * \name GL_EXT_texture_env_combine
1484 struct gl_tex_env_combine_state Combine
;
1487 * Derived state based on \c EnvMode and the \c BaseFormat of the
1488 * currently enabled texture.
1490 struct gl_tex_env_combine_state _EnvMode
;
1493 * Currently enabled combiner state. This will point to either
1494 * \c Combine or \c _EnvMode.
1496 struct gl_tex_env_combine_state
*_CurrentCombine
;
1498 struct gl_texture_object
*Current1D
;
1499 struct gl_texture_object
*Current2D
;
1500 struct gl_texture_object
*Current3D
;
1501 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1502 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1504 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1506 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1507 struct gl_texture_object Saved2D
;
1508 struct gl_texture_object Saved3D
;
1509 struct gl_texture_object SavedCubeMap
;
1510 struct gl_texture_object SavedRect
;
1512 /* GL_SGI_texture_color_table */
1513 struct gl_color_table ColorTable
;
1514 struct gl_color_table ProxyColorTable
;
1515 GLboolean ColorTableEnabled
;
1518 struct texenvprog_cache_item
{
1521 struct gl_fragment_program
*data
;
1522 struct texenvprog_cache_item
*next
;
1525 struct texenvprog_cache
{
1526 struct texenvprog_cache_item
**items
;
1527 GLuint size
, n_items
;
1532 * Texture attribute group (GL_TEXTURE_BIT).
1534 struct gl_texture_attrib
1540 GLuint CurrentUnit
; /**< Active texture unit */
1541 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1542 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1543 GLbitfield _GenFlags
; /**< for texgen */
1544 GLbitfield _TexGenEnabled
;
1545 GLbitfield _TexMatEnabled
;
1548 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1550 struct gl_texture_object
*Proxy1D
;
1551 struct gl_texture_object
*Proxy2D
;
1552 struct gl_texture_object
*Proxy3D
;
1553 struct gl_texture_object
*ProxyCubeMap
;
1554 struct gl_texture_object
*ProxyRect
;
1556 /** GL_EXT_shared_texture_palette */
1557 GLboolean SharedPalette
;
1558 struct gl_color_table Palette
;
1560 /** Cached texenv fragment programs */
1561 struct texenvprog_cache env_fp_cache
;
1566 * Transformation attribute group (GL_TRANSFORM_BIT).
1568 struct gl_transform_attrib
1570 GLenum MatrixMode
; /**< Matrix mode */
1571 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1572 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1573 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1574 GLboolean Normalize
; /**< Normalize all normals? */
1575 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1576 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1578 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1579 GLfloat CullEyePos
[4];
1580 GLfloat CullObjPos
[4];
1585 * Viewport attribute group (GL_VIEWPORT_BIT).
1587 struct gl_viewport_attrib
1589 GLint X
, Y
; /**< position */
1590 GLsizei Width
, Height
; /**< size */
1591 GLfloat Near
, Far
; /**< Depth buffer range */
1592 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1597 * Node for the attribute stack.
1599 struct gl_attrib_node
1603 struct gl_attrib_node
*next
;
1608 * GL_ARB_vertex/pixel_buffer_object buffer object
1610 struct gl_buffer_object
1616 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1617 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1618 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1619 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1625 * Client pixel packing/unpacking attributes
1627 struct gl_pixelstore_attrib
1633 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1634 GLint SkipImages
; /**< for GL_EXT_texture3D */
1635 GLboolean SwapBytes
;
1637 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1638 GLboolean Invert
; /**< GL_MESA_pack_invert */
1639 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1643 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1647 * Client vertex array attributes
1649 struct gl_client_array
1651 GLint Size
; /**< components per element (1,2,3,4) */
1652 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1653 GLsizei Stride
; /**< user-specified stride */
1654 GLsizei StrideB
; /**< actual stride in bytes */
1655 const GLubyte
*Ptr
; /**< Points to array data */
1656 GLbitfield Enabled
; /**< one of the _NEW_ARRAY_ bits */
1657 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1659 /**< GL_ARB_vertex_buffer_object */
1660 struct gl_buffer_object
*BufferObj
;
1668 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1669 * extension, but a nice encapsulation in any case.
1671 struct gl_array_object
1673 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1676 /** Conventional vertex arrays */
1678 struct gl_client_array Vertex
;
1679 struct gl_client_array Normal
;
1680 struct gl_client_array Color
;
1681 struct gl_client_array SecondaryColor
;
1682 struct gl_client_array FogCoord
;
1683 struct gl_client_array Index
;
1684 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1685 struct gl_client_array EdgeFlag
;
1688 /** Generic arrays for vertex programs/shaders */
1689 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1691 /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
1692 GLbitfield _Enabled
;
1697 * Vertex array state
1699 struct gl_array_attrib
1701 struct gl_array_object
*ArrayObj
;
1702 struct gl_array_object
*DefaultArrayObj
;
1704 GLint ActiveTexture
; /**< Client Active Texture */
1705 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1706 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1708 GLbitfield NewState
; /**< mask of _NEW_ARRAY_* values */
1710 #if FEATURE_ARB_vertex_buffer_object
1711 struct gl_buffer_object
*NullBufferObj
;
1712 struct gl_buffer_object
*ArrayBufferObj
;
1713 struct gl_buffer_object
*ElementArrayBufferObj
;
1715 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1720 * Feedback buffer state
1725 GLbitfield _Mask
; /* FB_* bits */
1733 * Selection buffer state
1737 GLuint
*Buffer
; /**< selection buffer */
1738 GLuint BufferSize
; /**< size of the selection buffer */
1739 GLuint BufferCount
; /**< number of values in the selection buffer */
1740 GLuint Hits
; /**< number of records in the selection buffer */
1741 GLuint NameStackDepth
; /**< name stack depth */
1742 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1743 GLboolean HitFlag
; /**< hit flag */
1744 GLfloat HitMinZ
; /**< minimum hit depth */
1745 GLfloat HitMaxZ
; /**< maximum hit depth */
1750 * 1-D Evaluator control points
1754 GLuint Order
; /**< Number of control points */
1755 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1756 GLfloat
*Points
; /**< Points to contiguous control points */
1761 * 2-D Evaluator control points
1765 GLuint Uorder
; /**< Number of control points in U dimension */
1766 GLuint Vorder
; /**< Number of control points in V dimension */
1769 GLfloat
*Points
; /**< Points to contiguous control points */
1774 * All evaluator control point state
1776 struct gl_evaluators
1782 struct gl_1d_map Map1Vertex3
;
1783 struct gl_1d_map Map1Vertex4
;
1784 struct gl_1d_map Map1Index
;
1785 struct gl_1d_map Map1Color4
;
1786 struct gl_1d_map Map1Normal
;
1787 struct gl_1d_map Map1Texture1
;
1788 struct gl_1d_map Map1Texture2
;
1789 struct gl_1d_map Map1Texture3
;
1790 struct gl_1d_map Map1Texture4
;
1791 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1798 struct gl_2d_map Map2Vertex3
;
1799 struct gl_2d_map Map2Vertex4
;
1800 struct gl_2d_map Map2Index
;
1801 struct gl_2d_map Map2Color4
;
1802 struct gl_2d_map Map2Normal
;
1803 struct gl_2d_map Map2Texture1
;
1804 struct gl_2d_map Map2Texture2
;
1805 struct gl_2d_map Map2Texture3
;
1806 struct gl_2d_map Map2Texture4
;
1807 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1813 * Names of the various vertex/fragment program register files, etc.
1814 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1815 * All values should fit in a 4-bit field.
1819 PROGRAM_TEMPORARY
= 0,
1820 PROGRAM_LOCAL_PARAM
= 1,
1821 PROGRAM_ENV_PARAM
= 2,
1822 PROGRAM_STATE_VAR
= 3,
1825 PROGRAM_NAMED_PARAM
= 6,
1826 PROGRAM_CONSTANT
= 7,
1827 PROGRAM_WRITE_ONLY
= 8,
1828 PROGRAM_ADDRESS
= 9,
1829 PROGRAM_UNDEFINED
= 10, /* invalid value */
1834 /** Vertex and fragment instructions */
1835 struct prog_instruction
;
1836 struct gl_program_parameter_list
;
1840 * Base class for any kind of program object
1845 GLubyte
*String
; /**< Null-terminated program text */
1848 GLenum Format
; /**< String encoding format */
1851 struct prog_instruction
*Instructions
;
1853 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1854 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1856 /** Named parameters, constants, etc. from program text */
1857 struct gl_program_parameter_list
*Parameters
;
1858 /** Numbered local parameters */
1859 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1861 /** Logical counts */
1863 GLuint NumInstructions
;
1864 GLuint NumTemporaries
;
1865 GLuint NumParameters
;
1866 GLuint NumAttributes
;
1867 GLuint NumAddressRegs
;
1869 /** Native, actual h/w counts */
1871 GLuint NumNativeInstructions
;
1872 GLuint NumNativeTemporaries
;
1873 GLuint NumNativeParameters
;
1874 GLuint NumNativeAttributes
;
1875 GLuint NumNativeAddressRegs
;
1880 /** Vertex program object */
1881 struct gl_vertex_program
1883 struct gl_program Base
; /**< base class */
1884 GLboolean IsNVProgram
; /**< is this a GL_NV_vertex_program program? */
1885 GLboolean IsPositionInvariant
;
1886 void *TnlData
; /**< should probably use Base.DriverData */
1890 /** Fragment program object */
1891 struct gl_fragment_program
1893 struct gl_program Base
; /**< base class */
1894 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
1895 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1896 GLuint NumTexInstructions
;
1897 GLuint NumTexIndirections
;
1898 GLuint NumNativeAluInstructions
; /**< GL_ARB_fragment_program */
1899 GLuint NumNativeTexInstructions
;
1900 GLuint NumNativeTexIndirections
;
1907 * State common to vertex and fragment programs.
1909 struct gl_program_state
1911 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1912 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1917 * Context state for vertex programs.
1919 struct gl_vertex_program_state
1921 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_ARB/NV */
1922 GLboolean _Enabled
; /**< Enabled and valid program? */
1923 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1924 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1925 struct gl_vertex_program
*Current
; /**< ptr to currently bound program */
1926 const struct gl_vertex_program
*_Current
; /**< ptr to currently bound
1927 program, including internal
1928 (t_vp_build.c) programs */
1930 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /**< Env params */
1932 /* For GL_NV_vertex_program only: */
1933 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1934 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1936 #if FEATURE_MESA_program_debug
1937 GLprogramcallbackMESA Callback
;
1938 GLvoid
*CallbackData
;
1939 GLboolean CallbackEnabled
;
1940 GLuint CurrentPosition
;
1946 * Context state for fragment programs.
1948 struct gl_fragment_program_state
1950 GLboolean Enabled
; /**< User-set fragment program enable flag */
1951 GLboolean _Enabled
; /**< Fragment program enabled and valid? */
1952 GLboolean _Active
; /**< Is a user program or internal program active? */
1953 struct gl_fragment_program
*Current
; /**< User-bound program */
1954 const struct gl_fragment_program
*_Current
; /**< currently active program
1955 (including internal programs) */
1956 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /**< Env params */
1958 #if FEATURE_MESA_program_debug
1959 GLprogramcallbackMESA Callback
;
1960 GLvoid
*CallbackData
;
1961 GLboolean CallbackEnabled
;
1962 GLuint CurrentPosition
;
1968 * ATI_fragment_shader runtime state
1970 #define ATI_FS_INPUT_PRIMARY 0
1971 #define ATI_FS_INPUT_SECONDARY 1
1973 struct atifs_instruction
;
1974 struct atifs_setupinst
;
1977 * ATI fragment shader
1979 struct ati_fragment_shader
1983 struct atifs_instruction
*Instructions
[2];
1984 struct atifs_setupinst
*SetupInst
[2];
1985 GLfloat Constants
[8][4];
1986 GLbitfield LocalConstDef
; /** Indicates which constants have been set */
1987 GLubyte numArithInstr
[2];
1988 GLubyte regsAssigned
[2];
1989 GLubyte NumPasses
; /** 1 or 2 */
1991 GLubyte last_optype
;
1992 GLboolean interpinp1
;
1998 * Context state for GL_ATI_fragment_shader
2000 struct gl_ati_fragment_shader_state
2003 GLboolean _Enabled
; /** enabled and valid shader? */
2004 GLboolean Compiling
;
2005 GLfloat GlobalConstants
[8][4];
2006 struct ati_fragment_shader
*Current
;
2011 * Occlusion/timer query object.
2013 struct gl_query_object
2016 GLuint64EXT Result
; /* the counter */
2017 GLboolean Active
; /* inside Begin/EndQuery */
2018 GLboolean Ready
; /* result is ready */
2023 * Context state for query objects.
2025 struct gl_query_state
2027 struct _mesa_HashTable
*QueryObjects
;
2028 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2029 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2034 * Context state for vertex/fragment shaders.
2036 struct gl_shader_objects_state
2038 struct gl2_program_intf
**CurrentProgram
;
2039 GLboolean _VertexShaderPresent
;
2040 GLboolean _FragmentShaderPresent
;
2045 * State which can be shared by multiple contexts:
2047 struct gl_shared_state
2049 _glthread_Mutex Mutex
; /**< for thread safety */
2050 GLint RefCount
; /**< Reference count */
2051 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2052 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2055 * \name Default texture objects (shared by all multi-texture units)
2058 struct gl_texture_object
*Default1D
;
2059 struct gl_texture_object
*Default2D
;
2060 struct gl_texture_object
*Default3D
;
2061 struct gl_texture_object
*DefaultCubeMap
;
2062 struct gl_texture_object
*DefaultRect
;
2066 * \name Thread safety and statechange notification for texture
2069 * \todo Improve the granularity of locking.
2072 _glthread_Mutex TexMutex
; /**< texobj thread safety */
2073 GLuint TextureStateStamp
; /**< state notification for shared tex */
2079 * \name Vertex/fragment programs
2082 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
2083 #if FEATURE_ARB_vertex_program
2084 struct gl_program
*DefaultVertexProgram
;
2086 #if FEATURE_ARB_fragment_program
2087 struct gl_program
*DefaultFragmentProgram
;
2091 #if FEATURE_ATI_fragment_shader
2092 struct _mesa_HashTable
*ATIShaders
;
2093 struct ati_fragment_shader
*DefaultFragmentShader
;
2096 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2097 struct _mesa_HashTable
*BufferObjects
;
2100 #if FEATURE_ARB_shader_objects
2101 struct _mesa_HashTable
*GL2Objects
;
2104 #if FEATURE_EXT_framebuffer_object
2105 struct _mesa_HashTable
*RenderBuffers
;
2106 struct _mesa_HashTable
*FrameBuffers
;
2109 /** Objects associated with the GL_APPLE_vertex_array_object extension. */
2110 struct _mesa_HashTable
*ArrayObjects
;
2112 void *DriverData
; /**< Device driver shared state */
2119 * A renderbuffer stores colors or depth values or stencil values.
2120 * A framebuffer object will have a collection of these.
2121 * Data are read/written to the buffer with a handful of Get/Put functions.
2123 * Instances of this object are allocated with the Driver's NewRenderbuffer
2124 * hook. Drivers will likely wrap this class inside a driver-specific
2125 * class to simulate inheritance.
2127 struct gl_renderbuffer
2129 _glthread_Mutex Mutex
; /**< for thread safety */
2130 GLuint ClassID
; /**< Useful for drivers */
2133 GLuint Width
, Height
;
2134 GLenum InternalFormat
; /**< The user-specified format */
2135 GLenum _ActualFormat
; /**< The driver-chosen format */
2136 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2137 GL_STENCIL_INDEX. */
2138 GLenum DataType
; /**< Type of values passed to the Get/Put functions */
2139 GLubyte RedBits
; /**< Bits of red per pixel */
2145 GLubyte StencilBits
;
2148 /* Used to wrap one renderbuffer around another: */
2149 struct gl_renderbuffer
*Wrapped
;
2151 /* Delete this renderbuffer */
2152 void (*Delete
)(struct gl_renderbuffer
*rb
);
2154 /* Allocate new storage for this renderbuffer */
2155 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2156 GLenum internalFormat
,
2157 GLuint width
, GLuint height
);
2159 /* Lock/Unlock are called before/after calling the Get/Put functions.
2160 * Not sure this is the right place for these yet.
2161 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2162 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2165 /* Return a pointer to the element/pixel at (x,y).
2166 * Should return NULL if the buffer memory can't be directly addressed.
2168 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2171 /* Get/Read a row of values.
2172 * The values will be of format _BaseFormat and type DataType.
2174 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2175 GLint x
, GLint y
, void *values
);
2177 /* Get/Read values at arbitrary locations.
2178 * The values will be of format _BaseFormat and type DataType.
2180 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2181 const GLint x
[], const GLint y
[], void *values
);
2183 /* Put/Write a row of values.
2184 * The values will be of format _BaseFormat and type DataType.
2186 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2187 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2189 /* Put/Write a row of RGB values. This is a special-case routine that's
2190 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2191 * a common case for glDrawPixels and some triangle routines.
2192 * The values will be of format GL_RGB and type DataType.
2194 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2195 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2198 /* Put/Write a row of identical values.
2199 * The values will be of format _BaseFormat and type DataType.
2201 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2202 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2204 /* Put/Write values at arbitrary locations.
2205 * The values will be of format _BaseFormat and type DataType.
2207 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2208 const GLint x
[], const GLint y
[], const void *values
,
2209 const GLubyte
*mask
);
2210 /* Put/Write identical values at arbitrary locations.
2211 * The values will be of format _BaseFormat and type DataType.
2213 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2214 GLuint count
, const GLint x
[], const GLint y
[],
2215 const void *value
, const GLubyte
*mask
);
2220 * A renderbuffer attachment point points to either a texture object
2221 * (and specifies a mipmap level, cube face or 3D texture slice) or
2222 * points to a renderbuffer.
2224 struct gl_renderbuffer_attachment
2226 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2229 /* IF Type == GL_RENDERBUFFER_EXT: */
2230 struct gl_renderbuffer
*Renderbuffer
;
2232 /* IF Type == GL_TEXTURE: */
2233 struct gl_texture_object
*Texture
;
2234 GLuint TextureLevel
;
2235 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2236 GLuint Zoffset
; /* for 3D textures */
2241 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2242 * In C++ terms, think of this as a base class from which device drivers
2243 * will make derived classes.
2245 struct gl_framebuffer
2247 _glthread_Mutex Mutex
; /**< for thread safety */
2248 GLuint Name
; /* if zero, this is a window system framebuffer */
2251 GLvisual Visual
; /**< The framebuffer's visual.
2252 Immutable if this is a window system buffer.
2253 Computed from attachments if user-made FBO. */
2255 GLboolean Initialized
;
2257 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2259 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2261 GLint _Xmin
, _Xmax
; /**< inclusive */
2262 GLint _Ymin
, _Ymax
; /**< exclusive */
2265 /** \name Derived Z buffer stuff */
2267 GLuint _DepthMax
; /**< Max depth buffer value */
2268 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2269 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2272 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2274 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2275 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2277 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2278 * attribute group and GL_PIXEL attribute group, respectively.
2280 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2281 GLenum ColorReadBuffer
;
2283 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2284 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2285 GLint _ColorReadBufferIndex
; /* -1 = None */
2287 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2288 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2289 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2290 struct gl_renderbuffer
*_ColorReadBuffer
;
2292 /** The Actual depth/stencil buffers to use. May be wrappers around the
2293 * depth/stencil buffers attached above. */
2294 struct gl_renderbuffer
*_DepthBuffer
;
2295 struct gl_renderbuffer
*_StencilBuffer
;
2297 /** Delete this framebuffer */
2298 void (*Delete
)(struct gl_framebuffer
*fb
);
2303 * Limits for vertex and fragment programs.
2305 struct gl_program_constants
2307 /* logical limits */
2308 GLuint MaxInstructions
;
2309 GLuint MaxAluInstructions
; /* fragment programs only, for now */
2310 GLuint MaxTexInstructions
; /* fragment programs only, for now */
2311 GLuint MaxTexIndirections
; /* fragment programs only, for now */
2314 GLuint MaxAddressRegs
; /* vertex program only, for now */
2315 GLuint MaxParameters
;
2316 GLuint MaxLocalParams
;
2317 GLuint MaxEnvParams
;
2318 /* native/hardware limits */
2319 GLuint MaxNativeInstructions
;
2320 GLuint MaxNativeAluInstructions
; /* fragment programs only, for now */
2321 GLuint MaxNativeTexInstructions
; /* fragment programs only, for now */
2322 GLuint MaxNativeTexIndirections
; /* fragment programs only, for now */
2323 GLuint MaxNativeAttribs
;
2324 GLuint MaxNativeTemps
;
2325 GLuint MaxNativeAddressRegs
; /* vertex program only, for now */
2326 GLuint MaxNativeParameters
;
2328 GLuint MaxUniformComponents
;
2333 * Constants which may be overridden by device driver during context creation
2334 * but are never changed after that.
2338 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2339 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2340 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2341 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2342 GLuint MaxTextureCoordUnits
;
2343 GLuint MaxTextureImageUnits
;
2344 GLuint MaxTextureUnits
; /* = MIN(CoordUnits, ImageUnits) */
2345 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2346 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2347 GLuint MaxArrayLockSize
;
2349 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2350 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2351 GLfloat PointSizeGranularity
;
2352 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2353 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2354 GLfloat LineWidthGranularity
;
2355 GLuint MaxColorTableSize
;
2356 GLuint MaxConvolutionWidth
;
2357 GLuint MaxConvolutionHeight
;
2358 GLuint MaxClipPlanes
;
2360 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2361 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2362 GLuint MaxViewportWidth
, MaxViewportHeight
;
2363 struct gl_program_constants VertexProgram
; /* GL_ARB_vertex_program */
2364 struct gl_program_constants FragmentProgram
; /* GL_ARB_fragment_program */
2365 /* shared by vertex and fragment program: */
2366 GLuint MaxProgramMatrices
;
2367 GLuint MaxProgramMatrixStackDepth
;
2368 /* vertex array / buffer object bounds checking */
2369 GLboolean CheckArrayBounds
;
2370 /* GL_ARB_draw_buffers */
2371 GLuint MaxDrawBuffers
;
2372 /* GL_OES_read_format */
2373 GLenum ColorReadFormat
;
2374 GLenum ColorReadType
;
2375 /* GL_EXT_framebuffer_object */
2376 GLuint MaxColorAttachments
;
2377 GLuint MaxRenderbufferSize
;
2378 /* GL_ARB_vertex_shader */
2379 GLuint MaxVertexTextureImageUnits
;
2380 GLuint MaxVaryingFloats
;
2385 * Enable flag for each OpenGL extension. Different device drivers will
2386 * enable different extensions at runtime.
2388 struct gl_extensions
2391 * \name Flags to quickly test if certain extensions are available.
2393 * Not every extension needs to have such a flag, but it's encouraged.
2396 GLboolean dummy
; /* don't remove this! */
2397 GLboolean ARB_depth_texture
;
2398 GLboolean ARB_draw_buffers
;
2399 GLboolean ARB_fragment_program
;
2400 GLboolean ARB_fragment_shader
;
2401 GLboolean ARB_half_float_pixel
;
2402 GLboolean ARB_imaging
;
2403 GLboolean ARB_multisample
;
2404 GLboolean ARB_multitexture
;
2405 GLboolean ARB_occlusion_query
;
2406 GLboolean ARB_point_sprite
;
2407 GLboolean ARB_shader_objects
;
2408 GLboolean ARB_shading_language_100
;
2409 GLboolean ARB_shadow
;
2410 GLboolean ARB_texture_border_clamp
;
2411 GLboolean ARB_texture_compression
;
2412 GLboolean ARB_texture_cube_map
;
2413 GLboolean ARB_texture_env_combine
;
2414 GLboolean ARB_texture_env_crossbar
;
2415 GLboolean ARB_texture_env_dot3
;
2416 GLboolean ARB_texture_float
;
2417 GLboolean ARB_texture_mirrored_repeat
;
2418 GLboolean ARB_texture_non_power_of_two
;
2419 GLboolean ARB_transpose_matrix
;
2420 GLboolean ARB_vertex_buffer_object
;
2421 GLboolean ARB_vertex_program
;
2422 GLboolean ARB_vertex_shader
;
2423 GLboolean ARB_window_pos
;
2426 GLboolean EXT_blend_color
;
2427 GLboolean EXT_blend_equation_separate
;
2428 GLboolean EXT_blend_func_separate
;
2429 GLboolean EXT_blend_logic_op
;
2430 GLboolean EXT_blend_minmax
;
2431 GLboolean EXT_blend_subtract
;
2432 GLboolean EXT_clip_volume_hint
;
2433 GLboolean EXT_cull_vertex
;
2434 GLboolean EXT_convolution
;
2435 GLboolean EXT_compiled_vertex_array
;
2436 GLboolean EXT_copy_texture
;
2437 GLboolean EXT_depth_bounds_test
;
2438 GLboolean EXT_draw_range_elements
;
2439 GLboolean EXT_framebuffer_object
;
2440 GLboolean EXT_fog_coord
;
2441 GLboolean EXT_framebuffer_blit
;
2442 GLboolean EXT_gpu_program_parameters
;
2443 GLboolean EXT_histogram
;
2444 GLboolean EXT_multi_draw_arrays
;
2445 GLboolean EXT_paletted_texture
;
2446 GLboolean EXT_packed_depth_stencil
;
2447 GLboolean EXT_packed_pixels
;
2448 GLboolean EXT_pixel_buffer_object
;
2449 GLboolean EXT_point_parameters
;
2450 GLboolean EXT_polygon_offset
;
2451 GLboolean EXT_rescale_normal
;
2452 GLboolean EXT_shadow_funcs
;
2453 GLboolean EXT_secondary_color
;
2454 GLboolean EXT_separate_specular_color
;
2455 GLboolean EXT_shared_texture_palette
;
2456 GLboolean EXT_stencil_wrap
;
2457 GLboolean EXT_stencil_two_side
;
2458 GLboolean EXT_subtexture
;
2459 GLboolean EXT_texture
;
2460 GLboolean EXT_texture_object
;
2461 GLboolean EXT_texture3D
;
2462 GLboolean EXT_texture_compression_s3tc
;
2463 GLboolean EXT_texture_env_add
;
2464 GLboolean EXT_texture_env_combine
;
2465 GLboolean EXT_texture_env_dot3
;
2466 GLboolean EXT_texture_filter_anisotropic
;
2467 GLboolean EXT_texture_lod_bias
;
2468 GLboolean EXT_texture_mirror_clamp
;
2469 GLboolean EXT_texture_sRGB
;
2470 GLboolean EXT_timer_query
;
2471 GLboolean EXT_vertex_array
;
2472 GLboolean EXT_vertex_array_set
;
2473 /* vendor extensions */
2474 GLboolean APPLE_client_storage
;
2475 GLboolean APPLE_packed_pixels
;
2476 GLboolean APPLE_vertex_array_object
;
2477 GLboolean ATI_texture_mirror_once
;
2478 GLboolean ATI_texture_env_combine3
;
2479 GLboolean ATI_fragment_shader
;
2480 GLboolean IBM_rasterpos_clip
;
2481 GLboolean IBM_multimode_draw_arrays
;
2482 GLboolean MESA_pack_invert
;
2483 GLboolean MESA_packed_depth_stencil
;
2484 GLboolean MESA_program_debug
;
2485 GLboolean MESA_resize_buffers
;
2486 GLboolean MESA_ycbcr_texture
;
2487 GLboolean NV_blend_square
;
2488 GLboolean NV_fragment_program
;
2489 GLboolean NV_light_max_exponent
;
2490 GLboolean NV_point_sprite
;
2491 GLboolean NV_texgen_reflection
;
2492 GLboolean NV_texture_rectangle
;
2493 GLboolean NV_vertex_program
;
2494 GLboolean NV_vertex_program1_1
;
2495 GLboolean OES_read_format
;
2496 GLboolean SGI_color_matrix
;
2497 GLboolean SGI_color_table
;
2498 GLboolean SGI_texture_color_table
;
2499 GLboolean SGIS_generate_mipmap
;
2500 GLboolean SGIS_texture_edge_clamp
;
2501 GLboolean SGIS_texture_lod
;
2502 GLboolean SGIX_depth_texture
;
2503 GLboolean SGIX_shadow
;
2504 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2505 GLboolean TDFX_texture_compression_FXT1
;
2508 /* The extension string */
2509 const GLubyte
*String
;
2514 * A stack of matrices (projection, modelview, color, texture, etc).
2518 GLmatrix
*Top
; /**< points into Stack */
2519 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2520 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2521 GLuint MaxDepth
; /**< size of Stack[] array */
2522 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2527 * \name Bits for image transfer operations
2529 * \sa __GLcontextRec::ImageTransferState.
2532 #define IMAGE_SCALE_BIAS_BIT 0x1
2533 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2534 #define IMAGE_MAP_COLOR_BIT 0x4
2535 #define IMAGE_COLOR_TABLE_BIT 0x8
2536 #define IMAGE_CONVOLUTION_BIT 0x10
2537 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2538 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2539 #define IMAGE_COLOR_MATRIX_BIT 0x80
2540 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2541 #define IMAGE_HISTOGRAM_BIT 0x200
2542 #define IMAGE_MIN_MAX_BIT 0x400
2543 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2546 /** Pixel Transfer ops up to convolution */
2547 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2548 IMAGE_SHIFT_OFFSET_BIT | \
2549 IMAGE_MAP_COLOR_BIT | \
2550 IMAGE_COLOR_TABLE_BIT)
2552 /** Pixel transfer ops after convolution */
2553 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2554 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2555 IMAGE_COLOR_MATRIX_BIT | \
2556 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2557 IMAGE_HISTOGRAM_BIT | \
2563 * \name Bits to indicate what state has changed.
2568 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2569 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2570 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2571 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2572 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2573 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2574 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2575 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2576 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2577 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2578 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2579 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2580 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2581 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2582 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2583 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2584 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2585 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2586 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2587 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2588 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2589 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2590 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2591 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2592 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2593 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2594 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2595 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2601 * \name Bits to track array state changes
2603 * Also used to summarize array enabled.
2606 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2607 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2608 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2609 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2610 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2611 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2612 #define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
2613 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2614 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2615 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2616 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2617 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2618 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2619 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2620 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2621 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2622 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2623 #define _NEW_ARRAY_ALL 0xffffffff
2626 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2627 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2632 * \name A bunch of flags that we think might be useful to drivers.
2634 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2637 #define DD_FLATSHADE 0x1
2638 #define DD_SEPARATE_SPECULAR 0x2
2639 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2640 #define DD_TRI_LIGHT_TWOSIDE 0x8
2641 #define DD_TRI_UNFILLED 0x10
2642 #define DD_TRI_SMOOTH 0x20
2643 #define DD_TRI_STIPPLE 0x40
2644 #define DD_TRI_OFFSET 0x80
2645 #define DD_LINE_SMOOTH 0x100
2646 #define DD_LINE_STIPPLE 0x200
2647 #define DD_LINE_WIDTH 0x400
2648 #define DD_POINT_SMOOTH 0x800
2649 #define DD_POINT_SIZE 0x1000
2650 #define DD_POINT_ATTEN 0x2000
2651 #define DD_TRI_TWOSTENCIL 0x4000
2656 * \name Define the state changes under which each of these bits might change
2659 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2660 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2661 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2662 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2663 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2664 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2665 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2666 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2667 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2668 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2669 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2670 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2671 #define _DD_NEW_POINT_SIZE _NEW_POINT
2672 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2676 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2681 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2684 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2690 * Forward declaration of display list data types:
2693 typedef union node Node
;
2696 /* This has to be included here. */
2700 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2703 * Core Mesa's support for tnl modules:
2705 struct gl_tnl_module
2708 * Vertex format to be lazily swapped into current dispatch.
2710 const GLvertexformat
*Current
;
2713 * \name Record of functions swapped out.
2714 * On restore, only need to swap these functions back in.
2718 _glapi_proc
* location
;
2719 _glapi_proc function
;
2720 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2725 /* Strictly this is a tnl/ private concept, but it doesn't seem
2726 * worthwhile adding a tnl private structure just to hold this one bit
2729 #define MESA_DLIST_DANGLING_REFS 0x1
2731 /* Provide a location where information about a display list can be
2732 * collected. Could be extended with driverPrivate structures,
2733 * etc. in the future.
2735 struct mesa_display_list
2744 * State used during display list compilation and execution.
2746 struct mesa_list_state
2748 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2749 GLuint CallDepth
; /**< Current recursion calling depth */
2751 struct mesa_display_list
*CurrentList
;
2752 Node
*CurrentListPtr
; /**< Head of list being compiled */
2753 GLuint CurrentListNum
; /**< Number of the list being compiled */
2754 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2755 GLuint CurrentPos
; /**< Index into current block of nodes */
2757 GLvertexformat ListVtxfmt
;
2759 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2760 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2762 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2763 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2765 GLubyte ActiveIndex
;
2766 GLfloat CurrentIndex
;
2768 GLubyte ActiveEdgeFlag
;
2769 GLboolean CurrentEdgeFlag
;
2774 * Mesa rendering context.
2776 * This is the central context data structure for Mesa. Almost all
2777 * OpenGL state is contained in this structure.
2778 * Think of this as a base class from which device drivers will derive
2781 * The GLcontext typedef names this structure.
2783 struct __GLcontextRec
2786 * \name OS related interfaces.
2788 * These \b must be the first members of this structure, because they are
2789 * exposed to the outside world (i.e. GLX extension).
2792 __GLimports imports
;
2793 __GLexports exports
;
2796 /** State possibly shared with other contexts in the address space */
2797 struct gl_shared_state
*Shared
;
2799 /** \name API function pointer tables */
2801 struct _glapi_table
*Save
; /**< Display list save functions */
2802 struct _glapi_table
*Exec
; /**< Execute functions */
2803 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2807 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2808 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2809 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2810 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2813 * Device driver function pointer table
2815 struct dd_function_table Driver
;
2817 void *DriverCtx
; /**< Points to device driver context/state */
2818 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2820 /** Core/Driver constants */
2821 struct gl_constants Const
;
2823 /** \name The various 4x4 matrix stacks */
2825 struct matrix_stack ModelviewMatrixStack
;
2826 struct matrix_stack ProjectionMatrixStack
;
2827 struct matrix_stack ColorMatrixStack
;
2828 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2829 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2830 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2833 /** Combined modelview and projection matrix */
2834 GLmatrix _ModelProjectMatrix
;
2836 /** \name Display lists */
2837 struct mesa_list_state ListState
;
2839 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2840 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2842 /** Extension information */
2843 struct gl_extensions Extensions
;
2845 /** \name State attribute stack (for glPush/PopAttrib) */
2847 GLuint AttribStackDepth
;
2848 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2851 /** \name Renderer attribute groups
2853 * We define a struct for each attribute group to make pushing and popping
2854 * attributes easy. Also it's a good organization.
2857 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
2858 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
2859 struct gl_current_attrib Current
; /**< Current attributes */
2860 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2861 struct gl_eval_attrib Eval
; /**< Eval attributes */
2862 struct gl_fog_attrib Fog
; /**< Fog attributes */
2863 struct gl_hint_attrib Hint
; /**< Hint attributes */
2864 struct gl_light_attrib Light
; /**< Light attributes */
2865 struct gl_line_attrib Line
; /**< Line attributes */
2866 struct gl_list_attrib List
; /**< List attributes */
2867 struct gl_multisample_attrib Multisample
;
2868 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2869 struct gl_point_attrib Point
; /**< Point attributes */
2870 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2871 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2872 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2873 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2874 struct gl_texture_attrib Texture
; /**< Texture attributes */
2875 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2876 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2879 /** \name Client attribute stack */
2881 GLuint ClientAttribStackDepth
;
2882 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2885 /** \name Client attribute groups */
2887 struct gl_array_attrib Array
; /**< Vertex arrays */
2888 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2889 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2890 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2893 /** \name Other assorted state (not pushed/popped on attribute stack) */
2895 struct gl_histogram_attrib Histogram
;
2896 struct gl_minmax_attrib MinMax
;
2897 struct gl_convolution_attrib Convolution1D
;
2898 struct gl_convolution_attrib Convolution2D
;
2899 struct gl_convolution_attrib Separable2D
;
2901 struct gl_evaluators EvalMap
; /**< All evaluators */
2902 struct gl_feedback Feedback
; /**< Feedback */
2903 struct gl_selection Select
; /**< Selection */
2905 struct gl_color_table ColorTable
; /**< Pre-convolution */
2906 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2907 struct gl_color_table PostConvolutionColorTable
;
2908 struct gl_color_table ProxyPostConvolutionColorTable
;
2909 struct gl_color_table PostColorMatrixColorTable
;
2910 struct gl_color_table ProxyPostColorMatrixColorTable
;
2912 struct gl_program_state Program
; /**< for vertex or fragment progs */
2913 struct gl_vertex_program_state VertexProgram
; /**< GL_ARB/NV_vertex_program */
2914 struct gl_fragment_program_state FragmentProgram
; /**< GL_ARB/NV_vertex_program */
2915 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2917 struct gl_fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2918 struct gl_vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2920 GLboolean _MaintainTnlProgram
;
2921 GLboolean _MaintainTexEnvProgram
;
2922 GLboolean _UseTexEnvProgram
;
2924 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2926 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2929 #if FEATURE_EXT_framebuffer_object
2930 struct gl_renderbuffer
*CurrentRenderbuffer
;
2933 GLenum ErrorValue
; /**< Last error code */
2934 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2935 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2937 /** \name Derived state */
2939 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2940 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2941 GLfloat _EyeZDir
[3];
2942 GLfloat _ModelViewInvScale
;
2943 GLboolean _NeedEyeCoords
;
2944 GLboolean _ForceEyeCoords
;
2945 GLenum _CurrentProgram
; /* currently executing program */
2947 GLuint TextureStateTimestamp
; /* detect changes to shared state */
2949 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2950 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2953 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2956 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2958 * We don't have a better way to communicate this value from
2959 * swrast_setup to swrast. */
2961 /** \name For debugging/development only */
2963 GLboolean FirstTimeCurrent
;
2966 /** Dither disable via MESA_NO_DITHER env var */
2969 /** software compression/decompression supported or not */
2970 GLboolean Mesa_DXTn
;
2972 /** Core tnl module support */
2973 struct gl_tnl_module TnlModule
;
2976 * \name Hooks for module contexts.
2978 * These will eventually live in the driver or elsewhere.
2981 void *swrast_context
;
2982 void *swsetup_context
;
2983 void *swtnl_context
;
2985 void *acache_context
;
2991 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2992 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2996 extern int MESA_VERBOSE
;
2997 extern int MESA_DEBUG_FLAGS
;
2998 # define MESA_FUNCTION __FUNCTION__
3000 # define MESA_VERBOSE 0
3001 # define MESA_DEBUG_FLAGS 0
3002 # define MESA_FUNCTION "a function"
3011 VERBOSE_VARRAY
= 0x0001,
3012 VERBOSE_TEXTURE
= 0x0002,
3013 VERBOSE_IMMEDIATE
= 0x0004,
3014 VERBOSE_PIPELINE
= 0x0008,
3015 VERBOSE_DRIVER
= 0x0010,
3016 VERBOSE_STATE
= 0x0020,
3017 VERBOSE_API
= 0x0040,
3018 VERBOSE_DISPLAY_LIST
= 0x0100,
3019 VERBOSE_LIGHTING
= 0x0200,
3020 VERBOSE_PRIMS
= 0x0400,
3021 VERBOSE_VERTS
= 0x0800,
3022 VERBOSE_DISASSEM
= 0x1000
3028 DEBUG_ALWAYS_FLUSH
= 0x1
3033 #define Elements(x) sizeof(x)/sizeof(*(x))
3036 #endif /* TYPES_H */