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-2007 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)))
218 * Indexes for vertex program result attributes
221 #define VERT_RESULT_HPOS 0
222 #define VERT_RESULT_COL0 1
223 #define VERT_RESULT_COL1 2
224 #define VERT_RESULT_FOGC 3
225 #define VERT_RESULT_TEX0 4
226 #define VERT_RESULT_TEX1 5
227 #define VERT_RESULT_TEX2 6
228 #define VERT_RESULT_TEX3 7
229 #define VERT_RESULT_TEX4 8
230 #define VERT_RESULT_TEX5 9
231 #define VERT_RESULT_TEX6 10
232 #define VERT_RESULT_TEX7 11
233 #define VERT_RESULT_PSIZ 12
234 #define VERT_RESULT_BFC0 13
235 #define VERT_RESULT_BFC1 14
236 #define VERT_RESULT_EDGE 15
237 #define VERT_RESULT_VAR0 16 /**< shader varying */
238 #define VERT_RESULT_MAX (VERT_RESULT_VAR0 + MAX_VARYING)
243 * Indexes for fragment program input attributes.
247 FRAG_ATTRIB_WPOS
= 0,
248 FRAG_ATTRIB_COL0
= 1,
249 FRAG_ATTRIB_COL1
= 2,
250 FRAG_ATTRIB_FOGC
= 3,
251 FRAG_ATTRIB_TEX0
= 4,
252 FRAG_ATTRIB_TEX1
= 5,
253 FRAG_ATTRIB_TEX2
= 6,
254 FRAG_ATTRIB_TEX3
= 7,
255 FRAG_ATTRIB_TEX4
= 8,
256 FRAG_ATTRIB_TEX5
= 9,
257 FRAG_ATTRIB_TEX6
= 10,
258 FRAG_ATTRIB_TEX7
= 11,
259 FRAG_ATTRIB_VAR0
= 12, /**< shader varying */
260 FRAG_ATTRIB_MAX
= (FRAG_ATTRIB_VAR0
+ MAX_VARYING
)
264 * Bitflags for fragment program input attributes.
267 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
268 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
269 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
270 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
271 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
272 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
273 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
274 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
275 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
276 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
277 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
278 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
280 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
292 * Fragment program results
296 FRAG_RESULT_COLR
= 0,
297 FRAG_RESULT_COLH
= 1,
298 FRAG_RESULT_DEPR
= 2,
304 * Indexes for all renderbuffers
307 BUFFER_FRONT_LEFT
= 0, /* the four standard color buffers */
308 BUFFER_BACK_LEFT
= 1,
309 BUFFER_FRONT_RIGHT
= 2,
310 BUFFER_BACK_RIGHT
= 3,
311 BUFFER_AUX0
= 4, /* optional aux buffer */
318 BUFFER_COLOR0
= 11, /* generic renderbuffers */
330 * Bit flags for all renderbuffers
332 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
333 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
334 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
335 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
336 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
337 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
338 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
339 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
340 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
341 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
342 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
343 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
344 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
345 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
346 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
347 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
348 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
349 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
350 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
353 * Mask of all the color buffer bits (but not accum).
355 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
356 BUFFER_BIT_BACK_LEFT | \
357 BUFFER_BIT_FRONT_RIGHT | \
358 BUFFER_BIT_BACK_RIGHT | \
363 BUFFER_BIT_COLOR0 | \
364 BUFFER_BIT_COLOR1 | \
365 BUFFER_BIT_COLOR2 | \
366 BUFFER_BIT_COLOR3 | \
367 BUFFER_BIT_COLOR4 | \
368 BUFFER_BIT_COLOR5 | \
369 BUFFER_BIT_COLOR6 | \
376 * Data structure for color tables
378 struct gl_color_table
380 GLenum InternalFormat
; /**< The user-specified format */
381 GLenum _BaseFormat
; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
382 GLuint Size
; /**< number of entries in table */
383 GLfloat
*TableF
; /**< Color table, floating point values */
384 GLubyte
*TableUB
; /**< Color table, ubyte values */
389 GLubyte LuminanceSize
;
390 GLubyte IntensitySize
;
395 * \name Bit flags used for updating material values.
398 #define MAT_ATTRIB_FRONT_AMBIENT 0
399 #define MAT_ATTRIB_BACK_AMBIENT 1
400 #define MAT_ATTRIB_FRONT_DIFFUSE 2
401 #define MAT_ATTRIB_BACK_DIFFUSE 3
402 #define MAT_ATTRIB_FRONT_SPECULAR 4
403 #define MAT_ATTRIB_BACK_SPECULAR 5
404 #define MAT_ATTRIB_FRONT_EMISSION 6
405 #define MAT_ATTRIB_BACK_EMISSION 7
406 #define MAT_ATTRIB_FRONT_SHININESS 8
407 #define MAT_ATTRIB_BACK_SHININESS 9
408 #define MAT_ATTRIB_FRONT_INDEXES 10
409 #define MAT_ATTRIB_BACK_INDEXES 11
410 #define MAT_ATTRIB_MAX 12
412 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
413 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
414 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
415 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
416 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
417 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
419 #define MAT_INDEX_AMBIENT 0
420 #define MAT_INDEX_DIFFUSE 1
421 #define MAT_INDEX_SPECULAR 2
423 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
424 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
425 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
426 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
427 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
428 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
429 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
430 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
431 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
432 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
433 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
434 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
437 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
438 MAT_BIT_FRONT_AMBIENT | \
439 MAT_BIT_FRONT_DIFFUSE | \
440 MAT_BIT_FRONT_SPECULAR | \
441 MAT_BIT_FRONT_SHININESS | \
442 MAT_BIT_FRONT_INDEXES)
444 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
445 MAT_BIT_BACK_AMBIENT | \
446 MAT_BIT_BACK_DIFFUSE | \
447 MAT_BIT_BACK_SPECULAR | \
448 MAT_BIT_BACK_SHININESS | \
449 MAT_BIT_BACK_INDEXES)
451 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
455 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
456 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
459 * Material shininess lookup table.
463 struct gl_shine_tab
*next
, *prev
;
464 GLfloat tab
[SHINE_TABLE_SIZE
+1];
471 * Light source state.
475 struct gl_light
*next
; /**< double linked list with sentinel */
476 struct gl_light
*prev
;
478 GLfloat Ambient
[4]; /**< ambient color */
479 GLfloat Diffuse
[4]; /**< diffuse color */
480 GLfloat Specular
[4]; /**< specular color */
481 GLfloat EyePosition
[4]; /**< position in eye coordinates */
482 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
483 GLfloat SpotExponent
;
484 GLfloat SpotCutoff
; /**< in degrees */
485 GLfloat _CosCutoffNeg
; /**< = cos(SpotCutoff) */
486 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
487 GLfloat ConstantAttenuation
;
488 GLfloat LinearAttenuation
;
489 GLfloat QuadraticAttenuation
;
490 GLboolean Enabled
; /**< On/off flag */
493 * \name Derived fields
496 GLbitfield _Flags
; /**< State */
498 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
499 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
500 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
501 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
502 GLfloat _VP_inf_spot_attenuation
;
504 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
505 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
506 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
507 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
508 GLfloat _dli
; /**< CI diffuse light intensity */
509 GLfloat _sli
; /**< CI specular light intensity */
519 GLfloat Ambient
[4]; /**< ambient color */
520 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
521 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
522 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
523 * or GL_SEPARATE_SPECULAR_COLOR */
532 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
537 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
539 struct gl_accum_attrib
541 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
546 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
548 struct gl_colorbuffer_attrib
550 GLuint ClearIndex
; /**< Index to use for glClear */
551 GLclampf ClearColor
[4]; /**< Color to use for glClear */
553 GLuint IndexMask
; /**< Color index write mask */
554 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
556 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
559 * \name alpha testing
562 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
563 GLenum AlphaFunc
; /**< Alpha test function */
564 GLclampf AlphaRef
; /**< Alpha reference value */
571 GLboolean BlendEnabled
; /**< Blending enabled flag */
572 GLenum BlendSrcRGB
; /**< Blending source operator */
573 GLenum BlendDstRGB
; /**< Blending destination operator */
574 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
575 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
576 GLenum BlendEquationRGB
; /**< Blending equation */
577 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
578 GLfloat BlendColor
[4]; /**< Blending color */
585 GLenum LogicOp
; /**< Logic operator */
586 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
587 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
588 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
591 GLboolean DitherFlag
; /**< Dither enable flag */
593 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
594 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
599 * Current attribute group (GL_CURRENT_BIT).
601 struct gl_current_attrib
604 * \name Current vertex attributes.
605 * \note Values are valid only after FLUSH_VERTICES has been called.
608 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Position, color, texcoords, etc */
609 GLfloat Index
; /**< Current color index */
610 GLboolean EdgeFlag
; /**< Current edge flag */
614 * \name Current raster position attributes (always valid).
615 * \note This set of attributes is very similar to the SWvertex struct.
618 GLfloat RasterPos
[4];
619 GLfloat RasterDistance
;
620 GLfloat RasterColor
[4];
621 GLfloat RasterSecondaryColor
[4];
623 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
624 GLboolean RasterPosValid
;
630 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
632 struct gl_depthbuffer_attrib
634 GLenum Func
; /**< Function for depth buffer compare */
635 GLclampd Clear
; /**< Value to clear depth buffer to */
636 GLboolean Test
; /**< Depth buffering enabled flag */
637 GLboolean Mask
; /**< Depth buffer writable? */
638 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
639 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
644 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
646 struct gl_enable_attrib
649 GLboolean AutoNormal
;
651 GLbitfield ClipPlanes
;
652 GLboolean ColorMaterial
;
653 GLboolean ColorTable
; /* SGI_color_table */
654 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
655 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
656 GLboolean Convolution1D
;
657 GLboolean Convolution2D
;
658 GLboolean Separable2D
;
664 GLboolean Light
[MAX_LIGHTS
];
666 GLboolean LineSmooth
;
667 GLboolean LineStipple
;
668 GLboolean IndexLogicOp
;
669 GLboolean ColorLogicOp
;
670 GLboolean Map1Color4
;
672 GLboolean Map1Normal
;
673 GLboolean Map1TextureCoord1
;
674 GLboolean Map1TextureCoord2
;
675 GLboolean Map1TextureCoord3
;
676 GLboolean Map1TextureCoord4
;
677 GLboolean Map1Vertex3
;
678 GLboolean Map1Vertex4
;
679 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
680 GLboolean Map2Color4
;
682 GLboolean Map2Normal
;
683 GLboolean Map2TextureCoord1
;
684 GLboolean Map2TextureCoord2
;
685 GLboolean Map2TextureCoord3
;
686 GLboolean Map2TextureCoord4
;
687 GLboolean Map2Vertex3
;
688 GLboolean Map2Vertex4
;
689 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
692 GLboolean PixelTexture
;
693 GLboolean PointSmooth
;
694 GLboolean PolygonOffsetPoint
;
695 GLboolean PolygonOffsetLine
;
696 GLboolean PolygonOffsetFill
;
697 GLboolean PolygonSmooth
;
698 GLboolean PolygonStipple
;
699 GLboolean RescaleNormals
;
702 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
703 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
704 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
705 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
706 GLboolean SampleCoverage
; /* GL_ARB_multisample */
707 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
708 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
709 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
710 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
711 /* SGI_texture_color_table */
712 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
713 /* GL_ARB_vertex_program / GL_NV_vertex_program */
714 GLboolean VertexProgram
;
715 GLboolean VertexProgramPointSize
;
716 GLboolean VertexProgramTwoSide
;
717 /* GL_ARB_point_sprite / GL_NV_point_sprite */
718 GLboolean PointSprite
;
719 GLboolean FragmentShaderATI
;
724 * Evaluator attribute group (GL_EVAL_BIT).
726 struct gl_eval_attrib
732 GLboolean Map1Color4
;
734 GLboolean Map1Normal
;
735 GLboolean Map1TextureCoord1
;
736 GLboolean Map1TextureCoord2
;
737 GLboolean Map1TextureCoord3
;
738 GLboolean Map1TextureCoord4
;
739 GLboolean Map1Vertex3
;
740 GLboolean Map1Vertex4
;
741 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
742 GLboolean Map2Color4
;
744 GLboolean Map2Normal
;
745 GLboolean Map2TextureCoord1
;
746 GLboolean Map2TextureCoord2
;
747 GLboolean Map2TextureCoord3
;
748 GLboolean Map2TextureCoord4
;
749 GLboolean Map2Vertex3
;
750 GLboolean Map2Vertex4
;
751 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
752 GLboolean AutoNormal
;
756 * \name Map Grid endpoints and divisions and calculated du values
760 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
761 GLint MapGrid2un
, MapGrid2vn
;
762 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
763 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
769 * Fog attribute group (GL_FOG_BIT).
773 GLboolean Enabled
; /**< Fog enabled flag */
774 GLfloat Color
[4]; /**< Fog color */
775 GLfloat Density
; /**< Density >= 0.0 */
776 GLfloat Start
; /**< Start distance in eye coords */
777 GLfloat End
; /**< End distance in eye coords */
778 GLfloat Index
; /**< Fog index */
779 GLenum Mode
; /**< Fog mode */
780 GLboolean ColorSumEnabled
;
781 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
782 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
787 * Hint attribute group (GL_HINT_BIT).
789 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
791 struct gl_hint_attrib
793 GLenum PerspectiveCorrection
;
796 GLenum PolygonSmooth
;
798 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
799 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
800 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
801 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
806 * Histogram attributes.
808 struct gl_histogram_attrib
810 GLuint Width
; /**< number of table entries */
811 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
812 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
813 GLboolean Sink
; /**< terminate image transfer? */
814 GLubyte RedSize
; /**< Bits per counter */
818 GLubyte LuminanceSize
;
823 * Color Min/max state.
825 struct gl_minmax_attrib
829 GLfloat Min
[4], Max
[4]; /**< RGBA */
834 * Image convolution state.
836 struct gl_convolution_attrib
839 GLenum InternalFormat
;
842 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
850 #define LIGHT_SPOT 0x1
851 #define LIGHT_LOCAL_VIEWER 0x2
852 #define LIGHT_POSITIONAL 0x4
853 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
858 * Lighting attribute group (GL_LIGHT_BIT).
860 struct gl_light_attrib
862 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
863 struct gl_lightmodel Model
; /**< Lighting model */
866 * Must flush FLUSH_VERTICES before referencing:
869 struct gl_material Material
; /**< Includes front & back values */
872 GLboolean Enabled
; /**< Lighting enabled flag */
873 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
874 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
875 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
876 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
877 GLboolean ColorMaterialEnabled
;
878 GLenum ClampVertexColor
;
880 struct gl_light EnabledList
; /**< List sentinel */
883 * Derived state for optimizations:
886 GLboolean _NeedEyeCoords
;
887 GLboolean _NeedVertices
; /**< Use fast shader? */
888 GLbitfield _Flags
; /**< LIGHT_* flags, see above */
889 GLfloat _BaseColor
[2][3];
895 * Line attribute group (GL_LINE_BIT).
897 struct gl_line_attrib
899 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
900 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
901 GLushort StipplePattern
; /**< Stipple pattern */
902 GLint StippleFactor
; /**< Stipple repeat factor */
903 GLfloat Width
; /**< Line width */
904 GLfloat _Width
; /**< Clamped Line width */
909 * Display list attribute group (GL_LIST_BIT).
911 struct gl_list_attrib
918 * Used by device drivers to hook new commands into display lists.
920 struct gl_list_instruction
923 void (*Execute
)( GLcontext
*ctx
, void *data
);
924 void (*Destroy
)( GLcontext
*ctx
, void *data
);
925 void (*Print
)( GLcontext
*ctx
, void *data
);
928 #define MAX_DLIST_EXT_OPCODES 16
931 * Used by device drivers to hook new commands into display lists.
933 struct gl_list_extensions
935 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
941 * Multisample attribute group (GL_MULTISAMPLE_BIT).
943 struct gl_multisample_attrib
946 GLboolean SampleAlphaToCoverage
;
947 GLboolean SampleAlphaToOne
;
948 GLboolean SampleCoverage
;
949 GLfloat SampleCoverageValue
;
950 GLboolean SampleCoverageInvert
;
955 * Pixel attribute group (GL_PIXEL_MODE_BIT).
957 struct gl_pixel_attrib
959 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
960 GLfloat RedBias
, RedScale
;
961 GLfloat GreenBias
, GreenScale
;
962 GLfloat BlueBias
, BlueScale
;
963 GLfloat AlphaBias
, AlphaScale
;
964 GLfloat DepthBias
, DepthScale
;
965 GLint IndexShift
, IndexOffset
;
966 GLboolean MapColorFlag
;
967 GLboolean MapStencilFlag
;
968 GLfloat ZoomX
, ZoomY
;
969 /* XXX move these out of gl_pixel_attrib */
970 GLint MapStoSsize
; /**< Size of each pixel map */
980 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
981 GLfloat MapItoI
[MAX_PIXEL_MAP_TABLE
];
982 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
983 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
984 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
985 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
986 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
987 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
988 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
989 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
990 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
991 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
992 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
993 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
994 /** GL_EXT_histogram */
995 GLboolean HistogramEnabled
;
996 GLboolean MinMaxEnabled
;
997 /** GL_SGI_color_matrix */
998 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
999 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
1000 /** GL_SGI_color_table */
1001 GLfloat ColorTableScale
[4];
1002 GLfloat ColorTableBias
[4];
1003 GLboolean ColorTableEnabled
;
1004 GLfloat PCCTscale
[4];
1005 GLfloat PCCTbias
[4];
1006 GLboolean PostConvolutionColorTableEnabled
;
1007 GLfloat PCMCTscale
[4];
1008 GLfloat PCMCTbias
[4];
1009 GLboolean PostColorMatrixColorTableEnabled
;
1010 /** GL_SGI_texture_color_table */
1011 GLfloat TextureColorTableScale
[4];
1012 GLfloat TextureColorTableBias
[4];
1014 GLboolean Convolution1DEnabled
;
1015 GLboolean Convolution2DEnabled
;
1016 GLboolean Separable2DEnabled
;
1017 GLfloat ConvolutionBorderColor
[3][4];
1018 GLenum ConvolutionBorderMode
[3];
1019 GLfloat ConvolutionFilterScale
[3][4];
1020 GLfloat ConvolutionFilterBias
[3][4];
1021 GLfloat PostConvolutionScale
[4]; /**< RGBA */
1022 GLfloat PostConvolutionBias
[4]; /**< RGBA */
1027 * Point attribute group (GL_POINT_BIT).
1029 struct gl_point_attrib
1031 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
1032 GLfloat Size
; /**< User-specified point size */
1033 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
1034 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
1035 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
1036 GLfloat Threshold
; /**< GL_EXT_point_parameters */
1037 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
1038 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
1039 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite */
1040 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
1041 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
1046 * Polygon attribute group (GL_POLYGON_BIT).
1048 struct gl_polygon_attrib
1050 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1051 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1052 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1053 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1054 GLboolean CullFlag
; /**< Culling on/off flag */
1055 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1056 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1057 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1058 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1059 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1060 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1061 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1062 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1067 * Scissor attributes (GL_SCISSOR_BIT).
1069 struct gl_scissor_attrib
1071 GLboolean Enabled
; /**< Scissor test enabled? */
1072 GLint X
, Y
; /**< Lower left corner of box */
1073 GLsizei Width
, Height
; /**< Size of box */
1078 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1080 struct gl_stencil_attrib
1082 GLboolean Enabled
; /**< Enabled flag */
1083 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1084 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1085 GLboolean _TestTwoSide
;
1086 GLenum Function
[2]; /**< Stencil function */
1087 GLenum FailFunc
[2]; /**< Fail function */
1088 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1089 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1090 GLint Ref
[2]; /**< Reference value */
1091 GLuint ValueMask
[2]; /**< Value mask */
1092 GLuint WriteMask
[2]; /**< Write mask */
1093 GLuint Clear
; /**< Clear value */
1097 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1100 * An index for each type of texture object
1103 #define TEXTURE_1D_INDEX 0
1104 #define TEXTURE_2D_INDEX 1
1105 #define TEXTURE_3D_INDEX 2
1106 #define TEXTURE_CUBE_INDEX 3
1107 #define TEXTURE_RECT_INDEX 4
1111 * Bit flags for each type of texture object
1112 * Used for Texture.Unit[]._ReallyEnabled flags.
1115 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1116 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1117 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1118 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1119 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1124 * TexGenEnabled flags.
1135 * Bit flag versions of the corresponding GL_ constants.
1138 #define TEXGEN_SPHERE_MAP 0x1
1139 #define TEXGEN_OBJ_LINEAR 0x2
1140 #define TEXGEN_EYE_LINEAR 0x4
1141 #define TEXGEN_REFLECTION_MAP_NV 0x8
1142 #define TEXGEN_NORMAL_MAP_NV 0x10
1144 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1145 TEXGEN_REFLECTION_MAP_NV | \
1146 TEXGEN_NORMAL_MAP_NV)
1147 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1148 TEXGEN_REFLECTION_MAP_NV | \
1149 TEXGEN_NORMAL_MAP_NV | \
1154 /* A selection of state flags to make driver and module's lives easier. */
1155 #define ENABLE_TEXGEN0 0x1
1156 #define ENABLE_TEXGEN1 0x2
1157 #define ENABLE_TEXGEN2 0x4
1158 #define ENABLE_TEXGEN3 0x8
1159 #define ENABLE_TEXGEN4 0x10
1160 #define ENABLE_TEXGEN5 0x20
1161 #define ENABLE_TEXGEN6 0x40
1162 #define ENABLE_TEXGEN7 0x80
1164 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1165 #define ENABLE_TEXMAT1 0x2
1166 #define ENABLE_TEXMAT2 0x4
1167 #define ENABLE_TEXMAT3 0x8
1168 #define ENABLE_TEXMAT4 0x10
1169 #define ENABLE_TEXMAT5 0x20
1170 #define ENABLE_TEXMAT6 0x40
1171 #define ENABLE_TEXMAT7 0x80
1173 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1174 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1178 * Texel fetch function prototype. We use texel fetch functions to
1179 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1180 * texture images. These functions help to isolate us from the gritty
1181 * details of all the various texture image encodings.
1183 * \param texImage texture image.
1184 * \param col texel column.
1185 * \param row texel row.
1186 * \param img texel image level/layer.
1187 * \param texelOut output texel (up to 4 GLchans)
1189 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1190 GLint col
, GLint row
, GLint img
,
1194 * As above, but returns floats.
1195 * Used for depth component images and for upcoming signed/float
1198 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1199 GLint col
, GLint row
, GLint img
,
1200 GLfloat
*texelOut
);
1203 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1204 GLint col
, GLint row
, GLint img
,
1209 * This macro defines the (many) parameters to the texstore functions.
1210 * \param dims either 1 or 2 or 3
1211 * \param baseInternalFormat user-specified base internal format
1212 * \param dstFormat destination Mesa texture format
1213 * \param dstAddr destination image address
1214 * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
1215 * \param dstRowStride destination image row stride, in bytes
1216 * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
1217 * \param srcWidth/Height/Depth source image size, in pixels
1218 * \param srcFormat incoming image format
1219 * \param srcType incoming image data type
1220 * \param srcAddr source image address
1221 * \param srcPacking source image packing parameters
1223 #define TEXSTORE_PARAMS \
1224 GLcontext *ctx, GLuint dims, \
1225 GLenum baseInternalFormat, \
1226 const struct gl_texture_format *dstFormat, \
1228 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
1229 GLint dstRowStride, const GLuint *dstImageOffsets, \
1230 GLint srcWidth, GLint srcHeight, GLint srcDepth, \
1231 GLenum srcFormat, GLenum srcType, \
1232 const GLvoid *srcAddr, \
1233 const struct gl_pixelstore_attrib *srcPacking
1238 * Texture image storage function.
1240 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
1244 * Texture format record
1246 struct gl_texture_format
1248 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1250 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1251 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1252 * GL_INTENSITY, GL_COLOR_INDEX or
1253 * GL_DEPTH_COMPONENT.
1255 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1256 GLubyte RedBits
; /**< Bits per texel component */
1257 GLubyte GreenBits
; /**< These are just rough approximations for */
1258 GLubyte BlueBits
; /**< compressed texture formats. */
1260 GLubyte LuminanceBits
;
1261 GLubyte IntensityBits
;
1264 GLubyte StencilBits
; /**< GL_EXT_packed_depth_stencil */
1266 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1268 StoreTexImageFunc StoreImage
;
1271 * \name Texel fetch function pointers
1274 FetchTexelFuncC FetchTexel1D
;
1275 FetchTexelFuncC FetchTexel2D
;
1276 FetchTexelFuncC FetchTexel3D
;
1277 FetchTexelFuncF FetchTexel1Df
;
1278 FetchTexelFuncF FetchTexel2Df
;
1279 FetchTexelFuncF FetchTexel3Df
;
1282 StoreTexelFunc StoreTexel
;
1286 #define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
1289 * Texture image state. Describes the dimensions of a texture image,
1290 * the texel format and pointers to Texel Fetch functions.
1292 struct gl_texture_image
1294 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1295 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1296 * GL_INTENSITY, GL_COLOR_INDEX,
1297 * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
1298 * only. Used for choosing TexEnv arithmetic.
1300 GLint InternalFormat
; /**< Internal format as given by the user */
1301 GLuint Border
; /**< 0 or 1 */
1302 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1303 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1304 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1305 GLuint Width2
; /**< = Width - 2*Border */
1306 GLuint Height2
; /**< = Height - 2*Border */
1307 GLuint Depth2
; /**< = Depth - 2*Border */
1308 GLuint WidthLog2
; /**< = log2(Width2) */
1309 GLuint HeightLog2
; /**< = log2(Height2) */
1310 GLuint DepthLog2
; /**< = log2(Depth2) */
1311 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1312 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1313 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1314 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1315 GLboolean IsClientData
; /**< Data owned by client? */
1316 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1318 const struct gl_texture_format
*TexFormat
;
1320 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1322 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1323 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1325 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1326 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1328 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1329 GLuint
*ImageOffsets
; /**< if 3D texture: array [Depth] of offsets to
1330 each 2D slice in 'Data', in texels */
1331 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1334 * \name For device driver:
1337 void *DriverData
; /**< Arbitrary device driver data */
1343 * Indexes for cube map faces.
1346 #define FACE_POS_X 0
1347 #define FACE_NEG_X 1
1348 #define FACE_POS_Y 2
1349 #define FACE_NEG_Y 3
1350 #define FACE_POS_Z 4
1351 #define FACE_NEG_Z 5
1357 * Texture object state. Contains the array of mipmap images, border color,
1358 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1361 struct gl_texture_object
1363 _glthread_Mutex Mutex
; /**< for thread safety */
1364 GLint RefCount
; /**< reference count */
1365 GLuint Name
; /**< the user-visible texture object ID */
1366 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1367 GLfloat Priority
; /**< in [0,1] */
1368 GLfloat BorderColor
[4]; /**< unclamped */
1369 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1370 GLenum WrapS
; /**< S-axis texture image wrap mode */
1371 GLenum WrapT
; /**< T-axis texture image wrap mode */
1372 GLenum WrapR
; /**< R-axis texture image wrap mode */
1373 GLenum MinFilter
; /**< minification filter */
1374 GLenum MagFilter
; /**< magnification filter */
1375 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1376 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1377 GLfloat LodBias
; /**< OpenGL 1.4 */
1378 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1379 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1380 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1381 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1382 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1383 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1384 GLenum CompareMode
; /**< GL_ARB_shadow */
1385 GLenum CompareFunc
; /**< GL_ARB_shadow */
1386 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1387 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1388 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1389 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1390 GLboolean Complete
; /**< Is texture object complete? */
1392 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1393 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1395 /** GL_EXT_paletted_texture */
1396 struct gl_color_table Palette
;
1400 * \name For device driver.
1401 * Note: instead of attaching driver data to this pointer, it's preferable
1402 * to instead use this struct as a base class for your own texture object
1403 * class. Driver->NewTextureObject() can be used to implement the
1406 void *DriverData
; /**< Arbitrary device driver data */
1411 * Texture combine environment state.
1414 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1415 * structure will need to be expanded for 4 elements.
1417 struct gl_tex_env_combine_state
1419 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1420 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1421 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1422 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1423 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1424 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1425 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1426 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1427 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1428 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1433 * Texture unit state. Contains enable flags, texture environment/function/
1434 * combiners, texgen state, pointers to current texture objects and
1435 * post-filter color tables.
1437 struct gl_texture_unit
1439 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1440 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1442 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1443 GLfloat EnvColor
[4];
1444 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1445 /** \name Tex coord generation mode
1446 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1453 GLbitfield _GenBitS
;
1454 GLbitfield _GenBitT
;
1455 GLbitfield _GenBitR
;
1456 GLbitfield _GenBitQ
;
1457 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1458 GLfloat ObjectPlaneS
[4];
1459 GLfloat ObjectPlaneT
[4];
1460 GLfloat ObjectPlaneR
[4];
1461 GLfloat ObjectPlaneQ
[4];
1462 GLfloat EyePlaneS
[4];
1463 GLfloat EyePlaneT
[4];
1464 GLfloat EyePlaneR
[4];
1465 GLfloat EyePlaneQ
[4];
1466 GLfloat LodBias
; /**< for biasing mipmap levels */
1469 * \name GL_EXT_texture_env_combine
1471 struct gl_tex_env_combine_state Combine
;
1474 * Derived state based on \c EnvMode and the \c BaseFormat of the
1475 * currently enabled texture.
1477 struct gl_tex_env_combine_state _EnvMode
;
1480 * Currently enabled combiner state. This will point to either
1481 * \c Combine or \c _EnvMode.
1483 struct gl_tex_env_combine_state
*_CurrentCombine
;
1485 struct gl_texture_object
*Current1D
;
1486 struct gl_texture_object
*Current2D
;
1487 struct gl_texture_object
*Current3D
;
1488 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1489 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1491 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1493 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1494 struct gl_texture_object Saved2D
;
1495 struct gl_texture_object Saved3D
;
1496 struct gl_texture_object SavedCubeMap
;
1497 struct gl_texture_object SavedRect
;
1499 /* GL_SGI_texture_color_table */
1500 struct gl_color_table ColorTable
;
1501 struct gl_color_table ProxyColorTable
;
1502 GLboolean ColorTableEnabled
;
1505 struct texenvprog_cache_item
{
1508 struct gl_fragment_program
*data
;
1509 struct texenvprog_cache_item
*next
;
1512 struct texenvprog_cache
{
1513 struct texenvprog_cache_item
**items
;
1514 GLuint size
, n_items
;
1519 * Texture attribute group (GL_TEXTURE_BIT).
1521 struct gl_texture_attrib
1527 GLuint CurrentUnit
; /**< Active texture unit */
1528 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1529 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1530 GLbitfield _GenFlags
; /**< for texgen */
1531 GLbitfield _TexGenEnabled
;
1532 GLbitfield _TexMatEnabled
;
1535 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1537 struct gl_texture_object
*Proxy1D
;
1538 struct gl_texture_object
*Proxy2D
;
1539 struct gl_texture_object
*Proxy3D
;
1540 struct gl_texture_object
*ProxyCubeMap
;
1541 struct gl_texture_object
*ProxyRect
;
1543 /** GL_EXT_shared_texture_palette */
1544 GLboolean SharedPalette
;
1545 struct gl_color_table Palette
;
1547 /** Cached texenv fragment programs */
1548 struct texenvprog_cache env_fp_cache
;
1553 * Transformation attribute group (GL_TRANSFORM_BIT).
1555 struct gl_transform_attrib
1557 GLenum MatrixMode
; /**< Matrix mode */
1558 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1559 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1560 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1561 GLboolean Normalize
; /**< Normalize all normals? */
1562 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1563 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1565 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1566 GLfloat CullEyePos
[4];
1567 GLfloat CullObjPos
[4];
1572 * Viewport attribute group (GL_VIEWPORT_BIT).
1574 struct gl_viewport_attrib
1576 GLint X
, Y
; /**< position */
1577 GLsizei Width
, Height
; /**< size */
1578 GLfloat Near
, Far
; /**< Depth buffer range */
1579 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1584 * Node for the attribute stack.
1586 struct gl_attrib_node
1590 struct gl_attrib_node
*next
;
1595 * GL_ARB_vertex/pixel_buffer_object buffer object
1597 struct gl_buffer_object
1603 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1604 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1605 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1606 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1612 * Client pixel packing/unpacking attributes
1614 struct gl_pixelstore_attrib
1620 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1621 GLint SkipImages
; /**< for GL_EXT_texture3D */
1622 GLboolean SwapBytes
;
1624 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1625 GLboolean Invert
; /**< GL_MESA_pack_invert */
1626 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1630 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1634 * Client vertex array attributes
1636 struct gl_client_array
1638 GLint Size
; /**< components per element (1,2,3,4) */
1639 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1640 GLsizei Stride
; /**< user-specified stride */
1641 GLsizei StrideB
; /**< actual stride in bytes */
1642 const GLubyte
*Ptr
; /**< Points to array data */
1643 GLbitfield Enabled
; /**< one of the _NEW_ARRAY_ bits */
1644 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1646 /**< GL_ARB_vertex_buffer_object */
1647 struct gl_buffer_object
*BufferObj
;
1655 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1656 * extension, but a nice encapsulation in any case.
1658 struct gl_array_object
1660 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1663 /** Conventional vertex arrays */
1665 struct gl_client_array Vertex
;
1666 struct gl_client_array Normal
;
1667 struct gl_client_array Color
;
1668 struct gl_client_array SecondaryColor
;
1669 struct gl_client_array FogCoord
;
1670 struct gl_client_array Index
;
1671 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1672 struct gl_client_array EdgeFlag
;
1675 /** Generic arrays for vertex programs/shaders */
1676 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
];
1678 /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
1679 GLbitfield _Enabled
;
1684 * Vertex array state
1686 struct gl_array_attrib
1688 struct gl_array_object
*ArrayObj
;
1689 struct gl_array_object
*DefaultArrayObj
;
1691 GLint ActiveTexture
; /**< Client Active Texture */
1692 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1693 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1695 GLbitfield NewState
; /**< mask of _NEW_ARRAY_* values */
1697 #if FEATURE_ARB_vertex_buffer_object
1698 struct gl_buffer_object
*NullBufferObj
;
1699 struct gl_buffer_object
*ArrayBufferObj
;
1700 struct gl_buffer_object
*ElementArrayBufferObj
;
1702 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1707 * Feedback buffer state
1712 GLbitfield _Mask
; /* FB_* bits */
1720 * Selection buffer state
1724 GLuint
*Buffer
; /**< selection buffer */
1725 GLuint BufferSize
; /**< size of the selection buffer */
1726 GLuint BufferCount
; /**< number of values in the selection buffer */
1727 GLuint Hits
; /**< number of records in the selection buffer */
1728 GLuint NameStackDepth
; /**< name stack depth */
1729 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1730 GLboolean HitFlag
; /**< hit flag */
1731 GLfloat HitMinZ
; /**< minimum hit depth */
1732 GLfloat HitMaxZ
; /**< maximum hit depth */
1737 * 1-D Evaluator control points
1741 GLuint Order
; /**< Number of control points */
1742 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1743 GLfloat
*Points
; /**< Points to contiguous control points */
1748 * 2-D Evaluator control points
1752 GLuint Uorder
; /**< Number of control points in U dimension */
1753 GLuint Vorder
; /**< Number of control points in V dimension */
1756 GLfloat
*Points
; /**< Points to contiguous control points */
1761 * All evaluator control point state
1763 struct gl_evaluators
1769 struct gl_1d_map Map1Vertex3
;
1770 struct gl_1d_map Map1Vertex4
;
1771 struct gl_1d_map Map1Index
;
1772 struct gl_1d_map Map1Color4
;
1773 struct gl_1d_map Map1Normal
;
1774 struct gl_1d_map Map1Texture1
;
1775 struct gl_1d_map Map1Texture2
;
1776 struct gl_1d_map Map1Texture3
;
1777 struct gl_1d_map Map1Texture4
;
1778 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1785 struct gl_2d_map Map2Vertex3
;
1786 struct gl_2d_map Map2Vertex4
;
1787 struct gl_2d_map Map2Index
;
1788 struct gl_2d_map Map2Color4
;
1789 struct gl_2d_map Map2Normal
;
1790 struct gl_2d_map Map2Texture1
;
1791 struct gl_2d_map Map2Texture2
;
1792 struct gl_2d_map Map2Texture3
;
1793 struct gl_2d_map Map2Texture4
;
1794 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1800 * Names of the various vertex/fragment program register files, etc.
1802 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1803 * All values should fit in a 4-bit field.
1805 * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
1806 * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
1807 * be "uniform" variables since they can only be set outside glBegin/End.
1808 * They're also all stored in the same Parameters array.
1812 PROGRAM_TEMPORARY
= 0, /**< machine->Temporary[] */
1813 PROGRAM_LOCAL_PARAM
= 1, /**< gl_program->LocalParams[] */
1814 PROGRAM_ENV_PARAM
= 2, /**< gl_program->Parameters[] */
1815 PROGRAM_STATE_VAR
= 3, /**< gl_program->Parameters[] */
1816 PROGRAM_INPUT
= 4, /**< machine->Inputs[] */
1817 PROGRAM_OUTPUT
= 5, /**< machine->Outputs[] */
1818 PROGRAM_NAMED_PARAM
= 6, /**< gl_program->Parameters[] */
1819 PROGRAM_CONSTANT
= 7, /**< gl_program->Parameters[] */
1820 PROGRAM_UNIFORM
= 8, /**< gl_program->Parameters[] */
1821 PROGRAM_VARYING
= 9, /**< machine->Inputs[]/Outputs[] */
1822 PROGRAM_WRITE_ONLY
= 10, /**< A dummy, write-only register */
1823 PROGRAM_ADDRESS
= 11, /**< machine->AddressReg */
1824 PROGRAM_UNDEFINED
= 12, /**< Invalid value */
1829 /** Vertex and fragment instructions */
1830 struct prog_instruction
;
1831 struct gl_program_parameter_list
;
1835 * Base class for any kind of program object
1840 GLubyte
*String
; /**< Null-terminated program text */
1843 GLenum Format
; /**< String encoding format */
1846 struct prog_instruction
*Instructions
;
1848 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1849 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1851 /** Named parameters, constants, etc. from program text */
1852 struct gl_program_parameter_list
*Parameters
;
1853 /** Numbered local parameters */
1854 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1856 /** Vertex/fragment shader varying vars */
1857 struct gl_program_parameter_list
*Varying
;
1859 /** Logical counts */
1861 GLuint NumInstructions
;
1862 GLuint NumTemporaries
;
1863 GLuint NumParameters
;
1864 GLuint NumAttributes
;
1865 GLuint NumAddressRegs
;
1867 /** Native, actual h/w counts */
1869 GLuint NumNativeInstructions
;
1870 GLuint NumNativeTemporaries
;
1871 GLuint NumNativeParameters
;
1872 GLuint NumNativeAttributes
;
1873 GLuint NumNativeAddressRegs
;
1878 /** Vertex program object */
1879 struct gl_vertex_program
1881 struct gl_program Base
; /**< base class */
1882 GLboolean IsNVProgram
; /**< is this a GL_NV_vertex_program program? */
1883 GLboolean IsPositionInvariant
;
1884 void *TnlData
; /**< should probably use Base.DriverData */
1888 /** Fragment program object */
1889 struct gl_fragment_program
1891 struct gl_program Base
; /**< base class */
1892 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
1893 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1894 GLuint NumTexInstructions
;
1895 GLuint NumTexIndirections
;
1896 GLuint NumNativeAluInstructions
; /**< GL_ARB_fragment_program */
1897 GLuint NumNativeTexInstructions
;
1898 GLuint NumNativeTexIndirections
;
1905 * State common to vertex and fragment programs.
1907 struct gl_program_state
1909 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1910 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1915 * Context state for vertex programs.
1917 struct gl_vertex_program_state
1919 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_ARB/NV */
1920 GLboolean _Enabled
; /**< Enabled and valid program? */
1921 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1922 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1923 struct gl_vertex_program
*Current
; /**< ptr to currently bound program */
1925 /** Currently enabled and valid program (including internal programs) */
1926 struct gl_vertex_program
*_Current
;
1928 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /**< Env params */
1930 /* For GL_NV_vertex_program only: */
1931 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1932 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1934 /** Should fixed-function T&L be implemented with a vertex prog? */
1935 GLboolean _MaintainTnlProgram
;
1937 /** Program to emulate fixed-function T&L (see above) */
1938 struct gl_vertex_program
*_TnlProgram
;
1940 #if FEATURE_MESA_program_debug
1941 GLprogramcallbackMESA Callback
;
1942 GLvoid
*CallbackData
;
1943 GLboolean CallbackEnabled
;
1944 GLuint CurrentPosition
;
1950 * Context state for fragment programs.
1952 struct gl_fragment_program_state
1954 GLboolean Enabled
; /**< User-set fragment program enable flag */
1955 GLboolean _Enabled
; /**< Fragment program enabled and valid? */
1956 struct gl_fragment_program
*Current
; /**< User-bound program */
1958 /** Currently enabled and valid program (including internal programs) */
1959 struct gl_fragment_program
*_Current
;
1961 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /**< Env params */
1963 /** Should fixed-function texturing be implemented with a fragment prog? */
1964 GLboolean _MaintainTexEnvProgram
;
1966 /** Program to emulate fixed-function texture env/combine (see above) */
1967 struct gl_fragment_program
*_TexEnvProgram
;
1969 #if FEATURE_MESA_program_debug
1970 GLprogramcallbackMESA Callback
;
1971 GLvoid
*CallbackData
;
1972 GLboolean CallbackEnabled
;
1973 GLuint CurrentPosition
;
1979 * ATI_fragment_shader runtime state
1981 #define ATI_FS_INPUT_PRIMARY 0
1982 #define ATI_FS_INPUT_SECONDARY 1
1984 struct atifs_instruction
;
1985 struct atifs_setupinst
;
1988 * ATI fragment shader
1990 struct ati_fragment_shader
1994 struct atifs_instruction
*Instructions
[2];
1995 struct atifs_setupinst
*SetupInst
[2];
1996 GLfloat Constants
[8][4];
1997 GLbitfield LocalConstDef
; /** Indicates which constants have been set */
1998 GLubyte numArithInstr
[2];
1999 GLubyte regsAssigned
[2];
2000 GLubyte NumPasses
; /** 1 or 2 */
2002 GLubyte last_optype
;
2003 GLboolean interpinp1
;
2009 * Context state for GL_ATI_fragment_shader
2011 struct gl_ati_fragment_shader_state
2014 GLboolean _Enabled
; /** enabled and valid shader? */
2015 GLboolean Compiling
;
2016 GLfloat GlobalConstants
[8][4];
2017 struct ati_fragment_shader
*Current
;
2022 * Occlusion/timer query object.
2024 struct gl_query_object
2027 GLuint64EXT Result
; /* the counter */
2028 GLboolean Active
; /* inside Begin/EndQuery */
2029 GLboolean Ready
; /* result is ready */
2034 * Context state for query objects.
2036 struct gl_query_state
2038 struct _mesa_HashTable
*QueryObjects
;
2039 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2040 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2046 * A GLSL shader object
2047 * A collection of one or more gl_programs...
2051 GLenum Type
; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER */
2052 GLuint Name
; /**< AKA the handle */
2053 GLchar
*Source
; /**< Source code string */
2054 GLboolean CompileStatus
;
2055 GLboolean DeletePending
;
2056 GLuint NumPrograms
; /**< size of Programs[] array */
2057 struct gl_program
**Programs
; /**< Post-compile assembly code */
2063 * This corresponds to a GLSL "program" and is basically a linked collection
2064 * of "shaders" (which are Mesa gl_programs).
2065 * Yes, the terminology is a bit confusing.
2067 struct gl_linked_program
2070 GLuint Name
; /**< aka handle or ID */
2071 GLuint NumShaders
; /**< total number of shaders in this program */
2072 struct gl_program
**Shaders
; /**< List of the shaders */
2073 struct gl_vertex_program
*VertexProgram
; /**< Linked vertex program */
2074 struct gl_fragment_program
*FragmentProgram
; /**< Linked fragment prog */
2075 struct gl_program_parameter_list
*Uniforms
; /**< Plus constants, etc */
2076 struct gl_program_parameter_list
*Varying
;
2077 struct gl_program_parameter_list
*Attributes
; /**< Vertex attributes */
2078 GLboolean LinkStatus
; /**< GL_LINK_STATUS */
2079 GLboolean Validated
;
2080 GLboolean DeletePending
;
2086 * Context state for GLSL vertex/fragment shaders.
2088 struct gl_shader_state
2090 GLboolean _VertexShaderPresent
;
2091 GLboolean _FragmentShaderPresent
;
2092 struct gl_linked_program
*CurrentProgram
;
2097 * State which can be shared by multiple contexts:
2099 struct gl_shared_state
2101 _glthread_Mutex Mutex
; /**< for thread safety */
2102 GLint RefCount
; /**< Reference count */
2103 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2104 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2107 * \name Default texture objects (shared by all multi-texture units)
2110 struct gl_texture_object
*Default1D
;
2111 struct gl_texture_object
*Default2D
;
2112 struct gl_texture_object
*Default3D
;
2113 struct gl_texture_object
*DefaultCubeMap
;
2114 struct gl_texture_object
*DefaultRect
;
2118 * \name Thread safety and statechange notification for texture
2121 * \todo Improve the granularity of locking.
2124 _glthread_Mutex TexMutex
; /**< texobj thread safety */
2125 GLuint TextureStateStamp
; /**< state notification for shared tex */
2131 * \name Vertex/fragment programs
2134 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
2135 #if FEATURE_ARB_vertex_program
2136 struct gl_program
*DefaultVertexProgram
;
2138 #if FEATURE_ARB_fragment_program
2139 struct gl_program
*DefaultFragmentProgram
;
2143 #if FEATURE_ATI_fragment_shader
2144 struct _mesa_HashTable
*ATIShaders
;
2145 struct ati_fragment_shader
*DefaultFragmentShader
;
2148 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2149 struct _mesa_HashTable
*BufferObjects
;
2152 #if FEATURE_ARB_shader_objects
2153 struct _mesa_HashTable
*ShaderObjects
;
2154 struct _mesa_HashTable
*ProgramObjects
;
2157 #if FEATURE_EXT_framebuffer_object
2158 struct _mesa_HashTable
*RenderBuffers
;
2159 struct _mesa_HashTable
*FrameBuffers
;
2162 /** Objects associated with the GL_APPLE_vertex_array_object extension. */
2163 struct _mesa_HashTable
*ArrayObjects
;
2165 void *DriverData
; /**< Device driver shared state */
2172 * A renderbuffer stores colors or depth values or stencil values.
2173 * A framebuffer object will have a collection of these.
2174 * Data are read/written to the buffer with a handful of Get/Put functions.
2176 * Instances of this object are allocated with the Driver's NewRenderbuffer
2177 * hook. Drivers will likely wrap this class inside a driver-specific
2178 * class to simulate inheritance.
2180 struct gl_renderbuffer
2182 _glthread_Mutex Mutex
; /**< for thread safety */
2183 GLuint ClassID
; /**< Useful for drivers */
2186 GLuint Width
, Height
;
2187 GLenum InternalFormat
; /**< The user-specified format */
2188 GLenum _ActualFormat
; /**< The driver-chosen format */
2189 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2190 GL_STENCIL_INDEX. */
2191 GLenum DataType
; /**< Type of values passed to the Get/Put functions */
2192 GLubyte RedBits
; /**< Bits of red per pixel */
2198 GLubyte StencilBits
;
2201 /* Used to wrap one renderbuffer around another: */
2202 struct gl_renderbuffer
*Wrapped
;
2204 /* Delete this renderbuffer */
2205 void (*Delete
)(struct gl_renderbuffer
*rb
);
2207 /* Allocate new storage for this renderbuffer */
2208 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2209 GLenum internalFormat
,
2210 GLuint width
, GLuint height
);
2212 /* Lock/Unlock are called before/after calling the Get/Put functions.
2213 * Not sure this is the right place for these yet.
2214 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2215 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2218 /* Return a pointer to the element/pixel at (x,y).
2219 * Should return NULL if the buffer memory can't be directly addressed.
2221 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2224 /* Get/Read a row of values.
2225 * The values will be of format _BaseFormat and type DataType.
2227 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2228 GLint x
, GLint y
, void *values
);
2230 /* Get/Read values at arbitrary locations.
2231 * The values will be of format _BaseFormat and type DataType.
2233 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2234 const GLint x
[], const GLint y
[], void *values
);
2236 /* Put/Write a row of values.
2237 * The values will be of format _BaseFormat and type DataType.
2239 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2240 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2242 /* Put/Write a row of RGB values. This is a special-case routine that's
2243 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2244 * a common case for glDrawPixels and some triangle routines.
2245 * The values will be of format GL_RGB and type DataType.
2247 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2248 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2251 /* Put/Write a row of identical values.
2252 * The values will be of format _BaseFormat and type DataType.
2254 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2255 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2257 /* Put/Write values at arbitrary locations.
2258 * The values will be of format _BaseFormat and type DataType.
2260 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2261 const GLint x
[], const GLint y
[], const void *values
,
2262 const GLubyte
*mask
);
2263 /* Put/Write identical values at arbitrary locations.
2264 * The values will be of format _BaseFormat and type DataType.
2266 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2267 GLuint count
, const GLint x
[], const GLint y
[],
2268 const void *value
, const GLubyte
*mask
);
2273 * A renderbuffer attachment point points to either a texture object
2274 * (and specifies a mipmap level, cube face or 3D texture slice) or
2275 * points to a renderbuffer.
2277 struct gl_renderbuffer_attachment
2279 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2282 /* IF Type == GL_RENDERBUFFER_EXT: */
2283 struct gl_renderbuffer
*Renderbuffer
;
2285 /* IF Type == GL_TEXTURE: */
2286 struct gl_texture_object
*Texture
;
2287 GLuint TextureLevel
;
2288 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2289 GLuint Zoffset
; /* for 3D textures */
2294 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2295 * In C++ terms, think of this as a base class from which device drivers
2296 * will make derived classes.
2298 struct gl_framebuffer
2300 _glthread_Mutex Mutex
; /**< for thread safety */
2301 GLuint Name
; /* if zero, this is a window system framebuffer */
2304 GLvisual Visual
; /**< The framebuffer's visual.
2305 Immutable if this is a window system buffer.
2306 Computed from attachments if user-made FBO. */
2308 GLboolean Initialized
;
2310 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2312 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2314 GLint _Xmin
, _Xmax
; /**< inclusive */
2315 GLint _Ymin
, _Ymax
; /**< exclusive */
2318 /** \name Derived Z buffer stuff */
2320 GLuint _DepthMax
; /**< Max depth buffer value */
2321 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2322 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2325 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2327 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2328 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2330 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2331 * attribute group and GL_PIXEL attribute group, respectively.
2333 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2334 GLenum ColorReadBuffer
;
2336 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2337 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2338 GLint _ColorReadBufferIndex
; /* -1 = None */
2340 /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
2341 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2342 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2343 struct gl_renderbuffer
*_ColorReadBuffer
;
2345 /** The Actual depth/stencil buffers to use. May be wrappers around the
2346 * depth/stencil buffers attached above. */
2347 struct gl_renderbuffer
*_DepthBuffer
;
2348 struct gl_renderbuffer
*_StencilBuffer
;
2350 /** Delete this framebuffer */
2351 void (*Delete
)(struct gl_framebuffer
*fb
);
2356 * Limits for vertex and fragment programs.
2358 struct gl_program_constants
2360 /* logical limits */
2361 GLuint MaxInstructions
;
2362 GLuint MaxAluInstructions
; /* fragment programs only, for now */
2363 GLuint MaxTexInstructions
; /* fragment programs only, for now */
2364 GLuint MaxTexIndirections
; /* fragment programs only, for now */
2367 GLuint MaxAddressRegs
; /* vertex program only, for now */
2368 GLuint MaxParameters
;
2369 GLuint MaxLocalParams
;
2370 GLuint MaxEnvParams
;
2371 /* native/hardware limits */
2372 GLuint MaxNativeInstructions
;
2373 GLuint MaxNativeAluInstructions
; /* fragment programs only, for now */
2374 GLuint MaxNativeTexInstructions
; /* fragment programs only, for now */
2375 GLuint MaxNativeTexIndirections
; /* fragment programs only, for now */
2376 GLuint MaxNativeAttribs
;
2377 GLuint MaxNativeTemps
;
2378 GLuint MaxNativeAddressRegs
; /* vertex program only, for now */
2379 GLuint MaxNativeParameters
;
2381 GLuint MaxUniformComponents
;
2386 * Constants which may be overridden by device driver during context creation
2387 * but are never changed after that.
2391 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2392 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2393 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2394 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2395 GLuint MaxTextureCoordUnits
;
2396 GLuint MaxTextureImageUnits
;
2397 GLuint MaxTextureUnits
; /* = MIN(CoordUnits, ImageUnits) */
2398 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2399 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2400 GLuint MaxArrayLockSize
;
2402 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2403 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2404 GLfloat PointSizeGranularity
;
2405 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2406 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2407 GLfloat LineWidthGranularity
;
2408 GLuint MaxColorTableSize
;
2409 GLuint MaxConvolutionWidth
;
2410 GLuint MaxConvolutionHeight
;
2411 GLuint MaxClipPlanes
;
2413 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2414 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2415 GLuint MaxViewportWidth
, MaxViewportHeight
;
2416 struct gl_program_constants VertexProgram
; /* GL_ARB_vertex_program */
2417 struct gl_program_constants FragmentProgram
; /* GL_ARB_fragment_program */
2418 /* shared by vertex and fragment program: */
2419 GLuint MaxProgramMatrices
;
2420 GLuint MaxProgramMatrixStackDepth
;
2421 /* vertex array / buffer object bounds checking */
2422 GLboolean CheckArrayBounds
;
2423 /* GL_ARB_draw_buffers */
2424 GLuint MaxDrawBuffers
;
2425 /* GL_OES_read_format */
2426 GLenum ColorReadFormat
;
2427 GLenum ColorReadType
;
2428 /* GL_EXT_framebuffer_object */
2429 GLuint MaxColorAttachments
;
2430 GLuint MaxRenderbufferSize
;
2431 /* GL_ARB_vertex_shader */
2432 GLuint MaxVertexTextureImageUnits
;
2438 * Enable flag for each OpenGL extension. Different device drivers will
2439 * enable different extensions at runtime.
2441 struct gl_extensions
2444 * \name Flags to quickly test if certain extensions are available.
2446 * Not every extension needs to have such a flag, but it's encouraged.
2449 GLboolean dummy
; /* don't remove this! */
2450 GLboolean ARB_depth_texture
;
2451 GLboolean ARB_draw_buffers
;
2452 GLboolean ARB_fragment_program
;
2453 GLboolean ARB_fragment_shader
;
2454 GLboolean ARB_half_float_pixel
;
2455 GLboolean ARB_imaging
;
2456 GLboolean ARB_multisample
;
2457 GLboolean ARB_multitexture
;
2458 GLboolean ARB_occlusion_query
;
2459 GLboolean ARB_point_sprite
;
2460 GLboolean ARB_shader_objects
;
2461 GLboolean ARB_shading_language_100
;
2462 GLboolean ARB_shading_language_120
;
2463 GLboolean ARB_shadow
;
2464 GLboolean ARB_texture_border_clamp
;
2465 GLboolean ARB_texture_compression
;
2466 GLboolean ARB_texture_cube_map
;
2467 GLboolean ARB_texture_env_combine
;
2468 GLboolean ARB_texture_env_crossbar
;
2469 GLboolean ARB_texture_env_dot3
;
2470 GLboolean ARB_texture_float
;
2471 GLboolean ARB_texture_mirrored_repeat
;
2472 GLboolean ARB_texture_non_power_of_two
;
2473 GLboolean ARB_transpose_matrix
;
2474 GLboolean ARB_vertex_buffer_object
;
2475 GLboolean ARB_vertex_program
;
2476 GLboolean ARB_vertex_shader
;
2477 GLboolean ARB_window_pos
;
2480 GLboolean EXT_blend_color
;
2481 GLboolean EXT_blend_equation_separate
;
2482 GLboolean EXT_blend_func_separate
;
2483 GLboolean EXT_blend_logic_op
;
2484 GLboolean EXT_blend_minmax
;
2485 GLboolean EXT_blend_subtract
;
2486 GLboolean EXT_clip_volume_hint
;
2487 GLboolean EXT_cull_vertex
;
2488 GLboolean EXT_convolution
;
2489 GLboolean EXT_compiled_vertex_array
;
2490 GLboolean EXT_copy_texture
;
2491 GLboolean EXT_depth_bounds_test
;
2492 GLboolean EXT_draw_range_elements
;
2493 GLboolean EXT_framebuffer_object
;
2494 GLboolean EXT_fog_coord
;
2495 GLboolean EXT_framebuffer_blit
;
2496 GLboolean EXT_gpu_program_parameters
;
2497 GLboolean EXT_histogram
;
2498 GLboolean EXT_multi_draw_arrays
;
2499 GLboolean EXT_paletted_texture
;
2500 GLboolean EXT_packed_depth_stencil
;
2501 GLboolean EXT_packed_pixels
;
2502 GLboolean EXT_pixel_buffer_object
;
2503 GLboolean EXT_point_parameters
;
2504 GLboolean EXT_polygon_offset
;
2505 GLboolean EXT_rescale_normal
;
2506 GLboolean EXT_shadow_funcs
;
2507 GLboolean EXT_secondary_color
;
2508 GLboolean EXT_separate_specular_color
;
2509 GLboolean EXT_shared_texture_palette
;
2510 GLboolean EXT_stencil_wrap
;
2511 GLboolean EXT_stencil_two_side
;
2512 GLboolean EXT_subtexture
;
2513 GLboolean EXT_texture
;
2514 GLboolean EXT_texture_object
;
2515 GLboolean EXT_texture3D
;
2516 GLboolean EXT_texture_compression_s3tc
;
2517 GLboolean EXT_texture_env_add
;
2518 GLboolean EXT_texture_env_combine
;
2519 GLboolean EXT_texture_env_dot3
;
2520 GLboolean EXT_texture_filter_anisotropic
;
2521 GLboolean EXT_texture_lod_bias
;
2522 GLboolean EXT_texture_mirror_clamp
;
2523 GLboolean EXT_texture_sRGB
;
2524 GLboolean EXT_timer_query
;
2525 GLboolean EXT_vertex_array
;
2526 GLboolean EXT_vertex_array_set
;
2527 /* vendor extensions */
2528 GLboolean APPLE_client_storage
;
2529 GLboolean APPLE_packed_pixels
;
2530 GLboolean APPLE_vertex_array_object
;
2531 GLboolean ATI_texture_mirror_once
;
2532 GLboolean ATI_texture_env_combine3
;
2533 GLboolean ATI_fragment_shader
;
2534 GLboolean IBM_rasterpos_clip
;
2535 GLboolean IBM_multimode_draw_arrays
;
2536 GLboolean MESA_pack_invert
;
2537 GLboolean MESA_packed_depth_stencil
;
2538 GLboolean MESA_program_debug
;
2539 GLboolean MESA_resize_buffers
;
2540 GLboolean MESA_ycbcr_texture
;
2541 GLboolean NV_blend_square
;
2542 GLboolean NV_fragment_program
;
2543 GLboolean NV_light_max_exponent
;
2544 GLboolean NV_point_sprite
;
2545 GLboolean NV_texgen_reflection
;
2546 GLboolean NV_texture_rectangle
;
2547 GLboolean NV_vertex_program
;
2548 GLboolean NV_vertex_program1_1
;
2549 GLboolean OES_read_format
;
2550 GLboolean SGI_color_matrix
;
2551 GLboolean SGI_color_table
;
2552 GLboolean SGI_texture_color_table
;
2553 GLboolean SGIS_generate_mipmap
;
2554 GLboolean SGIS_texture_edge_clamp
;
2555 GLboolean SGIS_texture_lod
;
2556 GLboolean SGIX_depth_texture
;
2557 GLboolean SGIX_shadow
;
2558 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2559 GLboolean TDFX_texture_compression_FXT1
;
2562 /* The extension string */
2563 const GLubyte
*String
;
2568 * A stack of matrices (projection, modelview, color, texture, etc).
2572 GLmatrix
*Top
; /**< points into Stack */
2573 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2574 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2575 GLuint MaxDepth
; /**< size of Stack[] array */
2576 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2581 * \name Bits for image transfer operations
2583 * \sa __GLcontextRec::ImageTransferState.
2586 #define IMAGE_SCALE_BIAS_BIT 0x1
2587 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2588 #define IMAGE_MAP_COLOR_BIT 0x4
2589 #define IMAGE_COLOR_TABLE_BIT 0x8
2590 #define IMAGE_CONVOLUTION_BIT 0x10
2591 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2592 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2593 #define IMAGE_COLOR_MATRIX_BIT 0x80
2594 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2595 #define IMAGE_HISTOGRAM_BIT 0x200
2596 #define IMAGE_MIN_MAX_BIT 0x400
2597 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2600 /** Pixel Transfer ops up to convolution */
2601 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2602 IMAGE_SHIFT_OFFSET_BIT | \
2603 IMAGE_MAP_COLOR_BIT | \
2604 IMAGE_COLOR_TABLE_BIT)
2606 /** Pixel transfer ops after convolution */
2607 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2608 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2609 IMAGE_COLOR_MATRIX_BIT | \
2610 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2611 IMAGE_HISTOGRAM_BIT | \
2617 * \name Bits to indicate what state has changed.
2622 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2623 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2624 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2625 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2626 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2627 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2628 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2629 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2630 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2631 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2632 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2633 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2634 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2635 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2636 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2637 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2638 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2639 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2640 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2641 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2642 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2643 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2644 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2645 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2646 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2647 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2648 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2649 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2655 * \name Bits to track array state changes
2657 * Also used to summarize array enabled.
2660 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2661 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2662 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2663 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2664 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2665 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2666 #define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
2667 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2668 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2669 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2670 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2671 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2672 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2673 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2674 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2675 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2676 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2677 #define _NEW_ARRAY_ALL 0xffffffff
2680 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2681 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2686 * \name A bunch of flags that we think might be useful to drivers.
2688 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2691 #define DD_FLATSHADE 0x1
2692 #define DD_SEPARATE_SPECULAR 0x2
2693 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2694 #define DD_TRI_LIGHT_TWOSIDE 0x8
2695 #define DD_TRI_UNFILLED 0x10
2696 #define DD_TRI_SMOOTH 0x20
2697 #define DD_TRI_STIPPLE 0x40
2698 #define DD_TRI_OFFSET 0x80
2699 #define DD_LINE_SMOOTH 0x100
2700 #define DD_LINE_STIPPLE 0x200
2701 #define DD_LINE_WIDTH 0x400
2702 #define DD_POINT_SMOOTH 0x800
2703 #define DD_POINT_SIZE 0x1000
2704 #define DD_POINT_ATTEN 0x2000
2705 #define DD_TRI_TWOSTENCIL 0x4000
2710 * \name Define the state changes under which each of these bits might change
2713 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2714 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2715 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2716 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2717 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2718 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2719 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2720 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2721 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2722 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2723 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2724 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2725 #define _DD_NEW_POINT_SIZE _NEW_POINT
2726 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2730 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2735 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2738 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2744 * Forward declaration of display list data types:
2747 typedef union node Node
;
2750 /* This has to be included here. */
2754 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2757 * Core Mesa's support for tnl modules:
2759 struct gl_tnl_module
2762 * Vertex format to be lazily swapped into current dispatch.
2764 const GLvertexformat
*Current
;
2767 * \name Record of functions swapped out.
2768 * On restore, only need to swap these functions back in.
2772 _glapi_proc
* location
;
2773 _glapi_proc function
;
2774 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2779 /* Strictly this is a tnl/ private concept, but it doesn't seem
2780 * worthwhile adding a tnl private structure just to hold this one bit
2783 #define MESA_DLIST_DANGLING_REFS 0x1
2785 /* Provide a location where information about a display list can be
2786 * collected. Could be extended with driverPrivate structures,
2787 * etc. in the future.
2789 struct mesa_display_list
2798 * State used during display list compilation and execution.
2800 struct mesa_list_state
2802 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2803 GLuint CallDepth
; /**< Current recursion calling depth */
2805 struct mesa_display_list
*CurrentList
;
2806 Node
*CurrentListPtr
; /**< Head of list being compiled */
2807 GLuint CurrentListNum
; /**< Number of the list being compiled */
2808 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2809 GLuint CurrentPos
; /**< Index into current block of nodes */
2811 GLvertexformat ListVtxfmt
;
2813 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2814 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2816 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2817 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2819 GLubyte ActiveIndex
;
2820 GLfloat CurrentIndex
;
2822 GLubyte ActiveEdgeFlag
;
2823 GLboolean CurrentEdgeFlag
;
2828 * Mesa rendering context.
2830 * This is the central context data structure for Mesa. Almost all
2831 * OpenGL state is contained in this structure.
2832 * Think of this as a base class from which device drivers will derive
2835 * The GLcontext typedef names this structure.
2837 struct __GLcontextRec
2840 * \name OS related interfaces.
2842 * These \b must be the first members of this structure, because they are
2843 * exposed to the outside world (i.e. GLX extension).
2846 __GLimports imports
;
2847 __GLexports exports
;
2850 /** State possibly shared with other contexts in the address space */
2851 struct gl_shared_state
*Shared
;
2853 /** \name API function pointer tables */
2855 struct _glapi_table
*Save
; /**< Display list save functions */
2856 struct _glapi_table
*Exec
; /**< Execute functions */
2857 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2861 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2862 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2863 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2864 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2867 * Device driver function pointer table
2869 struct dd_function_table Driver
;
2871 void *DriverCtx
; /**< Points to device driver context/state */
2872 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2874 /** Core/Driver constants */
2875 struct gl_constants Const
;
2877 /** \name The various 4x4 matrix stacks */
2879 struct matrix_stack ModelviewMatrixStack
;
2880 struct matrix_stack ProjectionMatrixStack
;
2881 struct matrix_stack ColorMatrixStack
;
2882 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2883 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2884 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2887 /** Combined modelview and projection matrix */
2888 GLmatrix _ModelProjectMatrix
;
2890 /** \name Display lists */
2891 struct mesa_list_state ListState
;
2893 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2894 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2896 /** Extension information */
2897 struct gl_extensions Extensions
;
2899 /** \name State attribute stack (for glPush/PopAttrib) */
2901 GLuint AttribStackDepth
;
2902 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2905 /** \name Renderer attribute groups
2907 * We define a struct for each attribute group to make pushing and popping
2908 * attributes easy. Also it's a good organization.
2911 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
2912 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
2913 struct gl_current_attrib Current
; /**< Current attributes */
2914 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2915 struct gl_eval_attrib Eval
; /**< Eval attributes */
2916 struct gl_fog_attrib Fog
; /**< Fog attributes */
2917 struct gl_hint_attrib Hint
; /**< Hint attributes */
2918 struct gl_light_attrib Light
; /**< Light attributes */
2919 struct gl_line_attrib Line
; /**< Line attributes */
2920 struct gl_list_attrib List
; /**< List attributes */
2921 struct gl_multisample_attrib Multisample
;
2922 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2923 struct gl_point_attrib Point
; /**< Point attributes */
2924 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2925 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2926 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2927 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2928 struct gl_texture_attrib Texture
; /**< Texture attributes */
2929 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2930 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2933 /** \name Client attribute stack */
2935 GLuint ClientAttribStackDepth
;
2936 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2939 /** \name Client attribute groups */
2941 struct gl_array_attrib Array
; /**< Vertex arrays */
2942 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2943 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2944 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2947 /** \name Other assorted state (not pushed/popped on attribute stack) */
2949 struct gl_histogram_attrib Histogram
;
2950 struct gl_minmax_attrib MinMax
;
2951 struct gl_convolution_attrib Convolution1D
;
2952 struct gl_convolution_attrib Convolution2D
;
2953 struct gl_convolution_attrib Separable2D
;
2955 struct gl_evaluators EvalMap
; /**< All evaluators */
2956 struct gl_feedback Feedback
; /**< Feedback */
2957 struct gl_selection Select
; /**< Selection */
2959 struct gl_color_table ColorTable
; /**< Pre-convolution */
2960 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2961 struct gl_color_table PostConvolutionColorTable
;
2962 struct gl_color_table ProxyPostConvolutionColorTable
;
2963 struct gl_color_table PostColorMatrixColorTable
;
2964 struct gl_color_table ProxyPostColorMatrixColorTable
;
2966 struct gl_program_state Program
; /**< for vertex or fragment progs */
2967 struct gl_vertex_program_state VertexProgram
; /**< GL_ARB/NV_vertex_program */
2968 struct gl_fragment_program_state FragmentProgram
; /**< GL_ARB/NV_vertex_program */
2969 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2971 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2973 struct gl_shader_state Shader
; /**< GLSL shader object state */
2976 #if FEATURE_EXT_framebuffer_object
2977 struct gl_renderbuffer
*CurrentRenderbuffer
;
2980 GLenum ErrorValue
; /**< Last error code */
2981 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2982 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2984 /** \name Derived state */
2986 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2987 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2988 GLfloat _EyeZDir
[3];
2989 GLfloat _ModelViewInvScale
;
2990 GLboolean _NeedEyeCoords
;
2991 GLboolean _ForceEyeCoords
;
2992 GLenum _CurrentProgram
; /* currently executing program */
2994 GLuint TextureStateTimestamp
; /* detect changes to shared state */
2996 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2997 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
3000 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
3003 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
3005 * We don't have a better way to communicate this value from
3006 * swrast_setup to swrast. */
3008 /** \name For debugging/development only */
3010 GLboolean FirstTimeCurrent
;
3013 /** Dither disable via MESA_NO_DITHER env var */
3016 /** software compression/decompression supported or not */
3017 GLboolean Mesa_DXTn
;
3019 /** Core tnl module support */
3020 struct gl_tnl_module TnlModule
;
3023 * \name Hooks for module contexts.
3025 * These will eventually live in the driver or elsewhere.
3028 void *swrast_context
;
3029 void *swsetup_context
;
3030 void *swtnl_context
;
3032 void *acache_context
;
3038 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
3039 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
3043 extern int MESA_VERBOSE
;
3044 extern int MESA_DEBUG_FLAGS
;
3045 # define MESA_FUNCTION __FUNCTION__
3047 # define MESA_VERBOSE 0
3048 # define MESA_DEBUG_FLAGS 0
3049 # define MESA_FUNCTION "a function"
3058 VERBOSE_VARRAY
= 0x0001,
3059 VERBOSE_TEXTURE
= 0x0002,
3060 VERBOSE_IMMEDIATE
= 0x0004,
3061 VERBOSE_PIPELINE
= 0x0008,
3062 VERBOSE_DRIVER
= 0x0010,
3063 VERBOSE_STATE
= 0x0020,
3064 VERBOSE_API
= 0x0040,
3065 VERBOSE_DISPLAY_LIST
= 0x0100,
3066 VERBOSE_LIGHTING
= 0x0200,
3067 VERBOSE_PRIMS
= 0x0400,
3068 VERBOSE_VERTS
= 0x0800,
3069 VERBOSE_DISASSEM
= 0x1000
3075 DEBUG_ALWAYS_FLUSH
= 0x1
3080 #define Elements(x) sizeof(x)/sizeof(*(x))
3083 #endif /* TYPES_H */