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 "compiler/shader_enums.h"
46 #include "compiler/shader_info.h"
47 #include "main/formats.h" /* MESA_FORMAT_COUNT */
48 #include "compiler/glsl/list.h"
49 #include "util/simple_mtx.h"
50 #include "util/u_dynarray.h"
58 /** Set a single bit */
59 #define BITFIELD_BIT(b) ((GLbitfield)1 << (b))
60 /** Set all bits up to excluding bit b */
61 #define BITFIELD_MASK(b) \
62 ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
63 /** Set count bits starting from bit b */
64 #define BITFIELD_RANGE(b, count) \
65 (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))
69 * \name 64-bit extension of GLbitfield.
72 typedef GLuint64 GLbitfield64
;
74 /** Set a single bit */
75 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
76 /** Set all bits up to excluding bit b */
77 #define BITFIELD64_MASK(b) \
78 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
79 /** Set count bits starting from bit b */
80 #define BITFIELD64_RANGE(b, count) \
81 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
84 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
85 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
89 * \name Some forward type declarations
92 struct _mesa_HashTable
;
93 struct gl_attrib_node
;
94 struct gl_list_extensions
;
96 struct gl_program_cache
;
97 struct gl_texture_object
;
98 struct gl_debug_state
;
101 struct gl_uniform_storage
;
102 struct prog_instruction
;
103 struct gl_program_parameter_list
;
104 struct gl_shader_spirv_data
;
110 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
111 #define PRIM_MAX GL_PATCHES
112 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
113 #define PRIM_UNKNOWN (PRIM_MAX + 2)
116 * Determine if the given gl_varying_slot appears in the fragment shader.
118 static inline GLboolean
119 _mesa_varying_slot_in_fs(gl_varying_slot slot
)
122 case VARYING_SLOT_PSIZ
:
123 case VARYING_SLOT_BFC0
:
124 case VARYING_SLOT_BFC1
:
125 case VARYING_SLOT_EDGE
:
126 case VARYING_SLOT_CLIP_VERTEX
:
127 case VARYING_SLOT_LAYER
:
128 case VARYING_SLOT_TESS_LEVEL_OUTER
:
129 case VARYING_SLOT_TESS_LEVEL_INNER
:
130 case VARYING_SLOT_BOUNDING_BOX0
:
131 case VARYING_SLOT_BOUNDING_BOX1
:
139 * Indexes for all renderbuffers
143 /* the four standard color buffers */
151 /* optional aux buffer */
153 /* generic renderbuffers */
167 * Bit flags for all renderbuffers
169 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
170 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
171 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
172 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
173 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
174 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
175 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
176 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
177 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
178 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
179 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
180 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
181 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
182 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
183 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
184 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
185 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
186 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
187 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
190 * Mask of all the color buffer bits (but not accum).
192 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
193 BUFFER_BIT_BACK_LEFT | \
194 BUFFER_BIT_FRONT_RIGHT | \
195 BUFFER_BIT_BACK_RIGHT | \
197 BUFFER_BIT_COLOR0 | \
198 BUFFER_BIT_COLOR1 | \
199 BUFFER_BIT_COLOR2 | \
200 BUFFER_BIT_COLOR3 | \
201 BUFFER_BIT_COLOR4 | \
202 BUFFER_BIT_COLOR5 | \
203 BUFFER_BIT_COLOR6 | \
206 /* Mask of bits for depth+stencil buffers */
207 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
210 * Framebuffer configuration (aka visual / pixelformat)
211 * Note: some of these fields should be boolean, but it appears that
212 * code in drivers/dri/common/util.c requires int-sized fields.
218 GLuint doubleBufferMode
;
221 GLboolean haveAccumBuffer
;
222 GLboolean haveDepthBuffer
;
223 GLboolean haveStencilBuffer
;
225 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
226 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
227 GLint rgbBits
; /* total bits for rgb */
228 GLint indexBits
; /* total bits for colorindex */
230 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
238 /* EXT_visual_rating / GLX 1.2 */
241 /* EXT_visual_info / GLX 1.2 */
242 GLint transparentPixel
;
243 /* colors are floats scaled to ints */
244 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
245 GLint transparentIndex
;
247 /* ARB_multisample / SGIS_multisample */
251 /* SGIX_pbuffer / GLX 1.3 */
252 GLint maxPbufferWidth
;
253 GLint maxPbufferHeight
;
254 GLint maxPbufferPixels
;
255 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
256 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
258 /* OML_swap_method */
261 /* EXT_texture_from_pixmap */
262 GLint bindToTextureRgb
;
263 GLint bindToTextureRgba
;
264 GLint bindToMipmapTexture
;
265 GLint bindToTextureTargets
;
268 /* EXT_framebuffer_sRGB */
274 * \name Bit flags used for updating material values.
277 #define MAT_ATTRIB_FRONT_AMBIENT 0
278 #define MAT_ATTRIB_BACK_AMBIENT 1
279 #define MAT_ATTRIB_FRONT_DIFFUSE 2
280 #define MAT_ATTRIB_BACK_DIFFUSE 3
281 #define MAT_ATTRIB_FRONT_SPECULAR 4
282 #define MAT_ATTRIB_BACK_SPECULAR 5
283 #define MAT_ATTRIB_FRONT_EMISSION 6
284 #define MAT_ATTRIB_BACK_EMISSION 7
285 #define MAT_ATTRIB_FRONT_SHININESS 8
286 #define MAT_ATTRIB_BACK_SHININESS 9
287 #define MAT_ATTRIB_FRONT_INDEXES 10
288 #define MAT_ATTRIB_BACK_INDEXES 11
289 #define MAT_ATTRIB_MAX 12
291 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
292 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
293 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
294 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
295 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
296 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
298 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
299 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
300 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
301 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
302 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
303 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
304 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
305 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
306 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
307 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
308 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
309 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
312 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
313 MAT_BIT_FRONT_AMBIENT | \
314 MAT_BIT_FRONT_DIFFUSE | \
315 MAT_BIT_FRONT_SPECULAR | \
316 MAT_BIT_FRONT_SHININESS | \
317 MAT_BIT_FRONT_INDEXES)
319 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
320 MAT_BIT_BACK_AMBIENT | \
321 MAT_BIT_BACK_DIFFUSE | \
322 MAT_BIT_BACK_SPECULAR | \
323 MAT_BIT_BACK_SHININESS | \
324 MAT_BIT_BACK_INDEXES)
326 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
335 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
343 #define LIGHT_SPOT 0x1
344 #define LIGHT_LOCAL_VIEWER 0x2
345 #define LIGHT_POSITIONAL 0x4
346 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
351 * Light source state.
355 GLfloat Ambient
[4]; /**< ambient color */
356 GLfloat Diffuse
[4]; /**< diffuse color */
357 GLfloat Specular
[4]; /**< specular color */
358 GLfloat EyePosition
[4]; /**< position in eye coordinates */
359 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
360 GLfloat SpotExponent
;
361 GLfloat SpotCutoff
; /**< in degrees */
362 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
363 GLfloat ConstantAttenuation
;
364 GLfloat LinearAttenuation
;
365 GLfloat QuadraticAttenuation
;
366 GLboolean Enabled
; /**< On/off flag */
369 * \name Derived fields
372 GLbitfield _Flags
; /**< Mask of LIGHT_x bits defined above */
374 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
375 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
376 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
377 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
378 GLfloat _VP_inf_spot_attenuation
;
380 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
381 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
382 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
392 GLfloat Ambient
[4]; /**< ambient color */
393 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
394 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
395 GLenum16 ColorControl
; /**< either GL_SINGLE_COLOR
396 or GL_SEPARATE_SPECULAR_COLOR */
401 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
403 struct gl_accum_attrib
405 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
410 * Used for storing clear color, texture border color, etc.
411 * The float values are typically unclamped.
421 * Remapped color logical operations
423 * With the exception of NVIDIA hardware, which consumes the OpenGL enumerants
424 * directly, everything wants this mapping of color logical operations.
426 * Fun fact: These values are just the bit-reverse of the low-nibble of the GL
427 * enumerant values (i.e., `GL_NOOP & 0x0f` is `b0101' while
428 * \c COLOR_LOGICOP_NOOP is `b1010`).
430 * Fun fact #2: These values are just an encoding of the operation as a table
431 * of bit values. The result of the logic op is:
433 * result_bit = (logic_op >> (2 * src_bit + dst_bit)) & 1
435 * For the GL enums, the result is:
437 * result_bit = logic_op & (1 << (2 * src_bit + dst_bit))
439 enum PACKED gl_logicop_mode
{
440 COLOR_LOGICOP_CLEAR
= 0,
441 COLOR_LOGICOP_NOR
= 1,
442 COLOR_LOGICOP_AND_INVERTED
= 2,
443 COLOR_LOGICOP_COPY_INVERTED
= 3,
444 COLOR_LOGICOP_AND_REVERSE
= 4,
445 COLOR_LOGICOP_INVERT
= 5,
446 COLOR_LOGICOP_XOR
= 6,
447 COLOR_LOGICOP_NAND
= 7,
448 COLOR_LOGICOP_AND
= 8,
449 COLOR_LOGICOP_EQUIV
= 9,
450 COLOR_LOGICOP_NOOP
= 10,
451 COLOR_LOGICOP_OR_INVERTED
= 11,
452 COLOR_LOGICOP_COPY
= 12,
453 COLOR_LOGICOP_OR_REVERSE
= 13,
454 COLOR_LOGICOP_OR
= 14,
455 COLOR_LOGICOP_SET
= 15
459 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
461 struct gl_colorbuffer_attrib
463 GLuint ClearIndex
; /**< Index for glClear */
464 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
465 GLuint IndexMask
; /**< Color index write mask */
467 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
468 GLbitfield ColorMask
;
470 GLenum16 DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
473 * \name alpha testing
476 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
477 GLenum16 AlphaFunc
; /**< Alpha test function */
478 GLfloat AlphaRefUnclamped
;
479 GLclampf AlphaRef
; /**< Alpha reference value */
486 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
488 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
489 * control, only on the fixed-pointness of the render target.
490 * The query does however depend on fragment color clamping.
492 GLfloat BlendColorUnclamped
[4]; /**< Blending color */
493 GLfloat BlendColor
[4]; /**< Blending color */
497 GLenum16 SrcRGB
; /**< RGB blend source term */
498 GLenum16 DstRGB
; /**< RGB blend dest term */
499 GLenum16 SrcA
; /**< Alpha blend source term */
500 GLenum16 DstA
; /**< Alpha blend dest term */
501 GLenum16 EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
502 GLenum16 EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
504 * Set if any blend factor uses SRC1. Computed at the time blend factors
507 GLboolean _UsesDualSrc
;
508 } Blend
[MAX_DRAW_BUFFERS
];
509 /** Are the blend func terms currently different for each buffer/target? */
510 GLboolean _BlendFuncPerBuffer
;
511 /** Are the blend equations currently different for each buffer/target? */
512 GLboolean _BlendEquationPerBuffer
;
515 * Which advanced blending mode is in use (or BLEND_NONE).
517 * KHR_blend_equation_advanced only allows advanced blending with a single
518 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
519 * requires all draw buffers to match, so we only need a single value.
521 enum gl_advanced_blend_mode _AdvancedBlendMode
;
523 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
531 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
532 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
533 GLenum16 LogicOp
; /**< Logic operator */
534 enum gl_logicop_mode _LogicOp
;
537 GLboolean DitherFlag
; /**< Dither enable flag */
539 GLboolean _ClampFragmentColor
; /** < with GL_FIXED_ONLY_ARB resolved */
540 GLenum16 ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
541 GLenum16 ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
543 GLboolean sRGBEnabled
; /**< Framebuffer sRGB blending/updating requested */
548 * Current attribute group (GL_CURRENT_BIT).
550 struct gl_current_attrib
553 * \name Current vertex attributes (color, texcoords, etc).
554 * \note Values are valid only after FLUSH_VERTICES has been called.
555 * \note Index and Edgeflag current values are stored as floats in the
556 * SIX and SEVEN attribute slots.
557 * \note We need double storage for 64-bit vertex attributes
559 GLfloat Attrib
[VERT_ATTRIB_MAX
][4*2];
562 * \name Current raster position attributes (always up to date after a
565 GLfloat RasterPos
[4];
566 GLfloat RasterDistance
;
567 GLfloat RasterColor
[4];
568 GLfloat RasterSecondaryColor
[4];
569 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
570 GLboolean RasterPosValid
;
575 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
577 struct gl_depthbuffer_attrib
579 GLenum16 Func
; /**< Function for depth buffer compare */
580 GLclampd Clear
; /**< Value to clear depth buffer to */
581 GLboolean Test
; /**< Depth buffering enabled flag */
582 GLboolean Mask
; /**< Depth buffer writable? */
583 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
584 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
589 * Evaluator attribute group (GL_EVAL_BIT).
591 struct gl_eval_attrib
597 GLboolean Map1Color4
;
599 GLboolean Map1Normal
;
600 GLboolean Map1TextureCoord1
;
601 GLboolean Map1TextureCoord2
;
602 GLboolean Map1TextureCoord3
;
603 GLboolean Map1TextureCoord4
;
604 GLboolean Map1Vertex3
;
605 GLboolean Map1Vertex4
;
606 GLboolean Map2Color4
;
608 GLboolean Map2Normal
;
609 GLboolean Map2TextureCoord1
;
610 GLboolean Map2TextureCoord2
;
611 GLboolean Map2TextureCoord3
;
612 GLboolean Map2TextureCoord4
;
613 GLboolean Map2Vertex3
;
614 GLboolean Map2Vertex4
;
615 GLboolean AutoNormal
;
619 * \name Map Grid endpoints and divisions and calculated du values
623 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
624 GLint MapGrid2un
, MapGrid2vn
;
625 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
626 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
632 * Compressed fog mode.
644 * Fog attribute group (GL_FOG_BIT).
648 GLboolean Enabled
; /**< Fog enabled flag */
649 GLboolean ColorSumEnabled
;
650 uint8_t _PackedMode
; /**< Fog mode as 2 bits */
651 uint8_t _PackedEnabledMode
; /**< Masked CompressedMode */
652 GLfloat ColorUnclamped
[4]; /**< Fog color */
653 GLfloat Color
[4]; /**< Fog color */
654 GLfloat Density
; /**< Density >= 0.0 */
655 GLfloat Start
; /**< Start distance in eye coords */
656 GLfloat End
; /**< End distance in eye coords */
657 GLfloat Index
; /**< Fog index */
658 GLenum16 Mode
; /**< Fog mode */
659 GLenum16 FogCoordinateSource
;/**< GL_EXT_fog_coord */
660 GLenum16 FogDistanceMode
; /**< GL_NV_fog_distance */
665 * Hint attribute group (GL_HINT_BIT).
667 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
669 struct gl_hint_attrib
671 GLenum16 PerspectiveCorrection
;
672 GLenum16 PointSmooth
;
674 GLenum16 PolygonSmooth
;
676 GLenum16 TextureCompression
; /**< GL_ARB_texture_compression */
677 GLenum16 GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
678 GLenum16 FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
683 * Lighting attribute group (GL_LIGHT_BIT).
685 struct gl_light_attrib
687 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
688 struct gl_lightmodel Model
; /**< Lighting model */
691 * Front and back material values.
692 * Note: must call FLUSH_VERTICES() before using.
694 struct gl_material Material
;
696 GLboolean Enabled
; /**< Lighting enabled flag */
697 GLboolean ColorMaterialEnabled
;
699 GLenum16 ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
700 GLenum16 ProvokingVertex
; /**< GL_EXT_provoking_vertex */
701 GLenum16 ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
702 GLenum16 ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
703 GLbitfield _ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
706 GLboolean _ClampVertexColor
;
707 GLenum16 ClampVertexColor
; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
710 * Derived state for optimizations:
713 GLbitfield _EnabledLights
; /**< bitmask containing enabled lights */
715 GLboolean _NeedEyeCoords
;
716 GLboolean _NeedVertices
; /**< Use fast shader? */
718 GLfloat _BaseColor
[2][3];
724 * Line attribute group (GL_LINE_BIT).
726 struct gl_line_attrib
728 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
729 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
730 GLushort StipplePattern
; /**< Stipple pattern */
731 GLint StippleFactor
; /**< Stipple repeat factor */
732 GLfloat Width
; /**< Line width */
737 * Display list attribute group (GL_LIST_BIT).
739 struct gl_list_attrib
746 * Multisample attribute group (GL_MULTISAMPLE_BIT).
748 struct gl_multisample_attrib
751 GLboolean SampleAlphaToCoverage
;
752 GLboolean SampleAlphaToOne
;
753 GLboolean SampleCoverage
;
754 GLboolean SampleCoverageInvert
;
755 GLboolean SampleShading
;
757 /* ARB_texture_multisample / GL3.2 additions */
758 GLboolean SampleMask
;
760 GLfloat SampleCoverageValue
; /**< In range [0, 1] */
761 GLfloat MinSampleShadingValue
; /**< In range [0, 1] */
763 /** The GL spec defines this as an array but >32x MSAA is madness */
764 GLbitfield SampleMaskValue
;
769 * A pixelmap (see glPixelMap)
774 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
779 * Collection of all pixelmaps
783 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
784 struct gl_pixelmap GtoG
;
785 struct gl_pixelmap BtoB
;
786 struct gl_pixelmap AtoA
;
787 struct gl_pixelmap ItoR
;
788 struct gl_pixelmap ItoG
;
789 struct gl_pixelmap ItoB
;
790 struct gl_pixelmap ItoA
;
791 struct gl_pixelmap ItoI
;
792 struct gl_pixelmap StoS
;
797 * Pixel attribute group (GL_PIXEL_MODE_BIT).
799 struct gl_pixel_attrib
801 GLenum16 ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
803 /*--- Begin Pixel Transfer State ---*/
804 /* Fields are in the order in which they're applied... */
806 /** Scale & Bias (index shift, offset) */
808 GLfloat RedBias
, RedScale
;
809 GLfloat GreenBias
, GreenScale
;
810 GLfloat BlueBias
, BlueScale
;
811 GLfloat AlphaBias
, AlphaScale
;
812 GLfloat DepthBias
, DepthScale
;
813 GLint IndexShift
, IndexOffset
;
817 /* Note: actual pixel maps are not part of this attrib group */
818 GLboolean MapColorFlag
;
819 GLboolean MapStencilFlag
;
821 /*--- End Pixel Transfer State ---*/
824 GLfloat ZoomX
, ZoomY
;
829 * Point attribute group (GL_POINT_BIT).
831 struct gl_point_attrib
833 GLfloat Size
; /**< User-specified point size */
834 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
835 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
836 GLfloat Threshold
; /**< GL_EXT_point_parameters */
837 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
838 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
839 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
840 GLbitfield CoordReplace
; /**< GL_ARB_point_sprite*/
841 GLenum16 SpriteRMode
; /**< GL_NV_point_sprite (only!) */
842 GLenum16 SpriteOrigin
; /**< GL_ARB_point_sprite */
847 * Polygon attribute group (GL_POLYGON_BIT).
849 struct gl_polygon_attrib
851 GLenum16 FrontFace
; /**< Either GL_CW or GL_CCW */
852 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
853 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
854 GLboolean CullFlag
; /**< Culling on/off flag */
855 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
856 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
857 GLenum16 CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
858 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
859 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
860 GLfloat OffsetClamp
; /**< Polygon offset clamp, from user */
861 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
862 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
863 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
868 * Scissor attributes (GL_SCISSOR_BIT).
870 struct gl_scissor_rect
872 GLint X
, Y
; /**< Lower left corner of box */
873 GLsizei Width
, Height
; /**< Size of box */
877 struct gl_scissor_attrib
879 GLbitfield EnableFlags
; /**< Scissor test enabled? */
880 struct gl_scissor_rect ScissorArray
[MAX_VIEWPORTS
];
881 GLint NumWindowRects
; /**< Count of enabled window rectangles */
882 GLenum16 WindowRectMode
; /**< Whether to include or exclude the rects */
883 struct gl_scissor_rect WindowRects
[MAX_WINDOW_RECTANGLES
];
888 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
890 * Three sets of stencil data are tracked so that OpenGL 2.0,
891 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
892 * simultaneously. In each of the stencil state arrays, element 0 corresponds
893 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
894 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
895 * GL_EXT_stencil_two_side GL_BACK state.
897 * The derived value \c _BackFace is either 1 or 2 depending on whether or
898 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
900 * The derived value \c _TestTwoSide is set when the front-face and back-face
901 * stencil state are different.
903 struct gl_stencil_attrib
905 GLboolean Enabled
; /**< Enabled flag */
906 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
907 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 2) */
908 GLubyte _BackFace
; /**< Current back stencil state (1 or 2) */
909 GLenum16 Function
[3]; /**< Stencil function */
910 GLenum16 FailFunc
[3]; /**< Fail function */
911 GLenum16 ZPassFunc
[3]; /**< Depth buffer pass function */
912 GLenum16 ZFailFunc
[3]; /**< Depth buffer fail function */
913 GLint Ref
[3]; /**< Reference value */
914 GLuint ValueMask
[3]; /**< Value mask */
915 GLuint WriteMask
[3]; /**< Write mask */
916 GLuint Clear
; /**< Clear value */
921 * An index for each type of texture object. These correspond to the GL
922 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
923 * Note: the order is from highest priority to lowest priority.
927 TEXTURE_2D_MULTISAMPLE_INDEX
,
928 TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
,
929 TEXTURE_CUBE_ARRAY_INDEX
,
930 TEXTURE_BUFFER_INDEX
,
931 TEXTURE_2D_ARRAY_INDEX
,
932 TEXTURE_1D_ARRAY_INDEX
,
933 TEXTURE_EXTERNAL_INDEX
,
944 * Bit flags for each type of texture object
947 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
948 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
949 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
950 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
951 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
952 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
953 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
954 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
955 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
956 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
957 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
958 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
963 * Texture image state. Drivers will typically create a subclass of this
964 * with extra fields for memory buffers, etc.
966 struct gl_texture_image
968 GLint InternalFormat
; /**< Internal format as given by the user */
969 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
970 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
971 * GL_INTENSITY, GL_DEPTH_COMPONENT or
972 * GL_DEPTH_STENCIL_EXT only. Used for
973 * choosing TexEnv arithmetic.
975 mesa_format TexFormat
; /**< The actual texture memory format */
977 GLuint Border
; /**< 0 or 1 */
978 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
979 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
980 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
981 GLuint Width2
; /**< = Width - 2*Border */
982 GLuint Height2
; /**< = Height - 2*Border */
983 GLuint Depth2
; /**< = Depth - 2*Border */
984 GLuint WidthLog2
; /**< = log2(Width2) */
985 GLuint HeightLog2
; /**< = log2(Height2) */
986 GLuint DepthLog2
; /**< = log2(Depth2) */
987 GLuint MaxNumLevels
; /**< = maximum possible number of mipmap
988 levels, computed from the dimensions */
990 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
991 GLuint Level
; /**< Which mipmap level am I? */
992 /** Cube map face: index into gl_texture_object::Image[] array */
995 /** GL_ARB_texture_multisample */
996 GLuint NumSamples
; /**< Sample count, or 0 for non-multisample */
997 GLboolean FixedSampleLocations
; /**< Same sample locations for all pixels? */
1002 * Indexes for cube map faces.
1017 * Sampler object state. These objects are new with GL_ARB_sampler_objects
1018 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
1020 struct gl_sampler_object
1024 GLchar
*Label
; /**< GL_KHR_debug */
1027 GLenum16 WrapS
; /**< S-axis texture image wrap mode */
1028 GLenum16 WrapT
; /**< T-axis texture image wrap mode */
1029 GLenum16 WrapR
; /**< R-axis texture image wrap mode */
1030 GLenum16 MinFilter
; /**< minification filter */
1031 GLenum16 MagFilter
; /**< magnification filter */
1032 GLenum16 sRGBDecode
; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
1033 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
1034 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1035 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1036 GLfloat LodBias
; /**< OpenGL 1.4 */
1037 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1038 GLenum16 CompareMode
; /**< GL_ARB_shadow */
1039 GLenum16 CompareFunc
; /**< GL_ARB_shadow */
1040 GLboolean CubeMapSeamless
; /**< GL_AMD_seamless_cubemap_per_texture */
1042 /** GL_ARB_bindless_texture */
1043 bool HandleAllocated
;
1044 struct util_dynarray Handles
;
1049 * Texture object state. Contains the array of mipmap images, border color,
1050 * wrap modes, filter modes, and shadow/texcompare state.
1052 struct gl_texture_object
1054 simple_mtx_t Mutex
; /**< for thread safety */
1055 GLint RefCount
; /**< reference count */
1056 GLuint Name
; /**< the user-visible texture object ID */
1057 GLenum16 Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1058 GLenum16 DepthMode
; /**< GL_ARB_depth_texture */
1059 GLchar
*Label
; /**< GL_KHR_debug */
1061 struct gl_sampler_object Sampler
;
1063 gl_texture_index TargetIndex
; /**< The gl_texture_unit::CurrentTex index.
1064 Only valid when Target is valid. */
1065 GLfloat Priority
; /**< in [0,1] */
1066 GLint MaxLevel
; /**< max mipmap level (max=1000), OpenGL 1.2 */
1067 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1068 GLbyte _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1069 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - p in spec) */
1070 GLint CropRect
[4]; /**< GL_OES_draw_texture */
1071 GLenum Swizzle
[4]; /**< GL_EXT_texture_swizzle */
1072 GLushort _Swizzle
; /**< same as Swizzle, but SWIZZLE_* format */
1073 GLbyte ImmutableLevels
; /**< ES 3.0 / ARB_texture_view */
1074 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1075 GLboolean _BaseComplete
; /**< Is the base texture level valid? */
1076 GLboolean _MipmapComplete
; /**< Is the whole mipmap valid? */
1077 GLboolean _IsIntegerFormat
; /**< Does the texture store integer values? */
1078 GLboolean _RenderToTexture
; /**< Any rendering to this texture? */
1079 GLboolean Purgeable
; /**< Is the buffer purgeable under memory
1081 GLboolean Immutable
; /**< GL_ARB_texture_storage */
1082 GLboolean _IsFloat
; /**< GL_OES_float_texture */
1083 GLboolean _IsHalfFloat
; /**< GL_OES_half_float_texture */
1084 bool StencilSampling
; /**< Should we sample stencil instead of depth? */
1085 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1087 /** GL_OES_EGL_image_external */
1088 GLubyte RequiredTextureImageUnits
;
1090 GLubyte MinLevel
; /**< GL_ARB_texture_view */
1091 GLubyte NumLevels
; /**< GL_ARB_texture_view */
1092 GLushort MinLayer
; /**< GL_ARB_texture_view */
1093 GLushort NumLayers
; /**< GL_ARB_texture_view */
1095 /** GL_EXT_memory_object */
1096 GLenum16 TextureTiling
;
1098 /** GL_ARB_shader_image_load_store */
1099 GLenum16 ImageFormatCompatibilityType
;
1101 /** GL_ARB_texture_buffer_object */
1102 GLenum16 BufferObjectFormat
;
1103 /** Equivalent Mesa format for BufferObjectFormat. */
1104 mesa_format _BufferObjectFormat
;
1105 struct gl_buffer_object
*BufferObject
;
1107 /** GL_ARB_texture_buffer_range */
1108 GLintptr BufferOffset
;
1109 GLsizeiptr BufferSize
; /**< if this is -1, use BufferObject->Size instead */
1111 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1112 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1114 /** GL_ARB_bindless_texture */
1115 struct util_dynarray SamplerHandles
;
1116 struct util_dynarray ImageHandles
;
1120 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1121 #define MAX_COMBINER_TERMS 4
1125 * Texture combine environment state.
1127 struct gl_tex_env_combine_state
1129 GLenum16 ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1130 GLenum16 ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1131 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1132 GLenum16 SourceRGB
[MAX_COMBINER_TERMS
];
1133 GLenum16 SourceA
[MAX_COMBINER_TERMS
];
1134 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1135 GLenum16 OperandRGB
[MAX_COMBINER_TERMS
];
1136 GLenum16 OperandA
[MAX_COMBINER_TERMS
];
1137 GLubyte ScaleShiftRGB
; /**< 0, 1 or 2 */
1138 GLubyte ScaleShiftA
; /**< 0, 1 or 2 */
1139 GLubyte _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1140 GLubyte _NumArgsA
; /**< Number of inputs used for the A combiner */
1144 /** Compressed TexEnv effective Combine mode */
1145 enum gl_tex_env_mode
1147 TEXENV_MODE_REPLACE
, /* r = a0 */
1148 TEXENV_MODE_MODULATE
, /* r = a0 * a1 */
1149 TEXENV_MODE_ADD
, /* r = a0 + a1 */
1150 TEXENV_MODE_ADD_SIGNED
, /* r = a0 + a1 - 0.5 */
1151 TEXENV_MODE_INTERPOLATE
, /* r = a0 * a2 + a1 * (1 - a2) */
1152 TEXENV_MODE_SUBTRACT
, /* r = a0 - a1 */
1153 TEXENV_MODE_DOT3_RGB
, /* r = a0 . a1 */
1154 TEXENV_MODE_DOT3_RGB_EXT
, /* r = a0 . a1 */
1155 TEXENV_MODE_DOT3_RGBA
, /* r = a0 . a1 */
1156 TEXENV_MODE_DOT3_RGBA_EXT
, /* r = a0 . a1 */
1157 TEXENV_MODE_MODULATE_ADD_ATI
, /* r = a0 * a2 + a1 */
1158 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI
, /* r = a0 * a2 + a1 - 0.5 */
1159 TEXENV_MODE_MODULATE_SUBTRACT_ATI
, /* r = a0 * a2 - a1 */
1160 TEXENV_MODE_ADD_PRODUCTS_NV
, /* r = a0 * a1 + a2 * a3 */
1161 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV
, /* r = a0 * a1 + a2 * a3 - 0.5 */
1165 /** Compressed TexEnv Combine source */
1166 enum gl_tex_env_source
1168 TEXENV_SRC_TEXTURE0
,
1169 TEXENV_SRC_TEXTURE1
,
1170 TEXENV_SRC_TEXTURE2
,
1171 TEXENV_SRC_TEXTURE3
,
1172 TEXENV_SRC_TEXTURE4
,
1173 TEXENV_SRC_TEXTURE5
,
1174 TEXENV_SRC_TEXTURE6
,
1175 TEXENV_SRC_TEXTURE7
,
1177 TEXENV_SRC_PREVIOUS
,
1178 TEXENV_SRC_PRIMARY_COLOR
,
1179 TEXENV_SRC_CONSTANT
,
1185 /** Compressed TexEnv Combine operand */
1186 enum gl_tex_env_operand
1189 TEXENV_OPR_ONE_MINUS_COLOR
,
1191 TEXENV_OPR_ONE_MINUS_ALPHA
,
1195 /** Compressed TexEnv Combine argument */
1196 struct gl_tex_env_argument
1199 __extension__
uint8_t Source
:4; /**< TEXENV_SRC_x */
1200 __extension__
uint8_t Operand
:2; /**< TEXENV_OPR_x */
1202 uint8_t Source
; /**< SRC_x */
1203 uint8_t Operand
; /**< OPR_x */
1209 * Compressed TexEnv Combine state.
1211 struct gl_tex_env_combine_packed
1213 uint32_t ModeRGB
:4; /**< Effective mode for RGB as 4 bits */
1214 uint32_t ModeA
:4; /**< Effective mode for RGB as 4 bits */
1215 uint32_t ScaleShiftRGB
:2; /**< 0, 1 or 2 */
1216 uint32_t ScaleShiftA
:2; /**< 0, 1 or 2 */
1217 uint32_t NumArgsRGB
:3; /**< Number of inputs used for the RGB combiner */
1218 uint32_t NumArgsA
:3; /**< Number of inputs used for the A combiner */
1219 /** Source arguments in a packed manner */
1220 struct gl_tex_env_argument ArgsRGB
[MAX_COMBINER_TERMS
];
1221 struct gl_tex_env_argument ArgsA
[MAX_COMBINER_TERMS
];
1226 * TexGenEnabled flags.
1233 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1238 * Bit flag versions of the corresponding GL_ constants.
1241 #define TEXGEN_SPHERE_MAP 0x1
1242 #define TEXGEN_OBJ_LINEAR 0x2
1243 #define TEXGEN_EYE_LINEAR 0x4
1244 #define TEXGEN_REFLECTION_MAP_NV 0x8
1245 #define TEXGEN_NORMAL_MAP_NV 0x10
1247 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1248 TEXGEN_REFLECTION_MAP_NV | \
1249 TEXGEN_NORMAL_MAP_NV)
1250 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1251 TEXGEN_REFLECTION_MAP_NV | \
1252 TEXGEN_NORMAL_MAP_NV | \
1258 /** Tex-gen enabled for texture unit? */
1259 #define ENABLE_TEXGEN(unit) (1 << (unit))
1261 /** Non-identity texture matrix for texture unit? */
1262 #define ENABLE_TEXMAT(unit) (1 << (unit))
1266 * Texture coord generation state.
1270 GLenum16 Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1271 GLbitfield8 _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1272 GLfloat ObjectPlane
[4];
1273 GLfloat EyePlane
[4];
1278 * Sampler-related subset of a texture unit, like current texture objects.
1280 struct gl_texture_unit
1282 GLfloat LodBias
; /**< for biasing mipmap levels */
1284 /** Texture targets that have a non-default texture bound */
1285 GLbitfield _BoundTextures
;
1287 /** Current sampler object (GL_ARB_sampler_objects) */
1288 struct gl_sampler_object
*Sampler
;
1290 /** Current texture object pointers */
1291 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1293 /** Points to highest priority, complete and enabled texture object */
1294 struct gl_texture_object
*_Current
;
1299 * Fixed-function-related subset of a texture unit, like enable flags,
1300 * texture environment/function/combiners, and texgen state.
1302 struct gl_fixedfunc_texture_unit
1304 GLbitfield16 Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1306 GLenum16 EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1307 GLclampf EnvColor
[4];
1308 GLfloat EnvColorUnclamped
[4];
1310 struct gl_texgen GenS
;
1311 struct gl_texgen GenT
;
1312 struct gl_texgen GenR
;
1313 struct gl_texgen GenQ
;
1314 GLbitfield8 TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1315 GLbitfield8 _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1318 * \name GL_EXT_texture_env_combine
1320 struct gl_tex_env_combine_state Combine
;
1323 * Derived state based on \c EnvMode and the \c BaseFormat of the
1324 * currently enabled texture.
1326 struct gl_tex_env_combine_state _EnvMode
;
1328 /** Current compressed TexEnv & Combine state */
1329 struct gl_tex_env_combine_packed _CurrentCombinePacked
;
1332 * Currently enabled combiner state. This will point to either
1333 * \c Combine or \c _EnvMode.
1335 struct gl_tex_env_combine_state
*_CurrentCombine
;
1340 * Texture attribute group (GL_TEXTURE_BIT).
1342 struct gl_texture_attrib
1344 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1346 /** GL_ARB_texture_buffer_object */
1347 struct gl_buffer_object
*BufferObject
;
1349 GLuint CurrentUnit
; /**< GL_ACTIVE_TEXTURE */
1351 /** Texture coord units/sets used for fragment texturing */
1352 GLbitfield8 _EnabledCoordUnits
;
1354 /** Texture coord units that have texgen enabled */
1355 GLbitfield8 _TexGenEnabled
;
1357 /** Texture coord units that have non-identity matrices */
1358 GLbitfield8 _TexMatEnabled
;
1360 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1361 GLbitfield8 _GenFlags
;
1363 /** Largest index of a texture unit with _Current != NULL. */
1364 GLshort _MaxEnabledTexImageUnit
;
1366 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1367 GLubyte NumCurrentTexUsed
;
1369 /** GL_ARB_seamless_cubemap */
1370 GLboolean CubeMapSeamless
;
1372 struct gl_texture_unit Unit
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
1373 struct gl_fixedfunc_texture_unit FixedFuncUnit
[MAX_TEXTURE_COORD_UNITS
];
1378 * Data structure representing a single clip plane (e.g. one of the elements
1379 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1381 typedef GLfloat gl_clip_plane
[4];
1385 * Transformation attribute group (GL_TRANSFORM_BIT).
1387 struct gl_transform_attrib
1389 GLenum16 MatrixMode
; /**< Matrix mode */
1390 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1391 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1392 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1393 GLboolean Normalize
; /**< Normalize all normals? */
1394 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1395 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1396 GLboolean DepthClamp
; /**< GL_ARB_depth_clamp */
1397 /** GL_ARB_clip_control */
1398 GLenum16 ClipOrigin
; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1399 GLenum16 ClipDepthMode
;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1404 * Viewport attribute group (GL_VIEWPORT_BIT).
1406 struct gl_viewport_attrib
1408 GLfloat X
, Y
; /**< position */
1409 GLfloat Width
, Height
; /**< size */
1410 GLfloat Near
, Far
; /**< Depth buffer range */
1419 } gl_map_buffer_index
;
1423 * Fields describing a mapped buffer range.
1425 struct gl_buffer_mapping
1427 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1428 GLvoid
*Pointer
; /**< User-space address of mapping */
1429 GLintptr Offset
; /**< Mapped offset */
1430 GLsizeiptr Length
; /**< Mapped length */
1435 * Usages we've seen for a buffer object.
1439 USAGE_UNIFORM_BUFFER
= 0x1,
1440 USAGE_TEXTURE_BUFFER
= 0x2,
1441 USAGE_ATOMIC_COUNTER_BUFFER
= 0x4,
1442 USAGE_SHADER_STORAGE_BUFFER
= 0x8,
1443 USAGE_TRANSFORM_FEEDBACK_BUFFER
= 0x10,
1444 USAGE_PIXEL_PACK_BUFFER
= 0x20,
1445 USAGE_DISABLE_MINMAX_CACHE
= 0x40,
1450 * GL_ARB_vertex/pixel_buffer_object buffer object
1452 struct gl_buffer_object
1456 GLchar
*Label
; /**< GL_KHR_debug */
1457 GLenum16 Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1458 GLbitfield StorageFlags
; /**< GL_MAP_PERSISTENT_BIT, etc. */
1459 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1460 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1461 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1462 GLboolean Written
; /**< Ever written to? (for debugging) */
1463 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1464 GLboolean Immutable
; /**< GL_ARB_buffer_storage */
1465 gl_buffer_usage UsageHistory
; /**< How has this buffer been used so far? */
1467 /** Counters used for buffer usage warnings */
1468 GLuint NumSubDataCalls
;
1469 GLuint NumMapBufferWriteCalls
;
1471 struct gl_buffer_mapping Mappings
[MAP_COUNT
];
1473 /** Memoization of min/max index computations for static index buffers */
1474 simple_mtx_t MinMaxCacheMutex
;
1475 struct hash_table
*MinMaxCache
;
1476 unsigned MinMaxCacheHitIndices
;
1477 unsigned MinMaxCacheMissIndices
;
1478 bool MinMaxCacheDirty
;
1480 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1485 * Client pixel packing/unpacking attributes
1487 struct gl_pixelstore_attrib
1495 GLboolean SwapBytes
;
1497 GLboolean Invert
; /**< GL_MESA_pack_invert */
1498 GLint CompressedBlockWidth
; /**< GL_ARB_compressed_texture_pixel_storage */
1499 GLint CompressedBlockHeight
;
1500 GLint CompressedBlockDepth
;
1501 GLint CompressedBlockSize
;
1502 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1507 * Vertex array information which is derived from gl_array_attributes
1508 * and gl_vertex_buffer_binding information. Used by the VBO module and
1511 struct gl_vertex_array
1513 /** if NULL, vertex data are in user memory */
1514 struct gl_buffer_object
*BufferObj
;
1515 /** Pointer into user memory, or offset into the BufferObj */
1517 GLsizei StrideB
; /**< actual stride in bytes */
1518 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1519 GLenum16 Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1520 GLenum16 Format
; /**< default: GL_RGBA, but may be GL_BGRA */
1521 unsigned Size
:4; /**< components per element (1,2,3,4) */
1522 unsigned _ElementSize
:8; /**< in bytes, up to 4*sizeof(GLdouble) */
1523 unsigned Normalized
:1; /**< GL_ARB_vertex_program */
1524 unsigned Integer
:1; /**< Integer-valued? */
1525 unsigned Doubles
:1; /**< doubles not converted to floats */
1530 * Enum for defining the mapping for the position/generic0 attribute.
1532 * Do not change the order of the values as these are used as
1537 ATTRIBUTE_MAP_MODE_IDENTITY
, /**< 1:1 mapping */
1538 ATTRIBUTE_MAP_MODE_POSITION
, /**< get position and generic0 from position */
1539 ATTRIBUTE_MAP_MODE_GENERIC0
, /**< get position and generic0 from generic0 */
1540 ATTRIBUTE_MAP_MODE_MAX
/**< for sizing arrays */
1541 } gl_attribute_map_mode
;
1545 * Attributes to describe a vertex array.
1547 * Contains the size, type, format and normalization flag,
1548 * along with the index of a vertex buffer binding point.
1550 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1551 * and is only present for backwards compatibility reasons.
1552 * Rendering always uses VERTEX_BINDING_STRIDE.
1553 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1554 * and VERTEX_BINDING_STRIDE to the same value, while
1555 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1557 struct gl_array_attributes
1559 /** Points to client array data. Not used when a VBO is bound */
1561 /** Offset of the first element relative to the binding offset */
1562 GLuint RelativeOffset
;
1563 GLshort Stride
; /**< Stride as specified with gl*Pointer() */
1564 GLenum16 Type
; /**< Datatype: GL_FLOAT, GL_INT, etc */
1565 GLenum16 Format
; /**< Default: GL_RGBA, but may be GL_BGRA */
1566 GLboolean Enabled
; /**< Whether the array is enabled */
1567 GLubyte Size
; /**< Components per element (1,2,3,4) */
1568 unsigned Normalized
:1; /**< Fixed-point values are normalized when converted to floats */
1569 unsigned Integer
:1; /**< Fixed-point values are not converted to floats */
1570 unsigned Doubles
:1; /**< double precision values are not converted to floats */
1571 unsigned _ElementSize
:8; /**< Size of each element in bytes */
1572 /** Index into gl_vertex_array_object::BufferBinding[] array */
1573 unsigned BufferBindingIndex
:6;
1578 * This describes the buffer object used for a vertex array (or
1579 * multiple vertex arrays). If BufferObj points to the default/null
1580 * buffer object, then the vertex array lives in user memory and not a VBO.
1582 struct gl_vertex_buffer_binding
1584 GLintptr Offset
; /**< User-specified offset */
1585 GLsizei Stride
; /**< User-specified stride */
1586 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1587 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_vertex_buffer_object */
1588 GLbitfield _BoundArrays
; /**< Arrays bound to this binding point */
1593 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1594 * the GL_ARB_vertex_array_object extension.
1596 struct gl_vertex_array_object
1598 /** Name of the VAO as received from glGenVertexArray. */
1603 GLchar
*Label
; /**< GL_KHR_debug */
1606 * Has this array object been bound?
1608 GLboolean EverBound
;
1611 * Marked to true if the object is shared between contexts and immutable.
1612 * Then reference counting is done using atomics and thread safe.
1613 * Is used for dlist VAOs.
1615 bool SharedAndImmutable
;
1618 * Derived vertex attribute arrays
1620 * This is a legacy data structure created from gl_array_attributes and
1621 * gl_vertex_buffer_binding, only used by the VBO module at this time.
1623 struct gl_vertex_array _VertexArray
[VERT_ATTRIB_MAX
];
1625 /** Vertex attribute arrays */
1626 struct gl_array_attributes VertexAttrib
[VERT_ATTRIB_MAX
];
1628 /** Vertex buffer bindings */
1629 struct gl_vertex_buffer_binding BufferBinding
[VERT_ATTRIB_MAX
];
1631 /** Mask indicating which vertex arrays have vertex buffer associated. */
1632 GLbitfield VertexAttribBufferMask
;
1634 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1635 GLbitfield _Enabled
;
1637 /** Denotes the way the position/generic0 attribute is mapped */
1638 gl_attribute_map_mode _AttributeMapMode
;
1640 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1641 GLbitfield NewArrays
;
1643 /** The index buffer (also known as the element array buffer in OpenGL). */
1644 struct gl_buffer_object
*IndexBufferObj
;
1649 * Enum for the OpenGL APIs we know about and may support.
1651 * NOTE: This must match the api_enum table in
1652 * src/mesa/main/get_hash_generator.py
1656 API_OPENGL_COMPAT
, /* legacy / compatibility contexts */
1660 API_OPENGL_LAST
= API_OPENGL_CORE
1665 * Vertex array state
1667 struct gl_array_attrib
1669 /** Currently bound array object. */
1670 struct gl_vertex_array_object
*VAO
;
1672 /** The default vertex array object */
1673 struct gl_vertex_array_object
*DefaultVAO
;
1675 /** The last VAO accessed by a DSA function */
1676 struct gl_vertex_array_object
*LastLookedUpVAO
;
1678 /** Array objects (GL_ARB_vertex_array_object) */
1679 struct _mesa_HashTable
*Objects
;
1681 GLint ActiveTexture
; /**< Client Active Texture */
1682 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1683 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1686 * \name Primitive restart controls
1688 * Primitive restart is enabled if either \c PrimitiveRestart or
1689 * \c PrimitiveRestartFixedIndex is set.
1692 GLboolean PrimitiveRestart
;
1693 GLboolean PrimitiveRestartFixedIndex
;
1694 GLboolean _PrimitiveRestart
;
1695 GLuint RestartIndex
;
1698 /* GL_ARB_vertex_buffer_object */
1699 struct gl_buffer_object
*ArrayBufferObj
;
1702 * Vertex array object that is used with the currently active draw command.
1703 * The _DrawVAO is either set to the currently bound VAO for array type
1704 * draws or to internal VAO's set up by the vbo module to execute immediate
1705 * mode or display list draws.
1707 struct gl_vertex_array_object
*_DrawVAO
;
1709 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
1710 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
1711 * but may omit those arrays that shall not be referenced by the current
1712 * gl_vertex_program_state::_VPMode. For example the generic attributes are
1713 * maked out form the _DrawVAO's enabled arrays when a fixed function
1714 * array draw is executed.
1716 GLbitfield _DrawVAOEnabledAttribs
;
1718 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
1719 * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
1721 struct gl_vertex_array_object
*_EmptyVAO
;
1724 * Vertex arrays as consumed by a driver.
1725 * The array pointer is set up only by the VBO module.
1727 const struct gl_vertex_array
**_DrawArrays
; /**< 0..VERT_ATTRIB_MAX-1 */
1729 /** Legal array datatypes and the API for which they have been computed */
1730 GLbitfield LegalTypesMask
;
1731 gl_api LegalTypesMaskAPI
;
1736 * Feedback buffer state
1741 GLbitfield _Mask
; /**< FB_* bits */
1749 * Selection buffer state
1753 GLuint
*Buffer
; /**< selection buffer */
1754 GLuint BufferSize
; /**< size of the selection buffer */
1755 GLuint BufferCount
; /**< number of values in the selection buffer */
1756 GLuint Hits
; /**< number of records in the selection buffer */
1757 GLuint NameStackDepth
; /**< name stack depth */
1758 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1759 GLboolean HitFlag
; /**< hit flag */
1760 GLfloat HitMinZ
; /**< minimum hit depth */
1761 GLfloat HitMaxZ
; /**< maximum hit depth */
1766 * 1-D Evaluator control points
1770 GLuint Order
; /**< Number of control points */
1771 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1772 GLfloat
*Points
; /**< Points to contiguous control points */
1777 * 2-D Evaluator control points
1781 GLuint Uorder
; /**< Number of control points in U dimension */
1782 GLuint Vorder
; /**< Number of control points in V dimension */
1785 GLfloat
*Points
; /**< Points to contiguous control points */
1790 * All evaluator control point state
1792 struct gl_evaluators
1798 struct gl_1d_map Map1Vertex3
;
1799 struct gl_1d_map Map1Vertex4
;
1800 struct gl_1d_map Map1Index
;
1801 struct gl_1d_map Map1Color4
;
1802 struct gl_1d_map Map1Normal
;
1803 struct gl_1d_map Map1Texture1
;
1804 struct gl_1d_map Map1Texture2
;
1805 struct gl_1d_map Map1Texture3
;
1806 struct gl_1d_map Map1Texture4
;
1813 struct gl_2d_map Map2Vertex3
;
1814 struct gl_2d_map Map2Vertex4
;
1815 struct gl_2d_map Map2Index
;
1816 struct gl_2d_map Map2Color4
;
1817 struct gl_2d_map Map2Normal
;
1818 struct gl_2d_map Map2Texture1
;
1819 struct gl_2d_map Map2Texture2
;
1820 struct gl_2d_map Map2Texture3
;
1821 struct gl_2d_map Map2Texture4
;
1826 struct gl_transform_feedback_varying_info
1837 * Per-output info vertex shaders for transform feedback.
1839 struct gl_transform_feedback_output
1841 uint32_t OutputRegister
;
1842 uint32_t OutputBuffer
;
1843 uint32_t NumComponents
;
1846 /** offset (in DWORDs) of this output within the interleaved structure */
1850 * Offset into the output register of the data to output. For example,
1851 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1852 * offset is in the y and z components of the output register.
1854 uint32_t ComponentOffset
;
1858 struct gl_transform_feedback_buffer
1862 uint32_t NumVaryings
;
1865 * Total number of components stored in each buffer. This may be used by
1866 * hardware back-ends to determine the correct stride when interleaving
1867 * multiple transform feedback outputs in the same buffer.
1872 * Which transform feedback stream this buffer binding is associated with.
1878 /** Post-link transform feedback info. */
1879 struct gl_transform_feedback_info
1881 /* Was xfb enabled via the api or in shader layout qualifiers */
1884 unsigned NumOutputs
;
1886 /* Bitmask of active buffer indices. */
1887 unsigned ActiveBuffers
;
1889 struct gl_transform_feedback_output
*Outputs
;
1891 /** Transform feedback varyings used for the linking of this shader program.
1893 * Use for glGetTransformFeedbackVarying().
1895 struct gl_transform_feedback_varying_info
*Varyings
;
1898 struct gl_transform_feedback_buffer Buffers
[MAX_FEEDBACK_BUFFERS
];
1903 * Transform feedback object state
1905 struct gl_transform_feedback_object
1907 GLuint Name
; /**< AKA the object ID */
1909 GLchar
*Label
; /**< GL_KHR_debug */
1910 GLboolean Active
; /**< Is transform feedback enabled? */
1911 GLboolean Paused
; /**< Is transform feedback paused? */
1912 GLboolean EndedAnytime
; /**< Has EndTransformFeedback been called
1914 GLboolean EverBound
; /**< Has this object been bound? */
1917 * GLES: if Active is true, remaining number of primitives which can be
1918 * rendered without overflow. This is necessary to track because GLES
1919 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1920 * glDrawArraysInstanced would overflow transform feedback buffers.
1921 * Undefined if Active is false.
1923 * Not tracked for desktop GL since it's unnecessary.
1925 unsigned GlesRemainingPrims
;
1928 * The program active when BeginTransformFeedback() was called.
1929 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1930 * where stage is the pipeline stage that is the source of data for
1931 * transform feedback.
1933 struct gl_program
*program
;
1935 /** The feedback buffers */
1936 GLuint BufferNames
[MAX_FEEDBACK_BUFFERS
];
1937 struct gl_buffer_object
*Buffers
[MAX_FEEDBACK_BUFFERS
];
1939 /** Start of feedback data in dest buffer */
1940 GLintptr Offset
[MAX_FEEDBACK_BUFFERS
];
1943 * Max data to put into dest buffer (in bytes). Computed based on
1944 * RequestedSize and the actual size of the buffer.
1946 GLsizeiptr Size
[MAX_FEEDBACK_BUFFERS
];
1949 * Size that was specified when the buffer was bound. If the buffer was
1950 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1953 GLsizeiptr RequestedSize
[MAX_FEEDBACK_BUFFERS
];
1958 * Context state for transform feedback.
1960 struct gl_transform_feedback_state
1962 GLenum16 Mode
; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1964 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1965 struct gl_buffer_object
*CurrentBuffer
;
1967 /** The table of all transform feedback objects */
1968 struct _mesa_HashTable
*Objects
;
1970 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1971 struct gl_transform_feedback_object
*CurrentObject
;
1973 /** The default xform-fb object (Name==0) */
1974 struct gl_transform_feedback_object
*DefaultObject
;
1979 * A "performance monitor" as described in AMD_performance_monitor.
1981 struct gl_perf_monitor_object
1985 /** True if the monitor is currently active (Begin called but not End). */
1989 * True if the monitor has ended.
1991 * This is distinct from !Active because it may never have began.
1996 * A list of groups with currently active counters.
1998 * ActiveGroups[g] == n if there are n counters active from group 'g'.
2000 unsigned *ActiveGroups
;
2003 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
2005 * Checking whether counter 'c' in group 'g' is active can be done via:
2007 * BITSET_TEST(ActiveCounters[g], c)
2009 GLuint
**ActiveCounters
;
2013 union gl_perf_monitor_counter_value
2021 struct gl_perf_monitor_counter
2023 /** Human readable name for the counter. */
2027 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
2028 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
2032 /** Minimum counter value. */
2033 union gl_perf_monitor_counter_value Minimum
;
2035 /** Maximum counter value. */
2036 union gl_perf_monitor_counter_value Maximum
;
2040 struct gl_perf_monitor_group
2042 /** Human readable name for the group. */
2046 * Maximum number of counters in this group which can be active at the
2049 GLuint MaxActiveCounters
;
2051 /** Array of counters within this group. */
2052 const struct gl_perf_monitor_counter
*Counters
;
2058 * A query object instance as described in INTEL_performance_query.
2060 * NB: We want to keep this and the corresponding backend structure
2061 * relatively lean considering that applications may expect to
2062 * allocate enough objects to be able to query around all draw calls
2065 struct gl_perf_query_object
2067 GLuint Id
; /**< hash table ID/name */
2068 unsigned Used
:1; /**< has been used for 1 or more queries */
2069 unsigned Active
:1; /**< inside Begin/EndPerfQuery */
2070 unsigned Ready
:1; /**< result is ready? */
2075 * Context state for AMD_performance_monitor.
2077 struct gl_perf_monitor_state
2079 /** Array of performance monitor groups (indexed by group ID) */
2080 const struct gl_perf_monitor_group
*Groups
;
2083 /** The table of all performance monitors. */
2084 struct _mesa_HashTable
*Monitors
;
2089 * Context state for INTEL_performance_query.
2091 struct gl_perf_query_state
2093 struct _mesa_HashTable
*Objects
; /**< The table of all performance query objects */
2098 * A bindless sampler object.
2100 struct gl_bindless_sampler
2102 /** Texture unit (set by glUniform1()). */
2105 /** Whether this bindless sampler is bound to a unit. */
2108 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2109 gl_texture_index target
;
2111 /** Pointer to the base of the data. */
2117 * A bindless image object.
2119 struct gl_bindless_image
2121 /** Image unit (set by glUniform1()). */
2124 /** Whether this bindless image is bound to a unit. */
2127 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
2130 /** Pointer to the base of the data. */
2136 * Names of the various vertex/fragment program register files, etc.
2138 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
2139 * All values should fit in a 4-bit field.
2141 * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be
2142 * considered to be "uniform" variables since they can only be set outside
2143 * glBegin/End. They're also all stored in the same Parameters array.
2147 PROGRAM_TEMPORARY
, /**< machine->Temporary[] */
2148 PROGRAM_ARRAY
, /**< Arrays & Matrixes */
2149 PROGRAM_INPUT
, /**< machine->Inputs[] */
2150 PROGRAM_OUTPUT
, /**< machine->Outputs[] */
2151 PROGRAM_STATE_VAR
, /**< gl_program->Parameters[] */
2152 PROGRAM_CONSTANT
, /**< gl_program->Parameters[] */
2153 PROGRAM_UNIFORM
, /**< gl_program->Parameters[] */
2154 PROGRAM_WRITE_ONLY
, /**< A dummy, write-only register */
2155 PROGRAM_ADDRESS
, /**< machine->AddressReg */
2156 PROGRAM_SAMPLER
, /**< for shader samplers, compile-time only */
2157 PROGRAM_SYSTEM_VALUE
,/**< InstanceId, PrimitiveID, etc. */
2158 PROGRAM_UNDEFINED
, /**< Invalid/TBD value */
2159 PROGRAM_IMMEDIATE
, /**< Immediate value, used by TGSI */
2160 PROGRAM_BUFFER
, /**< for shader buffers, compile-time only */
2161 PROGRAM_MEMORY
, /**< for shared, global and local memory */
2162 PROGRAM_IMAGE
, /**< for shader images, compile-time only */
2163 PROGRAM_HW_ATOMIC
, /**< for hw atomic counters, compile-time only */
2169 * Current vertex processing mode: fixed function vs. shader.
2170 * In reality, fixed function is probably implemented by a shader but that's
2171 * not what we care about here.
2175 VP_MODE_FF
, /**< legacy / fixed function */
2176 VP_MODE_SHADER
, /**< ARB vertex program or GLSL vertex shader */
2177 VP_MODE_MAX
/**< for sizing arrays */
2178 } gl_vertex_processing_mode
;
2182 * Base class for any kind of program object
2186 /** FIXME: This must be first until we split shader_info from nir_shader */
2187 struct shader_info info
;
2191 GLubyte
*String
; /**< Null-terminated program text */
2193 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2195 GLenum16 Format
; /**< String encoding format */
2197 GLboolean _Used
; /**< Ever used for drawing? Used for debugging */
2199 struct nir_shader
*nir
;
2201 /* Saved and restored with metadata. Freed with ralloc. */
2202 void *driver_cache_blob
;
2203 size_t driver_cache_blob_size
;
2205 bool is_arb_asm
; /** Is this an ARB assembly-style program */
2207 /** Is this program written to on disk shader cache */
2208 bool program_written_to_cache
;
2210 /** Subset of OutputsWritten outputs written with non-zero index. */
2211 GLbitfield64 SecondaryOutputsWritten
;
2212 /** TEXTURE_x_BIT bitmask */
2213 GLbitfield16 TexturesUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
2214 /** Bitfield of which samplers are used */
2215 GLbitfield SamplersUsed
;
2216 /** Texture units used for shadow sampling. */
2217 GLbitfield ShadowSamplers
;
2218 /** Texture units used for samplerExternalOES */
2219 GLbitfield ExternalSamplersUsed
;
2221 /* Fragement shader only fields */
2222 GLboolean OriginUpperLeft
;
2223 GLboolean PixelCenterInteger
;
2225 /** Named parameters, constants, etc. from program text */
2226 struct gl_program_parameter_list
*Parameters
;
2228 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2229 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2231 /* FIXME: We should be able to make this struct a union. However some
2232 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2233 * these fields, we should fix this.
2236 /** Fields used by GLSL programs */
2238 /** Data shared by gl_program and gl_shader_program */
2239 struct gl_shader_program_data
*data
;
2241 struct gl_active_atomic_buffer
**AtomicBuffers
;
2243 /** Post-link transform feedback info. */
2244 struct gl_transform_feedback_info
*LinkedTransformFeedback
;
2247 * Number of types for subroutine uniforms.
2249 GLuint NumSubroutineUniformTypes
;
2252 * Subroutine uniform remap table
2253 * based on the program level uniform remap table.
2255 GLuint NumSubroutineUniforms
; /* non-sparse total */
2256 GLuint NumSubroutineUniformRemapTable
;
2257 struct gl_uniform_storage
**SubroutineUniformRemapTable
;
2260 * Num of subroutine functions for this stage and storage for them.
2262 GLuint NumSubroutineFunctions
;
2263 GLuint MaxSubroutineFunctionIndex
;
2264 struct gl_subroutine_function
*SubroutineFunctions
;
2267 * Map from image uniform index to image unit (set by glUniform1i())
2269 * An image uniform index is associated with each image uniform by
2270 * the linker. The image index associated with each uniform is
2271 * stored in the \c gl_uniform_storage::image field.
2273 GLubyte ImageUnits
[MAX_IMAGE_UNIFORMS
];
2276 * Access qualifier specified in the shader for each image uniform
2277 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
2280 * It may be different, though only more strict than the value of
2281 * \c gl_image_unit::Access for the corresponding image unit.
2283 GLenum16 ImageAccess
[MAX_IMAGE_UNIFORMS
];
2285 struct gl_uniform_block
**UniformBlocks
;
2286 struct gl_uniform_block
**ShaderStorageBlocks
;
2288 /** Which texture target is being sampled
2289 * (TEXTURE_1D/2D/3D/etc_INDEX)
2291 GLubyte SamplerTargets
[MAX_SAMPLERS
];
2294 * Number of samplers declared with the bindless_sampler layout
2295 * qualifier as specified by ARB_bindless_texture.
2297 GLuint NumBindlessSamplers
;
2298 GLboolean HasBoundBindlessSampler
;
2299 struct gl_bindless_sampler
*BindlessSamplers
;
2302 * Number of images declared with the bindless_image layout qualifier
2303 * as specified by ARB_bindless_texture.
2305 GLuint NumBindlessImages
;
2306 GLboolean HasBoundBindlessImage
;
2307 struct gl_bindless_image
*BindlessImages
;
2312 * A bitmask of gl_advanced_blend_mode values
2314 GLbitfield BlendSupport
;
2319 /** ARB assembly-style program fields */
2321 struct prog_instruction
*Instructions
;
2324 * Local parameters used by the program.
2326 * It's dynamically allocated because it is rarely used (just
2327 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2328 * once it's allocated.
2330 GLfloat (*LocalParams
)[4];
2332 /** Bitmask of which register files are read/written with indirect
2333 * addressing. Mask of (1 << PROGRAM_x) bits.
2335 GLbitfield IndirectRegisterFiles
;
2337 /** Logical counts */
2339 GLuint NumInstructions
;
2340 GLuint NumTemporaries
;
2341 GLuint NumParameters
;
2342 GLuint NumAttributes
;
2343 GLuint NumAddressRegs
;
2344 GLuint NumAluInstructions
;
2345 GLuint NumTexInstructions
;
2346 GLuint NumTexIndirections
;
2348 /** Native, actual h/w counts */
2350 GLuint NumNativeInstructions
;
2351 GLuint NumNativeTemporaries
;
2352 GLuint NumNativeParameters
;
2353 GLuint NumNativeAttributes
;
2354 GLuint NumNativeAddressRegs
;
2355 GLuint NumNativeAluInstructions
;
2356 GLuint NumNativeTexInstructions
;
2357 GLuint NumNativeTexIndirections
;
2360 /** Used by ARB assembly-style programs. Can only be true for vertex
2363 GLboolean IsPositionInvariant
;
2370 * State common to vertex and fragment programs.
2372 struct gl_program_state
2374 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2375 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2380 * Context state for vertex programs.
2382 struct gl_vertex_program_state
2384 GLboolean Enabled
; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2385 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2386 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2387 /** Should fixed-function T&L be implemented with a vertex prog? */
2388 GLboolean _MaintainTnlProgram
;
2390 struct gl_program
*Current
; /**< User-bound vertex program */
2392 /** Currently enabled and valid vertex program (including internal
2393 * programs, user-defined vertex programs and GLSL vertex shaders).
2394 * This is the program we must use when rendering.
2396 struct gl_program
*_Current
;
2398 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2400 /** Program to emulate fixed-function T&L (see above) */
2401 struct gl_program
*_TnlProgram
;
2403 /** Cache of fixed-function programs */
2404 struct gl_program_cache
*Cache
;
2406 GLboolean _Overriden
;
2409 * If we have a vertex program, a TNL program or no program at all.
2410 * Note that this value should be kept up to date all the time,
2411 * nevertheless its correctness is asserted in _mesa_update_state.
2412 * The reason is to avoid calling _mesa_update_state twice we need
2413 * this value on draw *before* actually calling _mesa_update_state.
2414 * Also it should need to get recomputed only on changes to the
2415 * vertex program which are heavyweight already.
2417 gl_vertex_processing_mode _VPMode
;
2421 * Context state for tessellation control programs.
2423 struct gl_tess_ctrl_program_state
2425 /** Currently bound and valid shader. */
2426 struct gl_program
*_Current
;
2428 GLint patch_vertices
;
2429 GLfloat patch_default_outer_level
[4];
2430 GLfloat patch_default_inner_level
[2];
2434 * Context state for tessellation evaluation programs.
2436 struct gl_tess_eval_program_state
2438 /** Currently bound and valid shader. */
2439 struct gl_program
*_Current
;
2443 * Context state for geometry programs.
2445 struct gl_geometry_program_state
2448 * Currently enabled and valid program (including internal programs
2449 * and compiled shader programs).
2451 struct gl_program
*_Current
;
2455 * Context state for fragment programs.
2457 struct gl_fragment_program_state
2459 GLboolean Enabled
; /**< User-set fragment program enable flag */
2460 /** Should fixed-function texturing be implemented with a fragment prog? */
2461 GLboolean _MaintainTexEnvProgram
;
2463 struct gl_program
*Current
; /**< User-bound fragment program */
2466 * Currently enabled and valid fragment program (including internal
2467 * programs, user-defined fragment programs and GLSL fragment shaders).
2468 * This is the program we must use when rendering.
2470 struct gl_program
*_Current
;
2472 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2474 /** Program to emulate fixed-function texture env/combine (see above) */
2475 struct gl_program
*_TexEnvProgram
;
2477 /** Cache of fixed-function programs */
2478 struct gl_program_cache
*Cache
;
2483 * Context state for compute programs.
2485 struct gl_compute_program_state
2487 /** Currently enabled and valid program (including internal programs
2488 * and compiled shader programs).
2490 struct gl_program
*_Current
;
2495 * ATI_fragment_shader runtime state
2498 struct atifs_instruction
;
2499 struct atifs_setupinst
;
2502 * ATI fragment shader
2504 struct ati_fragment_shader
2508 struct atifs_instruction
*Instructions
[2];
2509 struct atifs_setupinst
*SetupInst
[2];
2510 GLfloat Constants
[8][4];
2511 GLbitfield LocalConstDef
; /**< Indicates which constants have been set */
2512 GLubyte numArithInstr
[2];
2513 GLubyte regsAssigned
[2];
2514 GLubyte NumPasses
; /**< 1 or 2 */
2516 * Current compile stage: 0 setup pass1, 1 arith pass1,
2517 * 2 setup pass2, 3 arith pass2.
2520 GLubyte last_optype
;
2521 GLboolean interpinp1
;
2524 * Array of 2 bit values for each tex unit to remember whether
2525 * STR or STQ swizzle was used
2528 struct gl_program
*Program
;
2532 * Context state for GL_ATI_fragment_shader
2534 struct gl_ati_fragment_shader_state
2537 GLboolean Compiling
;
2538 GLfloat GlobalConstants
[8][4];
2539 struct ati_fragment_shader
*Current
;
2543 * Shader subroutine function definition
2545 struct gl_subroutine_function
2549 int num_compat_types
;
2550 const struct glsl_type
**types
;
2554 * Shader information needed by both gl_shader and gl_linked shader.
2556 struct gl_shader_info
2559 * Tessellation Control shader state from layout qualifiers.
2563 * 0 - vertices not declared in shader, or
2564 * 1 .. GL_MAX_PATCH_VERTICES
2570 * Tessellation Evaluation shader state from layout qualifiers.
2574 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2577 GLenum16 PrimitiveMode
;
2579 enum gl_tess_spacing Spacing
;
2582 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2584 GLenum16 VertexOrder
;
2586 * 1, 0, or -1 if it's not set in this shader.
2592 * Geometry shader state from GLSL 1.50 layout qualifiers.
2597 * 0 - Invocations count not declared in shader, or
2598 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
2602 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2603 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2608 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2609 * it's not set in this shader.
2611 GLenum16 OutputType
;
2615 * Compute shader state from ARB_compute_shader and
2616 * ARB_compute_variable_group_size layout qualifiers.
2620 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2621 * it's not set in this shader.
2623 unsigned LocalSize
[3];
2626 * Whether a variable work group size has been specified as defined by
2627 * ARB_compute_variable_group_size.
2629 bool LocalSizeVariable
;
2634 * A linked GLSL shader object.
2636 struct gl_linked_shader
2638 gl_shader_stage Stage
;
2641 unsigned SourceChecksum
;
2644 struct gl_program
*Program
; /**< Post-compile assembly code */
2647 * \name Sampler tracking
2649 * \note Each of these fields is only set post-linking.
2652 GLbitfield shadow_samplers
; /**< Samplers used for shadow sampling. */
2656 * Number of default uniform block components used by this shader.
2658 * This field is only set post-linking.
2660 unsigned num_uniform_components
;
2663 * Number of combined uniform components used by this shader.
2665 * This field is only set post-linking. It is the sum of the uniform block
2666 * sizes divided by sizeof(float), and num_uniform_compoennts.
2668 unsigned num_combined_uniform_components
;
2670 struct exec_list
*ir
;
2671 struct exec_list
*packed_varyings
;
2672 struct exec_list
*fragdata_arrays
;
2673 struct glsl_symbol_table
*symbols
;
2678 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2679 * was skipped due to the shader matching one that's been seen before by
2680 * the on-disk cache.
2682 enum gl_compile_status
2684 COMPILE_FAILURE
= 0,
2691 * A GLSL shader object.
2695 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2696 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2697 * Must be the first field.
2700 gl_shader_stage Stage
;
2701 GLuint Name
; /**< AKA the handle */
2702 GLint RefCount
; /**< Reference count */
2703 GLchar
*Label
; /**< GL_KHR_debug */
2704 unsigned char sha1
[20]; /**< SHA1 hash of pre-processed source */
2705 GLboolean DeletePending
;
2706 bool IsES
; /**< True if this shader uses GLSL ES */
2708 enum gl_compile_status CompileStatus
;
2711 unsigned SourceChecksum
; /**< for debug/logging purposes */
2713 const GLchar
*Source
; /**< Source code string */
2715 const GLchar
*FallbackSource
; /**< Fallback string used by on-disk cache*/
2719 unsigned Version
; /**< GLSL version used for linking */
2722 * A bitmask of gl_advanced_blend_mode values
2724 GLbitfield BlendSupport
;
2726 struct exec_list
*ir
;
2727 struct glsl_symbol_table
*symbols
;
2730 * Whether early fragment tests are enabled as defined by
2731 * ARB_shader_image_load_store.
2733 bool EarlyFragmentTests
;
2735 bool ARB_fragment_coord_conventions_enable
;
2737 bool redeclares_gl_fragcoord
;
2738 bool uses_gl_fragcoord
;
2740 bool PostDepthCoverage
;
2744 * Fragment shader state from GLSL 1.50 layout qualifiers.
2746 bool origin_upper_left
;
2747 bool pixel_center_integer
;
2750 * Whether bindless_sampler/bindless_image, and respectively
2751 * bound_sampler/bound_image are declared at global scope as defined by
2752 * ARB_bindless_texture.
2754 bool bindless_sampler
;
2755 bool bindless_image
;
2759 /** Global xfb_stride out qualifier if any */
2760 GLuint TransformFeedbackBufferStride
[MAX_FEEDBACK_BUFFERS
];
2762 struct gl_shader_info info
;
2764 /* ARB_gl_spirv related data */
2765 struct gl_shader_spirv_data
*spirv_data
;
2769 struct gl_uniform_buffer_variable
2774 * Name of the uniform as seen by glGetUniformIndices.
2776 * glGetUniformIndices requires that the block instance index \b not be
2777 * present in the name of queried uniforms.
2780 * \c gl_uniform_buffer_variable::IndexName and
2781 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2785 const struct glsl_type
*Type
;
2786 unsigned int Offset
;
2791 struct gl_uniform_block
2793 /** Declared name of the uniform block */
2796 /** Array of supplemental information about UBO ir_variables. */
2797 struct gl_uniform_buffer_variable
*Uniforms
;
2801 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2802 * with glBindBufferBase to bind a buffer object to this uniform block.
2807 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2808 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2810 GLuint UniformBufferSize
;
2812 /** Stages that reference this block */
2816 * Linearized array index for uniform block instance arrays
2818 * Given a uniform block instance array declared with size
2819 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2820 * have the linearized array index
2823 * i_m + ∑ i_j * ∏ s_k
2826 * For a uniform block instance that is not an array, this is always 0.
2828 uint8_t linearized_array_index
;
2831 * Layout specified in the shader
2833 * This isn't accessible through the API, but it is used while
2834 * cross-validating uniform blocks.
2836 enum glsl_interface_packing _Packing
;
2837 GLboolean _RowMajor
;
2841 * Structure that represents a reference to an atomic buffer from some
2844 struct gl_active_atomic_buffer
2846 /** Uniform indices of the atomic counters declared within it. */
2850 /** Binding point index associated with it. */
2853 /** Minimum reasonable size it is expected to have. */
2856 /** Shader stages making use of it. */
2857 GLboolean StageReferences
[MESA_SHADER_STAGES
];
2861 * Data container for shader queries. This holds only the minimal
2862 * amount of required information for resource queries to work.
2864 struct gl_shader_variable
2867 * Declared type of the variable
2869 const struct glsl_type
*type
;
2872 * If the variable is in an interface block, this is the type of the block.
2874 const struct glsl_type
*interface_type
;
2877 * For variables inside structs (possibly recursively), this is the
2878 * outermost struct type.
2880 const struct glsl_type
*outermost_struct_type
;
2883 * Declared name of the variable
2888 * Storage location of the base of this variable
2890 * The precise meaning of this field depends on the nature of the variable.
2892 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2893 * - Vertex shader output: one of the values from \c gl_varying_slot.
2894 * - Geometry shader input: one of the values from \c gl_varying_slot.
2895 * - Geometry shader output: one of the values from \c gl_varying_slot.
2896 * - Fragment shader input: one of the values from \c gl_varying_slot.
2897 * - Fragment shader output: one of the values from \c gl_frag_result.
2898 * - Uniforms: Per-stage uniform slot number for default uniform block.
2899 * - Uniforms: Index within the uniform block definition for UBO members.
2900 * - Non-UBO Uniforms: explicit location until linking then reused to
2901 * store uniform slot number.
2902 * - Other: This field is not currently used.
2904 * If the variable is a uniform, shader input, or shader output, and the
2905 * slot has not been assigned, the value will be -1.
2910 * Specifies the first component the variable is stored in as per
2911 * ARB_enhanced_layouts.
2913 unsigned component
:2;
2916 * Output index for dual source blending.
2919 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2925 * Specifies whether a shader input/output is per-patch in tessellation
2931 * Storage class of the variable.
2933 * \sa (n)ir_variable_mode
2938 * Interpolation mode for shader inputs / outputs
2940 * \sa glsl_interp_mode
2942 unsigned interpolation
:2;
2945 * Was the location explicitly set in the shader?
2947 * If the location is explicitly set in the shader, it \b cannot be changed
2948 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2951 unsigned explicit_location
:1;
2954 * Precision qualifier.
2956 unsigned precision
:2;
2960 * Active resource in a gl_shader_program
2962 struct gl_program_resource
2964 GLenum16 Type
; /** Program interface type. */
2965 const void *Data
; /** Pointer to resource associated data structure. */
2966 uint8_t StageReferences
; /** Bitmask of shader stage references. */
2970 * Link status enum. LINKING_SKIPPED is used to indicate linking
2971 * was skipped due to the shader being loaded from the on-disk cache.
2975 LINKING_FAILURE
= 0,
2981 * A data structure to be shared by gl_shader_program and gl_program.
2983 struct gl_shader_program_data
2985 GLint RefCount
; /**< Reference count */
2987 /** SHA1 hash of linked shader program */
2988 unsigned char sha1
[20];
2990 unsigned NumUniformStorage
;
2991 unsigned NumHiddenUniforms
;
2992 struct gl_uniform_storage
*UniformStorage
;
2994 unsigned NumUniformBlocks
;
2995 unsigned NumShaderStorageBlocks
;
2997 struct gl_uniform_block
*UniformBlocks
;
2998 struct gl_uniform_block
*ShaderStorageBlocks
;
3000 struct gl_active_atomic_buffer
*AtomicBuffers
;
3001 unsigned NumAtomicBuffers
;
3003 /* Shader cache variables used during restore */
3004 unsigned NumUniformDataSlots
;
3005 union gl_constant_value
*UniformDataSlots
;
3007 /* Used to hold initial uniform values for program binary restores.
3009 * From the ARB_get_program_binary spec:
3011 * "A successful call to ProgramBinary will reset all uniform
3012 * variables to their initial values. The initial value is either
3013 * the value of the variable's initializer as specified in the
3014 * original shader source, or 0 if no initializer was present.
3016 union gl_constant_value
*UniformDataDefaults
;
3018 GLboolean Validated
;
3020 /** List of all active resources after linking. */
3021 struct gl_program_resource
*ProgramResourceList
;
3022 unsigned NumProgramResourceList
;
3024 enum gl_link_status LinkStatus
; /**< GL_LINK_STATUS */
3027 unsigned Version
; /**< GLSL version used for linking */
3029 /* Mask of stages this program was linked against */
3030 unsigned linked_stages
;
3034 * A GLSL program object.
3035 * Basically a linked collection of vertex and fragment shaders.
3037 struct gl_shader_program
3039 GLenum16 Type
; /**< Always GL_SHADER_PROGRAM (internal token) */
3040 GLuint Name
; /**< aka handle or ID */
3041 GLchar
*Label
; /**< GL_KHR_debug */
3042 GLint RefCount
; /**< Reference count */
3043 GLboolean DeletePending
;
3046 * Is the application intending to glGetProgramBinary this program?
3048 GLboolean BinaryRetreivableHint
;
3051 * Indicates whether program can be bound for individual pipeline stages
3052 * using UseProgramStages after it is next linked.
3054 GLboolean SeparateShader
;
3056 GLuint NumShaders
; /**< number of attached shaders */
3057 struct gl_shader
**Shaders
; /**< List of attached the shaders */
3060 * User-defined attribute bindings
3062 * These are set via \c glBindAttribLocation and are used to direct the
3063 * GLSL linker. These are \b not the values used in the compiled shader,
3064 * and they are \b not the values returned by \c glGetAttribLocation.
3066 struct string_to_uint_map
*AttributeBindings
;
3069 * User-defined fragment data bindings
3071 * These are set via \c glBindFragDataLocation and are used to direct the
3072 * GLSL linker. These are \b not the values used in the compiled shader,
3073 * and they are \b not the values returned by \c glGetFragDataLocation.
3075 struct string_to_uint_map
*FragDataBindings
;
3076 struct string_to_uint_map
*FragDataIndexBindings
;
3079 * Transform feedback varyings last specified by
3080 * glTransformFeedbackVaryings().
3082 * For the current set of transform feedback varyings used for transform
3083 * feedback output, see LinkedTransformFeedback.
3086 GLenum16 BufferMode
;
3087 /** Global xfb_stride out qualifier if any */
3088 GLuint BufferStride
[MAX_FEEDBACK_BUFFERS
];
3090 GLchar
**VaryingNames
; /**< Array [NumVarying] of char * */
3091 } TransformFeedback
;
3093 struct gl_program
*last_vert_prog
;
3095 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3096 enum gl_frag_depth_layout FragDepthLayout
;
3099 * Geometry shader state - copied into gl_program by
3100 * _mesa_copy_linked_program_data().
3105 bool UsesEndPrimitive
;
3110 * Compute shader state - copied into gl_program by
3111 * _mesa_copy_linked_program_data().
3115 * Size of shared variables accessed by the compute shader.
3117 unsigned SharedSize
;
3120 /** Data shared by gl_program and gl_shader_program */
3121 struct gl_shader_program_data
*data
;
3124 * Mapping from GL uniform locations returned by \c glUniformLocation to
3125 * UniformStorage entries. Arrays will have multiple contiguous slots
3126 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3128 unsigned NumUniformRemapTable
;
3129 struct gl_uniform_storage
**UniformRemapTable
;
3132 * Sometimes there are empty slots left over in UniformRemapTable after we
3133 * allocate slots to explicit locations. This list stores the blocks of
3134 * continuous empty slots inside UniformRemapTable.
3136 struct exec_list EmptyUniformLocations
;
3139 * Total number of explicit uniform location including inactive uniforms.
3141 unsigned NumExplicitUniformLocations
;
3144 * Map of active uniform names to locations
3146 * Maps any active uniform that is not an array element to a location.
3147 * Each active uniform, including individual structure members will appear
3148 * in this map. This roughly corresponds to the set of names that would be
3149 * enumerated by \c glGetActiveUniform.
3151 struct string_to_uint_map
*UniformHash
;
3153 GLboolean SamplersValidated
; /**< Samplers validated against texture units? */
3155 bool IsES
; /**< True if this program uses GLSL ES */
3158 * Per-stage shaders resulting from the first stage of linking.
3160 * Set of linked shaders for this program. The array is accessed using the
3161 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3164 struct gl_linked_shader
*_LinkedShaders
[MESA_SHADER_STAGES
];
3167 * True if any of the fragment shaders attached to this program use:
3168 * #extension ARB_fragment_coord_conventions: enable
3170 GLboolean ARB_fragment_coord_conventions_enable
;
3174 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3175 #define GLSL_LOG 0x2 /**< Write shaders to files */
3176 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3177 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3178 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3179 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3180 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3181 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3182 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3183 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3187 * Context state for GLSL vertex/fragment shaders.
3188 * Extended to support pipeline object
3190 struct gl_pipeline_object
3192 /** Name of the pipeline object as received from glGenProgramPipelines.
3193 * It would be 0 for shaders without separate shader objects.
3199 GLchar
*Label
; /**< GL_KHR_debug */
3202 * Programs used for rendering
3204 * There is a separate program set for each shader stage.
3206 struct gl_program
*CurrentProgram
[MESA_SHADER_STAGES
];
3208 struct gl_shader_program
*ReferencedPrograms
[MESA_SHADER_STAGES
];
3211 * Program used by glUniform calls.
3213 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3215 struct gl_shader_program
*ActiveProgram
;
3217 GLbitfield Flags
; /**< Mask of GLSL_x flags */
3218 GLboolean EverBound
; /**< Has the pipeline object been created */
3219 GLboolean Validated
; /**< Pipeline Validation status */
3225 * Context state for GLSL pipeline shaders.
3227 struct gl_pipeline_shader_state
3229 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3230 struct gl_pipeline_object
*Current
;
3232 /** Default Object to ensure that _Shader is never NULL */
3233 struct gl_pipeline_object
*Default
;
3235 /** Pipeline objects */
3236 struct _mesa_HashTable
*Objects
;
3240 * Compiler options for a single GLSL shaders type
3242 struct gl_shader_compiler_options
3244 /** Driver-selectable options: */
3245 GLboolean EmitNoLoops
;
3246 GLboolean EmitNoCont
; /**< Emit CONT opcode? */
3247 GLboolean EmitNoMainReturn
; /**< Emit CONT/RET opcodes? */
3248 GLboolean EmitNoPow
; /**< Emit POW opcodes? */
3249 GLboolean EmitNoSat
; /**< Emit SAT opcodes? */
3250 GLboolean LowerCombinedClipCullDistance
; /** Lower gl_ClipDistance and
3251 * gl_CullDistance together from
3252 * float[8] to vec4[2]
3256 * \name Forms of indirect addressing the driver cannot do.
3259 GLboolean EmitNoIndirectInput
; /**< No indirect addressing of inputs */
3260 GLboolean EmitNoIndirectOutput
; /**< No indirect addressing of outputs */
3261 GLboolean EmitNoIndirectTemp
; /**< No indirect addressing of temps */
3262 GLboolean EmitNoIndirectUniform
; /**< No indirect addressing of constants */
3263 GLboolean EmitNoIndirectSampler
; /**< No indirect addressing of samplers */
3266 GLuint MaxIfDepth
; /**< Maximum nested IF blocks */
3267 GLuint MaxUnrollIterations
;
3270 * Optimize code for array of structures backends.
3272 * This is a proxy for:
3273 * - preferring DP4 instructions (rather than MUL/MAD) for
3274 * matrix * vector operations, such as position transformation.
3276 GLboolean OptimizeForAOS
;
3278 /** Lower UBO and SSBO access to intrinsics. */
3279 GLboolean LowerBufferInterfaceBlocks
;
3281 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3282 GLboolean ClampBlockIndicesToArrayBounds
;
3284 const struct nir_shader_compiler_options
*NirOptions
;
3289 * Occlusion/timer query object.
3291 struct gl_query_object
3293 GLenum16 Target
; /**< The query target, when active */
3294 GLuint Id
; /**< hash table ID/name */
3295 GLchar
*Label
; /**< GL_KHR_debug */
3296 GLuint64EXT Result
; /**< the counter */
3297 GLboolean Active
; /**< inside Begin/EndQuery */
3298 GLboolean Ready
; /**< result is ready? */
3299 GLboolean EverBound
;/**< has query object ever been bound */
3300 GLuint Stream
; /**< The stream */
3305 * Context state for query objects.
3307 struct gl_query_state
3309 struct _mesa_HashTable
*QueryObjects
;
3310 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
3311 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
3313 /** GL_NV_conditional_render */
3314 struct gl_query_object
*CondRenderQuery
;
3316 /** GL_EXT_transform_feedback */
3317 struct gl_query_object
*PrimitivesGenerated
[MAX_VERTEX_STREAMS
];
3318 struct gl_query_object
*PrimitivesWritten
[MAX_VERTEX_STREAMS
];
3320 /** GL_ARB_transform_feedback_overflow_query */
3321 struct gl_query_object
*TransformFeedbackOverflow
[MAX_VERTEX_STREAMS
];
3322 struct gl_query_object
*TransformFeedbackOverflowAny
;
3324 /** GL_ARB_timer_query */
3325 struct gl_query_object
*TimeElapsed
;
3327 /** GL_ARB_pipeline_statistics_query */
3328 struct gl_query_object
*pipeline_stats
[MAX_PIPELINE_STATISTICS
];
3330 GLenum16 CondRenderMode
;
3334 /** Sync object state */
3335 struct gl_sync_object
3337 GLuint Name
; /**< Fence name */
3338 GLint RefCount
; /**< Reference count */
3339 GLchar
*Label
; /**< GL_KHR_debug */
3340 GLboolean DeletePending
; /**< Object was deleted while there were still
3341 * live references (e.g., sync not yet finished)
3343 GLenum16 SyncCondition
;
3344 GLbitfield Flags
; /**< Flags passed to glFenceSync */
3345 GLuint StatusFlag
:1; /**< Has the sync object been signaled? */
3350 * State which can be shared by multiple contexts:
3352 struct gl_shared_state
3354 simple_mtx_t Mutex
; /**< for thread safety */
3355 GLint RefCount
; /**< Reference count */
3356 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
3357 struct _mesa_HashTable
*BitmapAtlas
; /**< For optimized glBitmap text */
3358 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
3360 /** Default texture objects (shared by all texture units) */
3361 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
3363 /** Fallback texture used when a bound texture is incomplete */
3364 struct gl_texture_object
*FallbackTex
[NUM_TEXTURE_TARGETS
];
3367 * \name Thread safety and statechange notification for texture
3370 * \todo Improve the granularity of locking.
3373 mtx_t TexMutex
; /**< texobj thread safety */
3374 GLuint TextureStateStamp
; /**< state notification for shared tex */
3377 /** Default buffer object for vertex arrays that aren't in VBOs */
3378 struct gl_buffer_object
*NullBufferObj
;
3381 * \name Vertex/geometry/fragment programs
3384 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
3385 struct gl_program
*DefaultVertexProgram
;
3386 struct gl_program
*DefaultFragmentProgram
;
3389 /* GL_ATI_fragment_shader */
3390 struct _mesa_HashTable
*ATIShaders
;
3391 struct ati_fragment_shader
*DefaultFragmentShader
;
3393 struct _mesa_HashTable
*BufferObjects
;
3395 /** Table of both gl_shader and gl_shader_program objects */
3396 struct _mesa_HashTable
*ShaderObjects
;
3398 /* GL_EXT_framebuffer_object */
3399 struct _mesa_HashTable
*RenderBuffers
;
3400 struct _mesa_HashTable
*FrameBuffers
;
3403 struct set
*SyncObjects
;
3405 /** GL_ARB_sampler_objects */
3406 struct _mesa_HashTable
*SamplerObjects
;
3408 /* GL_ARB_bindless_texture */
3409 struct hash_table_u64
*TextureHandles
;
3410 struct hash_table_u64
*ImageHandles
;
3411 mtx_t HandlesMutex
; /**< For texture/image handles safety */
3414 * Some context in this share group was affected by a GPU reset
3416 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3417 * been affected by a GPU reset must also return
3418 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3420 * Once this field becomes true, it is never reset to false.
3422 bool ShareGroupReset
;
3424 /** EXT_external_objects */
3425 struct _mesa_HashTable
*MemoryObjects
;
3427 /** EXT_semaphore */
3428 struct _mesa_HashTable
*SemaphoreObjects
;
3431 * Some context in this share group was affected by a disjoint
3432 * operation. This operation can be anything that has effects on
3433 * values of timer queries in such manner that they become invalid for
3434 * performance metrics. As example gpu reset, counter overflow or gpu
3435 * frequency changes.
3437 bool DisjointOperation
;
3443 * Renderbuffers represent drawing surfaces such as color, depth and/or
3444 * stencil. A framebuffer object has a set of renderbuffers.
3445 * Drivers will typically derive subclasses of this type.
3447 struct gl_renderbuffer
3449 simple_mtx_t Mutex
; /**< for thread safety */
3450 GLuint ClassID
; /**< Useful for drivers */
3452 GLchar
*Label
; /**< GL_KHR_debug */
3454 GLuint Width
, Height
;
3456 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
3457 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
3459 * True for renderbuffers that wrap textures, giving the driver a chance to
3460 * flush render caches through the FinishRenderTexture hook.
3462 * Drivers may also set this on renderbuffers other than those generated by
3463 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3464 * called without a rb->TexImage.
3466 GLboolean NeedsFinishRenderTexture
;
3467 GLubyte NumSamples
; /**< zero means not multisampled */
3468 GLenum16 InternalFormat
; /**< The user-specified format */
3469 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3470 GL_STENCIL_INDEX. */
3471 mesa_format Format
; /**< The actual renderbuffer memory format */
3473 * Pointer to the texture image if this renderbuffer wraps a texture,
3476 * Note that the reference on the gl_texture_object containing this
3477 * TexImage is held by the gl_renderbuffer_attachment.
3479 struct gl_texture_image
*TexImage
;
3481 /** Delete this renderbuffer */
3482 void (*Delete
)(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
);
3484 /** Allocate new storage for this renderbuffer */
3485 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
3486 struct gl_renderbuffer
*rb
,
3487 GLenum internalFormat
,
3488 GLuint width
, GLuint height
);
3493 * A renderbuffer attachment points to either a texture object (and specifies
3494 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3496 struct gl_renderbuffer_attachment
3498 GLenum16 Type
; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3502 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3503 * application supplied renderbuffer object.
3505 struct gl_renderbuffer
*Renderbuffer
;
3508 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3509 * supplied texture object.
3511 struct gl_texture_object
*Texture
;
3512 GLuint TextureLevel
; /**< Attached mipmap level. */
3513 GLuint CubeMapFace
; /**< 0 .. 5, for cube map textures. */
3514 GLuint Zoffset
; /**< Slice for 3D textures, or layer for both 1D
3515 * and 2D array textures */
3521 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3522 * In C++ terms, think of this as a base class from which device drivers
3523 * will make derived classes.
3525 struct gl_framebuffer
3527 simple_mtx_t Mutex
; /**< for thread safety */
3529 * If zero, this is a window system framebuffer. If non-zero, this
3530 * is a FBO framebuffer; note that for some devices (i.e. those with
3531 * a natural pixel coordinate system for FBOs that differs from the
3532 * OpenGL/Mesa coordinate system), this means that the viewport,
3533 * polygon face orientation, and polygon stipple will have to be inverted.
3538 GLchar
*Label
; /**< GL_KHR_debug */
3540 GLboolean DeletePending
;
3543 * The framebuffer's visual. Immutable if this is a window system buffer.
3544 * Computed from attachments if user-made FBO.
3546 struct gl_config Visual
;
3549 * Size of frame buffer in pixels. If there are no attachments, then both
3552 GLuint Width
, Height
;
3555 * In the case that the framebuffer has no attachment (i.e.
3556 * GL_ARB_framebuffer_no_attachments) then the geometry of
3557 * the framebuffer is specified by the default values.
3560 GLuint Width
, Height
, Layers
, NumSamples
;
3561 GLboolean FixedSampleLocations
;
3562 /* Derived from NumSamples by the driver so that it can choose a valid
3563 * value for the hardware.
3568 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3569 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3570 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3577 /** \name Derived Z buffer stuff */
3579 GLuint _DepthMax
; /**< Max depth buffer value */
3580 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
3581 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
3584 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3587 /** Whether one of Attachment has Type != GL_NONE
3588 * NOTE: the values for Width and Height are set to 0 in case of having
3589 * no attachments, a backend driver supporting the extension
3590 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3591 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3592 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3593 * _Ymax do NOT take into account _HasAttachments being false). To get the
3594 * geometry of the framebuffer, the helper functions
3595 * _mesa_geometric_width(),
3596 * _mesa_geometric_height(),
3597 * _mesa_geometric_samples() and
3598 * _mesa_geometric_layers()
3599 * are available that check _HasAttachments.
3601 bool _HasAttachments
;
3603 GLbitfield _IntegerBuffers
; /**< Which color buffers are integer valued */
3605 /* ARB_color_buffer_float */
3606 GLboolean _AllColorBuffersFixedPoint
; /* no integer, no float */
3607 GLboolean _HasSNormOrFloatColorBuffer
;
3610 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3611 * is not layered. For cube maps and cube map arrays, each cube face
3612 * counts as a layer. As the case for Width, Height a backend driver
3613 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3614 * in the case that _HasAttachments is false
3616 GLuint MaxNumLayers
;
3618 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3619 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
3621 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3622 * attribute group and GL_PIXEL attribute group, respectively.
3624 GLenum16 ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
3625 GLenum16 ColorReadBuffer
;
3627 /** Computed from ColorDraw/ReadBuffer above */
3628 GLuint _NumColorDrawBuffers
;
3629 gl_buffer_index _ColorDrawBufferIndexes
[MAX_DRAW_BUFFERS
];
3630 gl_buffer_index _ColorReadBufferIndex
;
3631 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
];
3632 struct gl_renderbuffer
*_ColorReadBuffer
;
3634 /** Delete this framebuffer */
3635 void (*Delete
)(struct gl_framebuffer
*fb
);
3640 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3644 GLushort RangeMin
; /**< min value exponent */
3645 GLushort RangeMax
; /**< max value exponent */
3646 GLushort Precision
; /**< number of mantissa bits */
3651 * Limits for vertex, geometry and fragment programs/shaders.
3653 struct gl_program_constants
3655 /* logical limits */
3656 GLuint MaxInstructions
;
3657 GLuint MaxAluInstructions
;
3658 GLuint MaxTexInstructions
;
3659 GLuint MaxTexIndirections
;
3662 GLuint MaxAddressRegs
;
3663 GLuint MaxAddressOffset
; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3664 GLuint MaxParameters
;
3665 GLuint MaxLocalParams
;
3666 GLuint MaxEnvParams
;
3667 /* native/hardware limits */
3668 GLuint MaxNativeInstructions
;
3669 GLuint MaxNativeAluInstructions
;
3670 GLuint MaxNativeTexInstructions
;
3671 GLuint MaxNativeTexIndirections
;
3672 GLuint MaxNativeAttribs
;
3673 GLuint MaxNativeTemps
;
3674 GLuint MaxNativeAddressRegs
;
3675 GLuint MaxNativeParameters
;
3677 GLuint MaxUniformComponents
; /**< Usually == MaxParameters * 4 */
3680 * \name Per-stage input / output limits
3682 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3683 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3684 * ES). This is stored as \c gl_constants::MaxVarying.
3686 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3687 * variables. Each stage as a certain number of outputs that it can feed
3688 * to the next stage and a certain number inputs that it can consume from
3689 * the previous stage.
3691 * Vertex shader inputs do not participate this in this accounting.
3692 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3694 * Fragment shader outputs do not participate this in this accounting.
3695 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3698 GLuint MaxInputComponents
;
3699 GLuint MaxOutputComponents
;
3702 /* ES 2.0 and GL_ARB_ES2_compatibility */
3703 struct gl_precision LowFloat
, MediumFloat
, HighFloat
;
3704 struct gl_precision LowInt
, MediumInt
, HighInt
;
3705 /* GL_ARB_uniform_buffer_object */
3706 GLuint MaxUniformBlocks
;
3707 GLuint MaxCombinedUniformComponents
;
3708 GLuint MaxTextureImageUnits
;
3710 /* GL_ARB_shader_atomic_counters */
3711 GLuint MaxAtomicBuffers
;
3712 GLuint MaxAtomicCounters
;
3714 /* GL_ARB_shader_image_load_store */
3715 GLuint MaxImageUniforms
;
3717 /* GL_ARB_shader_storage_buffer_object */
3718 GLuint MaxShaderStorageBlocks
;
3722 * Constants which may be overridden by device driver during context creation
3723 * but are never changed after that.
3727 GLuint MaxTextureMbytes
; /**< Max memory per image, in MB */
3728 GLuint MaxTextureLevels
; /**< Max mipmap levels. */
3729 GLuint Max3DTextureLevels
; /**< Max mipmap levels for 3D textures */
3730 GLuint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
3731 GLuint MaxArrayTextureLayers
; /**< Max layers in array textures */
3732 GLuint MaxTextureRectSize
; /**< Max rectangle texture size, in pixes */
3733 GLuint MaxTextureCoordUnits
;
3734 GLuint MaxCombinedTextureImageUnits
;
3735 GLuint MaxTextureUnits
; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3736 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
3737 GLfloat MaxTextureLodBias
; /**< GL_EXT_texture_lod_bias */
3738 GLuint MaxTextureBufferSize
; /**< GL_ARB_texture_buffer_object */
3740 GLuint TextureBufferOffsetAlignment
; /**< GL_ARB_texture_buffer_range */
3742 GLuint MaxArrayLockSize
;
3746 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
3747 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
3748 GLfloat PointSizeGranularity
;
3749 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
3750 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
3751 GLfloat LineWidthGranularity
;
3753 GLuint MaxClipPlanes
;
3755 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
3756 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
3758 GLuint MaxViewportWidth
, MaxViewportHeight
;
3759 GLuint MaxViewports
; /**< GL_ARB_viewport_array */
3760 GLuint ViewportSubpixelBits
; /**< GL_ARB_viewport_array */
3764 } ViewportBounds
; /**< GL_ARB_viewport_array */
3765 GLuint MaxWindowRectangles
; /**< GL_EXT_window_rectangles */
3767 struct gl_program_constants Program
[MESA_SHADER_STAGES
];
3768 GLuint MaxProgramMatrices
;
3769 GLuint MaxProgramMatrixStackDepth
;
3772 GLuint SamplesPassed
;
3775 GLuint PrimitivesGenerated
;
3776 GLuint PrimitivesWritten
;
3777 GLuint VerticesSubmitted
;
3778 GLuint PrimitivesSubmitted
;
3779 GLuint VsInvocations
;
3781 GLuint TessInvocations
;
3782 GLuint GsInvocations
;
3783 GLuint GsPrimitives
;
3784 GLuint FsInvocations
;
3785 GLuint ComputeInvocations
;
3786 GLuint ClInPrimitives
;
3787 GLuint ClOutPrimitives
;
3790 GLuint MaxDrawBuffers
; /**< GL_ARB_draw_buffers */
3792 GLuint MaxColorAttachments
; /**< GL_EXT_framebuffer_object */
3793 GLuint MaxRenderbufferSize
; /**< GL_EXT_framebuffer_object */
3794 GLuint MaxSamples
; /**< GL_ARB_framebuffer_object */
3797 * GL_ARB_framebuffer_no_attachments
3799 GLuint MaxFramebufferWidth
;
3800 GLuint MaxFramebufferHeight
;
3801 GLuint MaxFramebufferLayers
;
3802 GLuint MaxFramebufferSamples
;
3804 /** Number of varying vectors between any two shader stages. */
3808 * GL_ARB_uniform_buffer_object
3810 GLuint MaxCombinedUniformBlocks
;
3811 GLuint MaxUniformBufferBindings
;
3812 GLuint MaxUniformBlockSize
;
3813 GLuint UniformBufferOffsetAlignment
;
3817 * GL_ARB_shader_storage_buffer_object
3819 GLuint MaxCombinedShaderStorageBlocks
;
3820 GLuint MaxShaderStorageBufferBindings
;
3821 GLuint MaxShaderStorageBlockSize
;
3822 GLuint ShaderStorageBufferOffsetAlignment
;
3826 * GL_ARB_explicit_uniform_location
3828 GLuint MaxUserAssignableUniformLocations
;
3830 /** geometry shader */
3831 GLuint MaxGeometryOutputVertices
;
3832 GLuint MaxGeometryTotalOutputComponents
;
3834 GLuint GLSLVersion
; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3837 * Changes default GLSL extension behavior from "error" to "warn". It's out
3838 * of spec, but it can make some apps work that otherwise wouldn't.
3840 GLboolean ForceGLSLExtensionsWarn
;
3843 * If non-zero, forces GLSL shaders to behave as if they began
3844 * with "#version ForceGLSLVersion".
3846 GLuint ForceGLSLVersion
;
3849 * Allow GLSL #extension directives in the middle of shaders.
3851 GLboolean AllowGLSLExtensionDirectiveMidShader
;
3854 * Allow GLSL built-in variables to be redeclared verbatim
3856 GLboolean AllowGLSLBuiltinVariableRedeclaration
;
3859 * Allow GLSL interpolation qualifier mismatch across shader stages.
3861 GLboolean AllowGLSLCrossStageInterpolationMismatch
;
3864 * Allow creating a higher compat profile (version 3.1+) for apps that
3865 * request it. Be careful when adding that driconf option because some
3866 * features are unimplemented and might not work correctly.
3868 GLboolean AllowHigherCompatVersion
;
3871 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3872 * D3D9 when apps rely on this behaviour.
3874 GLboolean ForceGLSLAbsSqrt
;
3877 * Force uninitialized variables to default to zero.
3879 GLboolean GLSLZeroInit
;
3882 * Does the driver support real 32-bit integers? (Otherwise, integers are
3883 * simulated via floats.)
3885 GLboolean NativeIntegers
;
3888 * Does VertexID count from zero or from base vertex?
3891 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3892 * ignored and need not be set.
3894 bool VertexID_is_zero_based
;
3897 * If the driver supports real 32-bit integers, what integer value should be
3898 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3900 GLuint UniformBooleanTrue
;
3903 * Maximum amount of time, measured in nanseconds, that the server can wait.
3905 GLuint64 MaxServerWaitTimeout
;
3907 /** GL_EXT_provoking_vertex */
3908 GLboolean QuadsFollowProvokingVertexConvention
;
3910 /** GL_ARB_viewport_array */
3911 GLenum16 LayerAndVPIndexProvokingVertex
;
3913 /** OpenGL version 3.0 */
3914 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3916 /** OpenGL version 3.2 */
3917 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
3919 /** OpenGL version 4.4 */
3920 GLuint MaxVertexAttribStride
;
3922 /** GL_EXT_transform_feedback */
3923 GLuint MaxTransformFeedbackBuffers
;
3924 GLuint MaxTransformFeedbackSeparateComponents
;
3925 GLuint MaxTransformFeedbackInterleavedComponents
;
3926 GLuint MaxVertexStreams
;
3928 /** GL_EXT_gpu_shader4 */
3929 GLint MinProgramTexelOffset
, MaxProgramTexelOffset
;
3931 /** GL_ARB_texture_gather */
3932 GLuint MinProgramTextureGatherOffset
;
3933 GLuint MaxProgramTextureGatherOffset
;
3934 GLuint MaxProgramTextureGatherComponents
;
3936 /* GL_ARB_robustness */
3937 GLenum16 ResetStrategy
;
3939 /* GL_KHR_robustness */
3940 GLboolean RobustAccess
;
3942 /* GL_ARB_blend_func_extended */
3943 GLuint MaxDualSourceDrawBuffers
;
3946 * Whether the implementation strips out and ignores texture borders.
3948 * Many GPU hardware implementations don't support rendering with texture
3949 * borders and mipmapped textures. (Note: not static border color, but the
3950 * old 1-pixel border around each edge). Implementations then have to do
3951 * slow fallbacks to be correct, or just ignore the border and be fast but
3952 * wrong. Setting the flag strips the border off of TexImage calls,
3953 * providing "fast but wrong" at significantly reduced driver complexity.
3955 * Texture borders are deprecated in GL 3.0.
3957 GLboolean StripTextureBorder
;
3960 * For drivers which can do a better job at eliminating unused uniforms
3961 * than the GLSL compiler.
3963 * XXX Remove these as soon as a better solution is available.
3965 GLboolean GLSLSkipStrictMaxUniformLimitCheck
;
3967 /** Whether gl_FragCoord and gl_FrontFacing are system values. */
3968 bool GLSLFragCoordIsSysVal
;
3969 bool GLSLFrontFacingIsSysVal
;
3972 * Run the minimum amount of GLSL optimizations to be able to link
3973 * shaders optimally (eliminate dead varyings and uniforms) and just do
3974 * all the necessary lowering.
3976 bool GLSLOptimizeConservatively
;
3979 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3980 * (otherwise, they're system values).
3982 bool GLSLTessLevelsAsInputs
;
3985 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3986 * than passing the transform feedback object to the drawing function.
3988 GLboolean AlwaysUseGetTransformFeedbackVertexCount
;
3990 /** GL_ARB_map_buffer_alignment */
3991 GLuint MinMapBufferAlignment
;
3994 * Disable varying packing. This is out of spec, but potentially useful
3995 * for older platforms that supports a limited number of texture
3996 * indirections--on these platforms, unpacking the varyings in the fragment
3997 * shader increases the number of texture indirections by 1, which might
3998 * make some shaders not executable at all.
4000 * Drivers that support transform feedback must set this value to GL_FALSE.
4002 GLboolean DisableVaryingPacking
;
4005 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
4006 * layout is set as shared (the default) or packed. However most Mesa drivers
4007 * just use STD140 for these layouts. This flag allows drivers to use STD430
4008 * for packed and shared layouts which allows arrays to be packed more
4011 bool UseSTD430AsDefaultPacking
;
4014 * Should meaningful names be generated for compiler temporary variables?
4016 * Generally, it is not useful to have the compiler generate "meaningful"
4017 * names for temporary variables that it creates. This can, however, be a
4018 * useful debugging aid. In Mesa debug builds or release builds when
4019 * MESA_GLSL is set at run-time, meaningful names will be generated.
4020 * Drivers can also force names to be generated by setting this field.
4021 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
4022 * vertex shader assembly) is set at run-time.
4024 bool GenerateTemporaryNames
;
4027 * Maximum value supported for an index in DrawElements and friends.
4029 * This must be at least (1ull<<24)-1. The default value is
4032 * \since ES 3.0 or GL_ARB_ES3_compatibility
4033 * \sa _mesa_init_constants
4035 GLuint64 MaxElementIndex
;
4038 * Disable interpretation of line continuations (lines ending with a
4039 * backslash character ('\') in GLSL source.
4041 GLboolean DisableGLSLLineContinuations
;
4043 /** GL_ARB_texture_multisample */
4044 GLint MaxColorTextureSamples
;
4045 GLint MaxDepthTextureSamples
;
4046 GLint MaxIntegerSamples
;
4049 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
4050 * samples are laid out in a rectangular grid roughly corresponding to
4051 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
4052 * are used to map indices of rectangular grid to sample numbers within
4053 * a pixel. This mapping of indices to sample numbers must be initialized
4054 * by the driver for the target hardware. For example, if we have the 8X
4055 * MSAA sample number layout (sample positions) for XYZ hardware:
4057 * sample indices layout sample number layout
4058 * --------- ---------
4059 * | 0 | 1 | | a | b |
4060 * --------- ---------
4061 * | 2 | 3 | | c | d |
4062 * --------- ---------
4063 * | 4 | 5 | | e | f |
4064 * --------- ---------
4065 * | 6 | 7 | | g | h |
4066 * --------- ---------
4068 * Where a,b,c,d,e,f,g,h are integers between [0-7].
4070 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
4072 * SampleMap8x = {a, b, c, d, e, f, g, h};
4074 * Follow the logic for sample counts 2-8.
4076 * For 16x the sample indices layout as a 4x4 grid as follows:
4088 uint8_t SampleMap2x
[2];
4089 uint8_t SampleMap4x
[4];
4090 uint8_t SampleMap8x
[8];
4091 uint8_t SampleMap16x
[16];
4093 /** GL_ARB_shader_atomic_counters */
4094 GLuint MaxAtomicBufferBindings
;
4095 GLuint MaxAtomicBufferSize
;
4096 GLuint MaxCombinedAtomicBuffers
;
4097 GLuint MaxCombinedAtomicCounters
;
4099 /** GL_ARB_vertex_attrib_binding */
4100 GLint MaxVertexAttribRelativeOffset
;
4101 GLint MaxVertexAttribBindings
;
4103 /* GL_ARB_shader_image_load_store */
4104 GLuint MaxImageUnits
;
4105 GLuint MaxCombinedShaderOutputResources
;
4106 GLuint MaxImageSamples
;
4107 GLuint MaxCombinedImageUniforms
;
4109 /** GL_ARB_compute_shader */
4110 GLuint MaxComputeWorkGroupCount
[3]; /* Array of x, y, z dimensions */
4111 GLuint MaxComputeWorkGroupSize
[3]; /* Array of x, y, z dimensions */
4112 GLuint MaxComputeWorkGroupInvocations
;
4113 GLuint MaxComputeSharedMemorySize
;
4115 /** GL_ARB_compute_variable_group_size */
4116 GLuint MaxComputeVariableGroupSize
[3]; /* Array of x, y, z dimensions */
4117 GLuint MaxComputeVariableGroupInvocations
;
4119 /** GL_ARB_gpu_shader5 */
4120 GLfloat MinFragmentInterpolationOffset
;
4121 GLfloat MaxFragmentInterpolationOffset
;
4123 GLboolean FakeSWMSAA
;
4125 /** GL_KHR_context_flush_control */
4126 GLenum16 ContextReleaseBehavior
;
4128 struct gl_shader_compiler_options ShaderCompilerOptions
[MESA_SHADER_STAGES
];
4130 /** GL_ARB_tessellation_shader */
4131 GLuint MaxPatchVertices
;
4132 GLuint MaxTessGenLevel
;
4133 GLuint MaxTessPatchComponents
;
4134 GLuint MaxTessControlTotalOutputComponents
;
4135 bool LowerTessLevel
; /**< Lower gl_TessLevel* from float[n] to vecn? */
4136 bool PrimitiveRestartForPatches
;
4137 bool LowerCsDerivedVariables
; /**< Lower gl_GlobalInvocationID and
4138 * gl_LocalInvocationIndex based on
4139 * other builtin variables. */
4141 /** GL_OES_primitive_bounding_box */
4142 bool NoPrimitiveBoundingBoxOutput
;
4144 /** GL_ARB_sparse_buffer */
4145 GLuint SparseBufferPageSize
;
4147 /** Used as an input for sha1 generation in the on-disk shader cache */
4148 unsigned char *dri_config_options_sha1
;
4150 /** When drivers are OK with mapped buffers during draw and other calls. */
4151 bool AllowMappedBuffersDuringExecution
;
4153 /** GL_ARB_get_program_binary */
4154 GLuint NumProgramBinaryFormats
;
4159 * Enable flag for each OpenGL extension. Different device drivers will
4160 * enable different extensions at runtime.
4162 struct gl_extensions
4164 GLboolean dummy
; /* don't remove this! */
4165 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
4166 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
4167 GLboolean ANGLE_texture_compression_dxt
;
4168 GLboolean ARB_ES2_compatibility
;
4169 GLboolean ARB_ES3_compatibility
;
4170 GLboolean ARB_ES3_1_compatibility
;
4171 GLboolean ARB_ES3_2_compatibility
;
4172 GLboolean ARB_arrays_of_arrays
;
4173 GLboolean ARB_base_instance
;
4174 GLboolean ARB_bindless_texture
;
4175 GLboolean ARB_blend_func_extended
;
4176 GLboolean ARB_buffer_storage
;
4177 GLboolean ARB_clear_texture
;
4178 GLboolean ARB_clip_control
;
4179 GLboolean ARB_color_buffer_float
;
4180 GLboolean ARB_compatibility
;
4181 GLboolean ARB_compute_shader
;
4182 GLboolean ARB_compute_variable_group_size
;
4183 GLboolean ARB_conditional_render_inverted
;
4184 GLboolean ARB_conservative_depth
;
4185 GLboolean ARB_copy_image
;
4186 GLboolean ARB_cull_distance
;
4187 GLboolean ARB_depth_buffer_float
;
4188 GLboolean ARB_depth_clamp
;
4189 GLboolean ARB_depth_texture
;
4190 GLboolean ARB_derivative_control
;
4191 GLboolean ARB_draw_buffers_blend
;
4192 GLboolean ARB_draw_elements_base_vertex
;
4193 GLboolean ARB_draw_indirect
;
4194 GLboolean ARB_draw_instanced
;
4195 GLboolean ARB_fragment_coord_conventions
;
4196 GLboolean ARB_fragment_layer_viewport
;
4197 GLboolean ARB_fragment_program
;
4198 GLboolean ARB_fragment_program_shadow
;
4199 GLboolean ARB_fragment_shader
;
4200 GLboolean ARB_framebuffer_no_attachments
;
4201 GLboolean ARB_framebuffer_object
;
4202 GLboolean ARB_enhanced_layouts
;
4203 GLboolean ARB_explicit_attrib_location
;
4204 GLboolean ARB_explicit_uniform_location
;
4205 GLboolean ARB_gl_spirv
;
4206 GLboolean ARB_gpu_shader5
;
4207 GLboolean ARB_gpu_shader_fp64
;
4208 GLboolean ARB_gpu_shader_int64
;
4209 GLboolean ARB_half_float_vertex
;
4210 GLboolean ARB_indirect_parameters
;
4211 GLboolean ARB_instanced_arrays
;
4212 GLboolean ARB_internalformat_query
;
4213 GLboolean ARB_internalformat_query2
;
4214 GLboolean ARB_map_buffer_range
;
4215 GLboolean ARB_occlusion_query
;
4216 GLboolean ARB_occlusion_query2
;
4217 GLboolean ARB_pipeline_statistics_query
;
4218 GLboolean ARB_point_sprite
;
4219 GLboolean ARB_polygon_offset_clamp
;
4220 GLboolean ARB_post_depth_coverage
;
4221 GLboolean ARB_query_buffer_object
;
4222 GLboolean ARB_robust_buffer_access_behavior
;
4223 GLboolean ARB_sample_shading
;
4224 GLboolean ARB_seamless_cube_map
;
4225 GLboolean ARB_shader_atomic_counter_ops
;
4226 GLboolean ARB_shader_atomic_counters
;
4227 GLboolean ARB_shader_ballot
;
4228 GLboolean ARB_shader_bit_encoding
;
4229 GLboolean ARB_shader_clock
;
4230 GLboolean ARB_shader_draw_parameters
;
4231 GLboolean ARB_shader_group_vote
;
4232 GLboolean ARB_shader_image_load_store
;
4233 GLboolean ARB_shader_image_size
;
4234 GLboolean ARB_shader_precision
;
4235 GLboolean ARB_shader_stencil_export
;
4236 GLboolean ARB_shader_storage_buffer_object
;
4237 GLboolean ARB_shader_texture_image_samples
;
4238 GLboolean ARB_shader_texture_lod
;
4239 GLboolean ARB_shader_viewport_layer_array
;
4240 GLboolean ARB_shading_language_packing
;
4241 GLboolean ARB_shading_language_420pack
;
4242 GLboolean ARB_shadow
;
4243 GLboolean ARB_sparse_buffer
;
4244 GLboolean ARB_stencil_texturing
;
4246 GLboolean ARB_tessellation_shader
;
4247 GLboolean ARB_texture_border_clamp
;
4248 GLboolean ARB_texture_buffer_object
;
4249 GLboolean ARB_texture_buffer_object_rgb32
;
4250 GLboolean ARB_texture_buffer_range
;
4251 GLboolean ARB_texture_compression_bptc
;
4252 GLboolean ARB_texture_compression_rgtc
;
4253 GLboolean ARB_texture_cube_map
;
4254 GLboolean ARB_texture_cube_map_array
;
4255 GLboolean ARB_texture_env_combine
;
4256 GLboolean ARB_texture_env_crossbar
;
4257 GLboolean ARB_texture_env_dot3
;
4258 GLboolean ARB_texture_filter_anisotropic
;
4259 GLboolean ARB_texture_float
;
4260 GLboolean ARB_texture_gather
;
4261 GLboolean ARB_texture_mirror_clamp_to_edge
;
4262 GLboolean ARB_texture_multisample
;
4263 GLboolean ARB_texture_non_power_of_two
;
4264 GLboolean ARB_texture_stencil8
;
4265 GLboolean ARB_texture_query_levels
;
4266 GLboolean ARB_texture_query_lod
;
4267 GLboolean ARB_texture_rg
;
4268 GLboolean ARB_texture_rgb10_a2ui
;
4269 GLboolean ARB_texture_view
;
4270 GLboolean ARB_timer_query
;
4271 GLboolean ARB_transform_feedback2
;
4272 GLboolean ARB_transform_feedback3
;
4273 GLboolean ARB_transform_feedback_instanced
;
4274 GLboolean ARB_transform_feedback_overflow_query
;
4275 GLboolean ARB_uniform_buffer_object
;
4276 GLboolean ARB_vertex_attrib_64bit
;
4277 GLboolean ARB_vertex_program
;
4278 GLboolean ARB_vertex_shader
;
4279 GLboolean ARB_vertex_type_10f_11f_11f_rev
;
4280 GLboolean ARB_vertex_type_2_10_10_10_rev
;
4281 GLboolean ARB_viewport_array
;
4282 GLboolean EXT_blend_color
;
4283 GLboolean EXT_blend_equation_separate
;
4284 GLboolean EXT_blend_func_separate
;
4285 GLboolean EXT_blend_minmax
;
4286 GLboolean EXT_depth_bounds_test
;
4287 GLboolean EXT_disjoint_timer_query
;
4288 GLboolean EXT_draw_buffers2
;
4289 GLboolean EXT_framebuffer_multisample
;
4290 GLboolean EXT_framebuffer_multisample_blit_scaled
;
4291 GLboolean EXT_framebuffer_sRGB
;
4292 GLboolean EXT_gpu_program_parameters
;
4293 GLboolean EXT_gpu_shader4
;
4294 GLboolean EXT_memory_object
;
4295 GLboolean EXT_memory_object_fd
;
4296 GLboolean EXT_packed_float
;
4297 GLboolean EXT_pixel_buffer_object
;
4298 GLboolean EXT_point_parameters
;
4299 GLboolean EXT_provoking_vertex
;
4300 GLboolean EXT_semaphore
;
4301 GLboolean EXT_semaphore_fd
;
4302 GLboolean EXT_shader_integer_mix
;
4303 GLboolean EXT_shader_samples_identical
;
4304 GLboolean EXT_stencil_two_side
;
4305 GLboolean EXT_texture_array
;
4306 GLboolean EXT_texture_compression_latc
;
4307 GLboolean EXT_texture_compression_s3tc
;
4308 GLboolean EXT_texture_env_dot3
;
4309 GLboolean EXT_texture_filter_anisotropic
;
4310 GLboolean EXT_texture_integer
;
4311 GLboolean EXT_texture_mirror_clamp
;
4312 GLboolean EXT_texture_shared_exponent
;
4313 GLboolean EXT_texture_snorm
;
4314 GLboolean EXT_texture_sRGB
;
4315 GLboolean EXT_texture_sRGB_decode
;
4316 GLboolean EXT_texture_swizzle
;
4317 GLboolean EXT_texture_type_2_10_10_10_REV
;
4318 GLboolean EXT_transform_feedback
;
4319 GLboolean EXT_timer_query
;
4320 GLboolean EXT_vertex_array_bgra
;
4321 GLboolean EXT_window_rectangles
;
4322 GLboolean OES_copy_image
;
4323 GLboolean OES_primitive_bounding_box
;
4324 GLboolean OES_sample_variables
;
4325 GLboolean OES_standard_derivatives
;
4326 GLboolean OES_texture_buffer
;
4327 GLboolean OES_texture_cube_map_array
;
4328 GLboolean OES_viewport_array
;
4329 /* vendor extensions */
4330 GLboolean AMD_performance_monitor
;
4331 GLboolean AMD_pinned_memory
;
4332 GLboolean AMD_seamless_cubemap_per_texture
;
4333 GLboolean AMD_vertex_shader_layer
;
4334 GLboolean AMD_vertex_shader_viewport_index
;
4335 GLboolean ANDROID_extension_pack_es31a
;
4336 GLboolean APPLE_object_purgeable
;
4337 GLboolean ATI_meminfo
;
4338 GLboolean ATI_texture_compression_3dc
;
4339 GLboolean ATI_texture_mirror_once
;
4340 GLboolean ATI_texture_env_combine3
;
4341 GLboolean ATI_fragment_shader
;
4342 GLboolean ATI_separate_stencil
;
4343 GLboolean GREMEDY_string_marker
;
4344 GLboolean INTEL_conservative_rasterization
;
4345 GLboolean INTEL_performance_query
;
4346 GLboolean KHR_blend_equation_advanced
;
4347 GLboolean KHR_blend_equation_advanced_coherent
;
4348 GLboolean KHR_robustness
;
4349 GLboolean KHR_texture_compression_astc_hdr
;
4350 GLboolean KHR_texture_compression_astc_ldr
;
4351 GLboolean KHR_texture_compression_astc_sliced_3d
;
4352 GLboolean MESA_tile_raster_order
;
4353 GLboolean MESA_pack_invert
;
4354 GLboolean EXT_shader_framebuffer_fetch
;
4355 GLboolean EXT_shader_framebuffer_fetch_non_coherent
;
4356 GLboolean MESA_shader_integer_functions
;
4357 GLboolean MESA_ycbcr_texture
;
4358 GLboolean NV_conditional_render
;
4359 GLboolean NV_fill_rectangle
;
4360 GLboolean NV_fog_distance
;
4361 GLboolean NV_point_sprite
;
4362 GLboolean NV_primitive_restart
;
4363 GLboolean NV_texture_barrier
;
4364 GLboolean NV_texture_env_combine4
;
4365 GLboolean NV_texture_rectangle
;
4366 GLboolean NV_vdpau_interop
;
4367 GLboolean NVX_gpu_memory_info
;
4368 GLboolean TDFX_texture_compression_FXT1
;
4369 GLboolean OES_EGL_image
;
4370 GLboolean OES_draw_texture
;
4371 GLboolean OES_depth_texture_cube_map
;
4372 GLboolean OES_EGL_image_external
;
4373 GLboolean OES_texture_float
;
4374 GLboolean OES_texture_float_linear
;
4375 GLboolean OES_texture_half_float
;
4376 GLboolean OES_texture_half_float_linear
;
4377 GLboolean OES_compressed_ETC1_RGB8_texture
;
4378 GLboolean OES_geometry_shader
;
4379 GLboolean OES_texture_compression_astc
;
4380 GLboolean extension_sentinel
;
4381 /** The extension string */
4382 const GLubyte
*String
;
4383 /** Number of supported extensions */
4386 * The context version which extension helper functions compare against.
4387 * By default, the value is equal to ctx->Version. This changes to ~0
4388 * while meta is in progress.
4392 * Force-enabled, yet unrecognized, extensions.
4393 * See _mesa_one_time_init_extension_overrides()
4395 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4396 const char *unrecognized_extensions
[MAX_UNRECOGNIZED_EXTENSIONS
];
4401 * A stack of matrices (projection, modelview, color, texture, etc).
4403 struct gl_matrix_stack
4405 GLmatrix
*Top
; /**< points into Stack */
4406 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
4407 unsigned StackSize
; /**< Number of elements in Stack */
4408 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
4409 GLuint MaxDepth
; /**< size of Stack[] array */
4410 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4415 * \name Bits for image transfer operations
4416 * \sa __struct gl_contextRec::ImageTransferState.
4419 #define IMAGE_SCALE_BIAS_BIT 0x1
4420 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4421 #define IMAGE_MAP_COLOR_BIT 0x4
4422 #define IMAGE_CLAMP_BIT 0x800
4425 /** Pixel Transfer ops */
4426 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4427 IMAGE_SHIFT_OFFSET_BIT | \
4428 IMAGE_MAP_COLOR_BIT)
4432 * \name Bits to indicate what state has changed.
4435 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4436 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4437 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4438 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4439 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4440 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4441 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4442 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4443 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4444 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4445 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4446 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4447 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4448 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4449 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4450 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4451 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4452 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4453 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4454 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4455 #define _NEW_ARRAY (1u << 20) /**< gl_context::Array */
4456 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4457 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4458 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4459 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4460 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4461 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4462 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4464 #define _NEW_FRAG_CLAMP (1u << 29)
4465 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4466 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4472 * Composite state flags
4475 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4477 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4478 _NEW_TEXTURE_STATE | \
4483 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4493 /* This has to be included here. */
4497 /** Opaque declaration of display list payload data type */
4498 union gl_dlist_node
;
4502 * Per-display list information.
4504 struct gl_display_list
4507 GLbitfield Flags
; /**< DLIST_x flags */
4508 GLchar
*Label
; /**< GL_KHR_debug */
4509 /** The dlist commands are in a linked list of nodes */
4510 union gl_dlist_node
*Head
;
4515 * State used during display list compilation and execution.
4517 struct gl_dlist_state
4519 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
4520 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
4521 GLuint CurrentPos
; /**< Index into current block of nodes */
4522 GLuint CallDepth
; /**< Current recursion calling depth */
4524 GLvertexformat ListVtxfmt
;
4526 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
4527 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
4529 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
4530 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
4533 /* State known to have been set by the currently-compiling display
4534 * list. Used to eliminate some redundant state changes.
4536 GLenum16 ShadeModel
;
4542 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
4543 * to small enums suitable for use as an array index.
4546 enum mesa_debug_source
4548 MESA_DEBUG_SOURCE_API
,
4549 MESA_DEBUG_SOURCE_WINDOW_SYSTEM
,
4550 MESA_DEBUG_SOURCE_SHADER_COMPILER
,
4551 MESA_DEBUG_SOURCE_THIRD_PARTY
,
4552 MESA_DEBUG_SOURCE_APPLICATION
,
4553 MESA_DEBUG_SOURCE_OTHER
,
4554 MESA_DEBUG_SOURCE_COUNT
4557 enum mesa_debug_type
4559 MESA_DEBUG_TYPE_ERROR
,
4560 MESA_DEBUG_TYPE_DEPRECATED
,
4561 MESA_DEBUG_TYPE_UNDEFINED
,
4562 MESA_DEBUG_TYPE_PORTABILITY
,
4563 MESA_DEBUG_TYPE_PERFORMANCE
,
4564 MESA_DEBUG_TYPE_OTHER
,
4565 MESA_DEBUG_TYPE_MARKER
,
4566 MESA_DEBUG_TYPE_PUSH_GROUP
,
4567 MESA_DEBUG_TYPE_POP_GROUP
,
4568 MESA_DEBUG_TYPE_COUNT
4571 enum mesa_debug_severity
4573 MESA_DEBUG_SEVERITY_LOW
,
4574 MESA_DEBUG_SEVERITY_MEDIUM
,
4575 MESA_DEBUG_SEVERITY_HIGH
,
4576 MESA_DEBUG_SEVERITY_NOTIFICATION
,
4577 MESA_DEBUG_SEVERITY_COUNT
4583 * Driver-specific state flags.
4585 * These are or'd with gl_context::NewDriverState to notify a driver about
4586 * a state change. The driver sets the flags at context creation and
4587 * the meaning of the bits set is opaque to core Mesa.
4589 struct gl_driver_flags
4591 /** gl_context::Array::_DrawArrays (vertex array state) */
4594 /** gl_context::TransformFeedback::CurrentObject */
4595 uint64_t NewTransformFeedback
;
4597 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4598 uint64_t NewTransformFeedbackProg
;
4600 /** gl_context::RasterDiscard */
4601 uint64_t NewRasterizerDiscard
;
4603 /** gl_context::TileRasterOrder* */
4604 uint64_t NewTileRasterOrder
;
4607 * gl_context::UniformBufferBindings
4608 * gl_shader_program::UniformBlocks
4610 uint64_t NewUniformBuffer
;
4613 * gl_context::ShaderStorageBufferBindings
4614 * gl_shader_program::ShaderStorageBlocks
4616 uint64_t NewShaderStorageBuffer
;
4618 uint64_t NewTextureBuffer
;
4621 * gl_context::AtomicBufferBindings
4623 uint64_t NewAtomicBuffer
;
4626 * gl_context::ImageUnits
4628 uint64_t NewImageUnits
;
4631 * gl_context::TessCtrlProgram::patch_default_*
4633 uint64_t NewDefaultTessLevels
;
4636 * gl_context::IntelConservativeRasterization
4638 uint64_t NewIntelConservativeRasterization
;
4641 * gl_context::Scissor::WindowRects
4643 uint64_t NewWindowRectangles
;
4645 /** gl_context::Color::sRGBEnabled */
4646 uint64_t NewFramebufferSRGB
;
4648 /** gl_context::Scissor::EnableFlags */
4649 uint64_t NewScissorTest
;
4651 /** gl_context::Scissor::ScissorArray */
4652 uint64_t NewScissorRect
;
4654 /** gl_context::Color::Alpha* */
4655 uint64_t NewAlphaTest
;
4657 /** gl_context::Color::Blend/Dither */
4660 /** gl_context::Color::BlendColor */
4661 uint64_t NewBlendColor
;
4663 /** gl_context::Color::Color/Index */
4664 uint64_t NewColorMask
;
4666 /** gl_context::Depth */
4669 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4670 uint64_t NewLogicOp
;
4672 /** gl_context::Multisample::Enabled */
4673 uint64_t NewMultisampleEnable
;
4675 /** gl_context::Multisample::SampleAlphaTo* */
4676 uint64_t NewSampleAlphaToXEnable
;
4678 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4679 uint64_t NewSampleMask
;
4681 /** gl_context::Multisample::(Min)SampleShading */
4682 uint64_t NewSampleShading
;
4684 /** gl_context::Stencil */
4685 uint64_t NewStencil
;
4687 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4688 uint64_t NewClipControl
;
4690 /** gl_context::Transform::EyeUserPlane */
4691 uint64_t NewClipPlane
;
4693 /** gl_context::Transform::ClipPlanesEnabled */
4694 uint64_t NewClipPlaneEnable
;
4696 /** gl_context::Transform::DepthClamp */
4697 uint64_t NewDepthClamp
;
4699 /** gl_context::Line */
4700 uint64_t NewLineState
;
4702 /** gl_context::Polygon */
4703 uint64_t NewPolygonState
;
4705 /** gl_context::PolygonStipple */
4706 uint64_t NewPolygonStipple
;
4708 /** gl_context::ViewportArray */
4709 uint64_t NewViewport
;
4711 /** Shader constants (uniforms, program parameters, state constants) */
4712 uint64_t NewShaderConstants
[MESA_SHADER_STAGES
];
4715 struct gl_buffer_binding
4717 struct gl_buffer_object
*BufferObject
;
4718 /** Start of uniform block data in the buffer */
4720 /** Size of data allowed to be referenced from the buffer (in bytes) */
4723 * glBindBufferBase() indicates that the Size should be ignored and only
4724 * limited by the current size of the BufferObject.
4726 GLboolean AutomaticSize
;
4730 * ARB_shader_image_load_store image unit.
4732 struct gl_image_unit
4735 * Texture object bound to this unit.
4737 struct gl_texture_object
*TexObj
;
4740 * Level of the texture object bound to this unit.
4745 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4746 * GL_FALSE if only some specific layer of the texture is bound.
4752 * Layer of the texture object bound to this unit as specified by the
4758 * Layer of the texture object bound to this unit, or zero if
4764 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4765 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4770 * GL internal format that determines the interpretation of the
4771 * image memory when shader image operations are performed through
4777 * Mesa format corresponding to \c Format.
4779 mesa_format _ActualFormat
:16;
4783 * Shader subroutines storage
4785 struct gl_subroutine_index_binding
4791 struct gl_texture_handle_object
4793 struct gl_texture_object
*texObj
;
4794 struct gl_sampler_object
*sampObj
;
4798 struct gl_image_handle_object
4800 struct gl_image_unit imgObj
;
4804 struct gl_memory_object
4806 GLuint Name
; /**< hash table ID/name */
4807 GLboolean Immutable
; /**< denotes mutability state of parameters */
4808 GLboolean Dedicated
; /**< import memory from a dedicated allocation */
4811 struct gl_semaphore_object
4813 GLuint Name
; /**< hash table ID/name */
4817 * Mesa rendering context.
4819 * This is the central context data structure for Mesa. Almost all
4820 * OpenGL state is contained in this structure.
4821 * Think of this as a base class from which device drivers will derive
4826 /** State possibly shared with other contexts in the address space */
4827 struct gl_shared_state
*Shared
;
4829 /** \name API function pointer tables */
4834 * The current dispatch table for non-displaylist-saving execution, either
4835 * BeginEnd or OutsideBeginEnd
4837 struct _glapi_table
*Exec
;
4839 * The normal dispatch table for non-displaylist-saving, non-begin/end
4841 struct _glapi_table
*OutsideBeginEnd
;
4842 /** The dispatch table used between glNewList() and glEndList() */
4843 struct _glapi_table
*Save
;
4845 * The dispatch table used between glBegin() and glEnd() (outside of a
4846 * display list). Only valid functions between those two are set, which is
4847 * mostly just the set in a GLvertexformat struct.
4849 struct _glapi_table
*BeginEnd
;
4851 * Dispatch table for when a graphics reset has happened.
4853 struct _glapi_table
*ContextLost
;
4855 * Dispatch table used to marshal API calls from the client program to a
4856 * separate server thread. NULL if API calls are not being marshalled to
4859 struct _glapi_table
*MarshalExec
;
4861 * Dispatch table currently in use for fielding API calls from the client
4862 * program. If API calls are being marshalled to another thread, this ==
4863 * MarshalExec. Otherwise it == CurrentServerDispatch.
4865 struct _glapi_table
*CurrentClientDispatch
;
4868 * Dispatch table currently in use for performing API calls. == Save or
4871 struct _glapi_table
*CurrentServerDispatch
;
4875 struct glthread_state
*GLThread
;
4877 struct gl_config Visual
;
4878 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
4879 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
4880 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
4881 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
4884 * Device driver function pointer table
4886 struct dd_function_table Driver
;
4888 /** Core/Driver constants */
4889 struct gl_constants Const
;
4891 /** \name The various 4x4 matrix stacks */
4893 struct gl_matrix_stack ModelviewMatrixStack
;
4894 struct gl_matrix_stack ProjectionMatrixStack
;
4895 struct gl_matrix_stack TextureMatrixStack
[MAX_TEXTURE_UNITS
];
4896 struct gl_matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
4897 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
4900 /** Combined modelview and projection matrix */
4901 GLmatrix _ModelProjectMatrix
;
4903 /** \name Display lists */
4904 struct gl_dlist_state ListState
;
4906 GLboolean ExecuteFlag
; /**< Execute GL commands? */
4907 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
4909 /** Extension information */
4910 struct gl_extensions Extensions
;
4912 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4914 char *VersionString
;
4916 /** \name State attribute stack (for glPush/PopAttrib) */
4918 GLuint AttribStackDepth
;
4919 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
4922 /** \name Renderer attribute groups
4924 * We define a struct for each attribute group to make pushing and popping
4925 * attributes easy. Also it's a good organization.
4928 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
4929 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
4930 struct gl_current_attrib Current
; /**< Current attributes */
4931 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
4932 struct gl_eval_attrib Eval
; /**< Eval attributes */
4933 struct gl_fog_attrib Fog
; /**< Fog attributes */
4934 struct gl_hint_attrib Hint
; /**< Hint attributes */
4935 struct gl_light_attrib Light
; /**< Light attributes */
4936 struct gl_line_attrib Line
; /**< Line attributes */
4937 struct gl_list_attrib List
; /**< List attributes */
4938 struct gl_multisample_attrib Multisample
;
4939 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
4940 struct gl_point_attrib Point
; /**< Point attributes */
4941 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
4942 GLuint PolygonStipple
[32]; /**< Polygon stipple */
4943 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
4944 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
4945 struct gl_texture_attrib Texture
; /**< Texture attributes */
4946 struct gl_transform_attrib Transform
; /**< Transformation attributes */
4947 struct gl_viewport_attrib ViewportArray
[MAX_VIEWPORTS
]; /**< Viewport attributes */
4950 /** \name Client attribute stack */
4952 GLuint ClientAttribStackDepth
;
4953 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
4956 /** \name Client attribute groups */
4958 struct gl_array_attrib Array
; /**< Vertex arrays */
4959 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
4960 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
4961 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
4964 /** \name Other assorted state (not pushed/popped on attribute stack) */
4966 struct gl_pixelmaps PixelMaps
;
4968 struct gl_evaluators EvalMap
; /**< All evaluators */
4969 struct gl_feedback Feedback
; /**< Feedback */
4970 struct gl_selection Select
; /**< Selection */
4972 struct gl_program_state Program
; /**< general program state */
4973 struct gl_vertex_program_state VertexProgram
;
4974 struct gl_fragment_program_state FragmentProgram
;
4975 struct gl_geometry_program_state GeometryProgram
;
4976 struct gl_compute_program_state ComputeProgram
;
4977 struct gl_tess_ctrl_program_state TessCtrlProgram
;
4978 struct gl_tess_eval_program_state TessEvalProgram
;
4979 struct gl_ati_fragment_shader_state ATIFragmentShader
;
4981 struct gl_pipeline_shader_state Pipeline
; /**< GLSL pipeline shader object state */
4982 struct gl_pipeline_object Shader
; /**< GLSL shader object state */
4985 * Current active shader pipeline state
4987 * Almost all internal users want ::_Shader instead of ::Shader. The
4988 * exceptions are bits of legacy GLSL API that do not know about separate
4991 * If a program is active via \c glUseProgram, this will point to
4994 * If a program pipeline is active via \c glBindProgramPipeline, this will
4995 * point to \c ::Pipeline.Current.
4997 * If neither a program nor a program pipeline is active, this will point to
4998 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
5001 struct gl_pipeline_object
*_Shader
;
5003 struct gl_query_state Query
; /**< occlusion, timer queries */
5005 struct gl_transform_feedback_state TransformFeedback
;
5007 struct gl_perf_monitor_state PerfMonitor
;
5008 struct gl_perf_query_state PerfQuery
;
5010 struct gl_buffer_object
*DrawIndirectBuffer
; /** < GL_ARB_draw_indirect */
5011 struct gl_buffer_object
*ParameterBuffer
; /** < GL_ARB_indirect_parameters */
5012 struct gl_buffer_object
*DispatchIndirectBuffer
; /** < GL_ARB_compute_shader */
5014 struct gl_buffer_object
*CopyReadBuffer
; /**< GL_ARB_copy_buffer */
5015 struct gl_buffer_object
*CopyWriteBuffer
; /**< GL_ARB_copy_buffer */
5017 struct gl_buffer_object
*QueryBuffer
; /**< GL_ARB_query_buffer_object */
5020 * Current GL_ARB_uniform_buffer_object binding referenced by
5021 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
5023 struct gl_buffer_object
*UniformBuffer
;
5026 * Current GL_ARB_shader_storage_buffer_object binding referenced by
5027 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
5029 struct gl_buffer_object
*ShaderStorageBuffer
;
5032 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
5033 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
5034 * associated with uniform blocks by glUniformBlockBinding()'s state in the
5037 struct gl_buffer_binding
5038 UniformBufferBindings
[MAX_COMBINED_UNIFORM_BUFFERS
];
5041 * Array of shader storage buffers for ARB_shader_storage_buffer_object
5042 * and GL 4.3. This is set up using glBindBufferRange() or
5043 * glBindBufferBase(). They are associated with shader storage blocks by
5044 * glShaderStorageBlockBinding()'s state in the shader program.
5046 struct gl_buffer_binding
5047 ShaderStorageBufferBindings
[MAX_COMBINED_SHADER_STORAGE_BUFFERS
];
5050 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
5053 struct gl_buffer_object
*AtomicBuffer
;
5056 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
5059 struct gl_buffer_object
*ExternalVirtualMemoryBuffer
;
5062 * Array of atomic counter buffer binding points.
5064 struct gl_buffer_binding
5065 AtomicBufferBindings
[MAX_COMBINED_ATOMIC_BUFFERS
];
5068 * Array of image units for ARB_shader_image_load_store.
5070 struct gl_image_unit ImageUnits
[MAX_IMAGE_UNITS
];
5072 struct gl_subroutine_index_binding SubroutineIndex
[MESA_SHADER_STAGES
];
5075 struct gl_meta_state
*Meta
; /**< for "meta" operations */
5077 /* GL_EXT_framebuffer_object */
5078 struct gl_renderbuffer
*CurrentRenderbuffer
;
5080 GLenum16 ErrorValue
; /**< Last error code */
5083 * Recognize and silence repeated error debug messages in buggy apps.
5085 const char *ErrorDebugFmtString
;
5086 GLuint ErrorDebugCount
;
5088 /* GL_ARB_debug_output/GL_KHR_debug */
5089 simple_mtx_t DebugMutex
;
5090 struct gl_debug_state
*Debug
;
5092 GLenum16 RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5093 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
5094 uint64_t NewDriverState
; /**< bitwise-or of flags from DriverFlags */
5096 struct gl_driver_flags DriverFlags
;
5098 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
5100 GLbitfield varying_vp_inputs
; /**< mask of VERT_BIT_* flags */
5102 /** \name Derived state */
5103 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
5104 GLfloat _EyeZDir
[3];
5105 GLfloat _ModelViewInvScale
; /* may be for model- or eyespace lighting */
5106 GLfloat _ModelViewInvScaleEyespace
; /* always factor defined in spec */
5107 GLboolean _NeedEyeCoords
;
5108 GLboolean _ForceEyeCoords
;
5110 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
5112 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
5114 /** \name For debugging/development only */
5116 GLboolean FirstTimeCurrent
;
5120 * False if this context was created without a config. This is needed
5121 * because the initial state of glDrawBuffers depends on this
5123 GLboolean HasConfig
;
5125 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
5127 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
5128 GLboolean IntelConservativeRasterization
; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
5130 /** Does glVertexAttrib(0) alias glVertex()? */
5131 bool _AttribZeroAliasesVertex
;
5134 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5135 * renderer's tiles should be excecuted, to meet the requirements of
5136 * GL_MESA_tile_raster_order.
5138 GLboolean TileRasterOrderFixed
;
5139 GLboolean TileRasterOrderIncreasingX
;
5140 GLboolean TileRasterOrderIncreasingY
;
5143 * \name Hooks for module contexts.
5145 * These will eventually live in the driver or elsewhere.
5148 void *swrast_context
;
5149 void *swsetup_context
;
5150 void *swtnl_context
;
5151 struct vbo_context
*vbo_context
;
5152 struct st_context
*st
;
5157 * \name NV_vdpau_interop
5160 const void *vdpDevice
;
5161 const void *vdpGetProcAddress
;
5162 struct set
*vdpSurfaces
;
5166 * Has this context observed a GPU reset in any context in the share group?
5168 * Once this field becomes true, it is never reset to false.
5170 GLboolean ShareGroupReset
;
5173 * \name OES_primitive_bounding_box
5175 * Stores the arguments to glPrimitiveBoundingBox
5177 GLfloat PrimitiveBoundingBox
[8];
5179 struct disk_cache
*Cache
;
5182 * \name GL_ARB_bindless_texture
5185 struct hash_table_u64
*ResidentTextureHandles
;
5186 struct hash_table_u64
*ResidentImageHandles
;
5191 * Information about memory usage. All sizes are in kilobytes.
5193 struct gl_memory_info
5195 unsigned total_device_memory
; /**< size of device memory, e.g. VRAM */
5196 unsigned avail_device_memory
; /**< free device memory at the moment */
5197 unsigned total_staging_memory
; /**< size of staging memory, e.g. GART */
5198 unsigned avail_staging_memory
; /**< free staging memory at the moment */
5199 unsigned device_memory_evicted
; /**< size of memory evicted (monotonic counter) */
5200 unsigned nr_device_memory_evictions
; /**< # of evictions (monotonic counter) */
5204 extern int MESA_VERBOSE
;
5205 extern int MESA_DEBUG_FLAGS
;
5207 # define MESA_VERBOSE 0
5208 # define MESA_DEBUG_FLAGS 0
5212 /** The MESA_VERBOSE var is a bitmask of these flags */
5215 VERBOSE_VARRAY
= 0x0001,
5216 VERBOSE_TEXTURE
= 0x0002,
5217 VERBOSE_MATERIAL
= 0x0004,
5218 VERBOSE_PIPELINE
= 0x0008,
5219 VERBOSE_DRIVER
= 0x0010,
5220 VERBOSE_STATE
= 0x0020,
5221 VERBOSE_API
= 0x0040,
5222 VERBOSE_DISPLAY_LIST
= 0x0100,
5223 VERBOSE_LIGHTING
= 0x0200,
5224 VERBOSE_PRIMS
= 0x0400,
5225 VERBOSE_VERTS
= 0x0800,
5226 VERBOSE_DISASSEM
= 0x1000,
5227 VERBOSE_DRAW
= 0x2000,
5228 VERBOSE_SWAPBUFFERS
= 0x4000
5232 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5235 DEBUG_SILENT
= (1 << 0),
5236 DEBUG_ALWAYS_FLUSH
= (1 << 1),
5237 DEBUG_INCOMPLETE_TEXTURE
= (1 << 2),
5238 DEBUG_INCOMPLETE_FBO
= (1 << 3),
5239 DEBUG_CONTEXT
= (1 << 4)
5246 #endif /* MTYPES_H */