7cc01fef843ac291a3c31b11f6f2ef889783c52a
[reactos.git] / reactos / dll / opengl / mesa / main / mtypes.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.7
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /**
27 * \file mtypes.h
28 * Main Mesa data structures.
29 *
30 * Please try to mark derived values with a leading underscore ('_').
31 */
32
33 #ifndef MTYPES_H
34 #define MTYPES_H
35
36
37 #include "main/glheader.h"
38 #include "main/config.h"
39 #include "main/mfeatures.h"
40 #include "math/m_matrix.h" /* GLmatrix */
41 #include "main/simple_list.h" /* struct simple_node */
42 #include "main/formats.h" /* MESA_FORMAT_COUNT */
43
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49
50 /**
51 * \name 64-bit extension of GLbitfield.
52 */
53 /*@{*/
54 typedef GLuint64 GLbitfield64;
55
56 /** Set a single bit */
57 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
58 /** Set all bits up to excluding bit b */
59 #define BITFIELD64_MASK(b) \
60 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
61 /** Set count bits starting from bit b */
62 #define BITFIELD64_RANGE(b, count) \
63 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
64
65
66 /**
67 * \name Some forward type declarations
68 */
69 /*@{*/
70 struct _mesa_HashTable;
71 struct gl_attrib_node;
72 struct gl_list_extensions;
73 struct gl_meta_state;
74 struct gl_texture_object;
75 struct gl_context;
76 struct st_context;
77 /*@}*/
78
79
80 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
81 #define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1)
82 #define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2)
83 #define PRIM_UNKNOWN (GL_POLYGON+3)
84
85
86
87 /**
88 * Indexes for vertex program attributes.
89 * GL_NV_vertex_program aliases generic attributes over the conventional
90 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
91 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
92 * generic attributes are distinct/separate).
93 */
94 typedef enum
95 {
96 VERT_ATTRIB_POS = 0,
97 VERT_ATTRIB_WEIGHT = 1,
98 VERT_ATTRIB_NORMAL = 2,
99 VERT_ATTRIB_COLOR0 = 3,
100 VERT_ATTRIB_COLOR1 = 4,
101 VERT_ATTRIB_FOG = 5,
102 VERT_ATTRIB_COLOR_INDEX = 6,
103 VERT_ATTRIB_EDGEFLAG = 7,
104 VERT_ATTRIB_TEX = 8,
105 VERT_ATTRIB_POINT_SIZE = 9,
106 VERT_ATTRIB_MAX = 10
107 } gl_vert_attrib;
108
109 /**
110 * Symbolic constats to help iterating over
111 * specific blocks of vertex attributes.
112 *
113 */
114 #define VERT_ATTRIB(i) (VERT_ATTRIB_POS + (i))
115
116 /**
117 * Bitflags for vertex attributes.
118 * These are used in bitfields in many places.
119 */
120 /*@{*/
121 #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
122 #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
123 #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
124 #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
125 #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
126 #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
127 #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
128 #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
129 #define VERT_BIT_TEX BITFIELD64_BIT(VERT_ATTRIB_TEX)
130 #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
131
132 #define VERT_BIT(i) BITFIELD64_BIT(i)
133 #define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1)
134
135 /*@}*/
136
137
138 /**
139 * Indexes for fragment program input attributes. Note that
140 * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make
141 * assumptions about the layout of this enum.
142 */
143 typedef enum
144 {
145 FRAG_ATTRIB_WPOS = 0,
146 FRAG_ATTRIB_COL0 = 1,
147 FRAG_ATTRIB_COL1 = 2,
148 FRAG_ATTRIB_FOGC = 3,
149 FRAG_ATTRIB_TEX = 4,
150 FRAG_ATTRIB_FACE = 5, /**< front/back face */
151 FRAG_ATTRIB_PNTC = 6, /**< sprite/point coord */
152 FRAG_ATTRIB_CLIP_DIST0 = 7,
153 FRAG_ATTRIB_CLIP_DIST1 = 8,
154 FRAG_ATTRIB_MAX = 9
155 } gl_frag_attrib;
156
157
158 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
159 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
160 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
161 #define FRAG_BIT_TEX (1 << FRAG_ATTRIB_TEX)
162
163 /**
164 * Indexes for all renderbuffers
165 */
166 typedef enum
167 {
168 /* the four standard color buffers */
169 BUFFER_FRONT_LEFT,
170 BUFFER_BACK_LEFT,
171 BUFFER_FRONT_RIGHT,
172 BUFFER_BACK_RIGHT,
173 BUFFER_DEPTH,
174 BUFFER_STENCIL,
175 BUFFER_ACCUM,
176 /* optional aux buffer */
177 BUFFER_AUX0,
178 BUFFER_COUNT
179 } gl_buffer_index;
180
181 /**
182 * Bit flags for all renderbuffers
183 */
184 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
185 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
186 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
187 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
188 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
189 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
190 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
191 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
192 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
193 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
194 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
195
196 /**
197 * Mask of all the color buffer bits (but not accum).
198 */
199 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
200 BUFFER_BIT_BACK_LEFT | \
201 BUFFER_BIT_FRONT_RIGHT | \
202 BUFFER_BIT_BACK_RIGHT | \
203 BUFFER_BIT_AUX0)
204
205
206 /**
207 * Framebuffer configuration (aka visual / pixelformat)
208 * Note: some of these fields should be boolean, but it appears that
209 * code in drivers/dri/common/util.c requires int-sized fields.
210 */
211 struct gl_config
212 {
213 GLboolean rgbMode;
214 GLboolean colorIndexMode; /* XXX is this used anywhere? */
215 GLuint doubleBufferMode;
216 GLuint stereoMode;
217
218 GLboolean haveAccumBuffer;
219 GLboolean haveDepthBuffer;
220 GLboolean haveStencilBuffer;
221
222 GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
223 GLuint redMask, greenMask, blueMask, alphaMask;
224 GLint rgbBits; /* total bits for rgb */
225 GLint indexBits; /* total bits for colorindex */
226
227 GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
228 GLint depthBits;
229 GLint stencilBits;
230
231 GLint numAuxBuffers;
232
233 GLint level;
234
235 /* EXT_visual_rating / GLX 1.2 */
236 GLint visualRating;
237
238 /* EXT_visual_info / GLX 1.2 */
239 GLint transparentPixel;
240 /* colors are floats scaled to ints */
241 GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
242 GLint transparentIndex;
243
244 /* SGIX_pbuffer / GLX 1.3 */
245 GLint maxPbufferWidth;
246 GLint maxPbufferHeight;
247 GLint maxPbufferPixels;
248 GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
249 GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
250
251 /* OML_swap_method */
252 GLint swapMethod;
253
254 /* EXT_texture_from_pixmap */
255 GLint bindToTextureRgb;
256 GLint bindToTextureRgba;
257 GLint bindToMipmapTexture;
258 GLint bindToTextureTargets;
259 GLint yInverted;
260 };
261
262
263 /**
264 * \name Bit flags used for updating material values.
265 */
266 /*@{*/
267 #define MAT_ATTRIB_FRONT_AMBIENT 0
268 #define MAT_ATTRIB_BACK_AMBIENT 1
269 #define MAT_ATTRIB_FRONT_DIFFUSE 2
270 #define MAT_ATTRIB_BACK_DIFFUSE 3
271 #define MAT_ATTRIB_FRONT_SPECULAR 4
272 #define MAT_ATTRIB_BACK_SPECULAR 5
273 #define MAT_ATTRIB_FRONT_EMISSION 6
274 #define MAT_ATTRIB_BACK_EMISSION 7
275 #define MAT_ATTRIB_FRONT_SHININESS 8
276 #define MAT_ATTRIB_BACK_SHININESS 9
277 #define MAT_ATTRIB_FRONT_INDEXES 10
278 #define MAT_ATTRIB_BACK_INDEXES 11
279 #define MAT_ATTRIB_MAX 12
280
281 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
282 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
283 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
284 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
285 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
286 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
287
288 #define MAT_INDEX_AMBIENT 0
289 #define MAT_INDEX_DIFFUSE 1
290 #define MAT_INDEX_SPECULAR 2
291
292 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
293 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
294 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
295 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
296 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
297 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
298 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
299 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
300 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
301 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
302 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
303 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
304
305
306 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
307 MAT_BIT_FRONT_AMBIENT | \
308 MAT_BIT_FRONT_DIFFUSE | \
309 MAT_BIT_FRONT_SPECULAR | \
310 MAT_BIT_FRONT_SHININESS | \
311 MAT_BIT_FRONT_INDEXES)
312
313 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
314 MAT_BIT_BACK_AMBIENT | \
315 MAT_BIT_BACK_DIFFUSE | \
316 MAT_BIT_BACK_SPECULAR | \
317 MAT_BIT_BACK_SHININESS | \
318 MAT_BIT_BACK_INDEXES)
319
320 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
321 /*@}*/
322
323
324 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
325 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
326
327 /**
328 * Material shininess lookup table.
329 */
330 struct gl_shine_tab
331 {
332 struct gl_shine_tab *next, *prev;
333 GLfloat tab[SHINE_TABLE_SIZE+1];
334 GLfloat shininess;
335 GLuint refcount;
336 };
337
338
339 /**
340 * Light source state.
341 */
342 struct gl_light
343 {
344 struct gl_light *next; /**< double linked list with sentinel */
345 struct gl_light *prev;
346
347 GLfloat Ambient[4]; /**< ambient color */
348 GLfloat Diffuse[4]; /**< diffuse color */
349 GLfloat Specular[4]; /**< specular color */
350 GLfloat EyePosition[4]; /**< position in eye coordinates */
351 GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */
352 GLfloat SpotExponent;
353 GLfloat SpotCutoff; /**< in degrees */
354 GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */
355 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
356 GLfloat ConstantAttenuation;
357 GLfloat LinearAttenuation;
358 GLfloat QuadraticAttenuation;
359 GLboolean Enabled; /**< On/off flag */
360
361 /**
362 * \name Derived fields
363 */
364 /*@{*/
365 GLbitfield _Flags; /**< State */
366
367 GLfloat _Position[4]; /**< position in eye/obj coordinates */
368 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
369 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
370 GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
371 GLfloat _VP_inf_spot_attenuation;
372
373 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
374 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
375 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
376 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
377 /*@}*/
378 };
379
380
381 /**
382 * Light model state.
383 */
384 struct gl_lightmodel
385 {
386 GLfloat Ambient[4]; /**< ambient color */
387 GLboolean LocalViewer; /**< Local (or infinite) view point? */
388 GLboolean TwoSide; /**< Two (or one) sided lighting? */
389 GLenum ColorControl; /**< either GL_SINGLE_COLOR
390 * or GL_SEPARATE_SPECULAR_COLOR */
391 };
392
393
394 /**
395 * Material state.
396 */
397 struct gl_material
398 {
399 GLfloat Attrib[MAT_ATTRIB_MAX][4];
400 };
401
402
403 /**
404 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
405 */
406 struct gl_accum_attrib
407 {
408 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
409 };
410
411
412 /**
413 * Used for storing clear color, texture border color, etc.
414 * The float values are typically unclamped.
415 */
416 union gl_color_union
417 {
418 GLfloat f[4];
419 GLint i[4];
420 GLuint ui[4];
421 };
422
423
424 /**
425 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
426 */
427 struct gl_colorbuffer_attrib
428 {
429 GLuint ClearIndex; /**< Index for glClear */
430 union gl_color_union ClearColor; /**< Color for glClear, unclamped */
431 GLuint IndexMask; /**< Color index write mask */
432 GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
433
434 GLenum DrawBuffer; /**< Which buffer to draw into */
435
436 /**
437 * \name alpha testing
438 */
439 /*@{*/
440 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
441 GLenum AlphaFunc; /**< Alpha test function */
442 GLclampf AlphaRef; /**< Alpha reference value */
443 /*@}*/
444
445 /**
446 * \name Blending
447 */
448 /*@{*/
449 GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
450
451 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
452 * control, only on the fixed-pointness of the render target.
453 * The query does however depend on fragment color clamping.
454 */
455 GLfloat BlendColor[4]; /**< Blending color */
456
457 GLenum SrcRGB; /**< RGB blend source term */
458 GLenum DstRGB; /**< RGB blend dest term */
459 GLenum SrcA; /**< Alpha blend source term */
460 GLenum DstA; /**< Alpha blend dest term */
461 GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
462 GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
463 /*@}*/
464
465 /**
466 * \name Logic op
467 */
468 /*@{*/
469 GLenum LogicOp; /**< Logic operator */
470 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
471 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
472 /*@}*/
473
474 GLboolean DitherFlag; /**< Dither enable flag */
475 };
476
477
478 /**
479 * Current attribute group (GL_CURRENT_BIT).
480 */
481 struct gl_current_attrib
482 {
483 /**
484 * \name Current vertex attributes.
485 * \note Values are valid only after FLUSH_VERTICES has been called.
486 * \note Index and Edgeflag current values are stored as floats in the
487 * SIX and SEVEN attribute slots.
488 */
489 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
490
491 /**
492 * \name Current raster position attributes (always valid).
493 * \note This set of attributes is very similar to the SWvertex struct.
494 */
495 /*@{*/
496 GLfloat RasterPos[4];
497 GLfloat RasterDistance;
498 GLfloat RasterColor[4];
499 GLfloat RasterSecondaryColor[4];
500 GLfloat RasterTexCoords[4];
501 GLboolean RasterPosValid;
502 /*@}*/
503 };
504
505
506 /**
507 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
508 */
509 struct gl_depthbuffer_attrib
510 {
511 GLenum Func; /**< Function for depth buffer compare */
512 GLclampd Clear; /**< Value to clear depth buffer to */
513 GLboolean Test; /**< Depth buffering enabled flag */
514 GLboolean Mask; /**< Depth buffer writable? */
515 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
516 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
517 };
518
519
520 /**
521 * Evaluator attribute group (GL_EVAL_BIT).
522 */
523 struct gl_eval_attrib
524 {
525 /**
526 * \name Enable bits
527 */
528 /*@{*/
529 GLboolean Map1Color4;
530 GLboolean Map1Index;
531 GLboolean Map1Normal;
532 GLboolean Map1TextureCoord1;
533 GLboolean Map1TextureCoord2;
534 GLboolean Map1TextureCoord3;
535 GLboolean Map1TextureCoord4;
536 GLboolean Map1Vertex3;
537 GLboolean Map1Vertex4;
538 GLboolean Map2Color4;
539 GLboolean Map2Index;
540 GLboolean Map2Normal;
541 GLboolean Map2TextureCoord1;
542 GLboolean Map2TextureCoord2;
543 GLboolean Map2TextureCoord3;
544 GLboolean Map2TextureCoord4;
545 GLboolean Map2Vertex3;
546 GLboolean Map2Vertex4;
547 GLboolean AutoNormal;
548 /*@}*/
549
550 /**
551 * \name Map Grid endpoints and divisions and calculated du values
552 */
553 /*@{*/
554 GLint MapGrid1un;
555 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
556 GLint MapGrid2un, MapGrid2vn;
557 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
558 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
559 /*@}*/
560 };
561
562
563 /**
564 * Fog attribute group (GL_FOG_BIT).
565 */
566 struct gl_fog_attrib
567 {
568 GLboolean Enabled; /**< Fog enabled flag */
569 GLfloat Color[4]; /**< Fog color */
570 GLfloat Density; /**< Density >= 0.0 */
571 GLfloat Start; /**< Start distance in eye coords */
572 GLfloat End; /**< End distance in eye coords */
573 GLfloat Index; /**< Fog index */
574 GLenum Mode; /**< Fog mode */
575 GLboolean ColorSumEnabled;
576 GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
577 GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
578 GLenum FogDistanceMode; /**< GL_NV_fog_distance */
579 };
580
581
582 /**
583 * \brief Layout qualifiers for gl_FragDepth.
584 *
585 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
586 * a layout qualifier.
587 *
588 * \see enum ir_depth_layout
589 */
590 enum gl_frag_depth_layout {
591 FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
592 FRAG_DEPTH_LAYOUT_ANY,
593 FRAG_DEPTH_LAYOUT_GREATER,
594 FRAG_DEPTH_LAYOUT_LESS,
595 FRAG_DEPTH_LAYOUT_UNCHANGED
596 };
597
598
599 /**
600 * Hint attribute group (GL_HINT_BIT).
601 *
602 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
603 */
604 struct gl_hint_attrib
605 {
606 GLenum PerspectiveCorrection;
607 GLenum PointSmooth;
608 GLenum LineSmooth;
609 GLenum PolygonSmooth;
610 GLenum Fog;
611 GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
612 };
613
614 /**
615 * Light state flags.
616 */
617 /*@{*/
618 #define LIGHT_SPOT 0x1
619 #define LIGHT_LOCAL_VIEWER 0x2
620 #define LIGHT_POSITIONAL 0x4
621 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
622 /*@}*/
623
624
625 /**
626 * Lighting attribute group (GL_LIGHT_BIT).
627 */
628 struct gl_light_attrib
629 {
630 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
631 struct gl_lightmodel Model; /**< Lighting model */
632
633 /**
634 * Must flush FLUSH_VERTICES before referencing:
635 */
636 /*@{*/
637 struct gl_material Material; /**< Includes front & back values */
638 /*@}*/
639
640 GLboolean Enabled; /**< Lighting enabled flag */
641 GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
642 GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
643 GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
644 GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
645 GLboolean ColorMaterialEnabled;
646
647 struct gl_light EnabledList; /**< List sentinel */
648
649 /**
650 * Derived state for optimizations:
651 */
652 /*@{*/
653 GLboolean _NeedEyeCoords;
654 GLboolean _NeedVertices; /**< Use fast shader? */
655 GLbitfield _Flags; /**< LIGHT_* flags, see above */
656 GLfloat _BaseColor[2][3];
657 /*@}*/
658 };
659
660
661 /**
662 * Line attribute group (GL_LINE_BIT).
663 */
664 struct gl_line_attrib
665 {
666 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
667 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
668 GLushort StipplePattern; /**< Stipple pattern */
669 GLint StippleFactor; /**< Stipple repeat factor */
670 GLfloat Width; /**< Line width */
671 };
672
673
674 /**
675 * Display list attribute group (GL_LIST_BIT).
676 */
677 struct gl_list_attrib
678 {
679 GLuint ListBase;
680 };
681
682
683 /**
684 * Multisample attribute group (GL_MULTISAMPLE_BIT).
685 */
686 struct gl_multisample_attrib
687 {
688 GLboolean Enabled;
689 GLboolean _Enabled; /**< true if Enabled and multisample buffer */
690 GLboolean SampleAlphaToCoverage;
691 GLboolean SampleAlphaToOne;
692 GLboolean SampleCoverage;
693 GLfloat SampleCoverageValue;
694 GLboolean SampleCoverageInvert;
695 };
696
697
698 /**
699 * A pixelmap (see glPixelMap)
700 */
701 struct gl_pixelmap
702 {
703 GLint Size;
704 GLfloat Map[MAX_PIXEL_MAP_TABLE];
705 GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
706 };
707
708
709 /**
710 * Collection of all pixelmaps
711 */
712 struct gl_pixelmaps
713 {
714 struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
715 struct gl_pixelmap GtoG;
716 struct gl_pixelmap BtoB;
717 struct gl_pixelmap AtoA;
718 struct gl_pixelmap ItoR;
719 struct gl_pixelmap ItoG;
720 struct gl_pixelmap ItoB;
721 struct gl_pixelmap ItoA;
722 struct gl_pixelmap ItoI;
723 struct gl_pixelmap StoS;
724 };
725
726
727 /**
728 * Pixel attribute group (GL_PIXEL_MODE_BIT).
729 */
730 struct gl_pixel_attrib
731 {
732 GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
733
734 /*--- Begin Pixel Transfer State ---*/
735 /* Fields are in the order in which they're applied... */
736
737 /** Scale & Bias (index shift, offset) */
738 /*@{*/
739 GLfloat RedBias, RedScale;
740 GLfloat GreenBias, GreenScale;
741 GLfloat BlueBias, BlueScale;
742 GLfloat AlphaBias, AlphaScale;
743 GLfloat DepthBias, DepthScale;
744 GLint IndexShift, IndexOffset;
745 /*@}*/
746
747 /* Pixel Maps */
748 /* Note: actual pixel maps are not part of this attrib group */
749 GLboolean MapColorFlag;
750 GLboolean MapStencilFlag;
751
752 /*--- End Pixel Transfer State ---*/
753
754 /** glPixelZoom */
755 GLfloat ZoomX, ZoomY;
756 };
757
758
759 /**
760 * Point attribute group (GL_POINT_BIT).
761 */
762 struct gl_point_attrib
763 {
764 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
765 GLfloat Size; /**< User-specified point size */
766 GLfloat Params[3]; /**< GL_EXT_point_parameters */
767 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
768 GLfloat Threshold; /**< GL_EXT_point_parameters */
769 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
770 GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
771 GLboolean CoordReplace; /**< GL_ARB_point_sprite*/
772 GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
773 GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
774 };
775
776
777 /**
778 * Polygon attribute group (GL_POLYGON_BIT).
779 */
780 struct gl_polygon_attrib
781 {
782 GLenum FrontFace; /**< Either GL_CW or GL_CCW */
783 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
784 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
785 GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
786 GLboolean CullFlag; /**< Culling on/off flag */
787 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
788 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
789 GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
790 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
791 GLfloat OffsetUnits; /**< Polygon offset units, from user */
792 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
793 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
794 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
795 };
796
797
798 /**
799 * Scissor attributes (GL_SCISSOR_BIT).
800 */
801 struct gl_scissor_attrib
802 {
803 GLboolean Enabled; /**< Scissor test enabled? */
804 GLint X, Y; /**< Lower left corner of box */
805 GLsizei Width, Height; /**< Size of box */
806 };
807
808
809 /**
810 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
811 *
812 */
813 struct gl_stencil_attrib
814 {
815 GLboolean Enabled; /**< Enabled flag */
816 GLboolean _Enabled; /**< Enabled and stencil buffer present */
817 GLenum Function; /**< Stencil function */
818 GLenum FailFunc; /**< Fail function */
819 GLenum ZPassFunc; /**< Depth buffer pass function */
820 GLenum ZFailFunc; /**< Depth buffer fail function */
821 GLint Ref; /**< Reference value */
822 GLuint ValueMask; /**< Value mask */
823 GLuint WriteMask; /**< Write mask */
824 GLuint Clear; /**< Clear value */
825 };
826
827
828 /**
829 * An index for each type of texture object. These correspond to the GL
830 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
831 * Note: the order is from highest priority to lowest priority.
832 */
833 typedef enum
834 {
835 TEXTURE_CUBE_INDEX,
836 TEXTURE_3D_INDEX,
837 TEXTURE_2D_INDEX,
838 TEXTURE_1D_INDEX,
839 NUM_TEXTURE_TARGETS
840 } gl_texture_index;
841
842
843 /**
844 * Bit flags for each type of texture object
845 * Used for Texture.Unit[]._ReallyEnabled flags.
846 */
847 /*@{*/
848 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
849 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
850 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
851 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
852 /*@}*/
853
854
855 /**
856 * TexGenEnabled flags.
857 */
858 /*@{*/
859 #define S_BIT 1
860 #define T_BIT 2
861 #define R_BIT 4
862 #define Q_BIT 8
863 #define STR_BITS (S_BIT | T_BIT | R_BIT)
864 /*@}*/
865
866
867 /**
868 * Bit flag versions of the corresponding GL_ constants.
869 */
870 /*@{*/
871 #define TEXGEN_SPHERE_MAP 0x1
872 #define TEXGEN_OBJ_LINEAR 0x2
873 #define TEXGEN_EYE_LINEAR 0x4
874 #define TEXGEN_REFLECTION_MAP_NV 0x8
875 #define TEXGEN_NORMAL_MAP_NV 0x10
876
877 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
878 TEXGEN_REFLECTION_MAP_NV | \
879 TEXGEN_NORMAL_MAP_NV)
880 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
881 TEXGEN_REFLECTION_MAP_NV | \
882 TEXGEN_NORMAL_MAP_NV | \
883 TEXGEN_EYE_LINEAR)
884 /*@}*/
885
886
887
888 /** Tex-gen enabled for texture unit? */
889 #define ENABLE_TEXGEN(unit) (1 << (unit))
890
891 /** Non-identity texture matrix for texture unit? */
892 #define ENABLE_TEXMAT(unit) (1 << (unit))
893
894
895 /**
896 * Texture image state. Drivers will typically create a subclass of this
897 * with extra fields for memory buffers, etc.
898 */
899 struct gl_texture_image
900 {
901 GLint InternalFormat; /**< Internal format as given by the user */
902 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
903 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
904 * GL_INTENSITY, GL_DEPTH_COMPONENT or
905 * GL_DEPTH_STENCIL_EXT only. Used for
906 * choosing TexEnv arithmetic.
907 */
908 gl_format TexFormat; /**< The actual texture memory format */
909
910 GLuint Border; /**< 0 or 1 */
911 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
912 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
913 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
914 GLuint Width2; /**< = Width - 2*Border */
915 GLuint Height2; /**< = Height - 2*Border */
916 GLuint Depth2; /**< = Depth - 2*Border */
917 GLuint WidthLog2; /**< = log2(Width2) */
918 GLuint HeightLog2; /**< = log2(Height2) */
919 GLuint DepthLog2; /**< = log2(Depth2) */
920 GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
921
922 struct gl_texture_object *TexObject; /**< Pointer back to parent object */
923 GLuint Level; /**< Which mipmap level am I? */
924 /** Cube map face: index into gl_texture_object::Image[] array */
925 GLuint Face;
926 };
927
928
929 /**
930 * Indexes for cube map faces.
931 */
932 typedef enum
933 {
934 FACE_POS_X = 0,
935 FACE_NEG_X = 1,
936 FACE_POS_Y = 2,
937 FACE_NEG_Y = 3,
938 FACE_POS_Z = 4,
939 FACE_NEG_Z = 5,
940 MAX_FACES = 6
941 } gl_face_index;
942
943 /**
944 * Sampler object state. These objects are new with GL_ARB_sampler_objects
945 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
946 */
947 struct gl_sampler_object
948 {
949 GLuint Name;
950 GLint RefCount;
951
952 GLenum WrapS; /**< S-axis texture image wrap mode */
953 GLenum WrapT; /**< T-axis texture image wrap mode */
954 GLenum WrapR; /**< R-axis texture image wrap mode */
955 GLenum MinFilter; /**< minification filter */
956 GLenum MagFilter; /**< magnification filter */
957 union gl_color_union BorderColor; /**< Interpreted according to texture format */
958 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
959
960 };
961
962
963 /**
964 * Texture object state. Contains the array of mipmap images, border color,
965 * wrap modes, filter modes, and shadow/texcompare state.
966 */
967 struct gl_texture_object
968 {
969 _glthread_Mutex Mutex; /**< for thread safety */
970 GLint RefCount; /**< reference count */
971 GLuint Name; /**< the user-visible texture object ID */
972 GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
973
974 struct gl_sampler_object Sampler;
975
976 GLfloat Priority; /**< in [0,1] */
977 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
978 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
979 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
980 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
981 GLboolean _Complete; /**< Is texture object complete? */
982 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
983 GLboolean Immutable; /**< GL_ARB_texture_storage */
984
985 /** Actual texture images, indexed by [cube face] and [mipmap level] */
986 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
987 };
988
989
990 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
991 #define MAX_COMBINER_TERMS 4
992
993
994 /**
995 * Texture combine environment state.
996 */
997 struct gl_tex_env_combine_state
998 {
999 GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1000 GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1001 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1002 GLenum SourceRGB[MAX_COMBINER_TERMS];
1003 GLenum SourceA[MAX_COMBINER_TERMS];
1004 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1005 GLenum OperandRGB[MAX_COMBINER_TERMS];
1006 GLenum OperandA[MAX_COMBINER_TERMS];
1007 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1008 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1009 GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
1010 GLuint _NumArgsA; /**< Number of inputs used for the A combiner */
1011 };
1012
1013
1014 /**
1015 * Texture coord generation state.
1016 */
1017 struct gl_texgen
1018 {
1019 GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1020 GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
1021 GLfloat ObjectPlane[4];
1022 GLfloat EyePlane[4];
1023 };
1024
1025
1026 /**
1027 * Texture unit state. Contains enable flags, texture environment/function/
1028 * combiners, texgen state, and pointers to current texture objects.
1029 */
1030 struct gl_texture_unit
1031 {
1032 GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1033 GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1034
1035 GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1036 GLclampf EnvColor[4];
1037
1038 struct gl_texgen GenS;
1039 struct gl_texgen GenT;
1040 struct gl_texgen GenR;
1041 struct gl_texgen GenQ;
1042 GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1043 GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1044
1045 GLfloat LodBias; /**< for biasing mipmap levels */
1046
1047 /**
1048 * \name GL_EXT_texture_env_combine
1049 */
1050 struct gl_tex_env_combine_state Combine;
1051
1052 /**
1053 * Derived state based on \c EnvMode and the \c BaseFormat of the
1054 * currently enabled texture.
1055 */
1056 struct gl_tex_env_combine_state _EnvMode;
1057
1058 /**
1059 * Currently enabled combiner state. This will point to either
1060 * \c Combine or \c _EnvMode.
1061 */
1062 struct gl_tex_env_combine_state *_CurrentCombine;
1063
1064 /** Current texture object pointers */
1065 struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
1066
1067 /** Points to highest priority, complete and enabled texture object */
1068 struct gl_texture_object *_Current;
1069 };
1070
1071
1072 /**
1073 * Texture attribute group (GL_TEXTURE_BIT).
1074 */
1075 struct gl_texture_attrib
1076 {
1077 struct gl_texture_unit Unit;
1078
1079 struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
1080
1081 GLboolean _Enabled;
1082
1083 /** Texture coord units/sets used for fragment texturing */
1084 GLboolean _EnabledCoord;
1085
1086 /** Texture coord units that have texgen enabled */
1087 GLboolean _TexGenEnabled;
1088
1089 /** Texture coord units that have non-identity matrices */
1090 GLboolean _TexMatEnabled;
1091
1092 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1093 GLbitfield _GenFlags;
1094 };
1095
1096
1097 /**
1098 * Data structure representing a single clip plane (e.g. one of the elements
1099 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1100 */
1101 typedef GLfloat gl_clip_plane[4];
1102
1103
1104 /**
1105 * Transformation attribute group (GL_TRANSFORM_BIT).
1106 */
1107 struct gl_transform_attrib
1108 {
1109 GLenum MatrixMode; /**< Matrix mode */
1110 gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */
1111 gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
1112 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
1113 GLboolean Normalize; /**< Normalize all normals? */
1114 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1115 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1116
1117 GLfloat CullEyePos[4];
1118 GLfloat CullObjPos[4];
1119 };
1120
1121
1122 /**
1123 * Viewport attribute group (GL_VIEWPORT_BIT).
1124 */
1125 struct gl_viewport_attrib
1126 {
1127 GLint X, Y; /**< position */
1128 GLsizei Width, Height; /**< size */
1129 GLfloat Near, Far; /**< Depth buffer range */
1130 GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
1131 };
1132
1133
1134 /**
1135 * GL_ARB_vertex/pixel_buffer_object buffer object
1136 */
1137 struct gl_buffer_object
1138 {
1139 _glthread_Mutex Mutex;
1140 GLint RefCount;
1141 GLuint Name;
1142 GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1143 GLsizeiptrARB Size; /**< Size of buffer storage in bytes */
1144 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1145 /** Fields describing a mapped buffer */
1146 /*@{*/
1147 GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
1148 GLvoid *Pointer; /**< User-space address of mapping */
1149 GLintptr Offset; /**< Mapped offset */
1150 GLsizeiptr Length; /**< Mapped length */
1151 /*@}*/
1152 GLboolean DeletePending; /**< true if buffer object is removed from the hash */
1153 GLboolean Written; /**< Ever written to? (for debugging) */
1154 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1155 };
1156
1157
1158 /**
1159 * Client pixel packing/unpacking attributes
1160 */
1161 struct gl_pixelstore_attrib
1162 {
1163 GLint Alignment;
1164 GLint RowLength;
1165 GLint SkipPixels;
1166 GLint SkipRows;
1167 GLint ImageHeight;
1168 GLint SkipImages;
1169 GLboolean SwapBytes;
1170 GLboolean LsbFirst;
1171 GLboolean Invert; /**< GL_MESA_pack_invert */
1172 };
1173
1174
1175 /**
1176 * Client vertex array attributes
1177 */
1178 struct gl_client_array
1179 {
1180 GLint Size; /**< components per element (1,2,3,4) */
1181 GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
1182 GLsizei Stride; /**< user-specified stride */
1183 GLsizei StrideB; /**< actual stride in bytes */
1184 const GLubyte *Ptr; /**< Points to array data */
1185 GLboolean Enabled; /**< Enabled flag is a boolean */
1186 GLboolean Normalized; /**< GL_ARB_vertex_program */
1187 GLboolean Integer; /**< Integer-valued? */
1188 GLuint _ElementSize; /**< size of each element in bytes */
1189
1190 struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
1191 GLuint _MaxElement; /**< max element index into array buffer + 1 */
1192 };
1193
1194
1195 /**
1196 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1197 * extension, but a nice encapsulation in any case.
1198 */
1199 struct gl_array_object
1200 {
1201 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1202 GLuint Name;
1203
1204 GLint RefCount;
1205 _glthread_Mutex Mutex;
1206
1207 /**
1208 * Does the VAO use ARB semantics or Apple semantics?
1209 *
1210 * There are several ways in which ARB_vertex_array_object and
1211 * APPLE_vertex_array_object VAOs have differing semantics. At the very
1212 * least,
1213 *
1214 * - ARB VAOs require that all array data be sourced from vertex buffer
1215 * objects, but Apple VAOs do not.
1216 *
1217 * - ARB VAOs require that names come from GenVertexArrays.
1218 *
1219 * This flag notes which behavior governs this VAO.
1220 */
1221 GLboolean ARBsemantics;
1222
1223 /**
1224 * Has this array object been bound?
1225 */
1226 GLboolean _Used;
1227
1228 /** Vertex attribute arrays */
1229 struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
1230
1231 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1232 GLbitfield64 _Enabled;
1233
1234 /**
1235 * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs
1236 * we can determine the max legal (in bounds) glDrawElements array index.
1237 */
1238 GLuint _MaxElement;
1239
1240 struct gl_buffer_object *ElementArrayBufferObj;
1241 };
1242
1243
1244 /**
1245 * Vertex array state
1246 */
1247 struct gl_array_attrib
1248 {
1249 /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
1250 struct gl_array_object *ArrayObj;
1251
1252 /** The default vertex array object */
1253 struct gl_array_object *DefaultArrayObj;
1254
1255 /** Array objects (GL_ARB/APPLE_vertex_array_object) */
1256 struct _mesa_HashTable *Objects;
1257
1258 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1259 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1260
1261 GLbitfield64 NewState; /**< mask of VERT_BIT_* values */
1262 GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */
1263
1264 /* GL_ARB_vertex_buffer_object */
1265 struct gl_buffer_object *ArrayBufferObj;
1266 };
1267
1268
1269 /**
1270 * Feedback buffer state
1271 */
1272 struct gl_feedback
1273 {
1274 GLenum Type;
1275 GLbitfield _Mask; /**< FB_* bits */
1276 GLfloat *Buffer;
1277 GLuint BufferSize;
1278 GLuint Count;
1279 };
1280
1281
1282 /**
1283 * Selection buffer state
1284 */
1285 struct gl_selection
1286 {
1287 GLuint *Buffer; /**< selection buffer */
1288 GLuint BufferSize; /**< size of the selection buffer */
1289 GLuint BufferCount; /**< number of values in the selection buffer */
1290 GLuint Hits; /**< number of records in the selection buffer */
1291 GLuint NameStackDepth; /**< name stack depth */
1292 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1293 GLboolean HitFlag; /**< hit flag */
1294 GLfloat HitMinZ; /**< minimum hit depth */
1295 GLfloat HitMaxZ; /**< maximum hit depth */
1296 };
1297
1298
1299 /**
1300 * 1-D Evaluator control points
1301 */
1302 struct gl_1d_map
1303 {
1304 GLuint Order; /**< Number of control points */
1305 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1306 GLfloat *Points; /**< Points to contiguous control points */
1307 };
1308
1309
1310 /**
1311 * 2-D Evaluator control points
1312 */
1313 struct gl_2d_map
1314 {
1315 GLuint Uorder; /**< Number of control points in U dimension */
1316 GLuint Vorder; /**< Number of control points in V dimension */
1317 GLfloat u1, u2, du;
1318 GLfloat v1, v2, dv;
1319 GLfloat *Points; /**< Points to contiguous control points */
1320 };
1321
1322
1323 /**
1324 * All evaluator control point state
1325 */
1326 struct gl_evaluators
1327 {
1328 /**
1329 * \name 1-D maps
1330 */
1331 /*@{*/
1332 struct gl_1d_map Map1Vertex3;
1333 struct gl_1d_map Map1Vertex4;
1334 struct gl_1d_map Map1Index;
1335 struct gl_1d_map Map1Color4;
1336 struct gl_1d_map Map1Normal;
1337 struct gl_1d_map Map1Texture1;
1338 struct gl_1d_map Map1Texture2;
1339 struct gl_1d_map Map1Texture3;
1340 struct gl_1d_map Map1Texture4;
1341 /*@}*/
1342
1343 /**
1344 * \name 2-D maps
1345 */
1346 /*@{*/
1347 struct gl_2d_map Map2Vertex3;
1348 struct gl_2d_map Map2Vertex4;
1349 struct gl_2d_map Map2Index;
1350 struct gl_2d_map Map2Color4;
1351 struct gl_2d_map Map2Normal;
1352 struct gl_2d_map Map2Texture1;
1353 struct gl_2d_map Map2Texture2;
1354 struct gl_2d_map Map2Texture3;
1355 struct gl_2d_map Map2Texture4;
1356 /*@}*/
1357 };
1358
1359
1360 /**
1361 * State which can be shared by multiple contexts:
1362 */
1363 struct gl_shared_state
1364 {
1365 _glthread_Mutex Mutex; /**< for thread safety */
1366 GLint RefCount; /**< Reference count */
1367 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
1368 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
1369
1370 /** Default texture objects (shared by all texture units) */
1371 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
1372
1373 /** Fallback texture used when a bound texture is incomplete */
1374 struct gl_texture_object *FallbackTex;
1375
1376 /**
1377 * \name Thread safety and statechange notification for texture
1378 * objects.
1379 *
1380 * \todo Improve the granularity of locking.
1381 */
1382 /*@{*/
1383 _glthread_Mutex TexMutex; /**< texobj thread safety */
1384 GLuint TextureStateStamp; /**< state notification for shared tex */
1385 /*@}*/
1386
1387 /** Default buffer object for vertex arrays that aren't in VBOs */
1388 struct gl_buffer_object *NullBufferObj;
1389
1390 struct _mesa_HashTable *BufferObjects;
1391
1392 void *DriverData; /**< Device driver shared state */
1393 };
1394
1395
1396
1397 /**
1398 * Renderbuffers represent drawing surfaces such as color, depth and/or
1399 * stencil. A framebuffer object has a set of renderbuffers.
1400 * Drivers will typically derive subclasses of this type.
1401 */
1402 struct gl_renderbuffer
1403 {
1404 _glthread_Mutex Mutex; /**< for thread safety */
1405 GLuint ClassID; /**< Useful for drivers */
1406 GLint RefCount;
1407 GLuint Width, Height;
1408 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1409 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
1410 GLenum InternalFormat; /**< The user-specified format */
1411 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
1412 GL_STENCIL_INDEX. */
1413 gl_format Format; /**< The actual renderbuffer memory format */
1414
1415 /** Delete this renderbuffer */
1416 void (*Delete)(struct gl_renderbuffer *rb);
1417
1418 /** Allocate new storage for this renderbuffer */
1419 GLboolean (*AllocStorage)(struct gl_context *ctx,
1420 struct gl_renderbuffer *rb,
1421 GLenum internalFormat,
1422 GLuint width, GLuint height);
1423 };
1424
1425
1426 /**
1427 * A renderbuffer attachment points to either a texture object (and specifies
1428 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
1429 */
1430 struct gl_renderbuffer_attachment
1431 {
1432 /**
1433 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
1434 * application supplied renderbuffer object.
1435 */
1436 struct gl_renderbuffer *Renderbuffer;
1437 };
1438
1439
1440 /**
1441 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
1442 * In C++ terms, think of this as a base class from which device drivers
1443 * will make derived classes.
1444 */
1445 struct gl_framebuffer
1446 {
1447 _glthread_Mutex Mutex; /**< for thread safety */
1448
1449 GLint RefCount;
1450 GLboolean DeletePending;
1451
1452 /**
1453 * The framebuffer's visual. Immutable if this is a window system buffer.
1454 * Computed from attachments if user-made FBO.
1455 */
1456 struct gl_config Visual;
1457
1458 GLboolean Initialized;
1459
1460 GLuint Width, Height; /**< size of frame buffer in pixels */
1461
1462 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
1463 /*@{*/
1464 GLint _Xmin, _Xmax; /**< inclusive */
1465 GLint _Ymin, _Ymax; /**< exclusive */
1466 /*@}*/
1467
1468 /** \name Derived Z buffer stuff */
1469 /*@{*/
1470 GLuint _DepthMax; /**< Max depth buffer value */
1471 GLfloat _DepthMaxF; /**< Float max depth buffer value */
1472 GLfloat _MRD; /**< minimum resolvable difference in Z values */
1473 /*@}*/
1474
1475 /** Integer color values */
1476 GLboolean _IntegerColor;
1477
1478 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
1479 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
1480
1481 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
1482 * attribute group and GL_PIXEL attribute group, respectively.
1483 */
1484 GLenum ColorDrawBuffer;
1485 GLenum ColorReadBuffer;
1486
1487 /** Computed from ColorDraw/ReadBuffer above */
1488 GLint _ColorDrawBufferIndex; /**< BUFFER_x or -1 */
1489 GLint _ColorReadBufferIndex; /* -1 = None */
1490 struct gl_renderbuffer *_ColorDrawBuffer;
1491 struct gl_renderbuffer *_ColorReadBuffer;
1492
1493 /** Delete this framebuffer */
1494 void (*Delete)(struct gl_framebuffer *fb);
1495 };
1496
1497
1498 /**
1499 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
1500 */
1501 struct gl_precision
1502 {
1503 GLushort RangeMin; /**< min value exponent */
1504 GLushort RangeMax; /**< max value exponent */
1505 GLushort Precision; /**< number of mantissa bits */
1506 };
1507
1508 /**
1509 * Constants which may be overridden by device driver during context creation
1510 * but are never changed after that.
1511 */
1512 struct gl_constants
1513 {
1514 GLint MaxTextureMbytes; /**< Max memory per image, in MB */
1515 GLint MaxTextureLevels; /**< Max mipmap levels. */
1516 GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
1517 GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
1518 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1519
1520 GLuint MaxArrayLockSize;
1521
1522 GLint SubPixelBits;
1523
1524 GLfloat MinPointSize, MaxPointSize; /**< aliased */
1525 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
1526 GLfloat PointSizeGranularity;
1527 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
1528 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
1529 GLfloat LineWidthGranularity;
1530
1531 GLuint MaxColorTableSize;
1532
1533 GLuint MaxClipPlanes;
1534 GLuint MaxLights;
1535 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
1536 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
1537
1538 GLuint MaxViewportWidth, MaxViewportHeight;
1539
1540 /** vertex array / buffer object bounds checking */
1541 GLboolean CheckArrayBounds;
1542
1543 /**
1544 * Does the driver support real 32-bit integers? (Otherwise, integers are
1545 * simulated via floats.)
1546 */
1547 GLboolean NativeIntegers;
1548
1549 /** OpenGL version 3.0 */
1550 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
1551
1552 /** OpenGL version 3.2 */
1553 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
1554
1555 /**
1556 * Whether the implementation strips out and ignores texture borders.
1557 *
1558 * Many GPU hardware implementations don't support rendering with texture
1559 * borders and mipmapped textures. (Note: not static border color, but the
1560 * old 1-pixel border around each edge). Implementations then have to do
1561 * slow fallbacks to be correct, or just ignore the border and be fast but
1562 * wrong. Setting the flag stripts the border off of TexImage calls,
1563 * providing "fast but wrong" at significantly reduced driver complexity.
1564 *
1565 * Texture borders are deprecated in GL 3.0.
1566 **/
1567 GLboolean StripTextureBorder;
1568 };
1569
1570
1571 /**
1572 * Enable flag for each OpenGL extension. Different device drivers will
1573 * enable different extensions at runtime.
1574 */
1575 struct gl_extensions
1576 {
1577 GLboolean dummy; /* don't remove this! */
1578 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
1579 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
1580 GLboolean ARB_half_float_pixel;
1581 GLboolean ARB_half_float_vertex;
1582 GLboolean ARB_map_buffer_range;
1583 GLboolean ARB_point_sprite;
1584 GLboolean ARB_texture_cube_map;
1585 GLboolean ARB_texture_env_combine;
1586 GLboolean ARB_texture_env_crossbar;
1587 GLboolean ARB_texture_env_dot3;
1588 GLboolean ARB_texture_float;
1589 GLboolean ARB_texture_non_power_of_two;
1590 GLboolean ARB_texture_storage;
1591 GLboolean ARB_transpose_matrix;
1592 GLboolean ARB_vertex_array_object;
1593 GLboolean ARB_window_pos;
1594 GLboolean EXT_blend_color;
1595 GLboolean EXT_blend_equation_separate;
1596 GLboolean EXT_blend_func_separate;
1597 GLboolean EXT_blend_minmax;
1598 GLboolean EXT_clip_volume_hint;
1599 GLboolean EXT_compiled_vertex_array;
1600 GLboolean EXT_depth_bounds_test;
1601 GLboolean EXT_draw_range_elements;
1602 GLboolean EXT_fog_coord;
1603 GLboolean EXT_packed_pixels;
1604 GLboolean EXT_point_parameters;
1605 GLboolean EXT_rescale_normal;
1606 GLboolean EXT_shadow_funcs;
1607 GLboolean EXT_secondary_color;
1608 GLboolean EXT_separate_shader_objects;
1609 GLboolean EXT_separate_specular_color;
1610 GLboolean EXT_texture3D;
1611 GLboolean EXT_texture_env_dot3;
1612 GLboolean EXT_texture_filter_anisotropic;
1613 GLboolean EXT_texture_integer;
1614 /* vendor extensions */
1615 GLboolean APPLE_packed_pixels;
1616 GLboolean APPLE_vertex_array_object;
1617 GLboolean APPLE_object_purgeable;
1618 GLboolean ATI_texture_env_combine3;
1619 GLboolean IBM_rasterpos_clip;
1620 GLboolean IBM_multimode_draw_arrays;
1621 GLboolean MESA_pack_invert;
1622 GLboolean MESA_resize_buffers;
1623 GLboolean MESA_ycbcr_texture;
1624 GLboolean NV_blend_square;
1625 GLboolean NV_fog_distance;
1626 GLboolean NV_light_max_exponent;
1627 GLboolean NV_point_sprite;
1628 GLboolean NV_texture_barrier;
1629 GLboolean NV_texgen_reflection;
1630 GLboolean NV_texture_env_combine4;
1631 GLboolean extension_sentinel;
1632 /** The extension string */
1633 const GLubyte *String;
1634 /** Number of supported extensions */
1635 GLuint Count;
1636 };
1637
1638
1639 /**
1640 * A stack of matrices (projection, modelview, color, texture, etc).
1641 */
1642 struct gl_matrix_stack
1643 {
1644 GLmatrix *Top; /**< points into Stack */
1645 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
1646 GLuint Depth; /**< 0 <= Depth < MaxDepth */
1647 GLuint MaxDepth; /**< size of Stack[] array */
1648 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1649 };
1650
1651
1652 /**
1653 * \name Bits for image transfer operations
1654 * \sa __struct gl_contextRec::ImageTransferState.
1655 */
1656 /*@{*/
1657 #define IMAGE_SCALE_BIAS_BIT 0x1
1658 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1659 #define IMAGE_MAP_COLOR_BIT 0x4
1660 #define IMAGE_CLAMP_BIT 0x800
1661
1662
1663 /** Pixel Transfer ops */
1664 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
1665 IMAGE_SHIFT_OFFSET_BIT | \
1666 IMAGE_MAP_COLOR_BIT)
1667
1668 /**
1669 * \name Bits to indicate what state has changed.
1670 */
1671 /*@{*/
1672 #define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */
1673 #define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */
1674 #define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */
1675 #define _NEW_COLOR (1 << 3) /**< gl_context::Color */
1676 #define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */
1677 #define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */
1678 #define _NEW_FOG (1 << 6) /**< gl_context::Fog */
1679 #define _NEW_HINT (1 << 7) /**< gl_context::Hint */
1680 #define _NEW_LIGHT (1 << 8) /**< gl_context::Light */
1681 #define _NEW_LINE (1 << 9) /**< gl_context::Line */
1682 #define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */
1683 #define _NEW_POINT (1 << 11) /**< gl_context::Point */
1684 #define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */
1685 #define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */
1686 #define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */
1687 #define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */
1688 #define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */
1689 #define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */
1690 #define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */
1691 #define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */
1692 #define _NEW_ARRAY (1 << 20) /**< gl_context::Array */
1693 #define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */
1694 #define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */
1695 #define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */
1696 #define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */
1697 #define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */
1698 #define _NEW_BUFFER_OBJECT (1 << 26)
1699 #define _NEW_ALL ~0
1700
1701 /**
1702 * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for
1703 * clarity.
1704 */
1705 #define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM
1706 /*@}*/
1707
1708
1709 /**
1710 * \name A bunch of flags that we think might be useful to drivers.
1711 *
1712 * Set in the __struct gl_contextRec::_TriangleCaps bitfield.
1713 */
1714 /*@{*/
1715 #define DD_FLATSHADE 0x1
1716 #define DD_SEPARATE_SPECULAR 0x2
1717 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1718 #define DD_TRI_LIGHT_TWOSIDE 0x8
1719 #define DD_TRI_UNFILLED 0x10
1720 #define DD_TRI_SMOOTH 0x20
1721 #define DD_TRI_STIPPLE 0x40
1722 #define DD_TRI_OFFSET 0x80
1723 #define DD_LINE_SMOOTH 0x100
1724 #define DD_LINE_STIPPLE 0x200
1725 #define DD_POINT_SMOOTH 0x400
1726 #define DD_POINT_ATTEN 0x800
1727 /*@}*/
1728
1729
1730 /**
1731 * \name Define the state changes under which each of these bits might change
1732 */
1733 /*@{*/
1734 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1735 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1736 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1737 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1738 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1739 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1740 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1741 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1742 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1743 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1744 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1745 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1746 #define _DD_NEW_POINT_SIZE _NEW_POINT
1747 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1748 /*@}*/
1749
1750
1751 /**
1752 * Composite state flags
1753 */
1754 /*@{*/
1755 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1756 _NEW_TEXTURE | \
1757 _NEW_POINT | \
1758 _NEW_MODELVIEW)
1759 /*@}*/
1760
1761
1762
1763
1764 /* This has to be included here. */
1765 #include "dd.h"
1766
1767
1768 /**
1769 * Display list flags.
1770 * Strictly this is a tnl-private concept, but it doesn't seem
1771 * worthwhile adding a tnl private structure just to hold this one bit
1772 * of information:
1773 */
1774 #define DLIST_DANGLING_REFS 0x1
1775
1776
1777 /** Opaque declaration of display list payload data type */
1778 union gl_dlist_node;
1779
1780
1781 /**
1782 * Provide a location where information about a display list can be
1783 * collected. Could be extended with driverPrivate structures,
1784 * etc. in the future.
1785 */
1786 struct gl_display_list
1787 {
1788 GLuint Name;
1789 GLbitfield Flags; /**< DLIST_x flags */
1790 /** The dlist commands are in a linked list of nodes */
1791 union gl_dlist_node *Head;
1792 };
1793
1794
1795 /**
1796 * State used during display list compilation and execution.
1797 */
1798 struct gl_dlist_state
1799 {
1800 GLuint CallDepth; /**< Current recursion calling depth */
1801
1802 struct gl_display_list *CurrentList; /**< List currently being compiled */
1803 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
1804 GLuint CurrentPos; /**< Index into current block of nodes */
1805
1806 GLvertexformat ListVtxfmt;
1807
1808 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
1809 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
1810
1811 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
1812 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
1813
1814 GLubyte ActiveIndex;
1815 GLfloat CurrentIndex;
1816
1817 GLubyte ActiveEdgeFlag;
1818 GLboolean CurrentEdgeFlag;
1819
1820 struct {
1821 /* State known to have been set by the currently-compiling display
1822 * list. Used to eliminate some redundant state changes.
1823 */
1824 GLenum ShadeModel;
1825 } Current;
1826 };
1827
1828
1829 /**
1830 * Mesa rendering context.
1831 *
1832 * This is the central context data structure for Mesa. Almost all
1833 * OpenGL state is contained in this structure.
1834 * Think of this as a base class from which device drivers will derive
1835 * sub classes.
1836 *
1837 * The struct gl_context typedef names this structure.
1838 */
1839 struct gl_context
1840 {
1841 /** State possibly shared with other contexts in the address space */
1842 struct gl_shared_state *Shared;
1843
1844 /** \name API function pointer tables */
1845 /*@{*/
1846 struct _glapi_table *Save; /**< Display list save functions */
1847 struct _glapi_table *Exec; /**< Execute functions */
1848 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
1849 /*@}*/
1850
1851 struct gl_config Visual;
1852 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
1853 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
1854 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
1855 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
1856
1857 /**
1858 * Device driver function pointer table
1859 */
1860 struct dd_function_table Driver;
1861
1862 void *DriverCtx; /**< Points to device driver context/state */
1863
1864 /** Core/Driver constants */
1865 struct gl_constants Const;
1866
1867 /** \name The various 4x4 matrix stacks */
1868 /*@{*/
1869 struct gl_matrix_stack ModelviewMatrixStack;
1870 struct gl_matrix_stack ProjectionMatrixStack;
1871 struct gl_matrix_stack TextureMatrixStack;
1872 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
1873 /*@}*/
1874
1875 /** Combined modelview and projection matrix */
1876 GLmatrix _ModelProjectMatrix;
1877
1878 /** \name Display lists */
1879 struct gl_dlist_state ListState;
1880
1881 GLboolean ExecuteFlag; /**< Execute GL commands? */
1882 GLboolean CompileFlag; /**< Compile GL commands into display list? */
1883
1884 /** Extension information */
1885 struct gl_extensions Extensions;
1886
1887 /** Version info */
1888 GLuint VersionMajor, VersionMinor;
1889 char *VersionString;
1890
1891 /** \name State attribute stack (for glPush/PopAttrib) */
1892 /*@{*/
1893 GLuint AttribStackDepth;
1894 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
1895 /*@}*/
1896
1897 /** \name Renderer attribute groups
1898 *
1899 * We define a struct for each attribute group to make pushing and popping
1900 * attributes easy. Also it's a good organization.
1901 */
1902 /*@{*/
1903 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
1904 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
1905 struct gl_current_attrib Current; /**< Current attributes */
1906 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
1907 struct gl_eval_attrib Eval; /**< Eval attributes */
1908 struct gl_fog_attrib Fog; /**< Fog attributes */
1909 struct gl_hint_attrib Hint; /**< Hint attributes */
1910 struct gl_light_attrib Light; /**< Light attributes */
1911 struct gl_line_attrib Line; /**< Line attributes */
1912 struct gl_list_attrib List; /**< List attributes */
1913 struct gl_multisample_attrib Multisample;
1914 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
1915 struct gl_point_attrib Point; /**< Point attributes */
1916 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
1917 GLuint PolygonStipple[32]; /**< Polygon stipple */
1918 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
1919 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
1920 struct gl_texture_attrib Texture; /**< Texture attributes */
1921 struct gl_transform_attrib Transform; /**< Transformation attributes */
1922 struct gl_viewport_attrib Viewport; /**< Viewport attributes */
1923 /*@}*/
1924
1925 /** \name Client attribute stack */
1926 /*@{*/
1927 GLuint ClientAttribStackDepth;
1928 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
1929 /*@}*/
1930
1931 /** \name Client attribute groups */
1932 /*@{*/
1933 struct gl_array_attrib Array; /**< Vertex arrays */
1934 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
1935 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
1936 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
1937 /*@}*/
1938
1939 /** \name Other assorted state (not pushed/popped on attribute stack) */
1940 /*@{*/
1941 struct gl_pixelmaps PixelMaps;
1942
1943 struct gl_evaluators EvalMap; /**< All evaluators */
1944 struct gl_feedback Feedback; /**< Feedback */
1945 struct gl_selection Select; /**< Selection */
1946 /*@}*/
1947
1948 struct gl_meta_state *Meta; /**< for "meta" operations */
1949
1950 /* GL_EXT_framebuffer_object */
1951 struct gl_renderbuffer *CurrentRenderbuffer;
1952
1953 GLenum ErrorValue; /**< Last error code */
1954
1955 /**
1956 * Recognize and silence repeated error debug messages in buggy apps.
1957 */
1958 const char *ErrorDebugFmtString;
1959 GLuint ErrorDebugCount;
1960
1961 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1962 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
1963
1964 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
1965
1966 /** \name Derived state */
1967 /*@{*/
1968 /** Bitwise-or of DD_* flags. Note that this bitfield may be used before
1969 * state validation so they need to always be current.
1970 */
1971 GLbitfield _TriangleCaps;
1972 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
1973 GLfloat _EyeZDir[3];
1974 GLfloat _ModelViewInvScale;
1975 GLboolean _NeedEyeCoords;
1976 GLboolean _ForceEyeCoords;
1977
1978 GLuint TextureStateTimestamp; /**< detect changes to shared state */
1979
1980 struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
1981 struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
1982 /**@}*/
1983
1984 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
1985
1986 /** \name For debugging/development only */
1987 /*@{*/
1988 GLboolean FirstTimeCurrent;
1989 /*@}*/
1990
1991 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
1992
1993 /**
1994 * Use dp4 (rather than mul/mad) instructions for position
1995 * transformation?
1996 */
1997 GLboolean mvp_with_dp4;
1998
1999 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
2000
2001 /**
2002 * \name Hooks for module contexts.
2003 *
2004 * These will eventually live in the driver or elsewhere.
2005 */
2006 /*@{*/
2007 void *swrast_context;
2008 void *swsetup_context;
2009 void *swtnl_context;
2010 void *swtnl_im;
2011 struct st_context *st;
2012 void *aelt_context;
2013 /*@}*/
2014 };
2015
2016
2017 #ifdef DEBUG
2018 extern int MESA_VERBOSE;
2019 extern int MESA_DEBUG_FLAGS;
2020 # define MESA_FUNCTION __FUNCTION__
2021 #else
2022 # define MESA_VERBOSE 0
2023 # define MESA_DEBUG_FLAGS 0
2024 # define MESA_FUNCTION "a function"
2025 # ifndef NDEBUG
2026 # define NDEBUG
2027 # endif
2028 #endif
2029
2030
2031 /** The MESA_VERBOSE var is a bitmask of these flags */
2032 enum _verbose
2033 {
2034 VERBOSE_VARRAY = 0x0001,
2035 VERBOSE_TEXTURE = 0x0002,
2036 VERBOSE_MATERIAL = 0x0004,
2037 VERBOSE_PIPELINE = 0x0008,
2038 VERBOSE_DRIVER = 0x0010,
2039 VERBOSE_STATE = 0x0020,
2040 VERBOSE_API = 0x0040,
2041 VERBOSE_DISPLAY_LIST = 0x0100,
2042 VERBOSE_LIGHTING = 0x0200,
2043 VERBOSE_PRIMS = 0x0400,
2044 VERBOSE_VERTS = 0x0800,
2045 VERBOSE_DISASSEM = 0x1000,
2046 VERBOSE_DRAW = 0x2000,
2047 VERBOSE_SWAPBUFFERS = 0x4000
2048 };
2049
2050
2051 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
2052 enum _debug
2053 {
2054 DEBUG_ALWAYS_FLUSH = 0x1
2055 };
2056
2057
2058
2059 #ifdef __cplusplus
2060 }
2061 #endif
2062
2063 #endif /* MTYPES_H */