183702540a9d8ab8f44837a1691ad15caae4233c
[reactos.git] / reactos / dll / opengl / mesa / src / 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 "glapi/glapi.h"
41 #include "math/m_matrix.h" /* GLmatrix */
42 #include "main/simple_list.h" /* struct simple_node */
43 #include "main/formats.h" /* MESA_FORMAT_COUNT */
44
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50
51 /**
52 * \name 64-bit extension of GLbitfield.
53 */
54 /*@{*/
55 typedef GLuint64 GLbitfield64;
56
57 /** Set a single bit */
58 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
59 /** Set all bits up to excluding bit b */
60 #define BITFIELD64_MASK(b) \
61 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
62 /** Set count bits starting from bit b */
63 #define BITFIELD64_RANGE(b, count) \
64 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
65
66
67 /**
68 * \name Some forward type declarations
69 */
70 /*@{*/
71 struct _mesa_HashTable;
72 struct gl_attrib_node;
73 struct gl_list_extensions;
74 struct gl_meta_state;
75 struct gl_program_cache;
76 struct gl_texture_object;
77 struct gl_context;
78 struct st_context;
79 struct gl_uniform_storage;
80 /*@}*/
81
82
83 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
84 #define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1)
85 #define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2)
86 #define PRIM_UNKNOWN (GL_POLYGON+3)
87
88
89 /**
90 * Shader stages. Note that these will become 5 with tessellation.
91 * These MUST have the same values as gallium's PIPE_SHADER_*
92 */
93 typedef enum
94 {
95 MESA_SHADER_VERTEX = 0,
96 MESA_SHADER_FRAGMENT = 1,
97 MESA_SHADER_TYPES = 2
98 } gl_shader_type;
99
100
101
102 /**
103 * Indexes for vertex program attributes.
104 * GL_NV_vertex_program aliases generic attributes over the conventional
105 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
106 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
107 * generic attributes are distinct/separate).
108 */
109 typedef enum
110 {
111 VERT_ATTRIB_POS = 0,
112 VERT_ATTRIB_WEIGHT = 1,
113 VERT_ATTRIB_NORMAL = 2,
114 VERT_ATTRIB_COLOR0 = 3,
115 VERT_ATTRIB_COLOR1 = 4,
116 VERT_ATTRIB_FOG = 5,
117 VERT_ATTRIB_COLOR_INDEX = 6,
118 VERT_ATTRIB_EDGEFLAG = 7,
119 VERT_ATTRIB_TEX0 = 8,
120 VERT_ATTRIB_TEX1 = 9,
121 VERT_ATTRIB_TEX2 = 10,
122 VERT_ATTRIB_TEX3 = 11,
123 VERT_ATTRIB_TEX4 = 12,
124 VERT_ATTRIB_TEX5 = 13,
125 VERT_ATTRIB_TEX6 = 14,
126 VERT_ATTRIB_TEX7 = 15,
127 VERT_ATTRIB_POINT_SIZE = 16,
128 VERT_ATTRIB_GENERIC0 = 17,
129 VERT_ATTRIB_GENERIC1 = 18,
130 VERT_ATTRIB_GENERIC2 = 19,
131 VERT_ATTRIB_GENERIC3 = 20,
132 VERT_ATTRIB_GENERIC4 = 21,
133 VERT_ATTRIB_GENERIC5 = 22,
134 VERT_ATTRIB_GENERIC6 = 23,
135 VERT_ATTRIB_GENERIC7 = 24,
136 VERT_ATTRIB_GENERIC8 = 25,
137 VERT_ATTRIB_GENERIC9 = 26,
138 VERT_ATTRIB_GENERIC10 = 27,
139 VERT_ATTRIB_GENERIC11 = 28,
140 VERT_ATTRIB_GENERIC12 = 29,
141 VERT_ATTRIB_GENERIC13 = 30,
142 VERT_ATTRIB_GENERIC14 = 31,
143 VERT_ATTRIB_GENERIC15 = 32,
144 VERT_ATTRIB_MAX = 33
145 } gl_vert_attrib;
146
147 /**
148 * Symbolic constats to help iterating over
149 * specific blocks of vertex attributes.
150 *
151 * VERT_ATTRIB_FF
152 * includes all fixed function attributes as well as
153 * the aliased GL_NV_vertex_program shader attributes.
154 * VERT_ATTRIB_TEX
155 * include the classic texture coordinate attributes.
156 * Is a subset of VERT_ATTRIB_FF.
157 * VERT_ATTRIB_GENERIC_NV
158 * include the NV shader attributes.
159 * Is a subset of VERT_ATTRIB_FF.
160 * VERT_ATTRIB_GENERIC
161 * include the OpenGL 2.0+ GLSL generic shader attributes.
162 * These alias the generic GL_ARB_vertex_shader attributes.
163 */
164 #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
165 #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
166
167 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
168 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
169
170 #define VERT_ATTRIB_GENERIC_NV(i) (VERT_ATTRIB_POS + (i))
171 #define VERT_ATTRIB_GENERIC_NV_MAX MAX_VERTEX_GENERIC_ATTRIBS
172
173 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
174 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
175
176 /**
177 * Bitflags for vertex attributes.
178 * These are used in bitfields in many places.
179 */
180 /*@{*/
181 #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
182 #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
183 #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
184 #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
185 #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
186 #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
187 #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
188 #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
189 #define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0)
190 #define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1)
191 #define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2)
192 #define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3)
193 #define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4)
194 #define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5)
195 #define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6)
196 #define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7)
197 #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
198 #define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
199
200 #define VERT_BIT(i) BITFIELD64_BIT(i)
201 #define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1)
202
203 #define VERT_BIT_FF(i) VERT_BIT(i)
204 #define VERT_BIT_FF_ALL (BITFIELD64_BIT(VERT_ATTRIB_FF_MAX) - 1)
205 #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
206 #define VERT_BIT_TEX_ALL \
207 ((BITFIELD64_BIT(VERT_ATTRIB_TEX_MAX) - 1) << VERT_ATTRIB_TEX(0))
208 #define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i))
209 #define VERT_BIT_GENERIC_NV_ALL \
210 ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_NV_MAX) - 1) << (VERT_ATTRIB_GENERIC_NV(0)))
211 #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
212 #define VERT_BIT_GENERIC_ALL \
213 ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_MAX) - 1) << (VERT_ATTRIB_GENERIC(0)))
214 /*@}*/
215
216
217 /**
218 * Indexes for vertex program result attributes. Note that
219 * _mesa_vert_result_to_frag_attrib() and _mesa_frag_attrib_to_vert_result() make
220 * assumptions about the layout of this enum.
221 */
222 typedef enum
223 {
224 VERT_RESULT_HPOS = 0,
225 VERT_RESULT_COL0 = 1,
226 VERT_RESULT_COL1 = 2,
227 VERT_RESULT_FOGC = 3,
228 VERT_RESULT_TEX0 = 4,
229 VERT_RESULT_TEX1 = 5,
230 VERT_RESULT_TEX2 = 6,
231 VERT_RESULT_TEX3 = 7,
232 VERT_RESULT_TEX4 = 8,
233 VERT_RESULT_TEX5 = 9,
234 VERT_RESULT_TEX6 = 10,
235 VERT_RESULT_TEX7 = 11,
236 VERT_RESULT_PSIZ = 12,
237 VERT_RESULT_BFC0 = 13,
238 VERT_RESULT_BFC1 = 14,
239 VERT_RESULT_EDGE = 15,
240 VERT_RESULT_CLIP_VERTEX = 16,
241 VERT_RESULT_CLIP_DIST0 = 17,
242 VERT_RESULT_CLIP_DIST1 = 18,
243 VERT_RESULT_VAR0 = 19, /**< shader varying */
244 VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING)
245 } gl_vert_result;
246
247
248 /*********************************************/
249
250 /**
251 * Indexes for fragment program input attributes. Note that
252 * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make
253 * assumptions about the layout of this enum.
254 */
255 typedef enum
256 {
257 FRAG_ATTRIB_WPOS = 0,
258 FRAG_ATTRIB_COL0 = 1,
259 FRAG_ATTRIB_COL1 = 2,
260 FRAG_ATTRIB_FOGC = 3,
261 FRAG_ATTRIB_TEX0 = 4,
262 FRAG_ATTRIB_TEX1 = 5,
263 FRAG_ATTRIB_TEX2 = 6,
264 FRAG_ATTRIB_TEX3 = 7,
265 FRAG_ATTRIB_TEX4 = 8,
266 FRAG_ATTRIB_TEX5 = 9,
267 FRAG_ATTRIB_TEX6 = 10,
268 FRAG_ATTRIB_TEX7 = 11,
269 FRAG_ATTRIB_FACE = 12, /**< front/back face */
270 FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */
271 FRAG_ATTRIB_CLIP_DIST0 = 14,
272 FRAG_ATTRIB_CLIP_DIST1 = 15,
273 FRAG_ATTRIB_VAR0 = 16, /**< shader varying */
274 FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
275 } gl_frag_attrib;
276
277
278 /**
279 * Convert from a gl_vert_result value to the corresponding gl_frag_attrib.
280 *
281 * VERT_RESULT_HPOS is converted to FRAG_ATTRIB_WPOS.
282 *
283 * gl_vert_result values which have no corresponding gl_frag_attrib
284 * (VERT_RESULT_PSIZ, VERT_RESULT_BFC0, VERT_RESULT_BFC1, and
285 * VERT_RESULT_EDGE) are converted to a value of -1.
286 */
287 static inline int
288 _mesa_vert_result_to_frag_attrib(gl_vert_result vert_result)
289 {
290 if (vert_result >= VERT_RESULT_CLIP_DIST0)
291 return vert_result - VERT_RESULT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0;
292 else if (vert_result <= VERT_RESULT_TEX7)
293 return vert_result;
294 else
295 return -1;
296 }
297
298
299 /**
300 * Convert from a gl_frag_attrib value to the corresponding gl_vert_result.
301 *
302 * FRAG_ATTRIB_WPOS is converted to VERT_RESULT_HPOS.
303 *
304 * gl_frag_attrib values which have no corresponding gl_vert_result
305 * (FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC) are converted to a value of -1.
306 */
307 static inline int
308 _mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib)
309 {
310 if (frag_attrib <= FRAG_ATTRIB_TEX7)
311 return frag_attrib;
312 else if (frag_attrib >= FRAG_ATTRIB_CLIP_DIST0)
313 return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VERT_RESULT_CLIP_DIST0;
314 else
315 return -1;
316 }
317
318
319 /**
320 * Bitflags for fragment program input attributes.
321 */
322 /*@{*/
323 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
324 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
325 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
326 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
327 #define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE)
328 #define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC)
329 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
330 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
331 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
332 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
333 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
334 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
335 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
336 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
337 #define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0)
338
339 #define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U))
340 #define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V))
341
342 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
343 FRAG_BIT_TEX1| \
344 FRAG_BIT_TEX2| \
345 FRAG_BIT_TEX3| \
346 FRAG_BIT_TEX4| \
347 FRAG_BIT_TEX5| \
348 FRAG_BIT_TEX6| \
349 FRAG_BIT_TEX7)
350 /*@}*/
351
352
353 /**
354 * Fragment program results
355 */
356 typedef enum
357 {
358 FRAG_RESULT_DEPTH = 0,
359 FRAG_RESULT_STENCIL = 1,
360 /* If a single color should be written to all render targets, this
361 * register is written. No FRAG_RESULT_DATAn will be written.
362 */
363 FRAG_RESULT_COLOR = 2,
364
365 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
366 * or ARB_fragment_program fragment.color[n]) color results. If
367 * any are written, FRAG_RESULT_COLOR will not be written.
368 */
369 FRAG_RESULT_DATA0 = 3,
370 FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
371 } gl_frag_result;
372
373
374 /**
375 * Indexes for all renderbuffers
376 */
377 typedef enum
378 {
379 /* the four standard color buffers */
380 BUFFER_FRONT_LEFT,
381 BUFFER_BACK_LEFT,
382 BUFFER_FRONT_RIGHT,
383 BUFFER_BACK_RIGHT,
384 BUFFER_DEPTH,
385 BUFFER_STENCIL,
386 BUFFER_ACCUM,
387 /* optional aux buffer */
388 BUFFER_AUX0,
389 /* generic renderbuffers */
390 BUFFER_COLOR0,
391 BUFFER_COLOR1,
392 BUFFER_COLOR2,
393 BUFFER_COLOR3,
394 BUFFER_COLOR4,
395 BUFFER_COLOR5,
396 BUFFER_COLOR6,
397 BUFFER_COLOR7,
398 BUFFER_COUNT
399 } gl_buffer_index;
400
401 /**
402 * Bit flags for all renderbuffers
403 */
404 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
405 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
406 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
407 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
408 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
409 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
410 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
411 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
412 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
413 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
414 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
415 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
416 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
417 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
418 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
419 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
420 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
421 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
422 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
423
424 /**
425 * Mask of all the color buffer bits (but not accum).
426 */
427 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
428 BUFFER_BIT_BACK_LEFT | \
429 BUFFER_BIT_FRONT_RIGHT | \
430 BUFFER_BIT_BACK_RIGHT | \
431 BUFFER_BIT_AUX0 | \
432 BUFFER_BIT_COLOR0 | \
433 BUFFER_BIT_COLOR1 | \
434 BUFFER_BIT_COLOR2 | \
435 BUFFER_BIT_COLOR3 | \
436 BUFFER_BIT_COLOR4 | \
437 BUFFER_BIT_COLOR5 | \
438 BUFFER_BIT_COLOR6 | \
439 BUFFER_BIT_COLOR7)
440
441
442 /**
443 * Framebuffer configuration (aka visual / pixelformat)
444 * Note: some of these fields should be boolean, but it appears that
445 * code in drivers/dri/common/util.c requires int-sized fields.
446 */
447 struct gl_config
448 {
449 GLboolean rgbMode;
450 GLboolean floatMode;
451 GLboolean colorIndexMode; /* XXX is this used anywhere? */
452 GLuint doubleBufferMode;
453 GLuint stereoMode;
454
455 GLboolean haveAccumBuffer;
456 GLboolean haveDepthBuffer;
457 GLboolean haveStencilBuffer;
458
459 GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
460 GLuint redMask, greenMask, blueMask, alphaMask;
461 GLint rgbBits; /* total bits for rgb */
462 GLint indexBits; /* total bits for colorindex */
463
464 GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
465 GLint depthBits;
466 GLint stencilBits;
467
468 GLint numAuxBuffers;
469
470 GLint level;
471
472 /* EXT_visual_rating / GLX 1.2 */
473 GLint visualRating;
474
475 /* EXT_visual_info / GLX 1.2 */
476 GLint transparentPixel;
477 /* colors are floats scaled to ints */
478 GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
479 GLint transparentIndex;
480
481 /* ARB_multisample / SGIS_multisample */
482 GLint sampleBuffers;
483 GLint samples;
484
485 /* SGIX_pbuffer / GLX 1.3 */
486 GLint maxPbufferWidth;
487 GLint maxPbufferHeight;
488 GLint maxPbufferPixels;
489 GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
490 GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
491
492 /* OML_swap_method */
493 GLint swapMethod;
494
495 /* EXT_texture_from_pixmap */
496 GLint bindToTextureRgb;
497 GLint bindToTextureRgba;
498 GLint bindToMipmapTexture;
499 GLint bindToTextureTargets;
500 GLint yInverted;
501 };
502
503
504 /**
505 * \name Bit flags used for updating material values.
506 */
507 /*@{*/
508 #define MAT_ATTRIB_FRONT_AMBIENT 0
509 #define MAT_ATTRIB_BACK_AMBIENT 1
510 #define MAT_ATTRIB_FRONT_DIFFUSE 2
511 #define MAT_ATTRIB_BACK_DIFFUSE 3
512 #define MAT_ATTRIB_FRONT_SPECULAR 4
513 #define MAT_ATTRIB_BACK_SPECULAR 5
514 #define MAT_ATTRIB_FRONT_EMISSION 6
515 #define MAT_ATTRIB_BACK_EMISSION 7
516 #define MAT_ATTRIB_FRONT_SHININESS 8
517 #define MAT_ATTRIB_BACK_SHININESS 9
518 #define MAT_ATTRIB_FRONT_INDEXES 10
519 #define MAT_ATTRIB_BACK_INDEXES 11
520 #define MAT_ATTRIB_MAX 12
521
522 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
523 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
524 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
525 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
526 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
527 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
528
529 #define MAT_INDEX_AMBIENT 0
530 #define MAT_INDEX_DIFFUSE 1
531 #define MAT_INDEX_SPECULAR 2
532
533 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
534 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
535 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
536 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
537 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
538 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
539 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
540 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
541 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
542 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
543 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
544 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
545
546
547 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
548 MAT_BIT_FRONT_AMBIENT | \
549 MAT_BIT_FRONT_DIFFUSE | \
550 MAT_BIT_FRONT_SPECULAR | \
551 MAT_BIT_FRONT_SHININESS | \
552 MAT_BIT_FRONT_INDEXES)
553
554 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
555 MAT_BIT_BACK_AMBIENT | \
556 MAT_BIT_BACK_DIFFUSE | \
557 MAT_BIT_BACK_SPECULAR | \
558 MAT_BIT_BACK_SHININESS | \
559 MAT_BIT_BACK_INDEXES)
560
561 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
562 /*@}*/
563
564
565 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
566 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
567
568 /**
569 * Material shininess lookup table.
570 */
571 struct gl_shine_tab
572 {
573 struct gl_shine_tab *next, *prev;
574 GLfloat tab[SHINE_TABLE_SIZE+1];
575 GLfloat shininess;
576 GLuint refcount;
577 };
578
579
580 /**
581 * Light source state.
582 */
583 struct gl_light
584 {
585 struct gl_light *next; /**< double linked list with sentinel */
586 struct gl_light *prev;
587
588 GLfloat Ambient[4]; /**< ambient color */
589 GLfloat Diffuse[4]; /**< diffuse color */
590 GLfloat Specular[4]; /**< specular color */
591 GLfloat EyePosition[4]; /**< position in eye coordinates */
592 GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */
593 GLfloat SpotExponent;
594 GLfloat SpotCutoff; /**< in degrees */
595 GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */
596 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
597 GLfloat ConstantAttenuation;
598 GLfloat LinearAttenuation;
599 GLfloat QuadraticAttenuation;
600 GLboolean Enabled; /**< On/off flag */
601
602 /**
603 * \name Derived fields
604 */
605 /*@{*/
606 GLbitfield _Flags; /**< State */
607
608 GLfloat _Position[4]; /**< position in eye/obj coordinates */
609 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
610 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
611 GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
612 GLfloat _VP_inf_spot_attenuation;
613
614 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
615 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
616 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
617 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
618 /*@}*/
619 };
620
621
622 /**
623 * Light model state.
624 */
625 struct gl_lightmodel
626 {
627 GLfloat Ambient[4]; /**< ambient color */
628 GLboolean LocalViewer; /**< Local (or infinite) view point? */
629 GLboolean TwoSide; /**< Two (or one) sided lighting? */
630 GLenum ColorControl; /**< either GL_SINGLE_COLOR
631 * or GL_SEPARATE_SPECULAR_COLOR */
632 };
633
634
635 /**
636 * Material state.
637 */
638 struct gl_material
639 {
640 GLfloat Attrib[MAT_ATTRIB_MAX][4];
641 };
642
643
644 /**
645 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
646 */
647 struct gl_accum_attrib
648 {
649 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
650 };
651
652
653 /**
654 * Used for storing clear color, texture border color, etc.
655 * The float values are typically unclamped.
656 */
657 union gl_color_union
658 {
659 GLfloat f[4];
660 GLint i[4];
661 GLuint ui[4];
662 };
663
664
665 /**
666 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
667 */
668 struct gl_colorbuffer_attrib
669 {
670 GLuint ClearIndex; /**< Index for glClear */
671 union gl_color_union ClearColor; /**< Color for glClear, unclamped */
672 GLuint IndexMask; /**< Color index write mask */
673 GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; /**< Each flag is 0xff or 0x0 */
674
675 GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
676
677 /**
678 * \name alpha testing
679 */
680 /*@{*/
681 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
682 GLenum AlphaFunc; /**< Alpha test function */
683 GLfloat AlphaRefUnclamped;
684 GLclampf AlphaRef; /**< Alpha reference value */
685 /*@}*/
686
687 /**
688 * \name Blending
689 */
690 /*@{*/
691 GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
692
693 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
694 * control, only on the fixed-pointness of the render target.
695 * The query does however depend on fragment color clamping.
696 */
697 GLfloat BlendColorUnclamped[4]; /**< Blending color */
698 GLfloat BlendColor[4]; /**< Blending color */
699
700 struct
701 {
702 GLenum SrcRGB; /**< RGB blend source term */
703 GLenum DstRGB; /**< RGB blend dest term */
704 GLenum SrcA; /**< Alpha blend source term */
705 GLenum DstA; /**< Alpha blend dest term */
706 GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
707 GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
708 } Blend[MAX_DRAW_BUFFERS];
709 /** Are the blend func terms currently different for each buffer/target? */
710 GLboolean _BlendFuncPerBuffer;
711 /** Are the blend equations currently different for each buffer/target? */
712 GLboolean _BlendEquationPerBuffer;
713 /*@}*/
714
715 /**
716 * \name Logic op
717 */
718 /*@{*/
719 GLenum LogicOp; /**< Logic operator */
720 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
721 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
722 /*@}*/
723
724 GLboolean DitherFlag; /**< Dither enable flag */
725
726 GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
727 GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
728 GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
729 GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */
730 };
731
732
733 /**
734 * Current attribute group (GL_CURRENT_BIT).
735 */
736 struct gl_current_attrib
737 {
738 /**
739 * \name Current vertex attributes.
740 * \note Values are valid only after FLUSH_VERTICES has been called.
741 * \note Index and Edgeflag current values are stored as floats in the
742 * SIX and SEVEN attribute slots.
743 */
744 GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
745
746 /**
747 * \name Current raster position attributes (always valid).
748 * \note This set of attributes is very similar to the SWvertex struct.
749 */
750 /*@{*/
751 GLfloat RasterPos[4];
752 GLfloat RasterDistance;
753 GLfloat RasterColor[4];
754 GLfloat RasterSecondaryColor[4];
755 GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
756 GLboolean RasterPosValid;
757 /*@}*/
758 };
759
760
761 /**
762 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
763 */
764 struct gl_depthbuffer_attrib
765 {
766 GLenum Func; /**< Function for depth buffer compare */
767 GLclampd Clear; /**< Value to clear depth buffer to */
768 GLboolean Test; /**< Depth buffering enabled flag */
769 GLboolean Mask; /**< Depth buffer writable? */
770 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
771 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
772 };
773
774
775 /**
776 * Evaluator attribute group (GL_EVAL_BIT).
777 */
778 struct gl_eval_attrib
779 {
780 /**
781 * \name Enable bits
782 */
783 /*@{*/
784 GLboolean Map1Color4;
785 GLboolean Map1Index;
786 GLboolean Map1Normal;
787 GLboolean Map1TextureCoord1;
788 GLboolean Map1TextureCoord2;
789 GLboolean Map1TextureCoord3;
790 GLboolean Map1TextureCoord4;
791 GLboolean Map1Vertex3;
792 GLboolean Map1Vertex4;
793 GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
794 GLboolean Map2Color4;
795 GLboolean Map2Index;
796 GLboolean Map2Normal;
797 GLboolean Map2TextureCoord1;
798 GLboolean Map2TextureCoord2;
799 GLboolean Map2TextureCoord3;
800 GLboolean Map2TextureCoord4;
801 GLboolean Map2Vertex3;
802 GLboolean Map2Vertex4;
803 GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
804 GLboolean AutoNormal;
805 /*@}*/
806
807 /**
808 * \name Map Grid endpoints and divisions and calculated du values
809 */
810 /*@{*/
811 GLint MapGrid1un;
812 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
813 GLint MapGrid2un, MapGrid2vn;
814 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
815 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
816 /*@}*/
817 };
818
819
820 /**
821 * Fog attribute group (GL_FOG_BIT).
822 */
823 struct gl_fog_attrib
824 {
825 GLboolean Enabled; /**< Fog enabled flag */
826 GLfloat ColorUnclamped[4]; /**< Fog color */
827 GLfloat Color[4]; /**< Fog color */
828 GLfloat Density; /**< Density >= 0.0 */
829 GLfloat Start; /**< Start distance in eye coords */
830 GLfloat End; /**< End distance in eye coords */
831 GLfloat Index; /**< Fog index */
832 GLenum Mode; /**< Fog mode */
833 GLboolean ColorSumEnabled;
834 GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
835 GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
836 GLenum FogDistanceMode; /**< GL_NV_fog_distance */
837 };
838
839
840 /**
841 * \brief Layout qualifiers for gl_FragDepth.
842 *
843 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
844 * a layout qualifier.
845 *
846 * \see enum ir_depth_layout
847 */
848 enum gl_frag_depth_layout {
849 FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
850 FRAG_DEPTH_LAYOUT_ANY,
851 FRAG_DEPTH_LAYOUT_GREATER,
852 FRAG_DEPTH_LAYOUT_LESS,
853 FRAG_DEPTH_LAYOUT_UNCHANGED
854 };
855
856
857 /**
858 * Hint attribute group (GL_HINT_BIT).
859 *
860 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
861 */
862 struct gl_hint_attrib
863 {
864 GLenum PerspectiveCorrection;
865 GLenum PointSmooth;
866 GLenum LineSmooth;
867 GLenum PolygonSmooth;
868 GLenum Fog;
869 GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
870 GLenum TextureCompression; /**< GL_ARB_texture_compression */
871 GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
872 GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
873 };
874
875 /**
876 * Light state flags.
877 */
878 /*@{*/
879 #define LIGHT_SPOT 0x1
880 #define LIGHT_LOCAL_VIEWER 0x2
881 #define LIGHT_POSITIONAL 0x4
882 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
883 /*@}*/
884
885
886 /**
887 * Lighting attribute group (GL_LIGHT_BIT).
888 */
889 struct gl_light_attrib
890 {
891 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
892 struct gl_lightmodel Model; /**< Lighting model */
893
894 /**
895 * Must flush FLUSH_VERTICES before referencing:
896 */
897 /*@{*/
898 struct gl_material Material; /**< Includes front & back values */
899 /*@}*/
900
901 GLboolean Enabled; /**< Lighting enabled flag */
902 GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
903 GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
904 GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
905 GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
906 GLboolean ColorMaterialEnabled;
907 GLenum ClampVertexColor;
908 GLboolean _ClampVertexColor;
909
910 struct gl_light EnabledList; /**< List sentinel */
911
912 /**
913 * Derived state for optimizations:
914 */
915 /*@{*/
916 GLboolean _NeedEyeCoords;
917 GLboolean _NeedVertices; /**< Use fast shader? */
918 GLbitfield _Flags; /**< LIGHT_* flags, see above */
919 GLfloat _BaseColor[2][3];
920 /*@}*/
921 };
922
923
924 /**
925 * Line attribute group (GL_LINE_BIT).
926 */
927 struct gl_line_attrib
928 {
929 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
930 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
931 GLushort StipplePattern; /**< Stipple pattern */
932 GLint StippleFactor; /**< Stipple repeat factor */
933 GLfloat Width; /**< Line width */
934 };
935
936
937 /**
938 * Display list attribute group (GL_LIST_BIT).
939 */
940 struct gl_list_attrib
941 {
942 GLuint ListBase;
943 };
944
945
946 /**
947 * Multisample attribute group (GL_MULTISAMPLE_BIT).
948 */
949 struct gl_multisample_attrib
950 {
951 GLboolean Enabled;
952 GLboolean _Enabled; /**< true if Enabled and multisample buffer */
953 GLboolean SampleAlphaToCoverage;
954 GLboolean SampleAlphaToOne;
955 GLboolean SampleCoverage;
956 GLfloat SampleCoverageValue;
957 GLboolean SampleCoverageInvert;
958 };
959
960
961 /**
962 * A pixelmap (see glPixelMap)
963 */
964 struct gl_pixelmap
965 {
966 GLint Size;
967 GLfloat Map[MAX_PIXEL_MAP_TABLE];
968 GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
969 };
970
971
972 /**
973 * Collection of all pixelmaps
974 */
975 struct gl_pixelmaps
976 {
977 struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
978 struct gl_pixelmap GtoG;
979 struct gl_pixelmap BtoB;
980 struct gl_pixelmap AtoA;
981 struct gl_pixelmap ItoR;
982 struct gl_pixelmap ItoG;
983 struct gl_pixelmap ItoB;
984 struct gl_pixelmap ItoA;
985 struct gl_pixelmap ItoI;
986 struct gl_pixelmap StoS;
987 };
988
989
990 /**
991 * Pixel attribute group (GL_PIXEL_MODE_BIT).
992 */
993 struct gl_pixel_attrib
994 {
995 GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
996
997 /*--- Begin Pixel Transfer State ---*/
998 /* Fields are in the order in which they're applied... */
999
1000 /** Scale & Bias (index shift, offset) */
1001 /*@{*/
1002 GLfloat RedBias, RedScale;
1003 GLfloat GreenBias, GreenScale;
1004 GLfloat BlueBias, BlueScale;
1005 GLfloat AlphaBias, AlphaScale;
1006 GLfloat DepthBias, DepthScale;
1007 GLint IndexShift, IndexOffset;
1008 /*@}*/
1009
1010 /* Pixel Maps */
1011 /* Note: actual pixel maps are not part of this attrib group */
1012 GLboolean MapColorFlag;
1013 GLboolean MapStencilFlag;
1014
1015 /*--- End Pixel Transfer State ---*/
1016
1017 /** glPixelZoom */
1018 GLfloat ZoomX, ZoomY;
1019 };
1020
1021
1022 /**
1023 * Point attribute group (GL_POINT_BIT).
1024 */
1025 struct gl_point_attrib
1026 {
1027 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
1028 GLfloat Size; /**< User-specified point size */
1029 GLfloat Params[3]; /**< GL_EXT_point_parameters */
1030 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
1031 GLfloat Threshold; /**< GL_EXT_point_parameters */
1032 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
1033 GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
1034 GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
1035 GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
1036 GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
1037 };
1038
1039
1040 /**
1041 * Polygon attribute group (GL_POLYGON_BIT).
1042 */
1043 struct gl_polygon_attrib
1044 {
1045 GLenum FrontFace; /**< Either GL_CW or GL_CCW */
1046 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
1047 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
1048 GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
1049 GLboolean CullFlag; /**< Culling on/off flag */
1050 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
1051 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
1052 GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
1053 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
1054 GLfloat OffsetUnits; /**< Polygon offset units, from user */
1055 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
1056 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
1057 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
1058 };
1059
1060
1061 /**
1062 * Scissor attributes (GL_SCISSOR_BIT).
1063 */
1064 struct gl_scissor_attrib
1065 {
1066 GLboolean Enabled; /**< Scissor test enabled? */
1067 GLint X, Y; /**< Lower left corner of box */
1068 GLsizei Width, Height; /**< Size of box */
1069 };
1070
1071
1072 /**
1073 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1074 *
1075 * Three sets of stencil data are tracked so that OpenGL 2.0,
1076 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
1077 * simultaneously. In each of the stencil state arrays, element 0 corresponds
1078 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
1079 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
1080 * GL_EXT_stencil_two_side GL_BACK state.
1081 *
1082 * The derived value \c _BackFace is either 1 or 2 depending on whether or
1083 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
1084 *
1085 * The derived value \c _TestTwoSide is set when the front-face and back-face
1086 * stencil state are different.
1087 */
1088 struct gl_stencil_attrib
1089 {
1090 GLboolean Enabled; /**< Enabled flag */
1091 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
1092 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */
1093 GLboolean _Enabled; /**< Enabled and stencil buffer present */
1094 GLboolean _TestTwoSide;
1095 GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
1096 GLenum Function[3]; /**< Stencil function */
1097 GLenum FailFunc[3]; /**< Fail function */
1098 GLenum ZPassFunc[3]; /**< Depth buffer pass function */
1099 GLenum ZFailFunc[3]; /**< Depth buffer fail function */
1100 GLint Ref[3]; /**< Reference value */
1101 GLuint ValueMask[3]; /**< Value mask */
1102 GLuint WriteMask[3]; /**< Write mask */
1103 GLuint Clear; /**< Clear value */
1104 };
1105
1106
1107 /**
1108 * An index for each type of texture object. These correspond to the GL
1109 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
1110 * Note: the order is from highest priority to lowest priority.
1111 */
1112 typedef enum
1113 {
1114 TEXTURE_CUBE_INDEX,
1115 TEXTURE_3D_INDEX,
1116 TEXTURE_2D_INDEX,
1117 TEXTURE_1D_INDEX,
1118 NUM_TEXTURE_TARGETS
1119 } gl_texture_index;
1120
1121
1122 /**
1123 * Bit flags for each type of texture object
1124 * Used for Texture.Unit[]._ReallyEnabled flags.
1125 */
1126 /*@{*/
1127 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1128 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1129 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1130 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1131 /*@}*/
1132
1133
1134 /**
1135 * TexGenEnabled flags.
1136 */
1137 /*@{*/
1138 #define S_BIT 1
1139 #define T_BIT 2
1140 #define R_BIT 4
1141 #define Q_BIT 8
1142 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1143 /*@}*/
1144
1145
1146 /**
1147 * Bit flag versions of the corresponding GL_ constants.
1148 */
1149 /*@{*/
1150 #define TEXGEN_SPHERE_MAP 0x1
1151 #define TEXGEN_OBJ_LINEAR 0x2
1152 #define TEXGEN_EYE_LINEAR 0x4
1153 #define TEXGEN_REFLECTION_MAP_NV 0x8
1154 #define TEXGEN_NORMAL_MAP_NV 0x10
1155
1156 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1157 TEXGEN_REFLECTION_MAP_NV | \
1158 TEXGEN_NORMAL_MAP_NV)
1159 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1160 TEXGEN_REFLECTION_MAP_NV | \
1161 TEXGEN_NORMAL_MAP_NV | \
1162 TEXGEN_EYE_LINEAR)
1163 /*@}*/
1164
1165
1166
1167 /** Tex-gen enabled for texture unit? */
1168 #define ENABLE_TEXGEN(unit) (1 << (unit))
1169
1170 /** Non-identity texture matrix for texture unit? */
1171 #define ENABLE_TEXMAT(unit) (1 << (unit))
1172
1173
1174 /**
1175 * Texture image state. Drivers will typically create a subclass of this
1176 * with extra fields for memory buffers, etc.
1177 */
1178 struct gl_texture_image
1179 {
1180 GLint InternalFormat; /**< Internal format as given by the user */
1181 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1182 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1183 * GL_INTENSITY, GL_DEPTH_COMPONENT or
1184 * GL_DEPTH_STENCIL_EXT only. Used for
1185 * choosing TexEnv arithmetic.
1186 */
1187 gl_format TexFormat; /**< The actual texture memory format */
1188
1189 GLuint Border; /**< 0 or 1 */
1190 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
1191 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
1192 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
1193 GLuint Width2; /**< = Width - 2*Border */
1194 GLuint Height2; /**< = Height - 2*Border */
1195 GLuint Depth2; /**< = Depth - 2*Border */
1196 GLuint WidthLog2; /**< = log2(Width2) */
1197 GLuint HeightLog2; /**< = log2(Height2) */
1198 GLuint DepthLog2; /**< = log2(Depth2) */
1199 GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
1200
1201 struct gl_texture_object *TexObject; /**< Pointer back to parent object */
1202 GLuint Level; /**< Which mipmap level am I? */
1203 /** Cube map face: index into gl_texture_object::Image[] array */
1204 GLuint Face;
1205 };
1206
1207
1208 /**
1209 * Indexes for cube map faces.
1210 */
1211 typedef enum
1212 {
1213 FACE_POS_X = 0,
1214 FACE_NEG_X = 1,
1215 FACE_POS_Y = 2,
1216 FACE_NEG_Y = 3,
1217 FACE_POS_Z = 4,
1218 FACE_NEG_Z = 5,
1219 MAX_FACES = 6
1220 } gl_face_index;
1221
1222 /**
1223 * Sampler object state. These objects are new with GL_ARB_sampler_objects
1224 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
1225 */
1226 struct gl_sampler_object
1227 {
1228 GLuint Name;
1229 GLint RefCount;
1230
1231 GLenum WrapS; /**< S-axis texture image wrap mode */
1232 GLenum WrapT; /**< T-axis texture image wrap mode */
1233 GLenum WrapR; /**< R-axis texture image wrap mode */
1234 GLenum MinFilter; /**< minification filter */
1235 GLenum MagFilter; /**< magnification filter */
1236 union gl_color_union BorderColor; /**< Interpreted according to texture format */
1237 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
1238 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
1239 GLfloat LodBias; /**< OpenGL 1.4 */
1240 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1241
1242 };
1243
1244
1245 /**
1246 * Texture object state. Contains the array of mipmap images, border color,
1247 * wrap modes, filter modes, and shadow/texcompare state.
1248 */
1249 struct gl_texture_object
1250 {
1251 _glthread_Mutex Mutex; /**< for thread safety */
1252 GLint RefCount; /**< reference count */
1253 GLuint Name; /**< the user-visible texture object ID */
1254 GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1255
1256 struct gl_sampler_object Sampler;
1257
1258 GLfloat Priority; /**< in [0,1] */
1259 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
1260 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
1261 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
1262 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1263 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
1264 GLboolean _Complete; /**< Is texture object complete? */
1265 GLboolean _RenderToTexture; /**< Any rendering to this texture? */
1266 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1267 GLboolean Immutable; /**< GL_ARB_texture_storage */
1268
1269 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1270 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1271 };
1272
1273
1274 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1275 #define MAX_COMBINER_TERMS 4
1276
1277
1278 /**
1279 * Texture combine environment state.
1280 */
1281 struct gl_tex_env_combine_state
1282 {
1283 GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1284 GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1285 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1286 GLenum SourceRGB[MAX_COMBINER_TERMS];
1287 GLenum SourceA[MAX_COMBINER_TERMS];
1288 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1289 GLenum OperandRGB[MAX_COMBINER_TERMS];
1290 GLenum OperandA[MAX_COMBINER_TERMS];
1291 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1292 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1293 GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
1294 GLuint _NumArgsA; /**< Number of inputs used for the A combiner */
1295 };
1296
1297
1298 /**
1299 * Texture coord generation state.
1300 */
1301 struct gl_texgen
1302 {
1303 GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1304 GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
1305 GLfloat ObjectPlane[4];
1306 GLfloat EyePlane[4];
1307 };
1308
1309
1310 /**
1311 * Texture unit state. Contains enable flags, texture environment/function/
1312 * combiners, texgen state, and pointers to current texture objects.
1313 */
1314 struct gl_texture_unit
1315 {
1316 GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1317 GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1318
1319 GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1320 GLclampf EnvColor[4];
1321 GLfloat EnvColorUnclamped[4];
1322
1323 struct gl_texgen GenS;
1324 struct gl_texgen GenT;
1325 struct gl_texgen GenR;
1326 struct gl_texgen GenQ;
1327 GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1328 GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1329
1330 GLfloat LodBias; /**< for biasing mipmap levels */
1331 GLenum BumpTarget;
1332 GLfloat RotMatrix[4]; /* 2x2 matrix */
1333
1334 /**
1335 * \name GL_EXT_texture_env_combine
1336 */
1337 struct gl_tex_env_combine_state Combine;
1338
1339 /**
1340 * Derived state based on \c EnvMode and the \c BaseFormat of the
1341 * currently enabled texture.
1342 */
1343 struct gl_tex_env_combine_state _EnvMode;
1344
1345 /**
1346 * Currently enabled combiner state. This will point to either
1347 * \c Combine or \c _EnvMode.
1348 */
1349 struct gl_tex_env_combine_state *_CurrentCombine;
1350
1351 /** Current texture object pointers */
1352 struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
1353
1354 /** Points to highest priority, complete and enabled texture object */
1355 struct gl_texture_object *_Current;
1356 };
1357
1358
1359 /**
1360 * Texture attribute group (GL_TEXTURE_BIT).
1361 */
1362 struct gl_texture_attrib
1363 {
1364 GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */
1365 struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
1366
1367 struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
1368
1369 /** Texture units/samplers used by vertex or fragment texturing */
1370 GLbitfield _EnabledUnits;
1371
1372 /** Texture coord units/sets used for fragment texturing */
1373 GLbitfield _EnabledCoordUnits;
1374
1375 /** Texture coord units that have texgen enabled */
1376 GLbitfield _TexGenEnabled;
1377
1378 /** Texture coord units that have non-identity matrices */
1379 GLbitfield _TexMatEnabled;
1380
1381 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1382 GLbitfield _GenFlags;
1383 };
1384
1385
1386 /**
1387 * Data structure representing a single clip plane (e.g. one of the elements
1388 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1389 */
1390 typedef GLfloat gl_clip_plane[4];
1391
1392
1393 /**
1394 * Transformation attribute group (GL_TRANSFORM_BIT).
1395 */
1396 struct gl_transform_attrib
1397 {
1398 GLenum MatrixMode; /**< Matrix mode */
1399 gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */
1400 gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
1401 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
1402 GLboolean Normalize; /**< Normalize all normals? */
1403 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1404 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1405
1406 GLfloat CullEyePos[4];
1407 GLfloat CullObjPos[4];
1408 };
1409
1410
1411 /**
1412 * Viewport attribute group (GL_VIEWPORT_BIT).
1413 */
1414 struct gl_viewport_attrib
1415 {
1416 GLint X, Y; /**< position */
1417 GLsizei Width, Height; /**< size */
1418 GLfloat Near, Far; /**< Depth buffer range */
1419 GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
1420 };
1421
1422
1423 /**
1424 * GL_ARB_vertex/pixel_buffer_object buffer object
1425 */
1426 struct gl_buffer_object
1427 {
1428 _glthread_Mutex Mutex;
1429 GLint RefCount;
1430 GLuint Name;
1431 GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1432 GLsizeiptrARB Size; /**< Size of buffer storage in bytes */
1433 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1434 /** Fields describing a mapped buffer */
1435 /*@{*/
1436 GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
1437 GLvoid *Pointer; /**< User-space address of mapping */
1438 GLintptr Offset; /**< Mapped offset */
1439 GLsizeiptr Length; /**< Mapped length */
1440 /*@}*/
1441 GLboolean DeletePending; /**< true if buffer object is removed from the hash */
1442 GLboolean Written; /**< Ever written to? (for debugging) */
1443 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1444 };
1445
1446
1447 /**
1448 * Client pixel packing/unpacking attributes
1449 */
1450 struct gl_pixelstore_attrib
1451 {
1452 GLint Alignment;
1453 GLint RowLength;
1454 GLint SkipPixels;
1455 GLint SkipRows;
1456 GLint ImageHeight;
1457 GLint SkipImages;
1458 GLboolean SwapBytes;
1459 GLboolean LsbFirst;
1460 GLboolean Invert; /**< GL_MESA_pack_invert */
1461 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
1462 };
1463
1464
1465 /**
1466 * Client vertex array attributes
1467 */
1468 struct gl_client_array
1469 {
1470 GLint Size; /**< components per element (1,2,3,4) */
1471 GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
1472 GLsizei Stride; /**< user-specified stride */
1473 GLsizei StrideB; /**< actual stride in bytes */
1474 const GLubyte *Ptr; /**< Points to array data */
1475 GLboolean Enabled; /**< Enabled flag is a boolean */
1476 GLboolean Normalized; /**< GL_ARB_vertex_program */
1477 GLboolean Integer; /**< Integer-valued? */
1478 GLuint _ElementSize; /**< size of each element in bytes */
1479
1480 struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
1481 GLuint _MaxElement; /**< max element index into array buffer + 1 */
1482 };
1483
1484
1485 /**
1486 * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
1487 * extension, but a nice encapsulation in any case.
1488 */
1489 struct gl_array_object
1490 {
1491 /** Name of the array object as received from glGenVertexArrayAPPLE. */
1492 GLuint Name;
1493
1494 GLint RefCount;
1495 _glthread_Mutex Mutex;
1496
1497 /**
1498 * Does the VAO use ARB semantics or Apple semantics?
1499 *
1500 * There are several ways in which ARB_vertex_array_object and
1501 * APPLE_vertex_array_object VAOs have differing semantics. At the very
1502 * least,
1503 *
1504 * - ARB VAOs require that all array data be sourced from vertex buffer
1505 * objects, but Apple VAOs do not.
1506 *
1507 * - ARB VAOs require that names come from GenVertexArrays.
1508 *
1509 * This flag notes which behavior governs this VAO.
1510 */
1511 GLboolean ARBsemantics;
1512
1513 /**
1514 * Has this array object been bound?
1515 */
1516 GLboolean _Used;
1517
1518 /** Vertex attribute arrays */
1519 struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
1520
1521 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1522 GLbitfield64 _Enabled;
1523
1524 /**
1525 * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs
1526 * we can determine the max legal (in bounds) glDrawElements array index.
1527 */
1528 GLuint _MaxElement;
1529
1530 struct gl_buffer_object *ElementArrayBufferObj;
1531 };
1532
1533
1534 /**
1535 * Vertex array state
1536 */
1537 struct gl_array_attrib
1538 {
1539 /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
1540 struct gl_array_object *ArrayObj;
1541
1542 /** The default vertex array object */
1543 struct gl_array_object *DefaultArrayObj;
1544
1545 /** Array objects (GL_ARB/APPLE_vertex_array_object) */
1546 struct _mesa_HashTable *Objects;
1547
1548 GLint ActiveTexture; /**< Client Active Texture */
1549 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1550 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1551
1552 GLbitfield64 NewState; /**< mask of VERT_BIT_* values */
1553 GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */
1554
1555 /* GL_ARB_vertex_buffer_object */
1556 struct gl_buffer_object *ArrayBufferObj;
1557 };
1558
1559
1560 /**
1561 * Feedback buffer state
1562 */
1563 struct gl_feedback
1564 {
1565 GLenum Type;
1566 GLbitfield _Mask; /**< FB_* bits */
1567 GLfloat *Buffer;
1568 GLuint BufferSize;
1569 GLuint Count;
1570 };
1571
1572
1573 /**
1574 * Selection buffer state
1575 */
1576 struct gl_selection
1577 {
1578 GLuint *Buffer; /**< selection buffer */
1579 GLuint BufferSize; /**< size of the selection buffer */
1580 GLuint BufferCount; /**< number of values in the selection buffer */
1581 GLuint Hits; /**< number of records in the selection buffer */
1582 GLuint NameStackDepth; /**< name stack depth */
1583 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1584 GLboolean HitFlag; /**< hit flag */
1585 GLfloat HitMinZ; /**< minimum hit depth */
1586 GLfloat HitMaxZ; /**< maximum hit depth */
1587 };
1588
1589
1590 /**
1591 * 1-D Evaluator control points
1592 */
1593 struct gl_1d_map
1594 {
1595 GLuint Order; /**< Number of control points */
1596 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1597 GLfloat *Points; /**< Points to contiguous control points */
1598 };
1599
1600
1601 /**
1602 * 2-D Evaluator control points
1603 */
1604 struct gl_2d_map
1605 {
1606 GLuint Uorder; /**< Number of control points in U dimension */
1607 GLuint Vorder; /**< Number of control points in V dimension */
1608 GLfloat u1, u2, du;
1609 GLfloat v1, v2, dv;
1610 GLfloat *Points; /**< Points to contiguous control points */
1611 };
1612
1613
1614 /**
1615 * All evaluator control point state
1616 */
1617 struct gl_evaluators
1618 {
1619 /**
1620 * \name 1-D maps
1621 */
1622 /*@{*/
1623 struct gl_1d_map Map1Vertex3;
1624 struct gl_1d_map Map1Vertex4;
1625 struct gl_1d_map Map1Index;
1626 struct gl_1d_map Map1Color4;
1627 struct gl_1d_map Map1Normal;
1628 struct gl_1d_map Map1Texture1;
1629 struct gl_1d_map Map1Texture2;
1630 struct gl_1d_map Map1Texture3;
1631 struct gl_1d_map Map1Texture4;
1632 struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
1633 /*@}*/
1634
1635 /**
1636 * \name 2-D maps
1637 */
1638 /*@{*/
1639 struct gl_2d_map Map2Vertex3;
1640 struct gl_2d_map Map2Vertex4;
1641 struct gl_2d_map Map2Index;
1642 struct gl_2d_map Map2Color4;
1643 struct gl_2d_map Map2Normal;
1644 struct gl_2d_map Map2Texture1;
1645 struct gl_2d_map Map2Texture2;
1646 struct gl_2d_map Map2Texture3;
1647 struct gl_2d_map Map2Texture4;
1648 struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
1649 /*@}*/
1650 };
1651
1652
1653 /**
1654 * Names of the various vertex/fragment program register files, etc.
1655 *
1656 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1657 * All values should fit in a 4-bit field.
1658 *
1659 * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
1660 * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
1661 * be "uniform" variables since they can only be set outside glBegin/End.
1662 * They're also all stored in the same Parameters array.
1663 */
1664 typedef enum
1665 {
1666 PROGRAM_TEMPORARY, /**< machine->Temporary[] */
1667 PROGRAM_INPUT, /**< machine->Inputs[] */
1668 PROGRAM_OUTPUT, /**< machine->Outputs[] */
1669 PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */
1670 PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */
1671 PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */
1672 PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */
1673 PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */
1674 PROGRAM_CONSTANT, /**< gl_program->Parameters[] */
1675 PROGRAM_UNIFORM, /**< gl_program->Parameters[] */
1676 PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */
1677 PROGRAM_ADDRESS, /**< machine->AddressReg */
1678 PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */
1679 PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */
1680 PROGRAM_UNDEFINED, /**< Invalid/TBD value */
1681 PROGRAM_FILE_MAX
1682 } gl_register_file;
1683
1684
1685 /**
1686 * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be
1687 * one of these values.
1688 */
1689 typedef enum
1690 {
1691 SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */
1692 SYSTEM_VALUE_VERTEX_ID, /**< Vertex shader only */
1693 SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */
1694 SYSTEM_VALUE_MAX /**< Number of values */
1695 } gl_system_value;
1696
1697
1698 /**
1699 * The possible interpolation qualifiers that can be applied to a fragment
1700 * shader input in GLSL.
1701 *
1702 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
1703 * gl_fragment_program data structure to 0 causes the default behavior.
1704 */
1705 enum glsl_interp_qualifier
1706 {
1707 INTERP_QUALIFIER_NONE = 0,
1708 INTERP_QUALIFIER_SMOOTH,
1709 INTERP_QUALIFIER_FLAT,
1710 INTERP_QUALIFIER_NOPERSPECTIVE
1711 };
1712
1713
1714 /** Vertex and fragment instructions */
1715 struct prog_instruction;
1716 struct gl_program_parameter_list;
1717 struct gl_uniform_list;
1718
1719 /**
1720 * Base class for any kind of program object
1721 */
1722 struct gl_program
1723 {
1724 GLuint Id;
1725 GLubyte *String; /**< Null-terminated program text */
1726 GLint RefCount;
1727 GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */
1728 GLenum Format; /**< String encoding format */
1729 GLboolean Resident;
1730
1731 struct prog_instruction *Instructions;
1732
1733 GLbitfield64 InputsRead; /**< Bitmask of which input regs are read */
1734 GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
1735 GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */
1736 GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
1737 GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
1738 GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
1739 GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
1740 GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
1741
1742
1743 /** Named parameters, constants, etc. from program text */
1744 struct gl_program_parameter_list *Parameters;
1745 /** Numbered local parameters */
1746 GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
1747
1748 /** Map from sampler unit to texture unit (set by glUniform1i()) */
1749 GLubyte SamplerUnits[MAX_SAMPLERS];
1750
1751 /** Bitmask of which register files are read/written with indirect
1752 * addressing. Mask of (1 << PROGRAM_x) bits.
1753 */
1754 GLbitfield IndirectRegisterFiles;
1755
1756 /** Logical counts */
1757 /*@{*/
1758 GLuint NumInstructions;
1759 GLuint NumTemporaries;
1760 GLuint NumParameters;
1761 GLuint NumAttributes;
1762 GLuint NumAddressRegs;
1763 GLuint NumAluInstructions;
1764 GLuint NumTexInstructions;
1765 GLuint NumTexIndirections;
1766 /*@}*/
1767 /** Native, actual h/w counts */
1768 /*@{*/
1769 GLuint NumNativeInstructions;
1770 GLuint NumNativeTemporaries;
1771 GLuint NumNativeParameters;
1772 GLuint NumNativeAttributes;
1773 GLuint NumNativeAddressRegs;
1774 GLuint NumNativeAluInstructions;
1775 GLuint NumNativeTexInstructions;
1776 GLuint NumNativeTexIndirections;
1777 /*@}*/
1778 };
1779
1780
1781 /** Vertex program object */
1782 struct gl_vertex_program
1783 {
1784 struct gl_program Base; /**< base class */
1785 GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */
1786 GLboolean IsPositionInvariant;
1787 GLboolean UsesClipDistance;
1788 };
1789
1790
1791 /** Fragment program object */
1792 struct gl_fragment_program
1793 {
1794 struct gl_program Base; /**< base class */
1795 GLboolean UsesKill; /**< shader uses KIL instruction */
1796 enum gl_frag_depth_layout FragDepthLayout;
1797
1798 /**
1799 * GLSL interpolation qualifier associated with each fragment shader input.
1800 * For inputs that do not have an interpolation qualifier specified in
1801 * GLSL, the value is INTERP_QUALIFIER_NONE.
1802 */
1803 enum glsl_interp_qualifier InterpQualifier[FRAG_ATTRIB_MAX];
1804 };
1805
1806
1807 /**
1808 * State common to vertex and fragment programs.
1809 */
1810 struct gl_program_state
1811 {
1812 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
1813 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
1814 };
1815
1816
1817 /**
1818 * Context state for vertex programs.
1819 */
1820 struct gl_vertex_program_state
1821 {
1822 GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
1823 GLboolean _Enabled; /**< Enabled and _valid_ user program? */
1824 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
1825 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
1826 /** Computed two sided lighting for fixed function/programs. */
1827 GLboolean _TwoSideEnabled;
1828 struct gl_vertex_program *Current; /**< User-bound vertex program */
1829
1830 /** Currently enabled and valid vertex program (including internal
1831 * programs, user-defined vertex programs and GLSL vertex shaders).
1832 * This is the program we must use when rendering.
1833 */
1834 struct gl_vertex_program *_Current;
1835
1836 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
1837
1838 /* For GL_NV_vertex_program only: */
1839 GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
1840 GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];
1841
1842 /** Cache of fixed-function programs */
1843 struct gl_program_cache *Cache;
1844
1845 GLboolean _Overriden;
1846 };
1847
1848
1849 /**
1850 * Context state for fragment programs.
1851 */
1852 struct gl_fragment_program_state
1853 {
1854 GLboolean Enabled; /**< User-set fragment program enable flag */
1855 GLboolean _Enabled; /**< Enabled and _valid_ user program? */
1856 struct gl_fragment_program *Current; /**< User-bound fragment program */
1857
1858 /** Currently enabled and valid fragment program (including internal
1859 * programs, user-defined fragment programs and GLSL fragment shaders).
1860 * This is the program we must use when rendering.
1861 */
1862 struct gl_fragment_program *_Current;
1863
1864 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
1865
1866 /** Cache of fixed-function programs */
1867 struct gl_program_cache *Cache;
1868 };
1869
1870 /** Set by #pragma directives */
1871 struct gl_sl_pragmas
1872 {
1873 GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */
1874 GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */
1875 GLboolean Optimize; /**< defaults on */
1876 GLboolean Debug; /**< defaults off */
1877 };
1878
1879
1880 /**
1881 * A GLSL vertex or fragment shader object.
1882 */
1883 struct gl_shader
1884 {
1885 GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */
1886 GLuint Name; /**< AKA the handle */
1887 GLint RefCount; /**< Reference count */
1888 GLboolean DeletePending;
1889 GLboolean CompileStatus;
1890 const GLchar *Source; /**< Source code string */
1891 GLuint SourceChecksum; /**< for debug/logging purposes */
1892 struct gl_program *Program; /**< Post-compile assembly code */
1893 GLchar *InfoLog;
1894 struct gl_sl_pragmas Pragmas;
1895
1896 unsigned Version; /**< GLSL version used for linking */
1897
1898 /**
1899 * \name Sampler tracking
1900 *
1901 * \note Each of these fields is only set post-linking.
1902 */
1903 /*@{*/
1904 unsigned num_samplers; /**< Number of samplers used by this shader. */
1905 GLbitfield active_samplers; /**< Bitfield of which samplers are used */
1906 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
1907 /*@}*/
1908
1909 /**
1910 * Number of uniform components used by this shader.
1911 *
1912 * This field is only set post-linking.
1913 */
1914 unsigned num_uniform_components;
1915
1916 struct exec_list *ir;
1917 struct glsl_symbol_table *symbols;
1918
1919 /** Shaders containing built-in functions that are used for linking. */
1920 struct gl_shader *builtins_to_link[16];
1921 unsigned num_builtins_to_link;
1922 };
1923
1924
1925 /**
1926 * A GLSL program object.
1927 * Basically a linked collection of vertex and fragment shaders.
1928 */
1929 struct gl_shader_program
1930 {
1931 GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
1932 GLuint Name; /**< aka handle or ID */
1933 GLint RefCount; /**< Reference count */
1934 GLboolean DeletePending;
1935
1936 /**
1937 * Flags that the linker should not reject the program if it lacks
1938 * a vertex or fragment shader. GLES2 doesn't allow separate
1939 * shader objects, and would reject them. However, we internally
1940 * build separate shader objects for fixed function programs, which
1941 * we use for drivers/common/meta.c and for handling
1942 * _mesa_update_state with no program bound (for example in
1943 * glClear()).
1944 */
1945 GLboolean InternalSeparateShader;
1946
1947 GLuint NumShaders; /**< number of attached shaders */
1948 struct gl_shader **Shaders; /**< List of attached the shaders */
1949
1950 /**
1951 * User-defined attribute bindings
1952 *
1953 * These are set via \c glBindAttribLocation and are used to direct the
1954 * GLSL linker. These are \b not the values used in the compiled shader,
1955 * and they are \b not the values returned by \c glGetAttribLocation.
1956 */
1957 struct string_to_uint_map *AttributeBindings;
1958
1959 /**
1960 * User-defined fragment data bindings
1961 *
1962 * These are set via \c glBindFragDataLocation and are used to direct the
1963 * GLSL linker. These are \b not the values used in the compiled shader,
1964 * and they are \b not the values returned by \c glGetFragDataLocation.
1965 */
1966 struct string_to_uint_map *FragDataBindings;
1967
1968 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
1969 enum gl_frag_depth_layout FragDepthLayout;
1970
1971 /** Vertex shader state - copied into gl_vertex_program at link time */
1972 struct {
1973 GLboolean UsesClipDistance; /**< True if gl_ClipDistance is written to. */
1974 GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
1975 0 if not present. */
1976 } Vert;
1977
1978 /* post-link info: */
1979 unsigned NumUserUniformStorage;
1980 struct gl_uniform_storage *UniformStorage;
1981
1982 /**
1983 * Map of active uniform names to locations
1984 *
1985 * Maps any active uniform that is not an array element to a location.
1986 * Each active uniform, including individual structure members will appear
1987 * in this map. This roughly corresponds to the set of names that would be
1988 * enumerated by \c glGetActiveUniform.
1989 */
1990 struct string_to_uint_map *UniformHash;
1991
1992 /**
1993 * Map from sampler unit to texture unit (set by glUniform1i())
1994 *
1995 * A sampler unit is associated with each sampler uniform by the linker.
1996 * The sampler unit associated with each uniform is stored in the
1997 * \c gl_uniform_storage::sampler field.
1998 */
1999 GLubyte SamplerUnits[MAX_SAMPLERS];
2000 /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
2001 gl_texture_index SamplerTargets[MAX_SAMPLERS];
2002
2003 GLboolean LinkStatus; /**< GL_LINK_STATUS */
2004 GLboolean Validated;
2005 GLboolean _Used; /**< Ever used for drawing? */
2006 GLchar *InfoLog;
2007
2008 unsigned Version; /**< GLSL version used for linking */
2009
2010 /**
2011 * Per-stage shaders resulting from the first stage of linking.
2012 *
2013 * Set of linked shaders for this program. The array is accessed using the
2014 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
2015 * \c NULL.
2016 */
2017 struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES];
2018 };
2019
2020
2021 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
2022 #define GLSL_LOG 0x2 /**< Write shaders to files */
2023 #define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */
2024 #define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */
2025 #define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */
2026 #define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */
2027 #define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */
2028 #define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */
2029
2030
2031 /**
2032 * Context state for GLSL vertex/fragment shaders.
2033 */
2034 struct gl_shader_state
2035 {
2036 /**
2037 * Programs used for rendering
2038 *
2039 * There is a separate program set for each shader stage. If
2040 * GL_EXT_separate_shader_objects is not supported, each of these must point
2041 * to \c NULL or to the same program.
2042 */
2043 struct gl_shader_program *CurrentVertexProgram;
2044 struct gl_shader_program *CurrentFragmentProgram;
2045
2046 struct gl_shader_program *_CurrentFragmentProgram;
2047
2048 /**
2049 * Program used by glUniform calls.
2050 *
2051 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
2052 */
2053 struct gl_shader_program *ActiveProgram;
2054
2055 GLbitfield Flags; /**< Mask of GLSL_x flags */
2056 };
2057
2058 /**
2059 * Compiler options for a single GLSL shaders type
2060 */
2061 struct gl_shader_compiler_options
2062 {
2063 /** Driver-selectable options: */
2064 GLboolean EmitCondCodes; /**< Use condition codes? */
2065 GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
2066 GLboolean EmitNoLoops;
2067 GLboolean EmitNoFunctions;
2068 GLboolean EmitNoCont; /**< Emit CONT opcode? */
2069 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
2070 GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */
2071 GLboolean EmitNoPow; /**< Emit POW opcodes? */
2072 GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */
2073
2074 /**
2075 * \name Forms of indirect addressing the driver cannot do.
2076 */
2077 /*@{*/
2078 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
2079 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
2080 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
2081 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
2082 /*@}*/
2083
2084 GLuint MaxIfDepth; /**< Maximum nested IF blocks */
2085 GLuint MaxUnrollIterations;
2086
2087 struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
2088 };
2089
2090 /**
2091 * State which can be shared by multiple contexts:
2092 */
2093 struct gl_shared_state
2094 {
2095 _glthread_Mutex Mutex; /**< for thread safety */
2096 GLint RefCount; /**< Reference count */
2097 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
2098 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
2099
2100 /** Default texture objects (shared by all texture units) */
2101 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
2102
2103 /** Fallback texture used when a bound texture is incomplete */
2104 struct gl_texture_object *FallbackTex;
2105
2106 /**
2107 * \name Thread safety and statechange notification for texture
2108 * objects.
2109 *
2110 * \todo Improve the granularity of locking.
2111 */
2112 /*@{*/
2113 _glthread_Mutex TexMutex; /**< texobj thread safety */
2114 GLuint TextureStateStamp; /**< state notification for shared tex */
2115 /*@}*/
2116
2117 /** Default buffer object for vertex arrays that aren't in VBOs */
2118 struct gl_buffer_object *NullBufferObj;
2119
2120 /**
2121 * \name Vertex/geometry/fragment programs
2122 */
2123 /*@{*/
2124 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
2125 struct gl_vertex_program *DefaultVertexProgram;
2126 struct gl_fragment_program *DefaultFragmentProgram;
2127 /*@}*/
2128
2129 struct _mesa_HashTable *BufferObjects;
2130
2131 /** Table of both gl_shader and gl_shader_program objects */
2132 struct _mesa_HashTable *ShaderObjects;
2133
2134 /* GL_EXT_framebuffer_object */
2135 struct _mesa_HashTable *RenderBuffers;
2136 struct _mesa_HashTable *FrameBuffers;
2137
2138 void *DriverData; /**< Device driver shared state */
2139 };
2140
2141
2142
2143 /**
2144 * Renderbuffers represent drawing surfaces such as color, depth and/or
2145 * stencil. A framebuffer object has a set of renderbuffers.
2146 * Drivers will typically derive subclasses of this type.
2147 */
2148 struct gl_renderbuffer
2149 {
2150 _glthread_Mutex Mutex; /**< for thread safety */
2151 GLuint ClassID; /**< Useful for drivers */
2152 GLuint Name;
2153 GLint RefCount;
2154 GLuint Width, Height;
2155 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
2156 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
2157 GLubyte NumSamples;
2158 GLenum InternalFormat; /**< The user-specified format */
2159 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
2160 GL_STENCIL_INDEX. */
2161 gl_format Format; /**< The actual renderbuffer memory format */
2162
2163 /** Delete this renderbuffer */
2164 void (*Delete)(struct gl_renderbuffer *rb);
2165
2166 /** Allocate new storage for this renderbuffer */
2167 GLboolean (*AllocStorage)(struct gl_context *ctx,
2168 struct gl_renderbuffer *rb,
2169 GLenum internalFormat,
2170 GLuint width, GLuint height);
2171 };
2172
2173
2174 /**
2175 * A renderbuffer attachment points to either a texture object (and specifies
2176 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
2177 */
2178 struct gl_renderbuffer_attachment
2179 {
2180 GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
2181 GLboolean Complete;
2182
2183 /**
2184 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
2185 * application supplied renderbuffer object.
2186 */
2187 struct gl_renderbuffer *Renderbuffer;
2188
2189 /**
2190 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
2191 * supplied texture object.
2192 */
2193 struct gl_texture_object *Texture;
2194 GLuint TextureLevel; /**< Attached mipmap level. */
2195 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
2196 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
2197 * and 2D array textures */
2198 };
2199
2200
2201 /**
2202 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2203 * In C++ terms, think of this as a base class from which device drivers
2204 * will make derived classes.
2205 */
2206 struct gl_framebuffer
2207 {
2208 _glthread_Mutex Mutex; /**< for thread safety */
2209 /**
2210 * If zero, this is a window system framebuffer. If non-zero, this
2211 * is a FBO framebuffer; note that for some devices (i.e. those with
2212 * a natural pixel coordinate system for FBOs that differs from the
2213 * OpenGL/Mesa coordinate system), this means that the viewport,
2214 * polygon face orientation, and polygon stipple will have to be inverted.
2215 */
2216 GLuint Name;
2217
2218 GLint RefCount;
2219 GLboolean DeletePending;
2220
2221 /**
2222 * The framebuffer's visual. Immutable if this is a window system buffer.
2223 * Computed from attachments if user-made FBO.
2224 */
2225 struct gl_config Visual;
2226
2227 GLboolean Initialized;
2228
2229 GLuint Width, Height; /**< size of frame buffer in pixels */
2230
2231 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2232 /*@{*/
2233 GLint _Xmin, _Xmax; /**< inclusive */
2234 GLint _Ymin, _Ymax; /**< exclusive */
2235 /*@}*/
2236
2237 /** \name Derived Z buffer stuff */
2238 /*@{*/
2239 GLuint _DepthMax; /**< Max depth buffer value */
2240 GLfloat _DepthMaxF; /**< Float max depth buffer value */
2241 GLfloat _MRD; /**< minimum resolvable difference in Z values */
2242 /*@}*/
2243
2244 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2245 GLenum _Status;
2246
2247 /** Integer color values */
2248 GLboolean _IntegerColor;
2249
2250 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2251 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
2252
2253 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2254 * attribute group and GL_PIXEL attribute group, respectively.
2255 */
2256 GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
2257 GLenum ColorReadBuffer;
2258
2259 /** Computed from ColorDraw/ReadBuffer above */
2260 GLuint _NumColorDrawBuffers;
2261 GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
2262 GLint _ColorReadBufferIndex; /* -1 = None */
2263 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
2264 struct gl_renderbuffer *_ColorReadBuffer;
2265
2266 /** Delete this framebuffer */
2267 void (*Delete)(struct gl_framebuffer *fb);
2268 };
2269
2270
2271 /**
2272 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
2273 */
2274 struct gl_precision
2275 {
2276 GLushort RangeMin; /**< min value exponent */
2277 GLushort RangeMax; /**< max value exponent */
2278 GLushort Precision; /**< number of mantissa bits */
2279 };
2280
2281
2282 /**
2283 * Limits for vertex, geometry and fragment programs/shaders.
2284 */
2285 struct gl_program_constants
2286 {
2287 /* logical limits */
2288 GLuint MaxInstructions;
2289 GLuint MaxAluInstructions;
2290 GLuint MaxTexInstructions;
2291 GLuint MaxTexIndirections;
2292 GLuint MaxAttribs;
2293 GLuint MaxTemps;
2294 GLuint MaxAddressRegs;
2295 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
2296 GLuint MaxParameters;
2297 GLuint MaxLocalParams;
2298 GLuint MaxEnvParams;
2299 /* native/hardware limits */
2300 GLuint MaxNativeInstructions;
2301 GLuint MaxNativeAluInstructions;
2302 GLuint MaxNativeTexInstructions;
2303 GLuint MaxNativeTexIndirections;
2304 GLuint MaxNativeAttribs;
2305 GLuint MaxNativeTemps;
2306 GLuint MaxNativeAddressRegs;
2307 GLuint MaxNativeParameters;
2308 /* For shaders */
2309 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
2310 };
2311
2312
2313 /**
2314 * Constants which may be overridden by device driver during context creation
2315 * but are never changed after that.
2316 */
2317 struct gl_constants
2318 {
2319 GLint MaxTextureMbytes; /**< Max memory per image, in MB */
2320 GLint MaxTextureLevels; /**< Max mipmap levels. */
2321 GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
2322 GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
2323 GLuint MaxTextureCoordUnits;
2324 GLuint MaxTextureImageUnits;
2325 GLuint MaxVertexTextureImageUnits;
2326 GLuint MaxCombinedTextureImageUnits;
2327 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */
2328 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
2329 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
2330
2331 GLuint MaxArrayLockSize;
2332
2333 GLint SubPixelBits;
2334
2335 GLfloat MinPointSize, MaxPointSize; /**< aliased */
2336 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
2337 GLfloat PointSizeGranularity;
2338 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
2339 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
2340 GLfloat LineWidthGranularity;
2341
2342 GLuint MaxColorTableSize;
2343
2344 GLuint MaxClipPlanes;
2345 GLuint MaxLights;
2346 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
2347 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
2348
2349 GLuint MaxViewportWidth, MaxViewportHeight;
2350
2351 struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */
2352 struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */
2353 GLuint MaxProgramMatrices;
2354 GLuint MaxProgramMatrixStackDepth;
2355
2356 /** vertex array / buffer object bounds checking */
2357 GLboolean CheckArrayBounds;
2358
2359 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
2360
2361 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
2362 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
2363 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
2364
2365 /** Number of varying vectors between vertex and fragment shaders */
2366 GLuint MaxVarying;
2367
2368 GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */
2369
2370 /**
2371 * Changes default GLSL extension behavior from "error" to "warn". It's out
2372 * of spec, but it can make some apps work that otherwise wouldn't.
2373 */
2374 GLboolean ForceGLSLExtensionsWarn;
2375
2376 /**
2377 * Does the driver support real 32-bit integers? (Otherwise, integers are
2378 * simulated via floats.)
2379 */
2380 GLboolean NativeIntegers;
2381
2382 /**
2383 * If the driver supports real 32-bit integers, what integer value should be
2384 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
2385 */
2386 GLuint UniformBooleanTrue;
2387
2388 /** Which texture units support GL_ATI_envmap_bumpmap as targets */
2389 GLbitfield SupportedBumpUnits;
2390
2391 /** OpenGL version 3.0 */
2392 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
2393
2394 /** OpenGL version 3.2 */
2395 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
2396
2397 /** GL_EXT_gpu_shader4 */
2398 GLint MinProgramTexelOffset, MaxProgramTexelOffset;
2399
2400 /* GL_ARB_robustness */
2401 GLenum ResetStrategy;
2402
2403 /**
2404 * Whether the implementation strips out and ignores texture borders.
2405 *
2406 * Many GPU hardware implementations don't support rendering with texture
2407 * borders and mipmapped textures. (Note: not static border color, but the
2408 * old 1-pixel border around each edge). Implementations then have to do
2409 * slow fallbacks to be correct, or just ignore the border and be fast but
2410 * wrong. Setting the flag stripts the border off of TexImage calls,
2411 * providing "fast but wrong" at significantly reduced driver complexity.
2412 *
2413 * Texture borders are deprecated in GL 3.0.
2414 **/
2415 GLboolean StripTextureBorder;
2416
2417 /**
2418 * For drivers which can do a better job at eliminating unused varyings
2419 * and uniforms than the GLSL compiler.
2420 *
2421 * XXX Remove these as soon as a better solution is available.
2422 */
2423 GLboolean GLSLSkipStrictMaxVaryingLimitCheck;
2424 GLboolean GLSLSkipStrictMaxUniformLimitCheck;
2425 };
2426
2427
2428 /**
2429 * Enable flag for each OpenGL extension. Different device drivers will
2430 * enable different extensions at runtime.
2431 */
2432 struct gl_extensions
2433 {
2434 GLboolean dummy; /* don't remove this! */
2435 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
2436 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
2437 GLboolean ARB_color_buffer_float;
2438 GLboolean ARB_conservative_depth;
2439 GLboolean ARB_depth_clamp;
2440 GLboolean ARB_draw_buffers_blend;
2441 GLboolean ARB_fragment_program;
2442 GLboolean ARB_fragment_program_shadow;
2443 GLboolean ARB_fragment_shader;
2444 GLboolean ARB_framebuffer_object;
2445 GLboolean ARB_half_float_pixel;
2446 GLboolean ARB_half_float_vertex;
2447 GLboolean ARB_map_buffer_range;
2448 GLboolean ARB_point_sprite;
2449 GLboolean ARB_shader_objects;
2450 GLboolean ARB_shader_stencil_export;
2451 GLboolean ARB_shader_texture_lod;
2452 GLboolean ARB_shading_language_100;
2453 GLboolean ARB_texture_border_clamp;
2454 GLboolean ARB_texture_cube_map;
2455 GLboolean ARB_texture_env_combine;
2456 GLboolean ARB_texture_env_crossbar;
2457 GLboolean ARB_texture_env_dot3;
2458 GLboolean ARB_texture_float;
2459 GLboolean ARB_texture_non_power_of_two;
2460 GLboolean ARB_texture_storage;
2461 GLboolean ARB_transpose_matrix;
2462 GLboolean ARB_vertex_array_object;
2463 GLboolean ARB_vertex_program;
2464 GLboolean ARB_vertex_shader;
2465 GLboolean ARB_window_pos;
2466 GLboolean EXT_blend_color;
2467 GLboolean EXT_blend_equation_separate;
2468 GLboolean EXT_blend_func_separate;
2469 GLboolean EXT_blend_minmax;
2470 GLboolean EXT_clip_volume_hint;
2471 GLboolean EXT_compiled_vertex_array;
2472 GLboolean EXT_depth_bounds_test;
2473 GLboolean EXT_draw_range_elements;
2474 GLboolean EXT_fog_coord;
2475 GLboolean EXT_framebuffer_blit;
2476 GLboolean EXT_framebuffer_multisample;
2477 GLboolean EXT_framebuffer_object;
2478 GLboolean EXT_gpu_program_parameters;
2479 GLboolean EXT_gpu_shader4;
2480 GLboolean EXT_packed_pixels;
2481 GLboolean EXT_pixel_buffer_object;
2482 GLboolean EXT_point_parameters;
2483 GLboolean EXT_rescale_normal;
2484 GLboolean EXT_shadow_funcs;
2485 GLboolean EXT_secondary_color;
2486 GLboolean EXT_separate_shader_objects;
2487 GLboolean EXT_separate_specular_color;
2488 GLboolean EXT_stencil_two_side;
2489 GLboolean EXT_texture3D;
2490 GLboolean EXT_texture_env_dot3;
2491 GLboolean EXT_texture_filter_anisotropic;
2492 GLboolean EXT_texture_integer;
2493 GLboolean EXT_texture_mirror_clamp;
2494 /* vendor extensions */
2495 GLboolean APPLE_packed_pixels;
2496 GLboolean APPLE_vertex_array_object;
2497 GLboolean APPLE_object_purgeable;
2498 GLboolean ATI_envmap_bumpmap;
2499 GLboolean ATI_texture_mirror_once;
2500 GLboolean ATI_texture_env_combine3;
2501 GLboolean ATI_separate_stencil;
2502 GLboolean IBM_rasterpos_clip;
2503 GLboolean IBM_multimode_draw_arrays;
2504 GLboolean MESA_pack_invert;
2505 GLboolean MESA_resize_buffers;
2506 GLboolean MESA_ycbcr_texture;
2507 GLboolean NV_blend_square;
2508 GLboolean NV_fog_distance;
2509 GLboolean NV_fragment_program;
2510 GLboolean NV_fragment_program_option;
2511 GLboolean NV_light_max_exponent;
2512 GLboolean NV_point_sprite;
2513 GLboolean NV_texture_barrier;
2514 GLboolean NV_texgen_reflection;
2515 GLboolean NV_texture_env_combine4;
2516 GLboolean NV_vertex_program;
2517 GLboolean NV_vertex_program1_1;
2518 GLboolean SGIS_texture_lod;
2519 GLboolean extension_sentinel;
2520 /** The extension string */
2521 const GLubyte *String;
2522 /** Number of supported extensions */
2523 GLuint Count;
2524 };
2525
2526
2527 /**
2528 * A stack of matrices (projection, modelview, color, texture, etc).
2529 */
2530 struct gl_matrix_stack
2531 {
2532 GLmatrix *Top; /**< points into Stack */
2533 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
2534 GLuint Depth; /**< 0 <= Depth < MaxDepth */
2535 GLuint MaxDepth; /**< size of Stack[] array */
2536 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2537 };
2538
2539
2540 /**
2541 * \name Bits for image transfer operations
2542 * \sa __struct gl_contextRec::ImageTransferState.
2543 */
2544 /*@{*/
2545 #define IMAGE_SCALE_BIAS_BIT 0x1
2546 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2547 #define IMAGE_MAP_COLOR_BIT 0x4
2548 #define IMAGE_CLAMP_BIT 0x800
2549
2550
2551 /** Pixel Transfer ops */
2552 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
2553 IMAGE_SHIFT_OFFSET_BIT | \
2554 IMAGE_MAP_COLOR_BIT)
2555
2556 /**
2557 * \name Bits to indicate what state has changed.
2558 */
2559 /*@{*/
2560 #define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */
2561 #define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */
2562 #define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */
2563 #define _NEW_COLOR (1 << 3) /**< gl_context::Color */
2564 #define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */
2565 #define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */
2566 #define _NEW_FOG (1 << 6) /**< gl_context::Fog */
2567 #define _NEW_HINT (1 << 7) /**< gl_context::Hint */
2568 #define _NEW_LIGHT (1 << 8) /**< gl_context::Light */
2569 #define _NEW_LINE (1 << 9) /**< gl_context::Line */
2570 #define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */
2571 #define _NEW_POINT (1 << 11) /**< gl_context::Point */
2572 #define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */
2573 #define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */
2574 #define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */
2575 #define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */
2576 #define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */
2577 #define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */
2578 #define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */
2579 #define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */
2580 #define _NEW_ARRAY (1 << 20) /**< gl_context::Array */
2581 #define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */
2582 #define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */
2583 #define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */
2584 #define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */
2585 #define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */
2586 #define _NEW_PROGRAM (1 << 26) /**< New program/shader state */
2587 #define _NEW_PROGRAM_CONSTANTS (1 << 27)
2588 #define _NEW_BUFFER_OBJECT (1 << 28)
2589 #define _NEW_FRAG_CLAMP (1 << 29)
2590 #define _NEW_ALL ~0
2591
2592 /**
2593 * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for
2594 * clarity.
2595 */
2596 #define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM
2597 /*@}*/
2598
2599
2600 /**
2601 * \name A bunch of flags that we think might be useful to drivers.
2602 *
2603 * Set in the __struct gl_contextRec::_TriangleCaps bitfield.
2604 */
2605 /*@{*/
2606 #define DD_FLATSHADE 0x1
2607 #define DD_SEPARATE_SPECULAR 0x2
2608 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2609 #define DD_TRI_LIGHT_TWOSIDE 0x8
2610 #define DD_TRI_UNFILLED 0x10
2611 #define DD_TRI_SMOOTH 0x20
2612 #define DD_TRI_STIPPLE 0x40
2613 #define DD_TRI_OFFSET 0x80
2614 #define DD_LINE_SMOOTH 0x100
2615 #define DD_LINE_STIPPLE 0x200
2616 #define DD_POINT_SMOOTH 0x400
2617 #define DD_POINT_ATTEN 0x800
2618 #define DD_TRI_TWOSTENCIL 0x1000
2619 /*@}*/
2620
2621
2622 /**
2623 * \name Define the state changes under which each of these bits might change
2624 */
2625 /*@{*/
2626 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2627 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2628 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2629 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2630 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2631 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2632 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2633 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2634 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2635 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2636 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2637 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2638 #define _DD_NEW_POINT_SIZE _NEW_POINT
2639 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2640 /*@}*/
2641
2642
2643 /**
2644 * Composite state flags
2645 */
2646 /*@{*/
2647 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2648 _NEW_TEXTURE | \
2649 _NEW_POINT | \
2650 _NEW_PROGRAM | \
2651 _NEW_MODELVIEW)
2652 /*@}*/
2653
2654
2655
2656
2657 /* This has to be included here. */
2658 #include "dd.h"
2659
2660
2661 /**
2662 * Display list flags.
2663 * Strictly this is a tnl-private concept, but it doesn't seem
2664 * worthwhile adding a tnl private structure just to hold this one bit
2665 * of information:
2666 */
2667 #define DLIST_DANGLING_REFS 0x1
2668
2669
2670 /** Opaque declaration of display list payload data type */
2671 union gl_dlist_node;
2672
2673
2674 /**
2675 * Provide a location where information about a display list can be
2676 * collected. Could be extended with driverPrivate structures,
2677 * etc. in the future.
2678 */
2679 struct gl_display_list
2680 {
2681 GLuint Name;
2682 GLbitfield Flags; /**< DLIST_x flags */
2683 /** The dlist commands are in a linked list of nodes */
2684 union gl_dlist_node *Head;
2685 };
2686
2687
2688 /**
2689 * State used during display list compilation and execution.
2690 */
2691 struct gl_dlist_state
2692 {
2693 GLuint CallDepth; /**< Current recursion calling depth */
2694
2695 struct gl_display_list *CurrentList; /**< List currently being compiled */
2696 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
2697 GLuint CurrentPos; /**< Index into current block of nodes */
2698
2699 GLvertexformat ListVtxfmt;
2700
2701 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
2702 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
2703
2704 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
2705 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
2706
2707 GLubyte ActiveIndex;
2708 GLfloat CurrentIndex;
2709
2710 GLubyte ActiveEdgeFlag;
2711 GLboolean CurrentEdgeFlag;
2712
2713 struct {
2714 /* State known to have been set by the currently-compiling display
2715 * list. Used to eliminate some redundant state changes.
2716 */
2717 GLenum ShadeModel;
2718 } Current;
2719 };
2720
2721
2722 /**
2723 * Mesa rendering context.
2724 *
2725 * This is the central context data structure for Mesa. Almost all
2726 * OpenGL state is contained in this structure.
2727 * Think of this as a base class from which device drivers will derive
2728 * sub classes.
2729 *
2730 * The struct gl_context typedef names this structure.
2731 */
2732 struct gl_context
2733 {
2734 /** State possibly shared with other contexts in the address space */
2735 struct gl_shared_state *Shared;
2736
2737 /** \name API function pointer tables */
2738 /*@{*/
2739 struct _glapi_table *Save; /**< Display list save functions */
2740 struct _glapi_table *Exec; /**< Execute functions */
2741 struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
2742 /*@}*/
2743
2744 struct gl_config Visual;
2745 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
2746 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
2747 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
2748 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
2749
2750 /**
2751 * Device driver function pointer table
2752 */
2753 struct dd_function_table Driver;
2754
2755 void *DriverCtx; /**< Points to device driver context/state */
2756
2757 /** Core/Driver constants */
2758 struct gl_constants Const;
2759
2760 /** \name The various 4x4 matrix stacks */
2761 /*@{*/
2762 struct gl_matrix_stack ModelviewMatrixStack;
2763 struct gl_matrix_stack ProjectionMatrixStack;
2764 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
2765 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
2766 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
2767 /*@}*/
2768
2769 /** Combined modelview and projection matrix */
2770 GLmatrix _ModelProjectMatrix;
2771
2772 /** \name Display lists */
2773 struct gl_dlist_state ListState;
2774
2775 GLboolean ExecuteFlag; /**< Execute GL commands? */
2776 GLboolean CompileFlag; /**< Compile GL commands into display list? */
2777
2778 /** Extension information */
2779 struct gl_extensions Extensions;
2780
2781 /** Version info */
2782 GLuint VersionMajor, VersionMinor;
2783 char *VersionString;
2784
2785 /** \name State attribute stack (for glPush/PopAttrib) */
2786 /*@{*/
2787 GLuint AttribStackDepth;
2788 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
2789 /*@}*/
2790
2791 /** \name Renderer attribute groups
2792 *
2793 * We define a struct for each attribute group to make pushing and popping
2794 * attributes easy. Also it's a good organization.
2795 */
2796 /*@{*/
2797 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
2798 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
2799 struct gl_current_attrib Current; /**< Current attributes */
2800 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
2801 struct gl_eval_attrib Eval; /**< Eval attributes */
2802 struct gl_fog_attrib Fog; /**< Fog attributes */
2803 struct gl_hint_attrib Hint; /**< Hint attributes */
2804 struct gl_light_attrib Light; /**< Light attributes */
2805 struct gl_line_attrib Line; /**< Line attributes */
2806 struct gl_list_attrib List; /**< List attributes */
2807 struct gl_multisample_attrib Multisample;
2808 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
2809 struct gl_point_attrib Point; /**< Point attributes */
2810 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
2811 GLuint PolygonStipple[32]; /**< Polygon stipple */
2812 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
2813 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
2814 struct gl_texture_attrib Texture; /**< Texture attributes */
2815 struct gl_transform_attrib Transform; /**< Transformation attributes */
2816 struct gl_viewport_attrib Viewport; /**< Viewport attributes */
2817 /*@}*/
2818
2819 /** \name Client attribute stack */
2820 /*@{*/
2821 GLuint ClientAttribStackDepth;
2822 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
2823 /*@}*/
2824
2825 /** \name Client attribute groups */
2826 /*@{*/
2827 struct gl_array_attrib Array; /**< Vertex arrays */
2828 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
2829 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
2830 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
2831 /*@}*/
2832
2833 /** \name Other assorted state (not pushed/popped on attribute stack) */
2834 /*@{*/
2835 struct gl_pixelmaps PixelMaps;
2836
2837 struct gl_evaluators EvalMap; /**< All evaluators */
2838 struct gl_feedback Feedback; /**< Feedback */
2839 struct gl_selection Select; /**< Selection */
2840
2841 struct gl_program_state Program; /**< general program state */
2842 struct gl_vertex_program_state VertexProgram;
2843 struct gl_fragment_program_state FragmentProgram;
2844
2845 struct gl_shader_state Shader; /**< GLSL shader object state */
2846 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES];
2847 /*@}*/
2848
2849 struct gl_meta_state *Meta; /**< for "meta" operations */
2850
2851 /* GL_EXT_framebuffer_object */
2852 struct gl_renderbuffer *CurrentRenderbuffer;
2853
2854 GLenum ErrorValue; /**< Last error code */
2855
2856 /* GL_ARB_robustness */
2857 GLenum ResetStatus;
2858
2859 /**
2860 * Recognize and silence repeated error debug messages in buggy apps.
2861 */
2862 const char *ErrorDebugFmtString;
2863 GLuint ErrorDebugCount;
2864
2865 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2866 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
2867
2868 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
2869
2870 GLbitfield64 varying_vp_inputs; /**< mask of VERT_BIT_* flags */
2871
2872 /** \name Derived state */
2873 /*@{*/
2874 /** Bitwise-or of DD_* flags. Note that this bitfield may be used before
2875 * state validation so they need to always be current.
2876 */
2877 GLbitfield _TriangleCaps;
2878 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
2879 GLfloat _EyeZDir[3];
2880 GLfloat _ModelViewInvScale;
2881 GLboolean _NeedEyeCoords;
2882 GLboolean _ForceEyeCoords;
2883
2884 GLuint TextureStateTimestamp; /**< detect changes to shared state */
2885
2886 struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
2887 struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
2888 /**@}*/
2889
2890 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
2891
2892 /** \name For debugging/development only */
2893 /*@{*/
2894 GLboolean FirstTimeCurrent;
2895 /*@}*/
2896
2897 /** software compression/decompression supported or not */
2898 GLboolean Mesa_DXTn;
2899
2900 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
2901
2902 /**
2903 * Use dp4 (rather than mul/mad) instructions for position
2904 * transformation?
2905 */
2906 GLboolean mvp_with_dp4;
2907
2908 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
2909
2910 /**
2911 * \name Hooks for module contexts.
2912 *
2913 * These will eventually live in the driver or elsewhere.
2914 */
2915 /*@{*/
2916 void *swrast_context;
2917 void *swsetup_context;
2918 void *swtnl_context;
2919 void *swtnl_im;
2920 struct st_context *st;
2921 void *aelt_context;
2922 /*@}*/
2923 };
2924
2925
2926 #ifdef DEBUG
2927 extern int MESA_VERBOSE;
2928 extern int MESA_DEBUG_FLAGS;
2929 # define MESA_FUNCTION __FUNCTION__
2930 #else
2931 # define MESA_VERBOSE 0
2932 # define MESA_DEBUG_FLAGS 0
2933 # define MESA_FUNCTION "a function"
2934 # ifndef NDEBUG
2935 # define NDEBUG
2936 # endif
2937 #endif
2938
2939
2940 /** The MESA_VERBOSE var is a bitmask of these flags */
2941 enum _verbose
2942 {
2943 VERBOSE_VARRAY = 0x0001,
2944 VERBOSE_TEXTURE = 0x0002,
2945 VERBOSE_MATERIAL = 0x0004,
2946 VERBOSE_PIPELINE = 0x0008,
2947 VERBOSE_DRIVER = 0x0010,
2948 VERBOSE_STATE = 0x0020,
2949 VERBOSE_API = 0x0040,
2950 VERBOSE_DISPLAY_LIST = 0x0100,
2951 VERBOSE_LIGHTING = 0x0200,
2952 VERBOSE_PRIMS = 0x0400,
2953 VERBOSE_VERTS = 0x0800,
2954 VERBOSE_DISASSEM = 0x1000,
2955 VERBOSE_DRAW = 0x2000,
2956 VERBOSE_SWAPBUFFERS = 0x4000
2957 };
2958
2959
2960 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
2961 enum _debug
2962 {
2963 DEBUG_ALWAYS_FLUSH = 0x1
2964 };
2965
2966
2967
2968 #ifdef __cplusplus
2969 }
2970 #endif
2971
2972 #endif /* MTYPES_H */