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