2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 * Main Mesa data structures.
30 * Please try to mark derived values with a leading underscore ('_').
37 #include <stdint.h> /* uint32_t */
39 #include "c11/threads.h"
41 #include "main/glheader.h"
42 #include "main/config.h"
43 #include "glapi/glapi.h"
44 #include "math/m_matrix.h" /* GLmatrix */
45 #include "glsl/shader_enums.h"
46 #include "main/formats.h" /* MESA_FORMAT_COUNT */
55 * \name 64-bit extension of GLbitfield.
58 typedef GLuint64 GLbitfield64
;
60 /** Set a single bit */
61 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
62 /** Set all bits up to excluding bit b */
63 #define BITFIELD64_MASK(b) \
64 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
65 /** Set count bits starting from bit b */
66 #define BITFIELD64_RANGE(b, count) \
67 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
71 * \name Some forward type declarations
74 struct _mesa_HashTable
;
75 struct gl_attrib_node
;
76 struct gl_list_extensions
;
78 struct gl_program_cache
;
79 struct gl_texture_object
;
80 struct gl_debug_state
;
83 struct gl_uniform_storage
;
84 struct prog_instruction
;
85 struct gl_program_parameter_list
;
92 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
93 #define PRIM_MAX GL_PATCHES
94 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
95 #define PRIM_UNKNOWN (PRIM_MAX + 2)
98 * Indexes for vertex program attributes.
99 * GL_NV_vertex_program aliases generic attributes over the conventional
100 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
101 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
102 * generic attributes are distinct/separate).
107 VERT_ATTRIB_WEIGHT
= 1,
108 VERT_ATTRIB_NORMAL
= 2,
109 VERT_ATTRIB_COLOR0
= 3,
110 VERT_ATTRIB_COLOR1
= 4,
112 VERT_ATTRIB_COLOR_INDEX
= 6,
113 VERT_ATTRIB_EDGEFLAG
= 7,
114 VERT_ATTRIB_TEX0
= 8,
115 VERT_ATTRIB_TEX1
= 9,
116 VERT_ATTRIB_TEX2
= 10,
117 VERT_ATTRIB_TEX3
= 11,
118 VERT_ATTRIB_TEX4
= 12,
119 VERT_ATTRIB_TEX5
= 13,
120 VERT_ATTRIB_TEX6
= 14,
121 VERT_ATTRIB_TEX7
= 15,
122 VERT_ATTRIB_POINT_SIZE
= 16,
123 VERT_ATTRIB_GENERIC0
= 17,
124 VERT_ATTRIB_GENERIC1
= 18,
125 VERT_ATTRIB_GENERIC2
= 19,
126 VERT_ATTRIB_GENERIC3
= 20,
127 VERT_ATTRIB_GENERIC4
= 21,
128 VERT_ATTRIB_GENERIC5
= 22,
129 VERT_ATTRIB_GENERIC6
= 23,
130 VERT_ATTRIB_GENERIC7
= 24,
131 VERT_ATTRIB_GENERIC8
= 25,
132 VERT_ATTRIB_GENERIC9
= 26,
133 VERT_ATTRIB_GENERIC10
= 27,
134 VERT_ATTRIB_GENERIC11
= 28,
135 VERT_ATTRIB_GENERIC12
= 29,
136 VERT_ATTRIB_GENERIC13
= 30,
137 VERT_ATTRIB_GENERIC14
= 31,
138 VERT_ATTRIB_GENERIC15
= 32,
143 * Symbolic constats to help iterating over
144 * specific blocks of vertex attributes.
147 * includes all fixed function attributes as well as
148 * the aliased GL_NV_vertex_program shader attributes.
150 * include the classic texture coordinate attributes.
151 * Is a subset of VERT_ATTRIB_FF.
152 * VERT_ATTRIB_GENERIC
153 * include the OpenGL 2.0+ GLSL generic shader attributes.
154 * These alias the generic GL_ARB_vertex_shader attributes.
156 #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
157 #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
159 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
160 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
162 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
163 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
166 * Bitflags for vertex attributes.
167 * These are used in bitfields in many places.
170 #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
171 #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
172 #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
173 #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
174 #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
175 #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
176 #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
177 #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
178 #define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0)
179 #define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1)
180 #define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2)
181 #define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3)
182 #define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4)
183 #define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5)
184 #define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6)
185 #define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7)
186 #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
187 #define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
189 #define VERT_BIT(i) BITFIELD64_BIT(i)
190 #define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX)
192 #define VERT_BIT_FF(i) VERT_BIT(i)
193 #define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX)
194 #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
195 #define VERT_BIT_TEX_ALL \
196 BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
198 #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
199 #define VERT_BIT_GENERIC_ALL \
200 BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
204 #define VARYING_SLOT_MAX (VARYING_SLOT_VAR0 + MAX_VARYING)
205 #define VARYING_SLOT_PATCH0 (VARYING_SLOT_MAX)
206 #define VARYING_SLOT_TESS_MAX (VARYING_SLOT_PATCH0 + MAX_VARYING)
207 #define FRAG_RESULT_MAX (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
210 * Determine if the given gl_varying_slot appears in the fragment shader.
212 static inline GLboolean
213 _mesa_varying_slot_in_fs(gl_varying_slot slot
)
216 case VARYING_SLOT_PSIZ
:
217 case VARYING_SLOT_BFC0
:
218 case VARYING_SLOT_BFC1
:
219 case VARYING_SLOT_EDGE
:
220 case VARYING_SLOT_CLIP_VERTEX
:
221 case VARYING_SLOT_LAYER
:
222 case VARYING_SLOT_TESS_LEVEL_OUTER
:
223 case VARYING_SLOT_TESS_LEVEL_INNER
:
231 * Indexes for all renderbuffers
235 /* the four standard color buffers */
243 /* optional aux buffer */
245 /* generic renderbuffers */
258 * Bit flags for all renderbuffers
260 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
261 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
262 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
263 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
264 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
265 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
266 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
267 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
268 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
269 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
270 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
271 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
272 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
273 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
274 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
275 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
276 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
277 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
278 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
281 * Mask of all the color buffer bits (but not accum).
283 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
284 BUFFER_BIT_BACK_LEFT | \
285 BUFFER_BIT_FRONT_RIGHT | \
286 BUFFER_BIT_BACK_RIGHT | \
288 BUFFER_BIT_COLOR0 | \
289 BUFFER_BIT_COLOR1 | \
290 BUFFER_BIT_COLOR2 | \
291 BUFFER_BIT_COLOR3 | \
292 BUFFER_BIT_COLOR4 | \
293 BUFFER_BIT_COLOR5 | \
294 BUFFER_BIT_COLOR6 | \
298 * Framebuffer configuration (aka visual / pixelformat)
299 * Note: some of these fields should be boolean, but it appears that
300 * code in drivers/dri/common/util.c requires int-sized fields.
306 GLuint doubleBufferMode
;
309 GLboolean haveAccumBuffer
;
310 GLboolean haveDepthBuffer
;
311 GLboolean haveStencilBuffer
;
313 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
314 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
315 GLint rgbBits
; /* total bits for rgb */
316 GLint indexBits
; /* total bits for colorindex */
318 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
326 /* EXT_visual_rating / GLX 1.2 */
329 /* EXT_visual_info / GLX 1.2 */
330 GLint transparentPixel
;
331 /* colors are floats scaled to ints */
332 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
333 GLint transparentIndex
;
335 /* ARB_multisample / SGIS_multisample */
339 /* SGIX_pbuffer / GLX 1.3 */
340 GLint maxPbufferWidth
;
341 GLint maxPbufferHeight
;
342 GLint maxPbufferPixels
;
343 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
344 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
346 /* OML_swap_method */
349 /* EXT_texture_from_pixmap */
350 GLint bindToTextureRgb
;
351 GLint bindToTextureRgba
;
352 GLint bindToMipmapTexture
;
353 GLint bindToTextureTargets
;
356 /* EXT_framebuffer_sRGB */
362 * \name Bit flags used for updating material values.
365 #define MAT_ATTRIB_FRONT_AMBIENT 0
366 #define MAT_ATTRIB_BACK_AMBIENT 1
367 #define MAT_ATTRIB_FRONT_DIFFUSE 2
368 #define MAT_ATTRIB_BACK_DIFFUSE 3
369 #define MAT_ATTRIB_FRONT_SPECULAR 4
370 #define MAT_ATTRIB_BACK_SPECULAR 5
371 #define MAT_ATTRIB_FRONT_EMISSION 6
372 #define MAT_ATTRIB_BACK_EMISSION 7
373 #define MAT_ATTRIB_FRONT_SHININESS 8
374 #define MAT_ATTRIB_BACK_SHININESS 9
375 #define MAT_ATTRIB_FRONT_INDEXES 10
376 #define MAT_ATTRIB_BACK_INDEXES 11
377 #define MAT_ATTRIB_MAX 12
379 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
380 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
381 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
382 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
383 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
384 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
386 #define MAT_INDEX_AMBIENT 0
387 #define MAT_INDEX_DIFFUSE 1
388 #define MAT_INDEX_SPECULAR 2
390 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
391 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
392 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
393 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
394 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
395 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
396 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
397 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
398 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
399 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
400 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
401 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
404 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
405 MAT_BIT_FRONT_AMBIENT | \
406 MAT_BIT_FRONT_DIFFUSE | \
407 MAT_BIT_FRONT_SPECULAR | \
408 MAT_BIT_FRONT_SHININESS | \
409 MAT_BIT_FRONT_INDEXES)
411 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
412 MAT_BIT_BACK_AMBIENT | \
413 MAT_BIT_BACK_DIFFUSE | \
414 MAT_BIT_BACK_SPECULAR | \
415 MAT_BIT_BACK_SHININESS | \
416 MAT_BIT_BACK_INDEXES)
418 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
427 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
435 #define LIGHT_SPOT 0x1
436 #define LIGHT_LOCAL_VIEWER 0x2
437 #define LIGHT_POSITIONAL 0x4
438 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
443 * Light source state.
447 struct gl_light
*next
; /**< double linked list with sentinel */
448 struct gl_light
*prev
;
450 GLfloat Ambient
[4]; /**< ambient color */
451 GLfloat Diffuse
[4]; /**< diffuse color */
452 GLfloat Specular
[4]; /**< specular color */
453 GLfloat EyePosition
[4]; /**< position in eye coordinates */
454 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
455 GLfloat SpotExponent
;
456 GLfloat SpotCutoff
; /**< in degrees */
457 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
458 GLfloat ConstantAttenuation
;
459 GLfloat LinearAttenuation
;
460 GLfloat QuadraticAttenuation
;
461 GLboolean Enabled
; /**< On/off flag */
464 * \name Derived fields
467 GLbitfield _Flags
; /**< Mask of LIGHT_x bits defined above */
469 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
470 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
471 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
472 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
473 GLfloat _VP_inf_spot_attenuation
;
475 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
476 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
477 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
487 GLfloat Ambient
[4]; /**< ambient color */
488 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
489 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
490 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
491 * or GL_SEPARATE_SPECULAR_COLOR */
496 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
498 struct gl_accum_attrib
500 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
505 * Used for storing clear color, texture border color, etc.
506 * The float values are typically unclamped.
517 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
519 struct gl_colorbuffer_attrib
521 GLuint ClearIndex
; /**< Index for glClear */
522 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
523 GLuint IndexMask
; /**< Color index write mask */
524 GLubyte ColorMask
[MAX_DRAW_BUFFERS
][4]; /**< Each flag is 0xff or 0x0 */
526 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
529 * \name alpha testing
532 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
533 GLenum AlphaFunc
; /**< Alpha test function */
534 GLfloat AlphaRefUnclamped
;
535 GLclampf AlphaRef
; /**< Alpha reference value */
542 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
544 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
545 * control, only on the fixed-pointness of the render target.
546 * The query does however depend on fragment color clamping.
548 GLfloat BlendColorUnclamped
[4]; /**< Blending color */
549 GLfloat BlendColor
[4]; /**< Blending color */
553 GLenum SrcRGB
; /**< RGB blend source term */
554 GLenum DstRGB
; /**< RGB blend dest term */
555 GLenum SrcA
; /**< Alpha blend source term */
556 GLenum DstA
; /**< Alpha blend dest term */
557 GLenum EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
558 GLenum EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
560 * Set if any blend factor uses SRC1. Computed at the time blend factors
563 GLboolean _UsesDualSrc
;
564 } Blend
[MAX_DRAW_BUFFERS
];
565 /** Are the blend func terms currently different for each buffer/target? */
566 GLboolean _BlendFuncPerBuffer
;
567 /** Are the blend equations currently different for each buffer/target? */
568 GLboolean _BlendEquationPerBuffer
;
575 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
576 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
577 GLenum LogicOp
; /**< Logic operator */
581 GLboolean DitherFlag
; /**< Dither enable flag */
583 GLboolean _ClampFragmentColor
; /** < with GL_FIXED_ONLY_ARB resolved */
584 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
585 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
587 GLboolean sRGBEnabled
; /**< Framebuffer sRGB blending/updating requested */
592 * Current attribute group (GL_CURRENT_BIT).
594 struct gl_current_attrib
597 * \name Current vertex attributes.
598 * \note Values are valid only after FLUSH_VERTICES has been called.
599 * \note Index and Edgeflag current values are stored as floats in the
600 * SIX and SEVEN attribute slots.
602 /* we need double storage for this for vertex attrib 64bit */
603 GLfloat Attrib
[VERT_ATTRIB_MAX
][4*2]; /**< Position, color, texcoords, etc */
606 * \name Current raster position attributes (always valid).
607 * \note This set of attributes is very similar to the SWvertex struct.
610 GLfloat RasterPos
[4];
611 GLfloat RasterDistance
;
612 GLfloat RasterColor
[4];
613 GLfloat RasterSecondaryColor
[4];
614 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
615 GLboolean RasterPosValid
;
621 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
623 struct gl_depthbuffer_attrib
625 GLenum Func
; /**< Function for depth buffer compare */
626 GLclampd Clear
; /**< Value to clear depth buffer to */
627 GLboolean Test
; /**< Depth buffering enabled flag */
628 GLboolean Mask
; /**< Depth buffer writable? */
629 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
630 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
635 * Evaluator attribute group (GL_EVAL_BIT).
637 struct gl_eval_attrib
643 GLboolean Map1Color4
;
645 GLboolean Map1Normal
;
646 GLboolean Map1TextureCoord1
;
647 GLboolean Map1TextureCoord2
;
648 GLboolean Map1TextureCoord3
;
649 GLboolean Map1TextureCoord4
;
650 GLboolean Map1Vertex3
;
651 GLboolean Map1Vertex4
;
652 GLboolean Map2Color4
;
654 GLboolean Map2Normal
;
655 GLboolean Map2TextureCoord1
;
656 GLboolean Map2TextureCoord2
;
657 GLboolean Map2TextureCoord3
;
658 GLboolean Map2TextureCoord4
;
659 GLboolean Map2Vertex3
;
660 GLboolean Map2Vertex4
;
661 GLboolean AutoNormal
;
665 * \name Map Grid endpoints and divisions and calculated du values
669 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
670 GLint MapGrid2un
, MapGrid2vn
;
671 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
672 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
678 * Fog attribute group (GL_FOG_BIT).
682 GLboolean Enabled
; /**< Fog enabled flag */
683 GLboolean ColorSumEnabled
;
684 GLfloat ColorUnclamped
[4]; /**< Fog color */
685 GLfloat Color
[4]; /**< Fog color */
686 GLfloat Density
; /**< Density >= 0.0 */
687 GLfloat Start
; /**< Start distance in eye coords */
688 GLfloat End
; /**< End distance in eye coords */
689 GLfloat Index
; /**< Fog index */
690 GLenum Mode
; /**< Fog mode */
691 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
692 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
693 GLenum FogDistanceMode
; /**< GL_NV_fog_distance */
698 * Hint attribute group (GL_HINT_BIT).
700 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
702 struct gl_hint_attrib
704 GLenum PerspectiveCorrection
;
707 GLenum PolygonSmooth
;
709 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
710 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
711 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
716 * Lighting attribute group (GL_LIGHT_BIT).
718 struct gl_light_attrib
720 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
721 struct gl_lightmodel Model
; /**< Lighting model */
724 * Front and back material values.
725 * Note: must call FLUSH_VERTICES() before using.
727 struct gl_material Material
;
729 GLboolean Enabled
; /**< Lighting enabled flag */
730 GLboolean ColorMaterialEnabled
;
732 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
733 GLenum ProvokingVertex
; /**< GL_EXT_provoking_vertex */
734 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
735 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
736 GLbitfield _ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
739 GLboolean _ClampVertexColor
;
740 GLenum ClampVertexColor
; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
743 * Derived state for optimizations:
746 GLboolean _NeedEyeCoords
;
747 GLboolean _NeedVertices
; /**< Use fast shader? */
748 struct gl_light EnabledList
; /**< List sentinel */
750 GLfloat _BaseColor
[2][3];
756 * Line attribute group (GL_LINE_BIT).
758 struct gl_line_attrib
760 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
761 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
762 GLushort StipplePattern
; /**< Stipple pattern */
763 GLint StippleFactor
; /**< Stipple repeat factor */
764 GLfloat Width
; /**< Line width */
769 * Display list attribute group (GL_LIST_BIT).
771 struct gl_list_attrib
778 * Multisample attribute group (GL_MULTISAMPLE_BIT).
780 struct gl_multisample_attrib
783 GLboolean _Enabled
; /**< true if Enabled and multisample buffer */
784 GLboolean SampleAlphaToCoverage
;
785 GLboolean SampleAlphaToOne
;
786 GLboolean SampleCoverage
;
787 GLboolean SampleCoverageInvert
;
788 GLboolean SampleShading
;
790 /* ARB_texture_multisample / GL3.2 additions */
791 GLboolean SampleMask
;
793 GLfloat SampleCoverageValue
;
794 GLfloat MinSampleShadingValue
;
796 /** The GL spec defines this as an array but >32x MSAA is madness */
797 GLbitfield SampleMaskValue
;
802 * A pixelmap (see glPixelMap)
807 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
812 * Collection of all pixelmaps
816 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
817 struct gl_pixelmap GtoG
;
818 struct gl_pixelmap BtoB
;
819 struct gl_pixelmap AtoA
;
820 struct gl_pixelmap ItoR
;
821 struct gl_pixelmap ItoG
;
822 struct gl_pixelmap ItoB
;
823 struct gl_pixelmap ItoA
;
824 struct gl_pixelmap ItoI
;
825 struct gl_pixelmap StoS
;
830 * Pixel attribute group (GL_PIXEL_MODE_BIT).
832 struct gl_pixel_attrib
834 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
836 /*--- Begin Pixel Transfer State ---*/
837 /* Fields are in the order in which they're applied... */
839 /** Scale & Bias (index shift, offset) */
841 GLfloat RedBias
, RedScale
;
842 GLfloat GreenBias
, GreenScale
;
843 GLfloat BlueBias
, BlueScale
;
844 GLfloat AlphaBias
, AlphaScale
;
845 GLfloat DepthBias
, DepthScale
;
846 GLint IndexShift
, IndexOffset
;
850 /* Note: actual pixel maps are not part of this attrib group */
851 GLboolean MapColorFlag
;
852 GLboolean MapStencilFlag
;
854 /*--- End Pixel Transfer State ---*/
857 GLfloat ZoomX
, ZoomY
;
862 * Point attribute group (GL_POINT_BIT).
864 struct gl_point_attrib
866 GLfloat Size
; /**< User-specified point size */
867 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
868 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
869 GLfloat Threshold
; /**< GL_EXT_point_parameters */
870 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
871 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
872 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
873 GLboolean CoordReplace
[MAX_TEXTURE_COORD_UNITS
]; /**< GL_ARB_point_sprite*/
874 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
875 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
880 * Polygon attribute group (GL_POLYGON_BIT).
882 struct gl_polygon_attrib
884 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
885 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
886 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
887 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
888 GLboolean CullFlag
; /**< Culling on/off flag */
889 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
890 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
891 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
892 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
893 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
894 GLfloat OffsetClamp
; /**< Polygon offset clamp, from user */
895 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
896 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
897 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
902 * Scissor attributes (GL_SCISSOR_BIT).
904 struct gl_scissor_rect
906 GLint X
, Y
; /**< Lower left corner of box */
907 GLsizei Width
, Height
; /**< Size of box */
909 struct gl_scissor_attrib
911 GLbitfield EnableFlags
; /**< Scissor test enabled? */
912 struct gl_scissor_rect ScissorArray
[MAX_VIEWPORTS
];
917 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
919 * Three sets of stencil data are tracked so that OpenGL 2.0,
920 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
921 * simultaneously. In each of the stencil state arrays, element 0 corresponds
922 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
923 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
924 * GL_EXT_stencil_two_side GL_BACK state.
926 * The derived value \c _BackFace is either 1 or 2 depending on whether or
927 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
929 * The derived value \c _TestTwoSide is set when the front-face and back-face
930 * stencil state are different.
932 struct gl_stencil_attrib
934 GLboolean Enabled
; /**< Enabled flag */
935 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
936 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 2) */
937 GLboolean _Enabled
; /**< Enabled and stencil buffer present */
938 GLboolean _WriteEnabled
; /**< _Enabled and non-zero writemasks */
939 GLboolean _TestTwoSide
;
940 GLubyte _BackFace
; /**< Current back stencil state (1 or 2) */
941 GLenum Function
[3]; /**< Stencil function */
942 GLenum FailFunc
[3]; /**< Fail function */
943 GLenum ZPassFunc
[3]; /**< Depth buffer pass function */
944 GLenum ZFailFunc
[3]; /**< Depth buffer fail function */
945 GLint Ref
[3]; /**< Reference value */
946 GLuint ValueMask
[3]; /**< Value mask */
947 GLuint WriteMask
[3]; /**< Write mask */
948 GLuint Clear
; /**< Clear value */
953 * An index for each type of texture object. These correspond to the GL
954 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
955 * Note: the order is from highest priority to lowest priority.
959 TEXTURE_2D_MULTISAMPLE_INDEX
,
960 TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
,
961 TEXTURE_CUBE_ARRAY_INDEX
,
962 TEXTURE_BUFFER_INDEX
,
963 TEXTURE_2D_ARRAY_INDEX
,
964 TEXTURE_1D_ARRAY_INDEX
,
965 TEXTURE_EXTERNAL_INDEX
,
976 * Bit flags for each type of texture object
979 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
980 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
981 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
982 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
983 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
984 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
985 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
986 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
987 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
988 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
989 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
990 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
995 * Texture image state. Drivers will typically create a subclass of this
996 * with extra fields for memory buffers, etc.
998 struct gl_texture_image
1000 GLint InternalFormat
; /**< Internal format as given by the user */
1001 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1002 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1003 * GL_INTENSITY, GL_DEPTH_COMPONENT or
1004 * GL_DEPTH_STENCIL_EXT only. Used for
1005 * choosing TexEnv arithmetic.
1007 mesa_format TexFormat
; /**< The actual texture memory format */
1009 GLuint Border
; /**< 0 or 1 */
1010 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1011 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1012 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1013 GLuint Width2
; /**< = Width - 2*Border */
1014 GLuint Height2
; /**< = Height - 2*Border */
1015 GLuint Depth2
; /**< = Depth - 2*Border */
1016 GLuint WidthLog2
; /**< = log2(Width2) */
1017 GLuint HeightLog2
; /**< = log2(Height2) */
1018 GLuint DepthLog2
; /**< = log2(Depth2) */
1019 GLuint MaxNumLevels
; /**< = maximum possible number of mipmap
1020 levels, computed from the dimensions */
1022 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1023 GLuint Level
; /**< Which mipmap level am I? */
1024 /** Cube map face: index into gl_texture_object::Image[] array */
1027 /** GL_ARB_texture_multisample */
1028 GLuint NumSamples
; /**< Sample count, or 0 for non-multisample */
1029 GLboolean FixedSampleLocations
; /**< Same sample locations for all pixels? */
1034 * Indexes for cube map faces.
1049 * Sampler object state. These objects are new with GL_ARB_sampler_objects
1050 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
1052 struct gl_sampler_object
1056 GLchar
*Label
; /**< GL_KHR_debug */
1058 GLenum WrapS
; /**< S-axis texture image wrap mode */
1059 GLenum WrapT
; /**< T-axis texture image wrap mode */
1060 GLenum WrapR
; /**< R-axis texture image wrap mode */
1061 GLenum MinFilter
; /**< minification filter */
1062 GLenum MagFilter
; /**< magnification filter */
1063 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
1064 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1065 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1066 GLfloat LodBias
; /**< OpenGL 1.4 */
1067 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1068 GLenum CompareMode
; /**< GL_ARB_shadow */
1069 GLenum CompareFunc
; /**< GL_ARB_shadow */
1070 GLenum sRGBDecode
; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
1071 GLboolean CubeMapSeamless
; /**< GL_AMD_seamless_cubemap_per_texture */
1076 * Texture object state. Contains the array of mipmap images, border color,
1077 * wrap modes, filter modes, and shadow/texcompare state.
1079 struct gl_texture_object
1081 mtx_t Mutex
; /**< for thread safety */
1082 GLint RefCount
; /**< reference count */
1083 GLuint Name
; /**< the user-visible texture object ID */
1084 GLchar
*Label
; /**< GL_KHR_debug */
1085 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1086 gl_texture_index TargetIndex
; /**< The gl_texture_unit::CurrentTex index.
1087 Only valid when Target is valid. */
1089 struct gl_sampler_object Sampler
;
1091 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1092 bool StencilSampling
; /**< Should we sample stencil instead of depth? */
1094 GLfloat Priority
; /**< in [0,1] */
1095 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1096 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1097 GLint ImmutableLevels
; /**< ES 3.0 / ARB_texture_view */
1098 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1099 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - p in spec) */
1100 GLint CropRect
[4]; /**< GL_OES_draw_texture */
1101 GLenum Swizzle
[4]; /**< GL_EXT_texture_swizzle */
1102 GLuint _Swizzle
; /**< same as Swizzle, but SWIZZLE_* format */
1103 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1104 GLboolean _BaseComplete
; /**< Is the base texture level valid? */
1105 GLboolean _MipmapComplete
; /**< Is the whole mipmap valid? */
1106 GLboolean _IsIntegerFormat
; /**< Does the texture store integer values? */
1107 GLboolean _RenderToTexture
; /**< Any rendering to this texture? */
1108 GLboolean Purgeable
; /**< Is the buffer purgeable under memory
1110 GLboolean Immutable
; /**< GL_ARB_texture_storage */
1111 GLboolean _IsFloat
; /**< GL_OES_float_texture */
1112 GLboolean _IsHalfFloat
; /**< GL_OES_half_float_texture */
1114 GLuint MinLevel
; /**< GL_ARB_texture_view */
1115 GLuint MinLayer
; /**< GL_ARB_texture_view */
1116 GLuint NumLevels
; /**< GL_ARB_texture_view */
1117 GLuint NumLayers
; /**< GL_ARB_texture_view */
1119 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1120 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1122 /** GL_ARB_texture_buffer_object */
1123 struct gl_buffer_object
*BufferObject
;
1124 GLenum BufferObjectFormat
;
1125 /** Equivalent Mesa format for BufferObjectFormat. */
1126 mesa_format _BufferObjectFormat
;
1127 /** GL_ARB_texture_buffer_range */
1128 GLintptr BufferOffset
;
1129 GLsizeiptr BufferSize
; /**< if this is -1, use BufferObject->Size instead */
1131 /** GL_OES_EGL_image_external */
1132 GLint RequiredTextureImageUnits
;
1134 /** GL_ARB_shader_image_load_store */
1135 GLenum ImageFormatCompatibilityType
;
1139 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1140 #define MAX_COMBINER_TERMS 4
1144 * Texture combine environment state.
1146 struct gl_tex_env_combine_state
1148 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1149 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1150 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1151 GLenum SourceRGB
[MAX_COMBINER_TERMS
];
1152 GLenum SourceA
[MAX_COMBINER_TERMS
];
1153 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1154 GLenum OperandRGB
[MAX_COMBINER_TERMS
];
1155 GLenum OperandA
[MAX_COMBINER_TERMS
];
1156 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1157 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1158 GLuint _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1159 GLuint _NumArgsA
; /**< Number of inputs used for the A combiner */
1164 * TexGenEnabled flags.
1171 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1176 * Bit flag versions of the corresponding GL_ constants.
1179 #define TEXGEN_SPHERE_MAP 0x1
1180 #define TEXGEN_OBJ_LINEAR 0x2
1181 #define TEXGEN_EYE_LINEAR 0x4
1182 #define TEXGEN_REFLECTION_MAP_NV 0x8
1183 #define TEXGEN_NORMAL_MAP_NV 0x10
1185 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1186 TEXGEN_REFLECTION_MAP_NV | \
1187 TEXGEN_NORMAL_MAP_NV)
1188 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1189 TEXGEN_REFLECTION_MAP_NV | \
1190 TEXGEN_NORMAL_MAP_NV | \
1196 /** Tex-gen enabled for texture unit? */
1197 #define ENABLE_TEXGEN(unit) (1 << (unit))
1199 /** Non-identity texture matrix for texture unit? */
1200 #define ENABLE_TEXMAT(unit) (1 << (unit))
1204 * Texture coord generation state.
1208 GLenum Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1209 GLbitfield _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1210 GLfloat ObjectPlane
[4];
1211 GLfloat EyePlane
[4];
1216 * Texture unit state. Contains enable flags, texture environment/function/
1217 * combiners, texgen state, and pointers to current texture objects.
1219 struct gl_texture_unit
1221 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1223 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1224 GLclampf EnvColor
[4];
1225 GLfloat EnvColorUnclamped
[4];
1227 struct gl_texgen GenS
;
1228 struct gl_texgen GenT
;
1229 struct gl_texgen GenR
;
1230 struct gl_texgen GenQ
;
1231 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1232 GLbitfield _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1234 GLfloat LodBias
; /**< for biasing mipmap levels */
1236 /** Texture targets that have a non-default texture bound */
1237 GLbitfield _BoundTextures
;
1239 /** Current sampler object (GL_ARB_sampler_objects) */
1240 struct gl_sampler_object
*Sampler
;
1243 * \name GL_EXT_texture_env_combine
1245 struct gl_tex_env_combine_state Combine
;
1248 * Derived state based on \c EnvMode and the \c BaseFormat of the
1249 * currently enabled texture.
1251 struct gl_tex_env_combine_state _EnvMode
;
1254 * Currently enabled combiner state. This will point to either
1255 * \c Combine or \c _EnvMode.
1257 struct gl_tex_env_combine_state
*_CurrentCombine
;
1259 /** Current texture object pointers */
1260 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1262 /** Points to highest priority, complete and enabled texture object */
1263 struct gl_texture_object
*_Current
;
1269 * Texture attribute group (GL_TEXTURE_BIT).
1271 struct gl_texture_attrib
1273 GLuint CurrentUnit
; /**< GL_ACTIVE_TEXTURE */
1275 /** GL_ARB_seamless_cubemap */
1276 GLboolean CubeMapSeamless
;
1278 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1280 /** GL_ARB_texture_buffer_object */
1281 struct gl_buffer_object
*BufferObject
;
1283 /** Texture coord units/sets used for fragment texturing */
1284 GLbitfield _EnabledCoordUnits
;
1286 /** Texture coord units that have texgen enabled */
1287 GLbitfield _TexGenEnabled
;
1289 /** Texture coord units that have non-identity matrices */
1290 GLbitfield _TexMatEnabled
;
1292 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1293 GLbitfield _GenFlags
;
1295 /** Largest index of a texture unit with _Current != NULL. */
1296 GLint _MaxEnabledTexImageUnit
;
1298 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1299 GLint NumCurrentTexUsed
;
1301 struct gl_texture_unit Unit
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
1306 * Data structure representing a single clip plane (e.g. one of the elements
1307 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1309 typedef GLfloat gl_clip_plane
[4];
1313 * Transformation attribute group (GL_TRANSFORM_BIT).
1315 struct gl_transform_attrib
1317 GLenum MatrixMode
; /**< Matrix mode */
1318 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1319 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1320 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1321 GLboolean Normalize
; /**< Normalize all normals? */
1322 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1323 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1324 GLboolean DepthClamp
; /**< GL_ARB_depth_clamp */
1325 /** GL_ARB_clip_control */
1326 GLenum ClipOrigin
; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1327 GLenum ClipDepthMode
; /**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1332 * Viewport attribute group (GL_VIEWPORT_BIT).
1334 struct gl_viewport_attrib
1336 GLfloat X
, Y
; /**< position */
1337 GLfloat Width
, Height
; /**< size */
1338 GLdouble Near
, Far
; /**< Depth buffer range */
1347 } gl_map_buffer_index
;
1351 * Fields describing a mapped buffer range.
1353 struct gl_buffer_mapping
{
1354 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1355 GLvoid
*Pointer
; /**< User-space address of mapping */
1356 GLintptr Offset
; /**< Mapped offset */
1357 GLsizeiptr Length
; /**< Mapped length */
1362 * Usages we've seen for a buffer object.
1365 USAGE_UNIFORM_BUFFER
= 0x1,
1366 USAGE_TEXTURE_BUFFER
= 0x2,
1367 USAGE_ATOMIC_COUNTER_BUFFER
= 0x4,
1368 USAGE_SHADER_STORAGE_BUFFER
= 0x8,
1373 * GL_ARB_vertex/pixel_buffer_object buffer object
1375 struct gl_buffer_object
1380 GLchar
*Label
; /**< GL_KHR_debug */
1381 GLenum Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1382 GLbitfield StorageFlags
; /**< GL_MAP_PERSISTENT_BIT, etc. */
1383 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1384 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1385 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1386 GLboolean Written
; /**< Ever written to? (for debugging) */
1387 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1388 GLboolean Immutable
; /**< GL_ARB_buffer_storage */
1389 gl_buffer_usage UsageHistory
; /**< How has this buffer been used so far? */
1391 struct gl_buffer_mapping Mappings
[MAP_COUNT
];
1396 * Client pixel packing/unpacking attributes
1398 struct gl_pixelstore_attrib
1406 GLboolean SwapBytes
;
1408 GLboolean Invert
; /**< GL_MESA_pack_invert */
1409 GLint CompressedBlockWidth
; /**< GL_ARB_compressed_texture_pixel_storage */
1410 GLint CompressedBlockHeight
;
1411 GLint CompressedBlockDepth
;
1412 GLint CompressedBlockSize
;
1413 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1418 * Client vertex array attributes
1420 struct gl_client_array
1422 GLint Size
; /**< components per element (1,2,3,4) */
1423 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1424 GLenum Format
; /**< default: GL_RGBA, but may be GL_BGRA */
1425 GLsizei Stride
; /**< user-specified stride */
1426 GLsizei StrideB
; /**< actual stride in bytes */
1427 GLuint _ElementSize
; /**< size of each element in bytes */
1428 const GLubyte
*Ptr
; /**< Points to array data */
1429 GLboolean Enabled
; /**< Enabled flag is a boolean */
1430 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1431 GLboolean Integer
; /**< Integer-valued? */
1432 GLboolean Doubles
; /**< double precision values are not converted to floats */
1433 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1435 struct gl_buffer_object
*BufferObj
;/**< GL_ARB_vertex_buffer_object */
1440 * Vertex attribute array as seen by the client.
1442 * Contains the size, type, format and normalization flag,
1443 * along with the index of a vertex buffer binding point.
1445 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1446 * and is only present for backwards compatibility reasons.
1447 * Rendering always uses VERTEX_BINDING_STRIDE.
1448 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1449 * and VERTEX_BINDING_STRIDE to the same value, while
1450 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1452 struct gl_vertex_attrib_array
1454 GLint Size
; /**< Components per element (1,2,3,4) */
1455 GLenum Type
; /**< Datatype: GL_FLOAT, GL_INT, etc */
1456 GLenum Format
; /**< Default: GL_RGBA, but may be GL_BGRA */
1457 GLsizei Stride
; /**< Stride as specified with gl*Pointer() */
1458 const GLubyte
*Ptr
; /**< Points to client array data. Not used when a VBO is bound */
1459 GLintptr RelativeOffset
; /**< Offset of the first element relative to the binding offset */
1460 GLboolean Enabled
; /**< Whether the array is enabled */
1461 GLboolean Normalized
; /**< Fixed-point values are normalized when converted to floats */
1462 GLboolean Integer
; /**< Fixed-point values are not converted to floats */
1463 GLboolean Doubles
; /**< double precision values are not converted to floats */
1464 GLuint _ElementSize
; /**< Size of each element in bytes */
1465 GLuint VertexBinding
; /**< Vertex buffer binding */
1470 * This describes the buffer object used for a vertex array (or
1471 * multiple vertex arrays). If BufferObj points to the default/null
1472 * buffer object, then the vertex array lives in user memory and not a VBO.
1474 struct gl_vertex_buffer_binding
1476 GLintptr Offset
; /**< User-specified offset */
1477 GLsizei Stride
; /**< User-specified stride */
1478 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1479 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_vertex_buffer_object */
1480 GLbitfield64 _BoundArrays
; /**< Arrays bound to this binding point */
1485 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+,
1486 * GL_ARB_vertex_array_object, or the original GL_APPLE_vertex_array_object
1489 struct gl_vertex_array_object
1491 /** Name of the VAO as received from glGenVertexArray. */
1496 GLchar
*Label
; /**< GL_KHR_debug */
1501 * Does the VAO use ARB semantics or Apple semantics?
1503 * There are several ways in which ARB_vertex_array_object and
1504 * APPLE_vertex_array_object VAOs have differing semantics. At the very
1507 * - ARB VAOs require that all array data be sourced from vertex buffer
1508 * objects, but Apple VAOs do not.
1510 * - ARB VAOs require that names come from GenVertexArrays.
1512 * This flag notes which behavior governs this VAO.
1514 GLboolean ARBsemantics
;
1517 * Has this array object been bound?
1519 GLboolean EverBound
;
1522 * Derived vertex attribute arrays
1524 * This is a legacy data structure created from gl_vertex_attrib_array and
1525 * gl_vertex_buffer_binding, for compatibility with existing driver code.
1527 struct gl_client_array _VertexAttrib
[VERT_ATTRIB_MAX
];
1529 /** Vertex attribute arrays */
1530 struct gl_vertex_attrib_array VertexAttrib
[VERT_ATTRIB_MAX
];
1532 /** Vertex buffer bindings */
1533 struct gl_vertex_buffer_binding VertexBinding
[VERT_ATTRIB_MAX
];
1535 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1536 GLbitfield64 _Enabled
;
1538 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1539 GLbitfield64 NewArrays
;
1541 /** The index buffer (also known as the element array buffer in OpenGL). */
1542 struct gl_buffer_object
*IndexBufferObj
;
1546 /** Used to signal when transitioning from one kind of drawing method
1550 DRAW_NONE
, /**< Initial value only */
1557 * Enum for the OpenGL APIs we know about and may support.
1559 * NOTE: This must match the api_enum table in
1560 * src/mesa/main/get_hash_generator.py
1564 API_OPENGL_COMPAT
, /* legacy / compatibility contexts */
1568 API_OPENGL_LAST
= API_OPENGL_CORE
1572 * Vertex array state
1574 struct gl_array_attrib
1576 /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
1577 struct gl_vertex_array_object
*VAO
;
1579 /** The default vertex array object */
1580 struct gl_vertex_array_object
*DefaultVAO
;
1582 /** The last VAO accessed by a DSA function */
1583 struct gl_vertex_array_object
*LastLookedUpVAO
;
1585 /** Array objects (GL_ARB/APPLE_vertex_array_object) */
1586 struct _mesa_HashTable
*Objects
;
1588 GLint ActiveTexture
; /**< Client Active Texture */
1589 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1590 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1593 * \name Primitive restart controls
1595 * Primitive restart is enabled if either \c PrimitiveRestart or
1596 * \c PrimitiveRestartFixedIndex is set.
1599 GLboolean PrimitiveRestart
;
1600 GLboolean PrimitiveRestartFixedIndex
;
1601 GLboolean _PrimitiveRestart
;
1602 GLuint RestartIndex
;
1605 /** One of the DRAW_xxx flags, not consumed by drivers */
1606 gl_draw_method DrawMethod
;
1608 /* GL_ARB_vertex_buffer_object */
1609 struct gl_buffer_object
*ArrayBufferObj
;
1612 * Vertex arrays as consumed by a driver.
1613 * The array pointer is set up only by the VBO module.
1615 const struct gl_client_array
**_DrawArrays
; /**< 0..VERT_ATTRIB_MAX-1 */
1617 /** Legal array datatypes and the API for which they have been computed */
1618 GLbitfield LegalTypesMask
;
1619 gl_api LegalTypesMaskAPI
;
1624 * Feedback buffer state
1629 GLbitfield _Mask
; /**< FB_* bits */
1637 * Selection buffer state
1641 GLuint
*Buffer
; /**< selection buffer */
1642 GLuint BufferSize
; /**< size of the selection buffer */
1643 GLuint BufferCount
; /**< number of values in the selection buffer */
1644 GLuint Hits
; /**< number of records in the selection buffer */
1645 GLuint NameStackDepth
; /**< name stack depth */
1646 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1647 GLboolean HitFlag
; /**< hit flag */
1648 GLfloat HitMinZ
; /**< minimum hit depth */
1649 GLfloat HitMaxZ
; /**< maximum hit depth */
1654 * 1-D Evaluator control points
1658 GLuint Order
; /**< Number of control points */
1659 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1660 GLfloat
*Points
; /**< Points to contiguous control points */
1665 * 2-D Evaluator control points
1669 GLuint Uorder
; /**< Number of control points in U dimension */
1670 GLuint Vorder
; /**< Number of control points in V dimension */
1673 GLfloat
*Points
; /**< Points to contiguous control points */
1678 * All evaluator control point state
1680 struct gl_evaluators
1686 struct gl_1d_map Map1Vertex3
;
1687 struct gl_1d_map Map1Vertex4
;
1688 struct gl_1d_map Map1Index
;
1689 struct gl_1d_map Map1Color4
;
1690 struct gl_1d_map Map1Normal
;
1691 struct gl_1d_map Map1Texture1
;
1692 struct gl_1d_map Map1Texture2
;
1693 struct gl_1d_map Map1Texture3
;
1694 struct gl_1d_map Map1Texture4
;
1701 struct gl_2d_map Map2Vertex3
;
1702 struct gl_2d_map Map2Vertex4
;
1703 struct gl_2d_map Map2Index
;
1704 struct gl_2d_map Map2Color4
;
1705 struct gl_2d_map Map2Normal
;
1706 struct gl_2d_map Map2Texture1
;
1707 struct gl_2d_map Map2Texture2
;
1708 struct gl_2d_map Map2Texture3
;
1709 struct gl_2d_map Map2Texture4
;
1714 struct gl_transform_feedback_varying_info
1723 * Per-output info vertex shaders for transform feedback.
1725 struct gl_transform_feedback_output
1727 unsigned OutputRegister
;
1728 unsigned OutputBuffer
;
1729 unsigned NumComponents
;
1732 /** offset (in DWORDs) of this output within the interleaved structure */
1736 * Offset into the output register of the data to output. For example,
1737 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1738 * offset is in the y and z components of the output register.
1740 unsigned ComponentOffset
;
1744 /** Post-link transform feedback info. */
1745 struct gl_transform_feedback_info
1747 unsigned NumOutputs
;
1750 * Number of transform feedback buffers in use by this program.
1752 unsigned NumBuffers
;
1754 struct gl_transform_feedback_output
*Outputs
;
1756 /** Transform feedback varyings used for the linking of this shader program.
1758 * Use for glGetTransformFeedbackVarying().
1760 struct gl_transform_feedback_varying_info
*Varyings
;
1764 * Total number of components stored in each buffer. This may be used by
1765 * hardware back-ends to determine the correct stride when interleaving
1766 * multiple transform feedback outputs in the same buffer.
1768 unsigned BufferStride
[MAX_FEEDBACK_BUFFERS
];
1771 * Which transform feedback stream this buffer binding is associated with.
1773 unsigned BufferStream
[MAX_FEEDBACK_BUFFERS
];
1778 * Transform feedback object state
1780 struct gl_transform_feedback_object
1782 GLuint Name
; /**< AKA the object ID */
1784 GLchar
*Label
; /**< GL_KHR_debug */
1785 GLboolean Active
; /**< Is transform feedback enabled? */
1786 GLboolean Paused
; /**< Is transform feedback paused? */
1787 GLboolean EndedAnytime
; /**< Has EndTransformFeedback been called
1789 GLboolean EverBound
; /**< Has this object been bound? */
1792 * GLES: if Active is true, remaining number of primitives which can be
1793 * rendered without overflow. This is necessary to track because GLES
1794 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1795 * glDrawArraysInstanced would overflow transform feedback buffers.
1796 * Undefined if Active is false.
1798 * Not tracked for desktop GL since it's unnecessary.
1800 unsigned GlesRemainingPrims
;
1803 * The shader program active when BeginTransformFeedback() was called.
1804 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1805 * where stage is the pipeline stage that is the source of data for
1806 * transform feedback.
1808 struct gl_shader_program
*shader_program
;
1810 /** The feedback buffers */
1811 GLuint BufferNames
[MAX_FEEDBACK_BUFFERS
];
1812 struct gl_buffer_object
*Buffers
[MAX_FEEDBACK_BUFFERS
];
1814 /** Start of feedback data in dest buffer */
1815 GLintptr Offset
[MAX_FEEDBACK_BUFFERS
];
1818 * Max data to put into dest buffer (in bytes). Computed based on
1819 * RequestedSize and the actual size of the buffer.
1821 GLsizeiptr Size
[MAX_FEEDBACK_BUFFERS
];
1824 * Size that was specified when the buffer was bound. If the buffer was
1825 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1828 GLsizeiptr RequestedSize
[MAX_FEEDBACK_BUFFERS
];
1833 * Context state for transform feedback.
1835 struct gl_transform_feedback_state
1837 GLenum Mode
; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1839 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1840 struct gl_buffer_object
*CurrentBuffer
;
1842 /** The table of all transform feedback objects */
1843 struct _mesa_HashTable
*Objects
;
1845 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1846 struct gl_transform_feedback_object
*CurrentObject
;
1848 /** The default xform-fb object (Name==0) */
1849 struct gl_transform_feedback_object
*DefaultObject
;
1854 * A "performance monitor" as described in AMD_performance_monitor.
1856 struct gl_perf_monitor_object
1860 /** True if the monitor is currently active (Begin called but not End). */
1864 * True if the monitor has ended.
1866 * This is distinct from !Active because it may never have began.
1871 * A list of groups with currently active counters.
1873 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1875 unsigned *ActiveGroups
;
1878 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1880 * Checking whether counter 'c' in group 'g' is active can be done via:
1882 * BITSET_TEST(ActiveCounters[g], c)
1884 GLuint
**ActiveCounters
;
1888 union gl_perf_monitor_counter_value
1896 struct gl_perf_monitor_counter
1898 /** Human readable name for the counter. */
1902 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1903 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1907 /** Minimum counter value. */
1908 union gl_perf_monitor_counter_value Minimum
;
1910 /** Maximum counter value. */
1911 union gl_perf_monitor_counter_value Maximum
;
1915 struct gl_perf_monitor_group
1917 /** Human readable name for the group. */
1921 * Maximum number of counters in this group which can be active at the
1924 GLuint MaxActiveCounters
;
1926 /** Array of counters within this group. */
1927 const struct gl_perf_monitor_counter
*Counters
;
1933 * Context state for AMD_performance_monitor.
1935 struct gl_perf_monitor_state
1937 /** Array of performance monitor groups (indexed by group ID) */
1938 const struct gl_perf_monitor_group
*Groups
;
1941 /** The table of all performance monitors. */
1942 struct _mesa_HashTable
*Monitors
;
1947 * Names of the various vertex/fragment program register files, etc.
1949 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
1950 * All values should fit in a 4-bit field.
1952 * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be
1953 * considered to be "uniform" variables since they can only be set outside
1954 * glBegin/End. They're also all stored in the same Parameters array.
1958 PROGRAM_TEMPORARY
, /**< machine->Temporary[] */
1959 PROGRAM_ARRAY
, /**< Arrays & Matrixes */
1960 PROGRAM_INPUT
, /**< machine->Inputs[] */
1961 PROGRAM_OUTPUT
, /**< machine->Outputs[] */
1962 PROGRAM_STATE_VAR
, /**< gl_program->Parameters[] */
1963 PROGRAM_CONSTANT
, /**< gl_program->Parameters[] */
1964 PROGRAM_UNIFORM
, /**< gl_program->Parameters[] */
1965 PROGRAM_WRITE_ONLY
, /**< A dummy, write-only register */
1966 PROGRAM_ADDRESS
, /**< machine->AddressReg */
1967 PROGRAM_SAMPLER
, /**< for shader samplers, compile-time only */
1968 PROGRAM_SYSTEM_VALUE
,/**< InstanceId, PrimitiveID, etc. */
1969 PROGRAM_UNDEFINED
, /**< Invalid/TBD value */
1975 * \brief Layout qualifiers for gl_FragDepth.
1977 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
1978 * a layout qualifier.
1980 * \see enum ir_depth_layout
1982 enum gl_frag_depth_layout
1984 FRAG_DEPTH_LAYOUT_NONE
, /**< No layout is specified. */
1985 FRAG_DEPTH_LAYOUT_ANY
,
1986 FRAG_DEPTH_LAYOUT_GREATER
,
1987 FRAG_DEPTH_LAYOUT_LESS
,
1988 FRAG_DEPTH_LAYOUT_UNCHANGED
1993 * Base class for any kind of program object
1999 GLubyte
*String
; /**< Null-terminated program text */
2001 GLenum Target
; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2002 GLenum Format
; /**< String encoding format */
2004 struct prog_instruction
*Instructions
;
2006 struct nir_shader
*nir
;
2008 GLbitfield64 InputsRead
; /**< Bitmask of which input regs are read */
2009 GLbitfield64 DoubleInputsRead
; /**< Bitmask of which input regs are read and are doubles */
2010 GLbitfield64 OutputsWritten
; /**< Bitmask of which output regs are written */
2011 GLbitfield PatchInputsRead
; /**< VAR[0..31] usage for patch inputs (user-defined only) */
2012 GLbitfield PatchOutputsWritten
; /**< VAR[0..31] usage for patch outputs (user-defined only) */
2013 GLbitfield SystemValuesRead
; /**< Bitmask of SYSTEM_VALUE_x inputs used */
2014 GLbitfield TexturesUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
2015 GLbitfield SamplersUsed
; /**< Bitfield of which samplers are used */
2016 GLbitfield ShadowSamplers
; /**< Texture units used for shadow sampling. */
2018 GLboolean UsesGather
; /**< Does this program use gather4 at all? */
2021 * For vertex and geometry shaders, true if the program uses the
2022 * gl_ClipDistance output. Ignored for fragment shaders.
2024 GLboolean UsesClipDistanceOut
;
2027 /** Named parameters, constants, etc. from program text */
2028 struct gl_program_parameter_list
*Parameters
;
2031 * Local parameters used by the program.
2033 * It's dynamically allocated because it is rarely used (just
2034 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries once it's
2037 GLfloat (*LocalParams
)[4];
2039 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2040 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2042 /** Bitmask of which register files are read/written with indirect
2043 * addressing. Mask of (1 << PROGRAM_x) bits.
2045 GLbitfield IndirectRegisterFiles
;
2047 /** Logical counts */
2049 GLuint NumInstructions
;
2050 GLuint NumTemporaries
;
2051 GLuint NumParameters
;
2052 GLuint NumAttributes
;
2053 GLuint NumAddressRegs
;
2054 GLuint NumAluInstructions
;
2055 GLuint NumTexInstructions
;
2056 GLuint NumTexIndirections
;
2058 /** Native, actual h/w counts */
2060 GLuint NumNativeInstructions
;
2061 GLuint NumNativeTemporaries
;
2062 GLuint NumNativeParameters
;
2063 GLuint NumNativeAttributes
;
2064 GLuint NumNativeAddressRegs
;
2065 GLuint NumNativeAluInstructions
;
2066 GLuint NumNativeTexInstructions
;
2067 GLuint NumNativeTexIndirections
;
2072 /** Vertex program object */
2073 struct gl_vertex_program
2075 struct gl_program Base
; /**< base class */
2076 GLboolean IsPositionInvariant
;
2080 /** Tessellation control program object */
2081 struct gl_tess_ctrl_program
2083 struct gl_program Base
; /**< base class */
2090 /** Tessellation evaluation program object */
2091 struct gl_tess_eval_program
2093 struct gl_program Base
; /**< base class */
2096 GLenum PrimitiveMode
; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
2097 GLenum Spacing
; /* GL_EQUAL, GL_FRACTIONAL_EVEN, GL_FRACTIONAL_ODD */
2098 GLenum VertexOrder
; /* GL_CW or GL_CCW */
2103 /** Geometry program object */
2104 struct gl_geometry_program
2106 struct gl_program Base
; /**< base class */
2111 GLenum InputType
; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,
2112 GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
2113 GLenum OutputType
; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
2114 bool UsesEndPrimitive
;
2119 /** Fragment program object */
2120 struct gl_fragment_program
2122 struct gl_program Base
; /**< base class */
2123 GLboolean UsesKill
; /**< shader uses KIL instruction */
2124 GLboolean UsesDFdy
; /**< shader uses DDY instruction */
2125 GLboolean OriginUpperLeft
;
2126 GLboolean PixelCenterInteger
;
2127 enum gl_frag_depth_layout FragDepthLayout
;
2130 * GLSL interpolation qualifier associated with each fragment shader input.
2131 * For inputs that do not have an interpolation qualifier specified in
2132 * GLSL, the value is INTERP_QUALIFIER_NONE.
2134 enum glsl_interp_qualifier InterpQualifier
[VARYING_SLOT_MAX
];
2137 * Bitfield indicating, for each fragment shader input, 1 if that input
2138 * uses centroid interpolation, 0 otherwise. Unused inputs are 0.
2140 GLbitfield64 IsCentroid
;
2143 * Bitfield indicating, for each fragment shader input, 1 if that input
2144 * uses sample interpolation, 0 otherwise. Unused inputs are 0.
2146 GLbitfield64 IsSample
;
2150 /** Compute program object */
2151 struct gl_compute_program
2153 struct gl_program Base
; /**< base class */
2156 * Size specified using local_size_{x,y,z}.
2158 unsigned LocalSize
[3];
2163 * State common to vertex and fragment programs.
2165 struct gl_program_state
2167 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2168 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2173 * Context state for vertex programs.
2175 struct gl_vertex_program_state
2177 GLboolean Enabled
; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2178 GLboolean _Enabled
; /**< Enabled and _valid_ user program? */
2179 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2180 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2181 /** Computed two sided lighting for fixed function/programs. */
2182 GLboolean _TwoSideEnabled
;
2183 struct gl_vertex_program
*Current
; /**< User-bound vertex program */
2185 /** Currently enabled and valid vertex program (including internal
2186 * programs, user-defined vertex programs and GLSL vertex shaders).
2187 * This is the program we must use when rendering.
2189 struct gl_vertex_program
*_Current
;
2191 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2193 /** Should fixed-function T&L be implemented with a vertex prog? */
2194 GLboolean _MaintainTnlProgram
;
2196 /** Program to emulate fixed-function T&L (see above) */
2197 struct gl_vertex_program
*_TnlProgram
;
2199 /** Cache of fixed-function programs */
2200 struct gl_program_cache
*Cache
;
2202 GLboolean _Overriden
;
2206 * Context state for tessellation control programs.
2208 struct gl_tess_ctrl_program_state
2210 /** Currently bound and valid shader. */
2211 struct gl_tess_ctrl_program
*_Current
;
2213 GLint patch_vertices
;
2214 GLfloat patch_default_outer_level
[4];
2215 GLfloat patch_default_inner_level
[2];
2219 * Context state for tessellation evaluation programs.
2221 struct gl_tess_eval_program_state
2223 /** Currently bound and valid shader. */
2224 struct gl_tess_eval_program
*_Current
;
2228 * Context state for geometry programs.
2230 struct gl_geometry_program_state
2232 /** Currently enabled and valid program (including internal programs
2233 * and compiled shader programs).
2235 struct gl_geometry_program
*_Current
;
2239 * Context state for fragment programs.
2241 struct gl_fragment_program_state
2243 GLboolean Enabled
; /**< User-set fragment program enable flag */
2244 GLboolean _Enabled
; /**< Enabled and _valid_ user program? */
2245 struct gl_fragment_program
*Current
; /**< User-bound fragment program */
2247 /** Currently enabled and valid fragment program (including internal
2248 * programs, user-defined fragment programs and GLSL fragment shaders).
2249 * This is the program we must use when rendering.
2251 struct gl_fragment_program
*_Current
;
2253 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2255 /** Should fixed-function texturing be implemented with a fragment prog? */
2256 GLboolean _MaintainTexEnvProgram
;
2258 /** Program to emulate fixed-function texture env/combine (see above) */
2259 struct gl_fragment_program
*_TexEnvProgram
;
2261 /** Cache of fixed-function programs */
2262 struct gl_program_cache
*Cache
;
2267 * Context state for compute programs.
2269 struct gl_compute_program_state
2271 /** Currently enabled and valid program (including internal programs
2272 * and compiled shader programs).
2274 struct gl_compute_program
*_Current
;
2279 * ATI_fragment_shader runtime state
2281 #define ATI_FS_INPUT_PRIMARY 0
2282 #define ATI_FS_INPUT_SECONDARY 1
2284 struct atifs_instruction
;
2285 struct atifs_setupinst
;
2288 * ATI fragment shader
2290 struct ati_fragment_shader
2294 struct atifs_instruction
*Instructions
[2];
2295 struct atifs_setupinst
*SetupInst
[2];
2296 GLfloat Constants
[8][4];
2297 GLbitfield LocalConstDef
; /**< Indicates which constants have been set */
2298 GLubyte numArithInstr
[2];
2299 GLubyte regsAssigned
[2];
2300 GLubyte NumPasses
; /**< 1 or 2 */
2302 GLubyte last_optype
;
2303 GLboolean interpinp1
;
2309 * Context state for GL_ATI_fragment_shader
2311 struct gl_ati_fragment_shader_state
2314 GLboolean _Enabled
; /**< enabled and valid shader? */
2315 GLboolean Compiling
;
2316 GLfloat GlobalConstants
[8][4];
2317 struct ati_fragment_shader
*Current
;
2321 * Shader subroutine function definition
2323 struct gl_subroutine_function
2326 int num_compat_types
;
2327 const struct glsl_type
**types
;
2331 * A GLSL vertex or fragment shader object.
2335 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2336 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2337 * Must be the first field.
2340 gl_shader_stage Stage
;
2341 GLuint Name
; /**< AKA the handle */
2342 GLint RefCount
; /**< Reference count */
2343 GLchar
*Label
; /**< GL_KHR_debug */
2344 GLboolean DeletePending
;
2345 GLboolean CompileStatus
;
2346 bool IsES
; /**< True if this shader uses GLSL ES */
2348 GLuint SourceChecksum
; /**< for debug/logging purposes */
2349 const GLchar
*Source
; /**< Source code string */
2351 struct gl_program
*Program
; /**< Post-compile assembly code */
2354 unsigned Version
; /**< GLSL version used for linking */
2357 * \name Sampler tracking
2359 * \note Each of these fields is only set post-linking.
2362 unsigned num_samplers
; /**< Number of samplers used by this shader. */
2363 GLbitfield active_samplers
; /**< Bitfield of which samplers are used */
2364 GLbitfield shadow_samplers
; /**< Samplers used for shadow sampling. */
2368 * Map from sampler unit to texture unit (set by glUniform1i())
2370 * A sampler unit is associated with each sampler uniform by the linker.
2371 * The sampler unit associated with each uniform is stored in the
2372 * \c gl_uniform_storage::sampler field.
2374 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2375 /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
2376 gl_texture_index SamplerTargets
[MAX_SAMPLERS
];
2379 * Number of default uniform block components used by this shader.
2381 * This field is only set post-linking.
2383 unsigned num_uniform_components
;
2386 * Number of combined uniform components used by this shader.
2388 * This field is only set post-linking. It is the sum of the uniform block
2389 * sizes divided by sizeof(float), and num_uniform_compoennts.
2391 unsigned num_combined_uniform_components
;
2394 * This shader's uniform block information.
2396 * These fields are only set post-linking.
2398 unsigned NumUniformBlocks
;
2399 struct gl_uniform_block
*UniformBlocks
;
2401 struct exec_list
*ir
;
2402 struct glsl_symbol_table
*symbols
;
2404 bool uses_builtin_functions
;
2405 bool uses_gl_fragcoord
;
2406 bool redeclares_gl_fragcoord
;
2407 bool ARB_fragment_coord_conventions_enable
;
2410 * Fragment shader state from GLSL 1.50 layout qualifiers.
2412 bool origin_upper_left
;
2413 bool pixel_center_integer
;
2416 * Tessellation Control shader state from layout qualifiers.
2420 * 0 - vertices not declared in shader, or
2421 * 1 .. GL_MAX_PATCH_VERTICES
2427 * Tessellation Evaluation shader state from layout qualifiers.
2431 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2434 GLenum PrimitiveMode
;
2436 * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
2441 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2445 * 1, 0, or -1 if it's not set in this shader.
2451 * Geometry shader state from GLSL 1.50 layout qualifiers.
2456 * 0 - Invocations count not declared in shader, or
2457 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
2461 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2462 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2467 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2468 * it's not set in this shader.
2474 * Map from image uniform index to image unit (set by glUniform1i())
2476 * An image uniform index is associated with each image uniform by
2477 * the linker. The image index associated with each uniform is
2478 * stored in the \c gl_uniform_storage::image field.
2480 GLubyte ImageUnits
[MAX_IMAGE_UNIFORMS
];
2483 * Access qualifier specified in the shader for each image uniform
2484 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
2487 * It may be different, though only more strict than the value of
2488 * \c gl_image_unit::Access for the corresponding image unit.
2490 GLenum ImageAccess
[MAX_IMAGE_UNIFORMS
];
2493 * Number of image uniforms defined in the shader. It specifies
2494 * the number of valid elements in the \c ImageUnits and \c
2495 * ImageAccess arrays above.
2500 * Whether early fragment tests are enabled as defined by
2501 * ARB_shader_image_load_store.
2503 bool EarlyFragmentTests
;
2506 * Compute shader state from ARB_compute_shader layout qualifiers.
2510 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2511 * it's not set in this shader.
2513 unsigned LocalSize
[3];
2517 * Number of types for subroutine uniforms.
2519 GLuint NumSubroutineUniformTypes
;
2522 * Subroutine uniform remap table
2523 * based on the program level uniform remap table.
2525 GLuint NumSubroutineUniformRemapTable
;
2526 struct gl_uniform_storage
**SubroutineUniformRemapTable
;
2529 * Num of subroutine functions for this stage
2530 * and storage for them.
2532 GLuint NumSubroutineFunctions
;
2533 struct gl_subroutine_function
*SubroutineFunctions
;
2537 struct gl_uniform_buffer_variable
2542 * Name of the uniform as seen by glGetUniformIndices.
2544 * glGetUniformIndices requires that the block instance index \b not be
2545 * present in the name of queried uniforms.
2548 * \c gl_uniform_buffer_variable::IndexName and
2549 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2553 const struct glsl_type
*Type
;
2554 unsigned int Offset
;
2559 enum gl_uniform_block_packing
2567 struct gl_uniform_block
2569 /** Declared name of the uniform block */
2572 /** Array of supplemental information about UBO ir_variables. */
2573 struct gl_uniform_buffer_variable
*Uniforms
;
2577 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2578 * with glBindBufferBase to bind a buffer object to this uniform block. When
2579 * updated in the program, _NEW_BUFFER_OBJECT will be set.
2584 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2585 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2587 GLuint UniformBufferSize
;
2590 * Is this actually an interface block for a shader storage buffer?
2592 bool IsShaderStorage
;
2595 * Layout specified in the shader
2597 * This isn't accessible through the API, but it is used while
2598 * cross-validating uniform blocks.
2600 enum gl_uniform_block_packing _Packing
;
2604 * Structure that represents a reference to an atomic buffer from some
2607 struct gl_active_atomic_buffer
2609 /** Uniform indices of the atomic counters declared within it. */
2613 /** Binding point index associated with it. */
2616 /** Minimum reasonable size it is expected to have. */
2619 /** Shader stages making use of it. */
2620 GLboolean StageReferences
[MESA_SHADER_STAGES
];
2624 * Active resource in a gl_shader_program
2626 struct gl_program_resource
2628 GLenum Type
; /** Program interface type. */
2629 const void *Data
; /** Pointer to resource associated data structure. */
2630 uint8_t StageReferences
; /** Bitmask of shader stage references. */
2634 * A GLSL program object.
2635 * Basically a linked collection of vertex and fragment shaders.
2637 struct gl_shader_program
2639 GLenum Type
; /**< Always GL_SHADER_PROGRAM (internal token) */
2640 GLuint Name
; /**< aka handle or ID */
2641 GLchar
*Label
; /**< GL_KHR_debug */
2642 GLint RefCount
; /**< Reference count */
2643 GLboolean DeletePending
;
2646 * Is the application intending to glGetProgramBinary this program?
2648 GLboolean BinaryRetreivableHint
;
2651 * Indicates whether program can be bound for individual pipeline stages
2652 * using UseProgramStages after it is next linked.
2654 GLboolean SeparateShader
;
2656 GLuint NumShaders
; /**< number of attached shaders */
2657 struct gl_shader
**Shaders
; /**< List of attached the shaders */
2660 * User-defined attribute bindings
2662 * These are set via \c glBindAttribLocation and are used to direct the
2663 * GLSL linker. These are \b not the values used in the compiled shader,
2664 * and they are \b not the values returned by \c glGetAttribLocation.
2666 struct string_to_uint_map
*AttributeBindings
;
2669 * User-defined fragment data bindings
2671 * These are set via \c glBindFragDataLocation and are used to direct the
2672 * GLSL linker. These are \b not the values used in the compiled shader,
2673 * and they are \b not the values returned by \c glGetFragDataLocation.
2675 struct string_to_uint_map
*FragDataBindings
;
2676 struct string_to_uint_map
*FragDataIndexBindings
;
2679 * Transform feedback varyings last specified by
2680 * glTransformFeedbackVaryings().
2682 * For the current set of transform feedback varyings used for transform
2683 * feedback output, see LinkedTransformFeedback.
2688 GLchar
**VaryingNames
; /**< Array [NumVarying] of char * */
2689 } TransformFeedback
;
2691 /** Post-link transform feedback info. */
2692 struct gl_transform_feedback_info LinkedTransformFeedback
;
2694 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
2695 enum gl_frag_depth_layout FragDepthLayout
;
2698 * Tessellation Control shader state from layout qualifiers.
2702 * 0 - vertices not declared in shader, or
2703 * 1 .. GL_MAX_PATCH_VERTICES
2709 * Tessellation Evaluation shader state from layout qualifiers.
2712 /** GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
2713 GLenum PrimitiveMode
;
2714 /** GL_EQUAL, GL_FRACTIONAL_ODD or GL_FRACTIONAL_EVEN */
2716 /** GL_CW or GL_CCW */
2720 * True if gl_ClipDistance is written to. Copied into
2721 * gl_tess_eval_program by _mesa_copy_linked_program_data().
2723 GLboolean UsesClipDistance
;
2724 GLuint ClipDistanceArraySize
; /**< Size of the gl_ClipDistance array, or
2725 0 if not present. */
2729 * Geometry shader state - copied into gl_geometry_program by
2730 * _mesa_copy_linked_program_data().
2736 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
2739 GLenum InputType
; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,
2740 GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
2741 GLenum OutputType
; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
2743 * True if gl_ClipDistance is written to. Copied into
2744 * gl_geometry_program by _mesa_copy_linked_program_data().
2746 GLboolean UsesClipDistance
;
2747 GLuint ClipDistanceArraySize
; /**< Size of the gl_ClipDistance array, or
2748 0 if not present. */
2749 bool UsesEndPrimitive
;
2753 /** Vertex shader state */
2756 * True if gl_ClipDistance is written to. Copied into gl_vertex_program
2757 * by _mesa_copy_linked_program_data().
2759 GLboolean UsesClipDistance
;
2760 GLuint ClipDistanceArraySize
; /**< Size of the gl_ClipDistance array, or
2761 0 if not present. */
2765 * Compute shader state - copied into gl_compute_program by
2766 * _mesa_copy_linked_program_data().
2770 * If this shader contains a compute stage, size specified using
2771 * local_size_{x,y,z}. Otherwise undefined.
2773 unsigned LocalSize
[3];
2776 /* post-link info: */
2777 unsigned NumUniformStorage
;
2778 unsigned NumHiddenUniforms
;
2779 struct gl_uniform_storage
*UniformStorage
;
2782 * Mapping from GL uniform locations returned by \c glUniformLocation to
2783 * UniformStorage entries. Arrays will have multiple contiguous slots
2784 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
2786 unsigned NumUniformRemapTable
;
2787 struct gl_uniform_storage
**UniformRemapTable
;
2790 * Size of the gl_ClipDistance array that is output from the last pipeline
2791 * stage before the fragment shader.
2793 unsigned LastClipDistanceArraySize
;
2795 unsigned NumUniformBlocks
;
2796 struct gl_uniform_block
*UniformBlocks
;
2799 * Indices into the _LinkedShaders's UniformBlocks[] array for each stage
2800 * they're used in, or -1.
2802 * This is used to maintain the Binding values of the stage's UniformBlocks[]
2803 * and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries.
2805 int *UniformBlockStageIndex
[MESA_SHADER_STAGES
];
2808 * Map of active uniform names to locations
2810 * Maps any active uniform that is not an array element to a location.
2811 * Each active uniform, including individual structure members will appear
2812 * in this map. This roughly corresponds to the set of names that would be
2813 * enumerated by \c glGetActiveUniform.
2815 struct string_to_uint_map
*UniformHash
;
2817 struct gl_active_atomic_buffer
*AtomicBuffers
;
2818 unsigned NumAtomicBuffers
;
2820 GLboolean LinkStatus
; /**< GL_LINK_STATUS */
2821 GLboolean Validated
;
2822 GLboolean _Used
; /**< Ever used for drawing? */
2823 GLboolean SamplersValidated
; /**< Samplers validated against texture units? */
2826 unsigned Version
; /**< GLSL version used for linking */
2827 bool IsES
; /**< True if this program uses GLSL ES */
2830 * Per-stage shaders resulting from the first stage of linking.
2832 * Set of linked shaders for this program. The array is accessed using the
2833 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
2836 struct gl_shader
*_LinkedShaders
[MESA_SHADER_STAGES
];
2838 /** List of all active resources after linking. */
2839 struct gl_program_resource
*ProgramResourceList
;
2840 unsigned NumProgramResourceList
;
2842 /* True if any of the fragment shaders attached to this program use:
2843 * #extension ARB_fragment_coord_conventions: enable
2845 GLboolean ARB_fragment_coord_conventions_enable
;
2849 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
2850 #define GLSL_LOG 0x2 /**< Write shaders to files */
2851 #define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */
2852 #define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */
2853 #define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */
2854 #define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */
2855 #define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */
2856 #define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */
2857 #define GLSL_REPORT_ERRORS 0x100 /**< Print compilation errors */
2858 #define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error */
2862 * Context state for GLSL vertex/fragment shaders.
2863 * Extended to support pipeline object
2865 struct gl_pipeline_object
2867 /** Name of the pipeline object as received from glGenProgramPipelines.
2868 * It would be 0 for shaders without separate shader objects.
2876 GLchar
*Label
; /**< GL_KHR_debug */
2879 * Programs used for rendering
2881 * There is a separate program set for each shader stage.
2883 struct gl_shader_program
*CurrentProgram
[MESA_SHADER_STAGES
];
2885 struct gl_shader_program
*_CurrentFragmentProgram
;
2888 * Program used by glUniform calls.
2890 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
2892 struct gl_shader_program
*ActiveProgram
;
2894 GLbitfield Flags
; /**< Mask of GLSL_x flags */
2896 GLboolean EverBound
; /**< Has the pipeline object been created */
2898 GLboolean Validated
; /**< Pipeline Validation status */
2904 * Context state for GLSL pipeline shaders.
2906 struct gl_pipeline_shader_state
2908 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
2909 struct gl_pipeline_object
*Current
;
2911 /* Default Object to ensure that _Shader is never NULL */
2912 struct gl_pipeline_object
*Default
;
2914 /** Pipeline objects */
2915 struct _mesa_HashTable
*Objects
;
2919 * Compiler options for a single GLSL shaders type
2921 struct gl_shader_compiler_options
2923 /** Driver-selectable options: */
2924 GLboolean EmitCondCodes
; /**< Use condition codes? */
2925 GLboolean EmitNoLoops
;
2926 GLboolean EmitNoFunctions
;
2927 GLboolean EmitNoCont
; /**< Emit CONT opcode? */
2928 GLboolean EmitNoMainReturn
; /**< Emit CONT/RET opcodes? */
2929 GLboolean EmitNoNoise
; /**< Emit NOISE opcodes? */
2930 GLboolean EmitNoPow
; /**< Emit POW opcodes? */
2931 GLboolean EmitNoSat
; /**< Emit SAT opcodes? */
2932 GLboolean LowerClipDistance
; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */
2935 * \name Forms of indirect addressing the driver cannot do.
2938 GLboolean EmitNoIndirectInput
; /**< No indirect addressing of inputs */
2939 GLboolean EmitNoIndirectOutput
; /**< No indirect addressing of outputs */
2940 GLboolean EmitNoIndirectTemp
; /**< No indirect addressing of temps */
2941 GLboolean EmitNoIndirectUniform
; /**< No indirect addressing of constants */
2942 GLboolean EmitNoIndirectSampler
; /**< No indirect addressing of samplers */
2945 GLuint MaxIfDepth
; /**< Maximum nested IF blocks */
2946 GLuint MaxUnrollIterations
;
2949 * Optimize code for array of structures backends.
2951 * This is a proxy for:
2952 * - preferring DP4 instructions (rather than MUL/MAD) for
2953 * matrix * vector operations, such as position transformation.
2955 GLboolean OptimizeForAOS
;
2957 const struct nir_shader_compiler_options
*NirOptions
;
2962 * Occlusion/timer query object.
2964 struct gl_query_object
2966 GLenum Target
; /**< The query target, when active */
2967 GLuint Id
; /**< hash table ID/name */
2968 GLchar
*Label
; /**< GL_KHR_debug */
2969 GLuint64EXT Result
; /**< the counter */
2970 GLboolean Active
; /**< inside Begin/EndQuery */
2971 GLboolean Ready
; /**< result is ready? */
2972 GLboolean EverBound
;/**< has query object ever been bound */
2973 GLuint Stream
; /**< The stream */
2978 * Context state for query objects.
2980 struct gl_query_state
2982 struct _mesa_HashTable
*QueryObjects
;
2983 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
2984 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
2986 /** GL_NV_conditional_render */
2987 struct gl_query_object
*CondRenderQuery
;
2989 /** GL_EXT_transform_feedback */
2990 struct gl_query_object
*PrimitivesGenerated
[MAX_VERTEX_STREAMS
];
2991 struct gl_query_object
*PrimitivesWritten
[MAX_VERTEX_STREAMS
];
2993 /** GL_ARB_timer_query */
2994 struct gl_query_object
*TimeElapsed
;
2996 /** GL_ARB_pipeline_statistics_query */
2997 struct gl_query_object
*pipeline_stats
[MAX_PIPELINE_STATISTICS
];
2999 GLenum CondRenderMode
;
3003 /** Sync object state */
3004 struct gl_sync_object
3006 GLenum Type
; /**< GL_SYNC_FENCE */
3007 GLuint Name
; /**< Fence name */
3008 GLchar
*Label
; /**< GL_KHR_debug */
3009 GLint RefCount
; /**< Reference count */
3010 GLboolean DeletePending
; /**< Object was deleted while there were still
3011 * live references (e.g., sync not yet finished)
3013 GLenum SyncCondition
;
3014 GLbitfield Flags
; /**< Flags passed to glFenceSync */
3015 GLuint StatusFlag
:1; /**< Has the sync object been signaled? */
3020 * State which can be shared by multiple contexts:
3022 struct gl_shared_state
3024 mtx_t Mutex
; /**< for thread safety */
3025 GLint RefCount
; /**< Reference count */
3026 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
3027 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
3029 /** Default texture objects (shared by all texture units) */
3030 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
3032 /** Fallback texture used when a bound texture is incomplete */
3033 struct gl_texture_object
*FallbackTex
[NUM_TEXTURE_TARGETS
];
3036 * \name Thread safety and statechange notification for texture
3039 * \todo Improve the granularity of locking.
3042 mtx_t TexMutex
; /**< texobj thread safety */
3043 GLuint TextureStateStamp
; /**< state notification for shared tex */
3046 /** Default buffer object for vertex arrays that aren't in VBOs */
3047 struct gl_buffer_object
*NullBufferObj
;
3050 * \name Vertex/geometry/fragment programs
3053 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
3054 struct gl_vertex_program
*DefaultVertexProgram
;
3055 struct gl_fragment_program
*DefaultFragmentProgram
;
3058 /* GL_ATI_fragment_shader */
3059 struct _mesa_HashTable
*ATIShaders
;
3060 struct ati_fragment_shader
*DefaultFragmentShader
;
3062 struct _mesa_HashTable
*BufferObjects
;
3064 /** Table of both gl_shader and gl_shader_program objects */
3065 struct _mesa_HashTable
*ShaderObjects
;
3067 /* GL_EXT_framebuffer_object */
3068 struct _mesa_HashTable
*RenderBuffers
;
3069 struct _mesa_HashTable
*FrameBuffers
;
3072 struct set
*SyncObjects
;
3074 /** GL_ARB_sampler_objects */
3075 struct _mesa_HashTable
*SamplerObjects
;
3078 * Some context in this share group was affected by a GPU reset
3080 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3081 * been affected by a GPU reset must also return
3082 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3084 * Once this field becomes true, it is never reset to false.
3086 bool ShareGroupReset
;
3092 * Renderbuffers represent drawing surfaces such as color, depth and/or
3093 * stencil. A framebuffer object has a set of renderbuffers.
3094 * Drivers will typically derive subclasses of this type.
3096 struct gl_renderbuffer
3098 mtx_t Mutex
; /**< for thread safety */
3099 GLuint ClassID
; /**< Useful for drivers */
3101 GLchar
*Label
; /**< GL_KHR_debug */
3103 GLuint Width
, Height
;
3105 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
3106 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
3108 * True for renderbuffers that wrap textures, giving the driver a chance to
3109 * flush render caches through the FinishRenderTexture hook.
3111 * Drivers may also set this on renderbuffers other than those generated by
3112 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3113 * called without a rb->TexImage.
3115 GLboolean NeedsFinishRenderTexture
;
3117 GLenum InternalFormat
; /**< The user-specified format */
3118 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3119 GL_STENCIL_INDEX. */
3120 mesa_format Format
; /**< The actual renderbuffer memory format */
3122 * Pointer to the texture image if this renderbuffer wraps a texture,
3125 * Note that the reference on the gl_texture_object containing this
3126 * TexImage is held by the gl_renderbuffer_attachment.
3128 struct gl_texture_image
*TexImage
;
3130 /** Delete this renderbuffer */
3131 void (*Delete
)(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
);
3133 /** Allocate new storage for this renderbuffer */
3134 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
3135 struct gl_renderbuffer
*rb
,
3136 GLenum internalFormat
,
3137 GLuint width
, GLuint height
);
3142 * A renderbuffer attachment points to either a texture object (and specifies
3143 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3145 struct gl_renderbuffer_attachment
3147 GLenum Type
; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3151 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3152 * application supplied renderbuffer object.
3154 struct gl_renderbuffer
*Renderbuffer
;
3157 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3158 * supplied texture object.
3160 struct gl_texture_object
*Texture
;
3161 GLuint TextureLevel
; /**< Attached mipmap level. */
3162 GLuint CubeMapFace
; /**< 0 .. 5, for cube map textures. */
3163 GLuint Zoffset
; /**< Slice for 3D textures, or layer for both 1D
3164 * and 2D array textures */
3170 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3171 * In C++ terms, think of this as a base class from which device drivers
3172 * will make derived classes.
3174 struct gl_framebuffer
3176 mtx_t Mutex
; /**< for thread safety */
3178 * If zero, this is a window system framebuffer. If non-zero, this
3179 * is a FBO framebuffer; note that for some devices (i.e. those with
3180 * a natural pixel coordinate system for FBOs that differs from the
3181 * OpenGL/Mesa coordinate system), this means that the viewport,
3182 * polygon face orientation, and polygon stipple will have to be inverted.
3187 GLchar
*Label
; /**< GL_KHR_debug */
3189 GLboolean DeletePending
;
3192 * The framebuffer's visual. Immutable if this is a window system buffer.
3193 * Computed from attachments if user-made FBO.
3195 struct gl_config Visual
;
3198 * Size of frame buffer in pixels. If there are no attachments, then both
3201 GLuint Width
, Height
;
3204 * In the case that the framebuffer has no attachment (i.e.
3205 * GL_ARB_framebuffer_no_attachments) then the geometry of
3206 * the framebuffer is specified by the default values.
3209 GLuint Width
, Height
, Layers
, NumSamples
;
3210 GLboolean FixedSampleLocations
;
3213 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3214 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3215 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3222 /** \name Derived Z buffer stuff */
3224 GLuint _DepthMax
; /**< Max depth buffer value */
3225 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
3226 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
3229 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3232 /** Whether one of Attachment has Type != GL_NONE
3233 * NOTE: the values for Width and Height are set to 0 in case of having
3234 * no attachments, a backend driver supporting the extension
3235 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3236 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3237 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3238 * _Ymax do NOT take into account _HasAttachments being false). To get the
3239 * geometry of the framebuffer, the helper functions
3240 * _mesa_geometric_width(),
3241 * _mesa_geometric_height(),
3242 * _mesa_geometric_samples() and
3243 * _mesa_geometric_layers()
3244 * are available that check _HasAttachments.
3246 bool _HasAttachments
;
3248 /** Integer color values */
3249 GLboolean _IntegerColor
;
3251 /* ARB_color_buffer_float */
3252 GLboolean _AllColorBuffersFixedPoint
; /* no integer, no float */
3253 GLboolean _HasSNormOrFloatColorBuffer
;
3256 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3257 * is not layered. For cube maps and cube map arrays, each cube face
3258 * counts as a layer. As the case for Width, Height a backend driver
3259 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3260 * in the case that _HasAttachments is false
3262 GLuint MaxNumLayers
;
3264 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3265 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
3267 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3268 * attribute group and GL_PIXEL attribute group, respectively.
3270 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
3271 GLenum ColorReadBuffer
;
3273 /** Computed from ColorDraw/ReadBuffer above */
3274 GLuint _NumColorDrawBuffers
;
3275 GLint _ColorDrawBufferIndexes
[MAX_DRAW_BUFFERS
]; /**< BUFFER_x or -1 */
3276 GLint _ColorReadBufferIndex
; /* -1 = None */
3277 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
];
3278 struct gl_renderbuffer
*_ColorReadBuffer
;
3280 /** Delete this framebuffer */
3281 void (*Delete
)(struct gl_framebuffer
*fb
);
3286 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3290 GLushort RangeMin
; /**< min value exponent */
3291 GLushort RangeMax
; /**< max value exponent */
3292 GLushort Precision
; /**< number of mantissa bits */
3297 * Limits for vertex, geometry and fragment programs/shaders.
3299 struct gl_program_constants
3301 /* logical limits */
3302 GLuint MaxInstructions
;
3303 GLuint MaxAluInstructions
;
3304 GLuint MaxTexInstructions
;
3305 GLuint MaxTexIndirections
;
3308 GLuint MaxAddressRegs
;
3309 GLuint MaxAddressOffset
; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3310 GLuint MaxParameters
;
3311 GLuint MaxLocalParams
;
3312 GLuint MaxEnvParams
;
3313 /* native/hardware limits */
3314 GLuint MaxNativeInstructions
;
3315 GLuint MaxNativeAluInstructions
;
3316 GLuint MaxNativeTexInstructions
;
3317 GLuint MaxNativeTexIndirections
;
3318 GLuint MaxNativeAttribs
;
3319 GLuint MaxNativeTemps
;
3320 GLuint MaxNativeAddressRegs
;
3321 GLuint MaxNativeParameters
;
3323 GLuint MaxUniformComponents
; /**< Usually == MaxParameters * 4 */
3326 * \name Per-stage input / output limits
3328 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3329 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3330 * ES). This is stored as \c gl_constants::MaxVarying.
3332 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3333 * variables. Each stage as a certain number of outputs that it can feed
3334 * to the next stage and a certain number inputs that it can consume from
3335 * the previous stage.
3337 * Vertex shader inputs do not participate this in this accounting.
3338 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3340 * Fragment shader outputs do not participate this in this accounting.
3341 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3344 GLuint MaxInputComponents
;
3345 GLuint MaxOutputComponents
;
3348 /* ES 2.0 and GL_ARB_ES2_compatibility */
3349 struct gl_precision LowFloat
, MediumFloat
, HighFloat
;
3350 struct gl_precision LowInt
, MediumInt
, HighInt
;
3351 /* GL_ARB_uniform_buffer_object */
3352 GLuint MaxUniformBlocks
;
3353 GLuint MaxCombinedUniformComponents
;
3354 GLuint MaxTextureImageUnits
;
3356 /* GL_ARB_shader_atomic_counters */
3357 GLuint MaxAtomicBuffers
;
3358 GLuint MaxAtomicCounters
;
3360 /* GL_ARB_shader_image_load_store */
3361 GLuint MaxImageUniforms
;
3363 /* GL_ARB_shader_storage_buffer_object */
3364 GLuint MaxShaderStorageBlocks
;
3369 * Constants which may be overridden by device driver during context creation
3370 * but are never changed after that.
3374 GLuint MaxTextureMbytes
; /**< Max memory per image, in MB */
3375 GLuint MaxTextureLevels
; /**< Max mipmap levels. */
3376 GLuint Max3DTextureLevels
; /**< Max mipmap levels for 3D textures */
3377 GLuint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
3378 GLuint MaxArrayTextureLayers
; /**< Max layers in array textures */
3379 GLuint MaxTextureRectSize
; /**< Max rectangle texture size, in pixes */
3380 GLuint MaxTextureCoordUnits
;
3381 GLuint MaxCombinedTextureImageUnits
;
3382 GLuint MaxTextureUnits
; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3383 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
3384 GLfloat MaxTextureLodBias
; /**< GL_EXT_texture_lod_bias */
3385 GLuint MaxTextureBufferSize
; /**< GL_ARB_texture_buffer_object */
3387 GLuint TextureBufferOffsetAlignment
; /**< GL_ARB_texture_buffer_range */
3389 GLuint MaxArrayLockSize
;
3393 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
3394 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
3395 GLfloat PointSizeGranularity
;
3396 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
3397 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
3398 GLfloat LineWidthGranularity
;
3400 GLuint MaxClipPlanes
;
3402 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
3403 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
3405 GLuint MaxViewportWidth
, MaxViewportHeight
;
3406 GLuint MaxViewports
; /**< GL_ARB_viewport_array */
3407 GLuint ViewportSubpixelBits
; /**< GL_ARB_viewport_array */
3411 } ViewportBounds
; /**< GL_ARB_viewport_array */
3413 struct gl_program_constants Program
[MESA_SHADER_STAGES
];
3414 GLuint MaxProgramMatrices
;
3415 GLuint MaxProgramMatrixStackDepth
;
3418 GLuint SamplesPassed
;
3421 GLuint PrimitivesGenerated
;
3422 GLuint PrimitivesWritten
;
3423 GLuint VerticesSubmitted
;
3424 GLuint PrimitivesSubmitted
;
3425 GLuint VsInvocations
;
3427 GLuint TessInvocations
;
3428 GLuint GsInvocations
;
3429 GLuint GsPrimitives
;
3430 GLuint FsInvocations
;
3431 GLuint ComputeInvocations
;
3432 GLuint ClInPrimitives
;
3433 GLuint ClOutPrimitives
;
3436 GLuint MaxDrawBuffers
; /**< GL_ARB_draw_buffers */
3438 GLuint MaxColorAttachments
; /**< GL_EXT_framebuffer_object */
3439 GLuint MaxRenderbufferSize
; /**< GL_EXT_framebuffer_object */
3440 GLuint MaxSamples
; /**< GL_ARB_framebuffer_object */
3443 * GL_ARB_framebuffer_no_attachments
3445 GLuint MaxFramebufferWidth
;
3446 GLuint MaxFramebufferHeight
;
3447 GLuint MaxFramebufferLayers
;
3448 GLuint MaxFramebufferSamples
;
3450 /** Number of varying vectors between any two shader stages. */
3454 * GL_ARB_uniform_buffer_object
3456 GLuint MaxCombinedUniformBlocks
;
3457 GLuint MaxUniformBufferBindings
;
3458 GLuint MaxUniformBlockSize
;
3459 GLuint UniformBufferOffsetAlignment
;
3463 * GL_ARB_shader_storage_buffer_object
3465 GLuint MaxCombinedShaderStorageBlocks
;
3466 GLuint MaxShaderStorageBufferBindings
;
3467 GLuint MaxShaderStorageBlockSize
;
3468 GLuint ShaderStorageBufferOffsetAlignment
;
3472 * GL_ARB_explicit_uniform_location
3474 GLuint MaxUserAssignableUniformLocations
;
3476 /** GL_ARB_geometry_shader4 */
3477 GLuint MaxGeometryOutputVertices
;
3478 GLuint MaxGeometryTotalOutputComponents
;
3480 GLuint GLSLVersion
; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3483 * Changes default GLSL extension behavior from "error" to "warn". It's out
3484 * of spec, but it can make some apps work that otherwise wouldn't.
3486 GLboolean ForceGLSLExtensionsWarn
;
3489 * If non-zero, forces GLSL shaders to behave as if they began
3490 * with "#version ForceGLSLVersion".
3492 GLuint ForceGLSLVersion
;
3495 * Allow GLSL #extension directives in the middle of shaders.
3497 GLboolean AllowGLSLExtensionDirectiveMidShader
;
3500 * Does the driver support real 32-bit integers? (Otherwise, integers are
3501 * simulated via floats.)
3503 GLboolean NativeIntegers
;
3506 * Does VertexID count from zero or from base vertex?
3509 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3510 * ignored and need not be set.
3512 bool VertexID_is_zero_based
;
3515 * If the driver supports real 32-bit integers, what integer value should be
3516 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3518 GLuint UniformBooleanTrue
;
3521 * Maximum amount of time, measured in nanseconds, that the server can wait.
3523 GLuint64 MaxServerWaitTimeout
;
3525 /** GL_EXT_provoking_vertex */
3526 GLboolean QuadsFollowProvokingVertexConvention
;
3528 /** OpenGL version 3.0 */
3529 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3531 /** OpenGL version 3.2 */
3532 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
3534 /** OpenGL version 4.4 */
3535 GLuint MaxVertexAttribStride
;
3537 /** GL_EXT_transform_feedback */
3538 GLuint MaxTransformFeedbackBuffers
;
3539 GLuint MaxTransformFeedbackSeparateComponents
;
3540 GLuint MaxTransformFeedbackInterleavedComponents
;
3541 GLuint MaxVertexStreams
;
3543 /** GL_EXT_gpu_shader4 */
3544 GLint MinProgramTexelOffset
, MaxProgramTexelOffset
;
3546 /** GL_ARB_texture_gather */
3547 GLuint MinProgramTextureGatherOffset
;
3548 GLuint MaxProgramTextureGatherOffset
;
3549 GLuint MaxProgramTextureGatherComponents
;
3551 /* GL_ARB_robustness */
3552 GLenum ResetStrategy
;
3554 /* GL_ARB_blend_func_extended */
3555 GLuint MaxDualSourceDrawBuffers
;
3558 * Whether the implementation strips out and ignores texture borders.
3560 * Many GPU hardware implementations don't support rendering with texture
3561 * borders and mipmapped textures. (Note: not static border color, but the
3562 * old 1-pixel border around each edge). Implementations then have to do
3563 * slow fallbacks to be correct, or just ignore the border and be fast but
3564 * wrong. Setting the flag strips the border off of TexImage calls,
3565 * providing "fast but wrong" at significantly reduced driver complexity.
3567 * Texture borders are deprecated in GL 3.0.
3569 GLboolean StripTextureBorder
;
3572 * For drivers which can do a better job at eliminating unused uniforms
3573 * than the GLSL compiler.
3575 * XXX Remove these as soon as a better solution is available.
3577 GLboolean GLSLSkipStrictMaxUniformLimitCheck
;
3580 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3581 * than passing the transform feedback object to the drawing function.
3583 GLboolean AlwaysUseGetTransformFeedbackVertexCount
;
3585 /** GL_ARB_map_buffer_alignment */
3586 GLuint MinMapBufferAlignment
;
3589 * Disable varying packing. This is out of spec, but potentially useful
3590 * for older platforms that supports a limited number of texture
3591 * indirections--on these platforms, unpacking the varyings in the fragment
3592 * shader increases the number of texture indirections by 1, which might
3593 * make some shaders not executable at all.
3595 * Drivers that support transform feedback must set this value to GL_FALSE.
3597 GLboolean DisableVaryingPacking
;
3600 * Should meaningful names be generated for compiler temporary variables?
3602 * Generally, it is not useful to have the compiler generate "meaningful"
3603 * names for temporary variables that it creates. This can, however, be a
3604 * useful debugging aid. In Mesa debug builds or release builds when
3605 * MESA_GLSL is set at run-time, meaningful names will be generated.
3606 * Drivers can also force names to be generated by setting this field.
3607 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
3608 * vertex shader assembly) is set at run-time.
3610 bool GenerateTemporaryNames
;
3613 * Maximum value supported for an index in DrawElements and friends.
3615 * This must be at least (1ull<<24)-1. The default value is
3618 * \since ES 3.0 or GL_ARB_ES3_compatibility
3619 * \sa _mesa_init_constants
3621 GLuint64 MaxElementIndex
;
3624 * Disable interpretation of line continuations (lines ending with a
3625 * backslash character ('\') in GLSL source.
3627 GLboolean DisableGLSLLineContinuations
;
3629 /** GL_ARB_texture_multisample */
3630 GLint MaxColorTextureSamples
;
3631 GLint MaxDepthTextureSamples
;
3632 GLint MaxIntegerSamples
;
3635 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
3636 * samples are laid out in a rectangular grid roughly corresponding to
3637 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
3638 * are used to map indices of rectangular grid to sample numbers within
3639 * a pixel. This mapping of indices to sample numbers must be initialized
3640 * by the driver for the target hardware. For example, if we have the 8X
3641 * MSAA sample number layout (sample positions) for XYZ hardware:
3643 * sample indices layout sample number layout
3644 * --------- ---------
3645 * | 0 | 1 | | a | b |
3646 * --------- ---------
3647 * | 2 | 3 | | c | d |
3648 * --------- ---------
3649 * | 4 | 5 | | e | f |
3650 * --------- ---------
3651 * | 6 | 7 | | g | h |
3652 * --------- ---------
3654 * Where a,b,c,d,e,f,g,h are integers between [0-7].
3656 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
3658 * SampleMap8x = {a, b, c, d, e, f, g, h};
3660 * Follow the logic for other sample counts.
3662 uint8_t SampleMap2x
[2];
3663 uint8_t SampleMap4x
[4];
3664 uint8_t SampleMap8x
[8];
3666 /** GL_ARB_shader_atomic_counters */
3667 GLuint MaxAtomicBufferBindings
;
3668 GLuint MaxAtomicBufferSize
;
3669 GLuint MaxCombinedAtomicBuffers
;
3670 GLuint MaxCombinedAtomicCounters
;
3672 /** GL_ARB_vertex_attrib_binding */
3673 GLint MaxVertexAttribRelativeOffset
;
3674 GLint MaxVertexAttribBindings
;
3676 /* GL_ARB_shader_image_load_store */
3677 GLuint MaxImageUnits
;
3678 GLuint MaxCombinedImageUnitsAndFragmentOutputs
;
3679 GLuint MaxImageSamples
;
3680 GLuint MaxCombinedImageUniforms
;
3682 /** GL_ARB_compute_shader */
3683 GLuint MaxComputeWorkGroupCount
[3]; /* Array of x, y, z dimensions */
3684 GLuint MaxComputeWorkGroupSize
[3]; /* Array of x, y, z dimensions */
3685 GLuint MaxComputeWorkGroupInvocations
;
3687 /** GL_ARB_gpu_shader5 */
3688 GLfloat MinFragmentInterpolationOffset
;
3689 GLfloat MaxFragmentInterpolationOffset
;
3691 GLboolean FakeSWMSAA
;
3693 /** GL_KHR_context_flush_control */
3694 GLenum ContextReleaseBehavior
;
3696 struct gl_shader_compiler_options ShaderCompilerOptions
[MESA_SHADER_STAGES
];
3698 /** GL_ARB_tessellation_shader */
3699 GLuint MaxPatchVertices
;
3700 GLuint MaxTessGenLevel
;
3701 GLuint MaxTessPatchComponents
;
3702 GLuint MaxTessControlTotalOutputComponents
;
3703 bool LowerTessLevel
; /**< Lower gl_TessLevel* from float[n] to vecn? */
3708 * Enable flag for each OpenGL extension. Different device drivers will
3709 * enable different extensions at runtime.
3711 struct gl_extensions
3713 GLboolean dummy
; /* don't remove this! */
3714 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
3715 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
3716 GLboolean ANGLE_texture_compression_dxt
;
3717 GLboolean ARB_ES2_compatibility
;
3718 GLboolean ARB_ES3_compatibility
;
3719 GLboolean ARB_arrays_of_arrays
;
3720 GLboolean ARB_base_instance
;
3721 GLboolean ARB_blend_func_extended
;
3722 GLboolean ARB_buffer_storage
;
3723 GLboolean ARB_clear_texture
;
3724 GLboolean ARB_clip_control
;
3725 GLboolean ARB_color_buffer_float
;
3726 GLboolean ARB_compute_shader
;
3727 GLboolean ARB_conditional_render_inverted
;
3728 GLboolean ARB_conservative_depth
;
3729 GLboolean ARB_copy_image
;
3730 GLboolean ARB_depth_buffer_float
;
3731 GLboolean ARB_depth_clamp
;
3732 GLboolean ARB_depth_texture
;
3733 GLboolean ARB_derivative_control
;
3734 GLboolean ARB_draw_buffers_blend
;
3735 GLboolean ARB_draw_elements_base_vertex
;
3736 GLboolean ARB_draw_indirect
;
3737 GLboolean ARB_draw_instanced
;
3738 GLboolean ARB_fragment_coord_conventions
;
3739 GLboolean ARB_fragment_layer_viewport
;
3740 GLboolean ARB_fragment_program
;
3741 GLboolean ARB_fragment_program_shadow
;
3742 GLboolean ARB_fragment_shader
;
3743 GLboolean ARB_framebuffer_no_attachments
;
3744 GLboolean ARB_framebuffer_object
;
3745 GLboolean ARB_explicit_attrib_location
;
3746 GLboolean ARB_explicit_uniform_location
;
3747 GLboolean ARB_geometry_shader4
;
3748 GLboolean ARB_gpu_shader5
;
3749 GLboolean ARB_gpu_shader_fp64
;
3750 GLboolean ARB_half_float_vertex
;
3751 GLboolean ARB_instanced_arrays
;
3752 GLboolean ARB_internalformat_query
;
3753 GLboolean ARB_map_buffer_range
;
3754 GLboolean ARB_occlusion_query
;
3755 GLboolean ARB_occlusion_query2
;
3756 GLboolean ARB_pipeline_statistics_query
;
3757 GLboolean ARB_point_sprite
;
3758 GLboolean ARB_sample_shading
;
3759 GLboolean ARB_seamless_cube_map
;
3760 GLboolean ARB_shader_atomic_counters
;
3761 GLboolean ARB_shader_bit_encoding
;
3762 GLboolean ARB_shader_image_load_store
;
3763 GLboolean ARB_shader_precision
;
3764 GLboolean ARB_shader_stencil_export
;
3765 GLboolean ARB_shader_storage_buffer_object
;
3766 GLboolean ARB_shader_subroutine
;
3767 GLboolean ARB_shader_texture_lod
;
3768 GLboolean ARB_shading_language_packing
;
3769 GLboolean ARB_shading_language_420pack
;
3770 GLboolean ARB_shadow
;
3771 GLboolean ARB_stencil_texturing
;
3773 GLboolean ARB_tessellation_shader
;
3774 GLboolean ARB_texture_border_clamp
;
3775 GLboolean ARB_texture_buffer_object
;
3776 GLboolean ARB_texture_buffer_object_rgb32
;
3777 GLboolean ARB_texture_buffer_range
;
3778 GLboolean ARB_texture_compression_bptc
;
3779 GLboolean ARB_texture_compression_rgtc
;
3780 GLboolean ARB_texture_cube_map
;
3781 GLboolean ARB_texture_cube_map_array
;
3782 GLboolean ARB_texture_env_combine
;
3783 GLboolean ARB_texture_env_crossbar
;
3784 GLboolean ARB_texture_env_dot3
;
3785 GLboolean ARB_texture_float
;
3786 GLboolean ARB_texture_gather
;
3787 GLboolean ARB_texture_mirror_clamp_to_edge
;
3788 GLboolean ARB_texture_multisample
;
3789 GLboolean ARB_texture_non_power_of_two
;
3790 GLboolean ARB_texture_stencil8
;
3791 GLboolean ARB_texture_query_levels
;
3792 GLboolean ARB_texture_query_lod
;
3793 GLboolean ARB_texture_rg
;
3794 GLboolean ARB_texture_rgb10_a2ui
;
3795 GLboolean ARB_texture_view
;
3796 GLboolean ARB_timer_query
;
3797 GLboolean ARB_transform_feedback2
;
3798 GLboolean ARB_transform_feedback3
;
3799 GLboolean ARB_transform_feedback_instanced
;
3800 GLboolean ARB_uniform_buffer_object
;
3801 GLboolean ARB_vertex_attrib_64bit
;
3802 GLboolean ARB_vertex_program
;
3803 GLboolean ARB_vertex_shader
;
3804 GLboolean ARB_vertex_type_10f_11f_11f_rev
;
3805 GLboolean ARB_vertex_type_2_10_10_10_rev
;
3806 GLboolean ARB_viewport_array
;
3807 GLboolean EXT_blend_color
;
3808 GLboolean EXT_blend_equation_separate
;
3809 GLboolean EXT_blend_func_separate
;
3810 GLboolean EXT_blend_minmax
;
3811 GLboolean EXT_depth_bounds_test
;
3812 GLboolean EXT_draw_buffers2
;
3813 GLboolean EXT_framebuffer_multisample
;
3814 GLboolean EXT_framebuffer_multisample_blit_scaled
;
3815 GLboolean EXT_framebuffer_sRGB
;
3816 GLboolean EXT_gpu_program_parameters
;
3817 GLboolean EXT_gpu_shader4
;
3818 GLboolean EXT_packed_float
;
3819 GLboolean EXT_pixel_buffer_object
;
3820 GLboolean EXT_point_parameters
;
3821 GLboolean EXT_polygon_offset_clamp
;
3822 GLboolean EXT_provoking_vertex
;
3823 GLboolean EXT_shader_integer_mix
;
3824 GLboolean EXT_stencil_two_side
;
3825 GLboolean EXT_texture3D
;
3826 GLboolean EXT_texture_array
;
3827 GLboolean EXT_texture_compression_latc
;
3828 GLboolean EXT_texture_compression_s3tc
;
3829 GLboolean EXT_texture_env_dot3
;
3830 GLboolean EXT_texture_filter_anisotropic
;
3831 GLboolean EXT_texture_integer
;
3832 GLboolean EXT_texture_mirror_clamp
;
3833 GLboolean EXT_texture_shared_exponent
;
3834 GLboolean EXT_texture_snorm
;
3835 GLboolean EXT_texture_sRGB
;
3836 GLboolean EXT_texture_sRGB_decode
;
3837 GLboolean EXT_texture_swizzle
;
3838 GLboolean EXT_transform_feedback
;
3839 GLboolean EXT_timer_query
;
3840 GLboolean EXT_vertex_array_bgra
;
3841 GLboolean OES_standard_derivatives
;
3842 /* vendor extensions */
3843 GLboolean AMD_performance_monitor
;
3844 GLboolean AMD_pinned_memory
;
3845 GLboolean AMD_seamless_cubemap_per_texture
;
3846 GLboolean AMD_vertex_shader_layer
;
3847 GLboolean AMD_vertex_shader_viewport_index
;
3848 GLboolean APPLE_object_purgeable
;
3849 GLboolean ATI_texture_compression_3dc
;
3850 GLboolean ATI_texture_mirror_once
;
3851 GLboolean ATI_texture_env_combine3
;
3852 GLboolean ATI_fragment_shader
;
3853 GLboolean ATI_separate_stencil
;
3854 GLboolean INTEL_performance_query
;
3855 GLboolean MESA_pack_invert
;
3856 GLboolean MESA_ycbcr_texture
;
3857 GLboolean NV_conditional_render
;
3858 GLboolean NV_fog_distance
;
3859 GLboolean NV_fragment_program_option
;
3860 GLboolean NV_point_sprite
;
3861 GLboolean NV_primitive_restart
;
3862 GLboolean NV_texture_barrier
;
3863 GLboolean NV_texture_env_combine4
;
3864 GLboolean NV_texture_rectangle
;
3865 GLboolean NV_vdpau_interop
;
3866 GLboolean TDFX_texture_compression_FXT1
;
3867 GLboolean OES_EGL_image
;
3868 GLboolean OES_draw_texture
;
3869 GLboolean OES_depth_texture_cube_map
;
3870 GLboolean OES_EGL_image_external
;
3871 GLboolean OES_texture_float
;
3872 GLboolean OES_texture_float_linear
;
3873 GLboolean OES_texture_half_float
;
3874 GLboolean OES_texture_half_float_linear
;
3875 GLboolean OES_compressed_ETC1_RGB8_texture
;
3876 GLboolean extension_sentinel
;
3877 /** The extension string */
3878 const GLubyte
*String
;
3879 /** Number of supported extensions */
3885 * A stack of matrices (projection, modelview, color, texture, etc).
3887 struct gl_matrix_stack
3889 GLmatrix
*Top
; /**< points into Stack */
3890 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
3891 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
3892 GLuint MaxDepth
; /**< size of Stack[] array */
3893 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
3898 * \name Bits for image transfer operations
3899 * \sa __struct gl_contextRec::ImageTransferState.
3902 #define IMAGE_SCALE_BIAS_BIT 0x1
3903 #define IMAGE_SHIFT_OFFSET_BIT 0x2
3904 #define IMAGE_MAP_COLOR_BIT 0x4
3905 #define IMAGE_CLAMP_BIT 0x800
3908 /** Pixel Transfer ops */
3909 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
3910 IMAGE_SHIFT_OFFSET_BIT | \
3911 IMAGE_MAP_COLOR_BIT)
3914 * \name Bits to indicate what state has changed.
3917 #define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */
3918 #define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */
3919 #define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */
3920 #define _NEW_COLOR (1 << 3) /**< gl_context::Color */
3921 #define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */
3922 #define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */
3923 #define _NEW_FOG (1 << 6) /**< gl_context::Fog */
3924 #define _NEW_HINT (1 << 7) /**< gl_context::Hint */
3925 #define _NEW_LIGHT (1 << 8) /**< gl_context::Light */
3926 #define _NEW_LINE (1 << 9) /**< gl_context::Line */
3927 #define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */
3928 #define _NEW_POINT (1 << 11) /**< gl_context::Point */
3929 #define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */
3930 #define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */
3931 #define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */
3932 #define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */
3933 #define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */
3934 #define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */
3935 #define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */
3936 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
3937 #define _NEW_ARRAY (1 << 20) /**< gl_context::Array */
3938 #define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */
3939 #define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */
3940 #define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */
3941 #define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */
3942 #define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */
3943 #define _NEW_PROGRAM (1 << 26) /**< New program/shader state */
3944 #define _NEW_PROGRAM_CONSTANTS (1 << 27)
3945 #define _NEW_BUFFER_OBJECT (1 << 28)
3946 #define _NEW_FRAG_CLAMP (1 << 29)
3947 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
3948 #define _NEW_VARYING_VP_INPUTS (1 << 31) /**< gl_context::varying_vp_inputs */
3954 * Composite state flags
3957 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
3963 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
3973 /* This has to be included here. */
3978 * Display list flags.
3979 * Strictly this is a tnl-private concept, but it doesn't seem
3980 * worthwhile adding a tnl private structure just to hold this one bit
3983 #define DLIST_DANGLING_REFS 0x1
3986 /** Opaque declaration of display list payload data type */
3987 union gl_dlist_node
;
3991 * Provide a location where information about a display list can be
3992 * collected. Could be extended with driverPrivate structures,
3993 * etc. in the future.
3995 struct gl_display_list
3998 GLchar
*Label
; /**< GL_KHR_debug */
3999 GLbitfield Flags
; /**< DLIST_x flags */
4000 /** The dlist commands are in a linked list of nodes */
4001 union gl_dlist_node
*Head
;
4006 * State used during display list compilation and execution.
4008 struct gl_dlist_state
4010 GLuint CallDepth
; /**< Current recursion calling depth */
4012 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
4013 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
4014 GLuint CurrentPos
; /**< Index into current block of nodes */
4016 GLvertexformat ListVtxfmt
;
4018 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
4019 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
4021 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
4022 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
4025 /* State known to have been set by the currently-compiling display
4026 * list. Used to eliminate some redundant state changes.
4034 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
4035 * to small enums suitable for use as an array index.
4038 enum mesa_debug_source
{
4039 MESA_DEBUG_SOURCE_API
,
4040 MESA_DEBUG_SOURCE_WINDOW_SYSTEM
,
4041 MESA_DEBUG_SOURCE_SHADER_COMPILER
,
4042 MESA_DEBUG_SOURCE_THIRD_PARTY
,
4043 MESA_DEBUG_SOURCE_APPLICATION
,
4044 MESA_DEBUG_SOURCE_OTHER
,
4045 MESA_DEBUG_SOURCE_COUNT
4048 enum mesa_debug_type
{
4049 MESA_DEBUG_TYPE_ERROR
,
4050 MESA_DEBUG_TYPE_DEPRECATED
,
4051 MESA_DEBUG_TYPE_UNDEFINED
,
4052 MESA_DEBUG_TYPE_PORTABILITY
,
4053 MESA_DEBUG_TYPE_PERFORMANCE
,
4054 MESA_DEBUG_TYPE_OTHER
,
4055 MESA_DEBUG_TYPE_MARKER
,
4056 MESA_DEBUG_TYPE_PUSH_GROUP
,
4057 MESA_DEBUG_TYPE_POP_GROUP
,
4058 MESA_DEBUG_TYPE_COUNT
4061 enum mesa_debug_severity
{
4062 MESA_DEBUG_SEVERITY_LOW
,
4063 MESA_DEBUG_SEVERITY_MEDIUM
,
4064 MESA_DEBUG_SEVERITY_HIGH
,
4065 MESA_DEBUG_SEVERITY_NOTIFICATION
,
4066 MESA_DEBUG_SEVERITY_COUNT
4072 * Driver-specific state flags.
4074 * These are or'd with gl_context::NewDriverState to notify a driver about
4075 * a state change. The driver sets the flags at context creation and
4076 * the meaning of the bits set is opaque to core Mesa.
4078 struct gl_driver_flags
4080 /** gl_context::Array::_DrawArrays (vertex array state) */
4083 /** gl_context::TransformFeedback::CurrentObject */
4084 uint64_t NewTransformFeedback
;
4086 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4087 uint64_t NewTransformFeedbackProg
;
4089 /** gl_context::RasterDiscard */
4090 uint64_t NewRasterizerDiscard
;
4093 * gl_context::UniformBufferBindings
4094 * gl_shader_program::UniformBlocks
4096 uint64_t NewUniformBuffer
;
4099 * gl_context::ShaderStorageBufferBindings
4100 * gl_shader_program::ShaderStorageBlocks
4102 uint64_t NewShaderStorageBuffer
;
4104 uint64_t NewTextureBuffer
;
4107 * gl_context::AtomicBufferBindings
4109 uint64_t NewAtomicBuffer
;
4112 * gl_context::ImageUnits
4114 uint64_t NewImageUnits
;
4117 * gl_context::TessCtrlProgram::patch_default_*
4119 uint64_t NewDefaultTessLevels
;
4122 struct gl_uniform_buffer_binding
4124 struct gl_buffer_object
*BufferObject
;
4125 /** Start of uniform block data in the buffer */
4127 /** Size of data allowed to be referenced from the buffer (in bytes) */
4130 * glBindBufferBase() indicates that the Size should be ignored and only
4131 * limited by the current size of the BufferObject.
4133 GLboolean AutomaticSize
;
4136 struct gl_shader_storage_buffer_binding
4138 struct gl_buffer_object
*BufferObject
;
4139 /** Start of shader storage block data in the buffer */
4141 /** Size of data allowed to be referenced from the buffer (in bytes) */
4144 * glBindBufferBase() indicates that the Size should be ignored and only
4145 * limited by the current size of the BufferObject.
4147 GLboolean AutomaticSize
;
4151 * ARB_shader_image_load_store image unit.
4153 struct gl_image_unit
4156 * Texture object bound to this unit.
4158 struct gl_texture_object
*TexObj
;
4161 * Level of the texture object bound to this unit.
4166 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4167 * GL_FALSE if only some specific layer of the texture is bound.
4173 * GL_TRUE if the state of this image unit is valid and access from
4174 * the shader is allowed. Otherwise loads from this unit should
4175 * return zero and stores should have no effect.
4180 * Layer of the texture object bound to this unit, or zero if the
4181 * whole level is bound.
4186 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4187 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4192 * GL internal format that determines the interpretation of the
4193 * image memory when shader image operations are performed through
4199 * Mesa format corresponding to \c Format.
4201 mesa_format _ActualFormat
;
4206 * Binding point for an atomic counter buffer object.
4208 struct gl_atomic_buffer_binding
4210 struct gl_buffer_object
*BufferObject
;
4216 * Mesa rendering context.
4218 * This is the central context data structure for Mesa. Almost all
4219 * OpenGL state is contained in this structure.
4220 * Think of this as a base class from which device drivers will derive
4225 /** State possibly shared with other contexts in the address space */
4226 struct gl_shared_state
*Shared
;
4228 /** \name API function pointer tables */
4232 * The current dispatch table for non-displaylist-saving execution, either
4233 * BeginEnd or OutsideBeginEnd
4235 struct _glapi_table
*Exec
;
4237 * The normal dispatch table for non-displaylist-saving, non-begin/end
4239 struct _glapi_table
*OutsideBeginEnd
;
4240 /** The dispatch table used between glNewList() and glEndList() */
4241 struct _glapi_table
*Save
;
4243 * The dispatch table used between glBegin() and glEnd() (outside of a
4244 * display list). Only valid functions between those two are set, which is
4245 * mostly just the set in a GLvertexformat struct.
4247 struct _glapi_table
*BeginEnd
;
4249 * Tracks the current dispatch table out of the 3 above, so that it can be
4250 * re-set on glXMakeCurrent().
4252 struct _glapi_table
*CurrentDispatch
;
4255 struct gl_config Visual
;
4256 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
4257 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
4258 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
4259 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
4262 * Device driver function pointer table
4264 struct dd_function_table Driver
;
4266 /** Core/Driver constants */
4267 struct gl_constants Const
;
4269 /** \name The various 4x4 matrix stacks */
4271 struct gl_matrix_stack ModelviewMatrixStack
;
4272 struct gl_matrix_stack ProjectionMatrixStack
;
4273 struct gl_matrix_stack TextureMatrixStack
[MAX_TEXTURE_UNITS
];
4274 struct gl_matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
4275 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
4278 /** Combined modelview and projection matrix */
4279 GLmatrix _ModelProjectMatrix
;
4281 /** \name Display lists */
4282 struct gl_dlist_state ListState
;
4284 GLboolean ExecuteFlag
; /**< Execute GL commands? */
4285 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
4287 /** Extension information */
4288 struct gl_extensions Extensions
;
4290 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4292 char *VersionString
;
4294 /** \name State attribute stack (for glPush/PopAttrib) */
4296 GLuint AttribStackDepth
;
4297 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
4300 /** \name Renderer attribute groups
4302 * We define a struct for each attribute group to make pushing and popping
4303 * attributes easy. Also it's a good organization.
4306 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
4307 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
4308 struct gl_current_attrib Current
; /**< Current attributes */
4309 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
4310 struct gl_eval_attrib Eval
; /**< Eval attributes */
4311 struct gl_fog_attrib Fog
; /**< Fog attributes */
4312 struct gl_hint_attrib Hint
; /**< Hint attributes */
4313 struct gl_light_attrib Light
; /**< Light attributes */
4314 struct gl_line_attrib Line
; /**< Line attributes */
4315 struct gl_list_attrib List
; /**< List attributes */
4316 struct gl_multisample_attrib Multisample
;
4317 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
4318 struct gl_point_attrib Point
; /**< Point attributes */
4319 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
4320 GLuint PolygonStipple
[32]; /**< Polygon stipple */
4321 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
4322 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
4323 struct gl_texture_attrib Texture
; /**< Texture attributes */
4324 struct gl_transform_attrib Transform
; /**< Transformation attributes */
4325 struct gl_viewport_attrib ViewportArray
[MAX_VIEWPORTS
]; /**< Viewport attributes */
4328 /** \name Client attribute stack */
4330 GLuint ClientAttribStackDepth
;
4331 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
4334 /** \name Client attribute groups */
4336 struct gl_array_attrib Array
; /**< Vertex arrays */
4337 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
4338 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
4339 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
4342 /** \name Other assorted state (not pushed/popped on attribute stack) */
4344 struct gl_pixelmaps PixelMaps
;
4346 struct gl_evaluators EvalMap
; /**< All evaluators */
4347 struct gl_feedback Feedback
; /**< Feedback */
4348 struct gl_selection Select
; /**< Selection */
4350 struct gl_program_state Program
; /**< general program state */
4351 struct gl_vertex_program_state VertexProgram
;
4352 struct gl_fragment_program_state FragmentProgram
;
4353 struct gl_geometry_program_state GeometryProgram
;
4354 struct gl_compute_program_state ComputeProgram
;
4355 struct gl_tess_ctrl_program_state TessCtrlProgram
;
4356 struct gl_tess_eval_program_state TessEvalProgram
;
4357 struct gl_ati_fragment_shader_state ATIFragmentShader
;
4359 struct gl_pipeline_shader_state Pipeline
; /**< GLSL pipeline shader object state */
4360 struct gl_pipeline_object Shader
; /**< GLSL shader object state */
4363 * Current active shader pipeline state
4365 * Almost all internal users want ::_Shader instead of ::Shader. The
4366 * exceptions are bits of legacy GLSL API that do not know about separate
4369 * If a program is active via \c glUseProgram, this will point to
4372 * If a program pipeline is active via \c glBindProgramPipeline, this will
4373 * point to \c ::Pipeline.Current.
4375 * If neither a program nor a program pipeline is active, this will point to
4376 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
4379 struct gl_pipeline_object
*_Shader
;
4381 struct gl_query_state Query
; /**< occlusion, timer queries */
4383 struct gl_transform_feedback_state TransformFeedback
;
4385 struct gl_perf_monitor_state PerfMonitor
;
4387 struct gl_buffer_object
*DrawIndirectBuffer
; /** < GL_ARB_draw_indirect */
4389 struct gl_buffer_object
*CopyReadBuffer
; /**< GL_ARB_copy_buffer */
4390 struct gl_buffer_object
*CopyWriteBuffer
; /**< GL_ARB_copy_buffer */
4393 * Current GL_ARB_uniform_buffer_object binding referenced by
4394 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
4396 struct gl_buffer_object
*UniformBuffer
;
4399 * Current GL_ARB_shader_storage_buffer_object binding referenced by
4400 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
4402 struct gl_buffer_object
*ShaderStorageBuffer
;
4405 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
4406 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
4407 * associated with uniform blocks by glUniformBlockBinding()'s state in the
4410 struct gl_uniform_buffer_binding
4411 UniformBufferBindings
[MAX_COMBINED_UNIFORM_BUFFERS
];
4414 * Array of shader storage buffers for ARB_shader_storage_buffer_object
4415 * and GL 4.3. This is set up using glBindBufferRange() or
4416 * glBindBufferBase(). They are associated with shader storage blocks by
4417 * glShaderStorageBlockBinding()'s state in the shader program.
4419 struct gl_shader_storage_buffer_binding
4420 ShaderStorageBufferBindings
[MAX_COMBINED_SHADER_STORAGE_BUFFERS
];
4423 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
4426 struct gl_buffer_object
*AtomicBuffer
;
4429 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
4432 struct gl_buffer_object
*ExternalVirtualMemoryBuffer
;
4435 * Array of atomic counter buffer binding points.
4437 struct gl_atomic_buffer_binding
4438 AtomicBufferBindings
[MAX_COMBINED_ATOMIC_BUFFERS
];
4441 * Array of image units for ARB_shader_image_load_store.
4443 struct gl_image_unit ImageUnits
[MAX_IMAGE_UNITS
];
4447 struct gl_meta_state
*Meta
; /**< for "meta" operations */
4449 /* GL_EXT_framebuffer_object */
4450 struct gl_renderbuffer
*CurrentRenderbuffer
;
4452 GLenum ErrorValue
; /**< Last error code */
4455 * Recognize and silence repeated error debug messages in buggy apps.
4457 const char *ErrorDebugFmtString
;
4458 GLuint ErrorDebugCount
;
4460 /* GL_ARB_debug_output/GL_KHR_debug */
4462 struct gl_debug_state
*Debug
;
4464 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
4465 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
4466 uint64_t NewDriverState
; /**< bitwise-or of flags from DriverFlags */
4468 struct gl_driver_flags DriverFlags
;
4470 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
4472 GLbitfield64 varying_vp_inputs
; /**< mask of VERT_BIT_* flags */
4474 /** \name Derived state */
4475 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
4476 GLfloat _EyeZDir
[3];
4477 GLfloat _ModelViewInvScale
;
4478 GLboolean _NeedEyeCoords
;
4479 GLboolean _ForceEyeCoords
;
4481 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
4483 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
4485 /** \name For debugging/development only */
4487 GLboolean FirstTimeCurrent
;
4491 * False if this context was created without a config. This is needed
4492 * because the initial state of glDrawBuffers depends on this
4494 GLboolean HasConfig
;
4496 /** software compression/decompression supported or not */
4497 GLboolean Mesa_DXTn
;
4499 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
4501 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
4504 * \name Hooks for module contexts.
4506 * These will eventually live in the driver or elsewhere.
4509 void *swrast_context
;
4510 void *swsetup_context
;
4511 void *swtnl_context
;
4512 struct vbo_context
*vbo_context
;
4513 struct st_context
*st
;
4518 * \name NV_vdpau_interop
4521 const void *vdpDevice
;
4522 const void *vdpGetProcAddress
;
4523 struct set
*vdpSurfaces
;
4527 * Has this context observed a GPU reset in any context in the share group?
4529 * Once this field becomes true, it is never reset to false.
4531 GLboolean ShareGroupReset
;
4536 extern int MESA_VERBOSE
;
4537 extern int MESA_DEBUG_FLAGS
;
4538 # define MESA_FUNCTION __func__
4540 # define MESA_VERBOSE 0
4541 # define MESA_DEBUG_FLAGS 0
4542 # define MESA_FUNCTION "a function"
4546 /** The MESA_VERBOSE var is a bitmask of these flags */
4549 VERBOSE_VARRAY
= 0x0001,
4550 VERBOSE_TEXTURE
= 0x0002,
4551 VERBOSE_MATERIAL
= 0x0004,
4552 VERBOSE_PIPELINE
= 0x0008,
4553 VERBOSE_DRIVER
= 0x0010,
4554 VERBOSE_STATE
= 0x0020,
4555 VERBOSE_API
= 0x0040,
4556 VERBOSE_DISPLAY_LIST
= 0x0100,
4557 VERBOSE_LIGHTING
= 0x0200,
4558 VERBOSE_PRIMS
= 0x0400,
4559 VERBOSE_VERTS
= 0x0800,
4560 VERBOSE_DISASSEM
= 0x1000,
4561 VERBOSE_DRAW
= 0x2000,
4562 VERBOSE_SWAPBUFFERS
= 0x4000
4566 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
4569 DEBUG_SILENT
= (1 << 0),
4570 DEBUG_ALWAYS_FLUSH
= (1 << 1),
4571 DEBUG_INCOMPLETE_TEXTURE
= (1 << 2),
4572 DEBUG_INCOMPLETE_FBO
= (1 << 3)
4576 _mesa_active_fragment_shader_has_atomic_ops(const struct gl_context
*ctx
)
4578 return ctx
->Shader
._CurrentFragmentProgram
!= NULL
&&
4579 ctx
->Shader
._CurrentFragmentProgram
->NumAtomicBuffers
> 0;
4586 #endif /* MTYPES_H */