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/glthread.h"
43 #include "main/menums.h"
44 #include "main/config.h"
45 #include "glapi/glapi.h"
46 #include "math/m_matrix.h" /* GLmatrix */
47 #include "compiler/shader_enums.h"
48 #include "compiler/shader_info.h"
49 #include "main/formats.h" /* MESA_FORMAT_COUNT */
50 #include "compiler/glsl/list.h"
51 #include "util/simple_mtx.h"
52 #include "util/u_dynarray.h"
59 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
60 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
64 * \name Some forward type declarations
67 struct _mesa_HashTable
;
68 struct gl_attrib_node
;
69 struct gl_list_extensions
;
71 struct gl_program_cache
;
72 struct gl_texture_object
;
73 struct gl_debug_state
;
76 struct gl_uniform_storage
;
77 struct prog_instruction
;
78 struct gl_program_parameter_list
;
79 struct gl_shader_spirv_data
;
81 struct shader_includes
;
86 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
87 #define PRIM_MAX GL_PATCHES
88 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
89 #define PRIM_UNKNOWN (PRIM_MAX + 2)
92 * Determine if the given gl_varying_slot appears in the fragment shader.
94 static inline GLboolean
95 _mesa_varying_slot_in_fs(gl_varying_slot slot
)
98 case VARYING_SLOT_PSIZ
:
99 case VARYING_SLOT_BFC0
:
100 case VARYING_SLOT_BFC1
:
101 case VARYING_SLOT_EDGE
:
102 case VARYING_SLOT_CLIP_VERTEX
:
103 case VARYING_SLOT_LAYER
:
104 case VARYING_SLOT_TESS_LEVEL_OUTER
:
105 case VARYING_SLOT_TESS_LEVEL_INNER
:
106 case VARYING_SLOT_BOUNDING_BOX0
:
107 case VARYING_SLOT_BOUNDING_BOX1
:
115 * Bit flags for all renderbuffers
117 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
118 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
119 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
120 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
121 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
122 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
123 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
124 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
125 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
126 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
127 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
128 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
129 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
130 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
131 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
132 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
133 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
134 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
135 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
138 * Mask of all the color buffer bits (but not accum).
140 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
141 BUFFER_BIT_BACK_LEFT | \
142 BUFFER_BIT_FRONT_RIGHT | \
143 BUFFER_BIT_BACK_RIGHT | \
145 BUFFER_BIT_COLOR0 | \
146 BUFFER_BIT_COLOR1 | \
147 BUFFER_BIT_COLOR2 | \
148 BUFFER_BIT_COLOR3 | \
149 BUFFER_BIT_COLOR4 | \
150 BUFFER_BIT_COLOR5 | \
151 BUFFER_BIT_COLOR6 | \
154 /* Mask of bits for depth+stencil buffers */
155 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
158 * Framebuffer configuration (aka visual / pixelformat)
159 * Note: some of these fields should be boolean, but it appears that
160 * code in drivers/dri/common/util.c requires int-sized fields.
165 GLuint doubleBufferMode
;
168 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
169 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
170 GLint redShift
, greenShift
, blueShift
, alphaShift
;
171 GLint rgbBits
; /* total bits for rgb */
173 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
181 /* EXT_visual_rating / GLX 1.2 */
184 /* EXT_visual_info / GLX 1.2 */
185 GLint transparentPixel
;
186 /* colors are floats scaled to ints */
187 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
188 GLint transparentIndex
;
190 /* ARB_multisample / SGIS_multisample */
194 /* SGIX_pbuffer / GLX 1.3 */
195 GLint maxPbufferWidth
;
196 GLint maxPbufferHeight
;
197 GLint maxPbufferPixels
;
198 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
199 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
201 /* OML_swap_method */
204 /* EXT_texture_from_pixmap */
205 GLint bindToTextureRgb
;
206 GLint bindToTextureRgba
;
207 GLint bindToMipmapTexture
;
208 GLint bindToTextureTargets
;
211 /* EXT_framebuffer_sRGB */
214 /* EGL_KHR_mutable_render_buffer */
215 GLuint mutableRenderBuffer
; /* bool */
220 * \name Bit flags used for updating material values.
223 #define MAT_ATTRIB_FRONT_AMBIENT 0
224 #define MAT_ATTRIB_BACK_AMBIENT 1
225 #define MAT_ATTRIB_FRONT_DIFFUSE 2
226 #define MAT_ATTRIB_BACK_DIFFUSE 3
227 #define MAT_ATTRIB_FRONT_SPECULAR 4
228 #define MAT_ATTRIB_BACK_SPECULAR 5
229 #define MAT_ATTRIB_FRONT_EMISSION 6
230 #define MAT_ATTRIB_BACK_EMISSION 7
231 #define MAT_ATTRIB_FRONT_SHININESS 8
232 #define MAT_ATTRIB_BACK_SHININESS 9
233 #define MAT_ATTRIB_FRONT_INDEXES 10
234 #define MAT_ATTRIB_BACK_INDEXES 11
235 #define MAT_ATTRIB_MAX 12
237 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
238 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
239 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
240 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
241 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
242 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
244 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
245 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
246 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
247 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
248 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
249 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
250 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
251 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
252 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
253 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
254 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
255 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
258 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
259 MAT_BIT_FRONT_AMBIENT | \
260 MAT_BIT_FRONT_DIFFUSE | \
261 MAT_BIT_FRONT_SPECULAR | \
262 MAT_BIT_FRONT_SHININESS | \
263 MAT_BIT_FRONT_INDEXES)
265 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
266 MAT_BIT_BACK_AMBIENT | \
267 MAT_BIT_BACK_DIFFUSE | \
268 MAT_BIT_BACK_SPECULAR | \
269 MAT_BIT_BACK_SHININESS | \
270 MAT_BIT_BACK_INDEXES)
272 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
281 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
289 #define LIGHT_SPOT 0x1
290 #define LIGHT_LOCAL_VIEWER 0x2
291 #define LIGHT_POSITIONAL 0x4
292 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
297 * Light source state.
301 GLfloat Ambient
[4]; /**< ambient color */
302 GLfloat Diffuse
[4]; /**< diffuse color */
303 GLfloat Specular
[4]; /**< specular color */
304 GLfloat EyePosition
[4]; /**< position in eye coordinates */
305 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
306 GLfloat SpotExponent
;
307 GLfloat SpotCutoff
; /**< in degrees */
308 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
309 GLfloat ConstantAttenuation
;
310 GLfloat LinearAttenuation
;
311 GLfloat QuadraticAttenuation
;
312 GLboolean Enabled
; /**< On/off flag */
315 * \name Derived fields
318 GLbitfield _Flags
; /**< Mask of LIGHT_x bits defined above */
320 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
321 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
322 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
323 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
324 GLfloat _VP_inf_spot_attenuation
;
326 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
327 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
328 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
338 GLfloat Ambient
[4]; /**< ambient color */
339 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
340 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
341 GLenum16 ColorControl
; /**< either GL_SINGLE_COLOR
342 or GL_SEPARATE_SPECULAR_COLOR */
347 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
349 struct gl_accum_attrib
351 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
356 * Used for storing clear color, texture border color, etc.
357 * The float values are typically unclamped.
368 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
370 struct gl_colorbuffer_attrib
372 GLuint ClearIndex
; /**< Index for glClear */
373 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
374 GLuint IndexMask
; /**< Color index write mask */
376 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
377 GLbitfield ColorMask
;
379 GLenum16 DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
382 * \name alpha testing
385 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
386 GLenum16 AlphaFunc
; /**< Alpha test function */
387 GLfloat AlphaRefUnclamped
;
388 GLclampf AlphaRef
; /**< Alpha reference value */
395 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
397 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
398 * control, only on the fixed-pointness of the render target.
399 * The query does however depend on fragment color clamping.
401 GLfloat BlendColorUnclamped
[4]; /**< Blending color */
402 GLfloat BlendColor
[4]; /**< Blending color */
406 GLenum16 SrcRGB
; /**< RGB blend source term */
407 GLenum16 DstRGB
; /**< RGB blend dest term */
408 GLenum16 SrcA
; /**< Alpha blend source term */
409 GLenum16 DstA
; /**< Alpha blend dest term */
410 GLenum16 EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
411 GLenum16 EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
413 * Set if any blend factor uses SRC1. Computed at the time blend factors
416 GLboolean _UsesDualSrc
;
417 } Blend
[MAX_DRAW_BUFFERS
];
418 /** Are the blend func terms currently different for each buffer/target? */
419 GLboolean _BlendFuncPerBuffer
;
420 /** Are the blend equations currently different for each buffer/target? */
421 GLboolean _BlendEquationPerBuffer
;
424 * Which advanced blending mode is in use (or BLEND_NONE).
426 * KHR_blend_equation_advanced only allows advanced blending with a single
427 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
428 * requires all draw buffers to match, so we only need a single value.
430 enum gl_advanced_blend_mode _AdvancedBlendMode
;
432 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
440 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
441 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
442 GLenum16 LogicOp
; /**< Logic operator */
443 enum gl_logicop_mode _LogicOp
;
446 GLboolean DitherFlag
; /**< Dither enable flag */
448 GLboolean _ClampFragmentColor
; /** < with GL_FIXED_ONLY_ARB resolved */
449 GLenum16 ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
450 GLenum16 ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
452 GLboolean sRGBEnabled
; /**< Framebuffer sRGB blending/updating requested */
457 * Vertex format to describe a vertex element.
459 struct gl_vertex_format
461 GLenum16 Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
462 GLenum16 Format
; /**< default: GL_RGBA, but may be GL_BGRA */
463 enum pipe_format _PipeFormat
:16; /**< pipe_format for Gallium */
464 GLubyte Size
:5; /**< components per element (1,2,3,4) */
465 GLubyte Normalized
:1; /**< GL_ARB_vertex_program */
466 GLubyte Integer
:1; /**< Integer-valued? */
467 GLubyte Doubles
:1; /**< double values are not converted to floats */
468 GLubyte _ElementSize
; /**< Size of each element in bytes */
473 * Current attribute group (GL_CURRENT_BIT).
475 struct gl_current_attrib
478 * \name Current vertex attributes (color, texcoords, etc).
479 * \note Values are valid only after FLUSH_VERTICES has been called.
480 * \note Index and Edgeflag current values are stored as floats in the
481 * SIX and SEVEN attribute slots.
482 * \note We need double storage for 64-bit vertex attributes
484 GLfloat Attrib
[VERT_ATTRIB_MAX
][4*2];
487 * \name Current raster position attributes (always up to date after a
490 GLfloat RasterPos
[4];
491 GLfloat RasterDistance
;
492 GLfloat RasterColor
[4];
493 GLfloat RasterSecondaryColor
[4];
494 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
495 GLboolean RasterPosValid
;
500 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
502 struct gl_depthbuffer_attrib
504 GLenum16 Func
; /**< Function for depth buffer compare */
505 GLclampd Clear
; /**< Value to clear depth buffer to */
506 GLboolean Test
; /**< Depth buffering enabled flag */
507 GLboolean Mask
; /**< Depth buffer writable? */
508 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
509 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
514 * Evaluator attribute group (GL_EVAL_BIT).
516 struct gl_eval_attrib
522 GLboolean Map1Color4
;
524 GLboolean Map1Normal
;
525 GLboolean Map1TextureCoord1
;
526 GLboolean Map1TextureCoord2
;
527 GLboolean Map1TextureCoord3
;
528 GLboolean Map1TextureCoord4
;
529 GLboolean Map1Vertex3
;
530 GLboolean Map1Vertex4
;
531 GLboolean Map2Color4
;
533 GLboolean Map2Normal
;
534 GLboolean Map2TextureCoord1
;
535 GLboolean Map2TextureCoord2
;
536 GLboolean Map2TextureCoord3
;
537 GLboolean Map2TextureCoord4
;
538 GLboolean Map2Vertex3
;
539 GLboolean Map2Vertex4
;
540 GLboolean AutoNormal
;
544 * \name Map Grid endpoints and divisions and calculated du values
548 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
549 GLint MapGrid2un
, MapGrid2vn
;
550 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
551 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
557 * Compressed fog mode.
569 * Fog attribute group (GL_FOG_BIT).
573 GLboolean Enabled
; /**< Fog enabled flag */
574 GLboolean ColorSumEnabled
;
575 uint8_t _PackedMode
; /**< Fog mode as 2 bits */
576 uint8_t _PackedEnabledMode
; /**< Masked CompressedMode */
577 GLfloat ColorUnclamped
[4]; /**< Fog color */
578 GLfloat Color
[4]; /**< Fog color */
579 GLfloat Density
; /**< Density >= 0.0 */
580 GLfloat Start
; /**< Start distance in eye coords */
581 GLfloat End
; /**< End distance in eye coords */
582 GLfloat Index
; /**< Fog index */
583 GLenum16 Mode
; /**< Fog mode */
584 GLenum16 FogCoordinateSource
;/**< GL_EXT_fog_coord */
585 GLenum16 FogDistanceMode
; /**< GL_NV_fog_distance */
590 * Hint attribute group (GL_HINT_BIT).
592 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
594 struct gl_hint_attrib
596 GLenum16 PerspectiveCorrection
;
597 GLenum16 PointSmooth
;
599 GLenum16 PolygonSmooth
;
601 GLenum16 TextureCompression
; /**< GL_ARB_texture_compression */
602 GLenum16 GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
603 GLenum16 FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
604 GLuint MaxShaderCompilerThreads
; /**< GL_ARB_parallel_shader_compile */
609 * Lighting attribute group (GL_LIGHT_BIT).
611 struct gl_light_attrib
613 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
614 struct gl_lightmodel Model
; /**< Lighting model */
617 * Front and back material values.
618 * Note: must call FLUSH_VERTICES() before using.
620 struct gl_material Material
;
622 GLboolean Enabled
; /**< Lighting enabled flag */
623 GLboolean ColorMaterialEnabled
;
625 GLenum16 ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
626 GLenum16 ProvokingVertex
; /**< GL_EXT_provoking_vertex */
627 GLenum16 ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
628 GLenum16 ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
629 GLbitfield _ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
632 GLboolean _ClampVertexColor
;
633 GLenum16 ClampVertexColor
; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
636 * Derived state for optimizations:
639 GLbitfield _EnabledLights
; /**< bitmask containing enabled lights */
641 GLboolean _NeedEyeCoords
;
642 GLboolean _NeedVertices
; /**< Use fast shader? */
644 GLfloat _BaseColor
[2][3];
650 * Line attribute group (GL_LINE_BIT).
652 struct gl_line_attrib
654 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
655 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
656 GLushort StipplePattern
; /**< Stipple pattern */
657 GLint StippleFactor
; /**< Stipple repeat factor */
658 GLfloat Width
; /**< Line width */
663 * Display list attribute group (GL_LIST_BIT).
665 struct gl_list_attrib
672 * Multisample attribute group (GL_MULTISAMPLE_BIT).
674 struct gl_multisample_attrib
677 GLboolean SampleAlphaToCoverage
;
678 GLboolean SampleAlphaToOne
;
679 GLboolean SampleCoverage
;
680 GLboolean SampleCoverageInvert
;
681 GLboolean SampleShading
;
683 /* ARB_texture_multisample / GL3.2 additions */
684 GLboolean SampleMask
;
686 GLfloat SampleCoverageValue
; /**< In range [0, 1] */
687 GLfloat MinSampleShadingValue
; /**< In range [0, 1] */
689 /** The GL spec defines this as an array but >32x MSAA is madness */
690 GLbitfield SampleMaskValue
;
695 * A pixelmap (see glPixelMap)
700 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
705 * Collection of all pixelmaps
709 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
710 struct gl_pixelmap GtoG
;
711 struct gl_pixelmap BtoB
;
712 struct gl_pixelmap AtoA
;
713 struct gl_pixelmap ItoR
;
714 struct gl_pixelmap ItoG
;
715 struct gl_pixelmap ItoB
;
716 struct gl_pixelmap ItoA
;
717 struct gl_pixelmap ItoI
;
718 struct gl_pixelmap StoS
;
723 * Pixel attribute group (GL_PIXEL_MODE_BIT).
725 struct gl_pixel_attrib
727 GLenum16 ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
729 /*--- Begin Pixel Transfer State ---*/
730 /* Fields are in the order in which they're applied... */
732 /** Scale & Bias (index shift, offset) */
734 GLfloat RedBias
, RedScale
;
735 GLfloat GreenBias
, GreenScale
;
736 GLfloat BlueBias
, BlueScale
;
737 GLfloat AlphaBias
, AlphaScale
;
738 GLfloat DepthBias
, DepthScale
;
739 GLint IndexShift
, IndexOffset
;
743 /* Note: actual pixel maps are not part of this attrib group */
744 GLboolean MapColorFlag
;
745 GLboolean MapStencilFlag
;
747 /*--- End Pixel Transfer State ---*/
750 GLfloat ZoomX
, ZoomY
;
755 * Point attribute group (GL_POINT_BIT).
757 struct gl_point_attrib
759 GLfloat Size
; /**< User-specified point size */
760 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
761 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
762 GLfloat Threshold
; /**< GL_EXT_point_parameters */
763 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
764 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
765 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
766 GLbitfield CoordReplace
; /**< GL_ARB_point_sprite*/
767 GLenum16 SpriteRMode
; /**< GL_NV_point_sprite (only!) */
768 GLenum16 SpriteOrigin
; /**< GL_ARB_point_sprite */
773 * Polygon attribute group (GL_POLYGON_BIT).
775 struct gl_polygon_attrib
777 GLenum16 FrontFace
; /**< Either GL_CW or GL_CCW */
778 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
779 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
780 GLboolean CullFlag
; /**< Culling on/off flag */
781 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
782 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
783 GLenum16 CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
784 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
785 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
786 GLfloat OffsetClamp
; /**< Polygon offset clamp, from user */
787 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
788 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
789 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
794 * Scissor attributes (GL_SCISSOR_BIT).
796 struct gl_scissor_rect
798 GLint X
, Y
; /**< Lower left corner of box */
799 GLsizei Width
, Height
; /**< Size of box */
803 struct gl_scissor_attrib
805 GLbitfield EnableFlags
; /**< Scissor test enabled? */
806 struct gl_scissor_rect ScissorArray
[MAX_VIEWPORTS
];
807 GLint NumWindowRects
; /**< Count of enabled window rectangles */
808 GLenum16 WindowRectMode
; /**< Whether to include or exclude the rects */
809 struct gl_scissor_rect WindowRects
[MAX_WINDOW_RECTANGLES
];
814 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
816 * Three sets of stencil data are tracked so that OpenGL 2.0,
817 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
818 * simultaneously. In each of the stencil state arrays, element 0 corresponds
819 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
820 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
821 * GL_EXT_stencil_two_side GL_BACK state.
823 * The derived value \c _BackFace is either 1 or 2 depending on whether or
824 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
826 * The derived value \c _TestTwoSide is set when the front-face and back-face
827 * stencil state are different.
829 struct gl_stencil_attrib
831 GLboolean Enabled
; /**< Enabled flag */
832 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
833 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 2) */
834 GLubyte _BackFace
; /**< Current back stencil state (1 or 2) */
835 GLenum16 Function
[3]; /**< Stencil function */
836 GLenum16 FailFunc
[3]; /**< Fail function */
837 GLenum16 ZPassFunc
[3]; /**< Depth buffer pass function */
838 GLenum16 ZFailFunc
[3]; /**< Depth buffer fail function */
839 GLint Ref
[3]; /**< Reference value */
840 GLuint ValueMask
[3]; /**< Value mask */
841 GLuint WriteMask
[3]; /**< Write mask */
842 GLuint Clear
; /**< Clear value */
847 * Bit flags for each type of texture object
850 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
851 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
852 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
853 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
854 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
855 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
856 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
857 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
858 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
859 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
860 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
861 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
866 * Texture image state. Drivers will typically create a subclass of this
867 * with extra fields for memory buffers, etc.
869 struct gl_texture_image
871 GLint InternalFormat
; /**< Internal format as given by the user */
872 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
873 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
874 * GL_INTENSITY, GL_DEPTH_COMPONENT or
875 * GL_DEPTH_STENCIL_EXT only. Used for
876 * choosing TexEnv arithmetic.
878 mesa_format TexFormat
; /**< The actual texture memory format */
880 GLuint Border
; /**< 0 or 1 */
881 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
882 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
883 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
884 GLuint Width2
; /**< = Width - 2*Border */
885 GLuint Height2
; /**< = Height - 2*Border */
886 GLuint Depth2
; /**< = Depth - 2*Border */
887 GLuint WidthLog2
; /**< = log2(Width2) */
888 GLuint HeightLog2
; /**< = log2(Height2) */
889 GLuint DepthLog2
; /**< = log2(Depth2) */
890 GLuint MaxNumLevels
; /**< = maximum possible number of mipmap
891 levels, computed from the dimensions */
893 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
894 GLuint Level
; /**< Which mipmap level am I? */
895 /** Cube map face: index into gl_texture_object::Image[] array */
898 /** GL_ARB_texture_multisample */
899 GLuint NumSamples
; /**< Sample count, or 0 for non-multisample */
900 GLboolean FixedSampleLocations
; /**< Same sample locations for all pixels? */
905 * Indexes for cube map faces.
920 * Sampler object state. These objects are new with GL_ARB_sampler_objects
921 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
923 struct gl_sampler_object
927 GLchar
*Label
; /**< GL_KHR_debug */
930 GLenum16 WrapS
; /**< S-axis texture image wrap mode */
931 GLenum16 WrapT
; /**< T-axis texture image wrap mode */
932 GLenum16 WrapR
; /**< R-axis texture image wrap mode */
933 GLenum16 MinFilter
; /**< minification filter */
934 GLenum16 MagFilter
; /**< magnification filter */
935 GLenum16 sRGBDecode
; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
936 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
937 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
938 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
939 GLfloat LodBias
; /**< OpenGL 1.4 */
940 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
941 GLenum16 CompareMode
; /**< GL_ARB_shadow */
942 GLenum16 CompareFunc
; /**< GL_ARB_shadow */
943 GLboolean CubeMapSeamless
; /**< GL_AMD_seamless_cubemap_per_texture */
945 /** GL_ARB_bindless_texture */
946 bool HandleAllocated
;
947 struct util_dynarray Handles
;
952 * Texture object state. Contains the array of mipmap images, border color,
953 * wrap modes, filter modes, and shadow/texcompare state.
955 struct gl_texture_object
957 simple_mtx_t Mutex
; /**< for thread safety */
958 GLint RefCount
; /**< reference count */
959 GLuint Name
; /**< the user-visible texture object ID */
960 GLenum16 Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
961 GLenum16 DepthMode
; /**< GL_ARB_depth_texture */
962 GLchar
*Label
; /**< GL_KHR_debug */
964 struct gl_sampler_object Sampler
;
966 gl_texture_index TargetIndex
; /**< The gl_texture_unit::CurrentTex index.
967 Only valid when Target is valid. */
968 GLfloat Priority
; /**< in [0,1] */
969 GLint MaxLevel
; /**< max mipmap level (max=1000), OpenGL 1.2 */
970 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
971 GLbyte _MaxLevel
; /**< actual max mipmap level (q in the spec) */
972 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - p in spec) */
973 GLint CropRect
[4]; /**< GL_OES_draw_texture */
974 GLenum Swizzle
[4]; /**< GL_EXT_texture_swizzle */
975 GLushort _Swizzle
; /**< same as Swizzle, but SWIZZLE_* format */
976 GLbyte ImmutableLevels
; /**< ES 3.0 / ARB_texture_view */
977 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
978 GLboolean _BaseComplete
; /**< Is the base texture level valid? */
979 GLboolean _MipmapComplete
; /**< Is the whole mipmap valid? */
980 GLboolean _IsIntegerFormat
; /**< Does the texture store integer values? */
981 GLboolean _RenderToTexture
; /**< Any rendering to this texture? */
982 GLboolean Purgeable
; /**< Is the buffer purgeable under memory
984 GLboolean Immutable
; /**< GL_ARB_texture_storage */
985 GLboolean _IsFloat
; /**< GL_OES_float_texture */
986 GLboolean _IsHalfFloat
; /**< GL_OES_half_float_texture */
987 bool StencilSampling
; /**< Should we sample stencil instead of depth? */
988 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
990 /** GL_OES_EGL_image_external */
991 GLubyte RequiredTextureImageUnits
;
993 GLubyte MinLevel
; /**< GL_ARB_texture_view */
994 GLubyte NumLevels
; /**< GL_ARB_texture_view */
995 GLushort MinLayer
; /**< GL_ARB_texture_view */
996 GLushort NumLayers
; /**< GL_ARB_texture_view */
998 /** GL_EXT_memory_object */
999 GLenum16 TextureTiling
;
1001 /** GL_ARB_shader_image_load_store */
1002 GLenum16 ImageFormatCompatibilityType
;
1004 /** GL_ARB_texture_buffer_object */
1005 GLenum16 BufferObjectFormat
;
1006 /** Equivalent Mesa format for BufferObjectFormat. */
1007 mesa_format _BufferObjectFormat
;
1008 struct gl_buffer_object
*BufferObject
;
1010 /** GL_ARB_texture_buffer_range */
1011 GLintptr BufferOffset
;
1012 GLsizeiptr BufferSize
; /**< if this is -1, use BufferObject->Size instead */
1014 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1015 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1017 /** GL_ARB_bindless_texture */
1018 struct util_dynarray SamplerHandles
;
1019 struct util_dynarray ImageHandles
;
1023 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1024 #define MAX_COMBINER_TERMS 4
1028 * Texture combine environment state.
1030 struct gl_tex_env_combine_state
1032 GLenum16 ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1033 GLenum16 ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1034 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1035 GLenum16 SourceRGB
[MAX_COMBINER_TERMS
];
1036 GLenum16 SourceA
[MAX_COMBINER_TERMS
];
1037 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1038 GLenum16 OperandRGB
[MAX_COMBINER_TERMS
];
1039 GLenum16 OperandA
[MAX_COMBINER_TERMS
];
1040 GLubyte ScaleShiftRGB
; /**< 0, 1 or 2 */
1041 GLubyte ScaleShiftA
; /**< 0, 1 or 2 */
1042 GLubyte _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1043 GLubyte _NumArgsA
; /**< Number of inputs used for the A combiner */
1047 /** Compressed TexEnv effective Combine mode */
1048 enum gl_tex_env_mode
1050 TEXENV_MODE_REPLACE
, /* r = a0 */
1051 TEXENV_MODE_MODULATE
, /* r = a0 * a1 */
1052 TEXENV_MODE_ADD
, /* r = a0 + a1 */
1053 TEXENV_MODE_ADD_SIGNED
, /* r = a0 + a1 - 0.5 */
1054 TEXENV_MODE_INTERPOLATE
, /* r = a0 * a2 + a1 * (1 - a2) */
1055 TEXENV_MODE_SUBTRACT
, /* r = a0 - a1 */
1056 TEXENV_MODE_DOT3_RGB
, /* r = a0 . a1 */
1057 TEXENV_MODE_DOT3_RGB_EXT
, /* r = a0 . a1 */
1058 TEXENV_MODE_DOT3_RGBA
, /* r = a0 . a1 */
1059 TEXENV_MODE_DOT3_RGBA_EXT
, /* r = a0 . a1 */
1060 TEXENV_MODE_MODULATE_ADD_ATI
, /* r = a0 * a2 + a1 */
1061 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI
, /* r = a0 * a2 + a1 - 0.5 */
1062 TEXENV_MODE_MODULATE_SUBTRACT_ATI
, /* r = a0 * a2 - a1 */
1063 TEXENV_MODE_ADD_PRODUCTS_NV
, /* r = a0 * a1 + a2 * a3 */
1064 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV
, /* r = a0 * a1 + a2 * a3 - 0.5 */
1068 /** Compressed TexEnv Combine source */
1069 enum gl_tex_env_source
1071 TEXENV_SRC_TEXTURE0
,
1072 TEXENV_SRC_TEXTURE1
,
1073 TEXENV_SRC_TEXTURE2
,
1074 TEXENV_SRC_TEXTURE3
,
1075 TEXENV_SRC_TEXTURE4
,
1076 TEXENV_SRC_TEXTURE5
,
1077 TEXENV_SRC_TEXTURE6
,
1078 TEXENV_SRC_TEXTURE7
,
1080 TEXENV_SRC_PREVIOUS
,
1081 TEXENV_SRC_PRIMARY_COLOR
,
1082 TEXENV_SRC_CONSTANT
,
1088 /** Compressed TexEnv Combine operand */
1089 enum gl_tex_env_operand
1092 TEXENV_OPR_ONE_MINUS_COLOR
,
1094 TEXENV_OPR_ONE_MINUS_ALPHA
,
1098 /** Compressed TexEnv Combine argument */
1099 struct gl_tex_env_argument
1102 __extension__
uint8_t Source
:4; /**< TEXENV_SRC_x */
1103 __extension__
uint8_t Operand
:2; /**< TEXENV_OPR_x */
1105 uint8_t Source
; /**< SRC_x */
1106 uint8_t Operand
; /**< OPR_x */
1112 * Compressed TexEnv Combine state.
1114 struct gl_tex_env_combine_packed
1116 uint32_t ModeRGB
:4; /**< Effective mode for RGB as 4 bits */
1117 uint32_t ModeA
:4; /**< Effective mode for RGB as 4 bits */
1118 uint32_t ScaleShiftRGB
:2; /**< 0, 1 or 2 */
1119 uint32_t ScaleShiftA
:2; /**< 0, 1 or 2 */
1120 uint32_t NumArgsRGB
:3; /**< Number of inputs used for the RGB combiner */
1121 uint32_t NumArgsA
:3; /**< Number of inputs used for the A combiner */
1122 /** Source arguments in a packed manner */
1123 struct gl_tex_env_argument ArgsRGB
[MAX_COMBINER_TERMS
];
1124 struct gl_tex_env_argument ArgsA
[MAX_COMBINER_TERMS
];
1129 * TexGenEnabled flags.
1136 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1141 * Bit flag versions of the corresponding GL_ constants.
1144 #define TEXGEN_SPHERE_MAP 0x1
1145 #define TEXGEN_OBJ_LINEAR 0x2
1146 #define TEXGEN_EYE_LINEAR 0x4
1147 #define TEXGEN_REFLECTION_MAP_NV 0x8
1148 #define TEXGEN_NORMAL_MAP_NV 0x10
1150 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1151 TEXGEN_REFLECTION_MAP_NV | \
1152 TEXGEN_NORMAL_MAP_NV)
1153 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1154 TEXGEN_REFLECTION_MAP_NV | \
1155 TEXGEN_NORMAL_MAP_NV | \
1161 /** Tex-gen enabled for texture unit? */
1162 #define ENABLE_TEXGEN(unit) (1 << (unit))
1164 /** Non-identity texture matrix for texture unit? */
1165 #define ENABLE_TEXMAT(unit) (1 << (unit))
1169 * Texture coord generation state.
1173 GLenum16 Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1174 GLbitfield8 _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1175 GLfloat ObjectPlane
[4];
1176 GLfloat EyePlane
[4];
1181 * Sampler-related subset of a texture unit, like current texture objects.
1183 struct gl_texture_unit
1185 GLfloat LodBias
; /**< for biasing mipmap levels */
1187 /** Texture targets that have a non-default texture bound */
1188 GLbitfield _BoundTextures
;
1190 /** Current sampler object (GL_ARB_sampler_objects) */
1191 struct gl_sampler_object
*Sampler
;
1193 /** Current texture object pointers */
1194 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1196 /** Points to highest priority, complete and enabled texture object */
1197 struct gl_texture_object
*_Current
;
1202 * Fixed-function-related subset of a texture unit, like enable flags,
1203 * texture environment/function/combiners, and texgen state.
1205 struct gl_fixedfunc_texture_unit
1207 GLbitfield16 Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1209 GLenum16 EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1210 GLclampf EnvColor
[4];
1211 GLfloat EnvColorUnclamped
[4];
1213 struct gl_texgen GenS
;
1214 struct gl_texgen GenT
;
1215 struct gl_texgen GenR
;
1216 struct gl_texgen GenQ
;
1217 GLbitfield8 TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1218 GLbitfield8 _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1221 * \name GL_EXT_texture_env_combine
1223 struct gl_tex_env_combine_state Combine
;
1226 * Derived state based on \c EnvMode and the \c BaseFormat of the
1227 * currently enabled texture.
1229 struct gl_tex_env_combine_state _EnvMode
;
1231 /** Current compressed TexEnv & Combine state */
1232 struct gl_tex_env_combine_packed _CurrentCombinePacked
;
1235 * Currently enabled combiner state. This will point to either
1236 * \c Combine or \c _EnvMode.
1238 struct gl_tex_env_combine_state
*_CurrentCombine
;
1243 * Texture attribute group (GL_TEXTURE_BIT).
1245 struct gl_texture_attrib
1247 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1249 /** GL_ARB_texture_buffer_object */
1250 struct gl_buffer_object
*BufferObject
;
1252 GLuint CurrentUnit
; /**< GL_ACTIVE_TEXTURE */
1254 /** Texture coord units/sets used for fragment texturing */
1255 GLbitfield8 _EnabledCoordUnits
;
1257 /** Texture coord units that have texgen enabled */
1258 GLbitfield8 _TexGenEnabled
;
1260 /** Texture coord units that have non-identity matrices */
1261 GLbitfield8 _TexMatEnabled
;
1263 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1264 GLbitfield8 _GenFlags
;
1266 /** Largest index of a texture unit with _Current != NULL. */
1267 GLshort _MaxEnabledTexImageUnit
;
1269 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1270 GLubyte NumCurrentTexUsed
;
1272 /** GL_ARB_seamless_cubemap */
1273 GLboolean CubeMapSeamless
;
1275 struct gl_texture_unit Unit
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
1276 struct gl_fixedfunc_texture_unit FixedFuncUnit
[MAX_TEXTURE_COORD_UNITS
];
1281 * Data structure representing a single clip plane (e.g. one of the elements
1282 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1284 typedef GLfloat gl_clip_plane
[4];
1288 * Transformation attribute group (GL_TRANSFORM_BIT).
1290 struct gl_transform_attrib
1292 GLenum16 MatrixMode
; /**< Matrix mode */
1293 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1294 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1295 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1296 GLboolean Normalize
; /**< Normalize all normals? */
1297 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1298 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1299 GLboolean DepthClampNear
; /**< GL_AMD_depth_clamp_separate */
1300 GLboolean DepthClampFar
; /**< GL_AMD_depth_clamp_separate */
1301 /** GL_ARB_clip_control */
1302 GLenum16 ClipOrigin
; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1303 GLenum16 ClipDepthMode
;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1308 * Viewport attribute group (GL_VIEWPORT_BIT).
1310 struct gl_viewport_attrib
1312 GLfloat X
, Y
; /**< position */
1313 GLfloat Width
, Height
; /**< size */
1314 GLfloat Near
, Far
; /**< Depth buffer range */
1319 * Fields describing a mapped buffer range.
1321 struct gl_buffer_mapping
1323 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1324 GLvoid
*Pointer
; /**< User-space address of mapping */
1325 GLintptr Offset
; /**< Mapped offset */
1326 GLsizeiptr Length
; /**< Mapped length */
1331 * Usages we've seen for a buffer object.
1335 USAGE_UNIFORM_BUFFER
= 0x1,
1336 USAGE_TEXTURE_BUFFER
= 0x2,
1337 USAGE_ATOMIC_COUNTER_BUFFER
= 0x4,
1338 USAGE_SHADER_STORAGE_BUFFER
= 0x8,
1339 USAGE_TRANSFORM_FEEDBACK_BUFFER
= 0x10,
1340 USAGE_PIXEL_PACK_BUFFER
= 0x20,
1341 USAGE_ARRAY_BUFFER
= 0x40,
1342 USAGE_ELEMENT_ARRAY_BUFFER
= 0x80,
1343 USAGE_DISABLE_MINMAX_CACHE
= 0x100,
1348 * GL_ARB_vertex/pixel_buffer_object buffer object
1350 struct gl_buffer_object
1354 GLchar
*Label
; /**< GL_KHR_debug */
1355 GLenum16 Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1356 GLbitfield StorageFlags
; /**< GL_MAP_PERSISTENT_BIT, etc. */
1357 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1358 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1359 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1360 GLboolean Written
; /**< Ever written to? (for debugging) */
1361 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1362 GLboolean Immutable
; /**< GL_ARB_buffer_storage */
1363 gl_buffer_usage UsageHistory
; /**< How has this buffer been used so far? */
1365 /** Counters used for buffer usage warnings */
1366 GLuint NumSubDataCalls
;
1367 GLuint NumMapBufferWriteCalls
;
1369 struct gl_buffer_mapping Mappings
[MAP_COUNT
];
1371 /** Memoization of min/max index computations for static index buffers */
1372 simple_mtx_t MinMaxCacheMutex
;
1373 struct hash_table
*MinMaxCache
;
1374 unsigned MinMaxCacheHitIndices
;
1375 unsigned MinMaxCacheMissIndices
;
1376 bool MinMaxCacheDirty
;
1378 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1383 * Client pixel packing/unpacking attributes
1385 struct gl_pixelstore_attrib
1393 GLboolean SwapBytes
;
1395 GLboolean Invert
; /**< GL_MESA_pack_invert */
1396 GLint CompressedBlockWidth
; /**< GL_ARB_compressed_texture_pixel_storage */
1397 GLint CompressedBlockHeight
;
1398 GLint CompressedBlockDepth
;
1399 GLint CompressedBlockSize
;
1400 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1405 * Enum for defining the mapping for the position/generic0 attribute.
1407 * Do not change the order of the values as these are used as
1412 ATTRIBUTE_MAP_MODE_IDENTITY
, /**< 1:1 mapping */
1413 ATTRIBUTE_MAP_MODE_POSITION
, /**< get position and generic0 from position */
1414 ATTRIBUTE_MAP_MODE_GENERIC0
, /**< get position and generic0 from generic0 */
1415 ATTRIBUTE_MAP_MODE_MAX
/**< for sizing arrays */
1416 } gl_attribute_map_mode
;
1420 * Attributes to describe a vertex array.
1422 * Contains the size, type, format and normalization flag,
1423 * along with the index of a vertex buffer binding point.
1425 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1426 * and is only present for backwards compatibility reasons.
1427 * Rendering always uses VERTEX_BINDING_STRIDE.
1428 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1429 * and VERTEX_BINDING_STRIDE to the same value, while
1430 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1432 struct gl_array_attributes
1434 /** Points to client array data. Not used when a VBO is bound */
1436 /** Offset of the first element relative to the binding offset */
1437 GLuint RelativeOffset
;
1438 /** Vertex format */
1439 struct gl_vertex_format Format
;
1440 /** Stride as specified with gl*Pointer() */
1442 /** Index into gl_vertex_array_object::BufferBinding[] array */
1443 GLubyte BufferBindingIndex
;
1446 * Derived effective buffer binding index
1448 * Index into the gl_vertex_buffer_binding array of the vao.
1449 * Similar to BufferBindingIndex, but with the mapping of the
1450 * position/generic0 attributes applied and with identical
1451 * gl_vertex_buffer_binding entries collapsed to a single
1452 * entry within the vao.
1454 * The value is valid past calling _mesa_update_vao_derived_arrays.
1455 * Note that _mesa_update_vao_derived_arrays is called when binding
1456 * the VAO to Array._DrawVAO.
1458 GLubyte _EffBufferBindingIndex
;
1460 * Derived effective relative offset.
1462 * Relative offset to the effective buffers offset in
1463 * gl_vertex_buffer_binding::_EffOffset.
1465 * The value is valid past calling _mesa_update_vao_derived_arrays.
1466 * Note that _mesa_update_vao_derived_arrays is called when binding
1467 * the VAO to Array._DrawVAO.
1469 GLushort _EffRelativeOffset
;
1474 * This describes the buffer object used for a vertex array (or
1475 * multiple vertex arrays). If BufferObj points to the default/null
1476 * buffer object, then the vertex array lives in user memory and not a VBO.
1478 struct gl_vertex_buffer_binding
1480 GLintptr Offset
; /**< User-specified offset */
1481 GLsizei Stride
; /**< User-specified stride */
1482 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1483 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_vertex_buffer_object */
1484 GLbitfield _BoundArrays
; /**< Arrays bound to this binding point */
1487 * Derived effective bound arrays.
1489 * The effective binding handles enabled arrays past the
1490 * position/generic0 attribute mapping and reduces the refered
1491 * gl_vertex_buffer_binding entries to a unique subset.
1493 * The value is valid past calling _mesa_update_vao_derived_arrays.
1494 * Note that _mesa_update_vao_derived_arrays is called when binding
1495 * the VAO to Array._DrawVAO.
1497 GLbitfield _EffBoundArrays
;
1501 * The absolute offset to that we can collapse some attributes
1502 * to this unique effective binding.
1503 * For user space array bindings this contains the smallest pointer value
1504 * in the bound and interleaved arrays.
1505 * For VBO bindings this contains an offset that lets the attributes
1506 * _EffRelativeOffset stay positive and in bounds with
1507 * Const.MaxVertexAttribRelativeOffset
1509 * The value is valid past calling _mesa_update_vao_derived_arrays.
1510 * Note that _mesa_update_vao_derived_arrays is called when binding
1511 * the VAO to Array._DrawVAO.
1513 GLintptr _EffOffset
;
1518 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1519 * the GL_ARB_vertex_array_object extension.
1521 struct gl_vertex_array_object
1523 /** Name of the VAO as received from glGenVertexArray. */
1528 GLchar
*Label
; /**< GL_KHR_debug */
1531 * Has this array object been bound?
1533 GLboolean EverBound
;
1536 * Marked to true if the object is shared between contexts and immutable.
1537 * Then reference counting is done using atomics and thread safe.
1538 * Is used for dlist VAOs.
1540 bool SharedAndImmutable
;
1542 /** Vertex attribute arrays */
1543 struct gl_array_attributes VertexAttrib
[VERT_ATTRIB_MAX
];
1545 /** Vertex buffer bindings */
1546 struct gl_vertex_buffer_binding BufferBinding
[VERT_ATTRIB_MAX
];
1548 /** Mask indicating which vertex arrays have vertex buffer associated. */
1549 GLbitfield VertexAttribBufferMask
;
1551 /** Mask indicating which vertex arrays have a non-zero instance divisor. */
1552 GLbitfield NonZeroDivisorMask
;
1554 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1558 * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
1560 * The value is valid past calling _mesa_update_vao_derived_arrays.
1561 * Note that _mesa_update_vao_derived_arrays is called when binding
1562 * the VAO to Array._DrawVAO.
1564 GLbitfield _EffEnabledVBO
;
1566 /** Same as _EffEnabledVBO, but for instance divisors. */
1567 GLbitfield _EffEnabledNonZeroDivisor
;
1569 /** Denotes the way the position/generic0 attribute is mapped */
1570 gl_attribute_map_mode _AttributeMapMode
;
1572 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1573 GLbitfield NewArrays
;
1575 /** The index buffer (also known as the element array buffer in OpenGL). */
1576 struct gl_buffer_object
*IndexBufferObj
;
1581 * Vertex array state
1583 struct gl_array_attrib
1585 /** Currently bound array object. */
1586 struct gl_vertex_array_object
*VAO
;
1588 /** The default vertex array object */
1589 struct gl_vertex_array_object
*DefaultVAO
;
1591 /** The last VAO accessed by a DSA function */
1592 struct gl_vertex_array_object
*LastLookedUpVAO
;
1594 /** Array objects (GL_ARB_vertex_array_object) */
1595 struct _mesa_HashTable
*Objects
;
1597 GLint ActiveTexture
; /**< Client Active Texture */
1598 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1599 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1602 * \name Primitive restart controls
1604 * Primitive restart is enabled if either \c PrimitiveRestart or
1605 * \c PrimitiveRestartFixedIndex is set.
1608 GLboolean PrimitiveRestart
;
1609 GLboolean PrimitiveRestartFixedIndex
;
1610 GLboolean _PrimitiveRestart
;
1611 GLuint RestartIndex
;
1614 /* GL_ARB_vertex_buffer_object */
1615 struct gl_buffer_object
*ArrayBufferObj
;
1618 * Vertex array object that is used with the currently active draw command.
1619 * The _DrawVAO is either set to the currently bound VAO for array type
1620 * draws or to internal VAO's set up by the vbo module to execute immediate
1621 * mode or display list draws.
1623 struct gl_vertex_array_object
*_DrawVAO
;
1625 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
1626 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
1627 * but may omit those arrays that shall not be referenced by the current
1628 * gl_vertex_program_state::_VPMode. For example the generic attributes are
1629 * maked out form the _DrawVAO's enabled arrays when a fixed function
1630 * array draw is executed.
1632 GLbitfield _DrawVAOEnabledAttribs
;
1634 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
1635 * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
1637 struct gl_vertex_array_object
*_EmptyVAO
;
1639 /** Legal array datatypes and the API for which they have been computed */
1640 GLbitfield LegalTypesMask
;
1641 gl_api LegalTypesMaskAPI
;
1646 * Feedback buffer state
1651 GLbitfield _Mask
; /**< FB_* bits */
1659 * Selection buffer state
1663 GLuint
*Buffer
; /**< selection buffer */
1664 GLuint BufferSize
; /**< size of the selection buffer */
1665 GLuint BufferCount
; /**< number of values in the selection buffer */
1666 GLuint Hits
; /**< number of records in the selection buffer */
1667 GLuint NameStackDepth
; /**< name stack depth */
1668 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1669 GLboolean HitFlag
; /**< hit flag */
1670 GLfloat HitMinZ
; /**< minimum hit depth */
1671 GLfloat HitMaxZ
; /**< maximum hit depth */
1676 * 1-D Evaluator control points
1680 GLuint Order
; /**< Number of control points */
1681 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1682 GLfloat
*Points
; /**< Points to contiguous control points */
1687 * 2-D Evaluator control points
1691 GLuint Uorder
; /**< Number of control points in U dimension */
1692 GLuint Vorder
; /**< Number of control points in V dimension */
1695 GLfloat
*Points
; /**< Points to contiguous control points */
1700 * All evaluator control point state
1702 struct gl_evaluators
1708 struct gl_1d_map Map1Vertex3
;
1709 struct gl_1d_map Map1Vertex4
;
1710 struct gl_1d_map Map1Index
;
1711 struct gl_1d_map Map1Color4
;
1712 struct gl_1d_map Map1Normal
;
1713 struct gl_1d_map Map1Texture1
;
1714 struct gl_1d_map Map1Texture2
;
1715 struct gl_1d_map Map1Texture3
;
1716 struct gl_1d_map Map1Texture4
;
1723 struct gl_2d_map Map2Vertex3
;
1724 struct gl_2d_map Map2Vertex4
;
1725 struct gl_2d_map Map2Index
;
1726 struct gl_2d_map Map2Color4
;
1727 struct gl_2d_map Map2Normal
;
1728 struct gl_2d_map Map2Texture1
;
1729 struct gl_2d_map Map2Texture2
;
1730 struct gl_2d_map Map2Texture3
;
1731 struct gl_2d_map Map2Texture4
;
1736 struct gl_transform_feedback_varying_info
1747 * Per-output info vertex shaders for transform feedback.
1749 struct gl_transform_feedback_output
1751 uint32_t OutputRegister
;
1752 uint32_t OutputBuffer
;
1753 uint32_t NumComponents
;
1756 /** offset (in DWORDs) of this output within the interleaved structure */
1760 * Offset into the output register of the data to output. For example,
1761 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1762 * offset is in the y and z components of the output register.
1764 uint32_t ComponentOffset
;
1768 struct gl_transform_feedback_buffer
1772 uint32_t NumVaryings
;
1775 * Total number of components stored in each buffer. This may be used by
1776 * hardware back-ends to determine the correct stride when interleaving
1777 * multiple transform feedback outputs in the same buffer.
1782 * Which transform feedback stream this buffer binding is associated with.
1788 /** Post-link transform feedback info. */
1789 struct gl_transform_feedback_info
1791 unsigned NumOutputs
;
1793 /* Bitmask of active buffer indices. */
1794 unsigned ActiveBuffers
;
1796 struct gl_transform_feedback_output
*Outputs
;
1798 /** Transform feedback varyings used for the linking of this shader program.
1800 * Use for glGetTransformFeedbackVarying().
1802 struct gl_transform_feedback_varying_info
*Varyings
;
1805 struct gl_transform_feedback_buffer Buffers
[MAX_FEEDBACK_BUFFERS
];
1810 * Transform feedback object state
1812 struct gl_transform_feedback_object
1814 GLuint Name
; /**< AKA the object ID */
1816 GLchar
*Label
; /**< GL_KHR_debug */
1817 GLboolean Active
; /**< Is transform feedback enabled? */
1818 GLboolean Paused
; /**< Is transform feedback paused? */
1819 GLboolean EndedAnytime
; /**< Has EndTransformFeedback been called
1821 GLboolean EverBound
; /**< Has this object been bound? */
1824 * GLES: if Active is true, remaining number of primitives which can be
1825 * rendered without overflow. This is necessary to track because GLES
1826 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1827 * glDrawArraysInstanced would overflow transform feedback buffers.
1828 * Undefined if Active is false.
1830 * Not tracked for desktop GL since it's unnecessary.
1832 unsigned GlesRemainingPrims
;
1835 * The program active when BeginTransformFeedback() was called.
1836 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1837 * where stage is the pipeline stage that is the source of data for
1838 * transform feedback.
1840 struct gl_program
*program
;
1842 /** The feedback buffers */
1843 GLuint BufferNames
[MAX_FEEDBACK_BUFFERS
];
1844 struct gl_buffer_object
*Buffers
[MAX_FEEDBACK_BUFFERS
];
1846 /** Start of feedback data in dest buffer */
1847 GLintptr Offset
[MAX_FEEDBACK_BUFFERS
];
1850 * Max data to put into dest buffer (in bytes). Computed based on
1851 * RequestedSize and the actual size of the buffer.
1853 GLsizeiptr Size
[MAX_FEEDBACK_BUFFERS
];
1856 * Size that was specified when the buffer was bound. If the buffer was
1857 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1860 GLsizeiptr RequestedSize
[MAX_FEEDBACK_BUFFERS
];
1865 * Context state for transform feedback.
1867 struct gl_transform_feedback_state
1869 GLenum16 Mode
; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1871 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1872 struct gl_buffer_object
*CurrentBuffer
;
1874 /** The table of all transform feedback objects */
1875 struct _mesa_HashTable
*Objects
;
1877 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1878 struct gl_transform_feedback_object
*CurrentObject
;
1880 /** The default xform-fb object (Name==0) */
1881 struct gl_transform_feedback_object
*DefaultObject
;
1886 * A "performance monitor" as described in AMD_performance_monitor.
1888 struct gl_perf_monitor_object
1892 /** True if the monitor is currently active (Begin called but not End). */
1896 * True if the monitor has ended.
1898 * This is distinct from !Active because it may never have began.
1903 * A list of groups with currently active counters.
1905 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1907 unsigned *ActiveGroups
;
1910 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1912 * Checking whether counter 'c' in group 'g' is active can be done via:
1914 * BITSET_TEST(ActiveCounters[g], c)
1916 GLuint
**ActiveCounters
;
1920 union gl_perf_monitor_counter_value
1928 struct gl_perf_monitor_counter
1930 /** Human readable name for the counter. */
1934 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1935 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1939 /** Minimum counter value. */
1940 union gl_perf_monitor_counter_value Minimum
;
1942 /** Maximum counter value. */
1943 union gl_perf_monitor_counter_value Maximum
;
1947 struct gl_perf_monitor_group
1949 /** Human readable name for the group. */
1953 * Maximum number of counters in this group which can be active at the
1956 GLuint MaxActiveCounters
;
1958 /** Array of counters within this group. */
1959 const struct gl_perf_monitor_counter
*Counters
;
1965 * A query object instance as described in INTEL_performance_query.
1967 * NB: We want to keep this and the corresponding backend structure
1968 * relatively lean considering that applications may expect to
1969 * allocate enough objects to be able to query around all draw calls
1972 struct gl_perf_query_object
1974 GLuint Id
; /**< hash table ID/name */
1975 unsigned Used
:1; /**< has been used for 1 or more queries */
1976 unsigned Active
:1; /**< inside Begin/EndPerfQuery */
1977 unsigned Ready
:1; /**< result is ready? */
1982 * Context state for AMD_performance_monitor.
1984 struct gl_perf_monitor_state
1986 /** Array of performance monitor groups (indexed by group ID) */
1987 const struct gl_perf_monitor_group
*Groups
;
1990 /** The table of all performance monitors. */
1991 struct _mesa_HashTable
*Monitors
;
1996 * Context state for INTEL_performance_query.
1998 struct gl_perf_query_state
2000 struct _mesa_HashTable
*Objects
; /**< The table of all performance query objects */
2005 * A bindless sampler object.
2007 struct gl_bindless_sampler
2009 /** Texture unit (set by glUniform1()). */
2012 /** Whether this bindless sampler is bound to a unit. */
2015 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2016 gl_texture_index target
;
2018 /** Pointer to the base of the data. */
2024 * A bindless image object.
2026 struct gl_bindless_image
2028 /** Image unit (set by glUniform1()). */
2031 /** Whether this bindless image is bound to a unit. */
2034 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
2035 * GL_NONE to indicate both read-only and write-only)
2039 /** Pointer to the base of the data. */
2045 * Current vertex processing mode: fixed function vs. shader.
2046 * In reality, fixed function is probably implemented by a shader but that's
2047 * not what we care about here.
2051 VP_MODE_FF
, /**< legacy / fixed function */
2052 VP_MODE_SHADER
, /**< ARB vertex program or GLSL vertex shader */
2053 VP_MODE_MAX
/**< for sizing arrays */
2054 } gl_vertex_processing_mode
;
2058 * Base class for any kind of program object
2062 /** FIXME: This must be first until we split shader_info from nir_shader */
2063 struct shader_info info
;
2067 GLubyte
*String
; /**< Null-terminated program text */
2069 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2071 GLenum16 Format
; /**< String encoding format */
2073 GLboolean _Used
; /**< Ever used for drawing? Used for debugging */
2075 struct nir_shader
*nir
;
2077 /* Saved and restored with metadata. Freed with ralloc. */
2078 void *driver_cache_blob
;
2079 size_t driver_cache_blob_size
;
2081 bool is_arb_asm
; /** Is this an ARB assembly-style program */
2083 /** Is this program written to on disk shader cache */
2084 bool program_written_to_cache
;
2086 /** A bitfield indicating which vertex shader inputs consume two slots
2088 * This is used for mapping from single-slot input locations in the GL API
2089 * to dual-slot double input locations in the shader. This field is set
2090 * once as part of linking and never updated again to ensure the mapping
2091 * remains consistent.
2093 * Note: There may be dual-slot variables in the original shader source
2094 * which do not appear in this bitfield due to having been eliminated by
2095 * the compiler prior to DualSlotInputs being calculated. There may also
2096 * be bits set in this bitfield which are set but which the shader never
2097 * reads due to compiler optimizations eliminating such variables after
2098 * DualSlotInputs is calculated.
2100 GLbitfield64 DualSlotInputs
;
2101 /** Subset of OutputsWritten outputs written with non-zero index. */
2102 GLbitfield64 SecondaryOutputsWritten
;
2103 /** TEXTURE_x_BIT bitmask */
2104 GLbitfield16 TexturesUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
2105 /** Bitfield of which samplers are used */
2106 GLbitfield SamplersUsed
;
2107 /** Texture units used for shadow sampling. */
2108 GLbitfield ShadowSamplers
;
2109 /** Texture units used for samplerExternalOES */
2110 GLbitfield ExternalSamplersUsed
;
2112 /** Named parameters, constants, etc. from program text */
2113 struct gl_program_parameter_list
*Parameters
;
2115 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2116 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2118 /* FIXME: We should be able to make this struct a union. However some
2119 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2120 * these fields, we should fix this.
2123 /** Fields used by GLSL programs */
2125 /** Data shared by gl_program and gl_shader_program */
2126 struct gl_shader_program_data
*data
;
2128 struct gl_active_atomic_buffer
**AtomicBuffers
;
2130 /** Post-link transform feedback info. */
2131 struct gl_transform_feedback_info
*LinkedTransformFeedback
;
2134 * Number of types for subroutine uniforms.
2136 GLuint NumSubroutineUniformTypes
;
2139 * Subroutine uniform remap table
2140 * based on the program level uniform remap table.
2142 GLuint NumSubroutineUniforms
; /* non-sparse total */
2143 GLuint NumSubroutineUniformRemapTable
;
2144 struct gl_uniform_storage
**SubroutineUniformRemapTable
;
2147 * Num of subroutine functions for this stage and storage for them.
2149 GLuint NumSubroutineFunctions
;
2150 GLuint MaxSubroutineFunctionIndex
;
2151 struct gl_subroutine_function
*SubroutineFunctions
;
2154 * Map from image uniform index to image unit (set by glUniform1i())
2156 * An image uniform index is associated with each image uniform by
2157 * the linker. The image index associated with each uniform is
2158 * stored in the \c gl_uniform_storage::image field.
2160 GLubyte ImageUnits
[MAX_IMAGE_UNIFORMS
];
2163 * Access qualifier specified in the shader for each image uniform
2164 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY, \c
2165 * GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
2168 * It may be different, though only more strict than the value of
2169 * \c gl_image_unit::Access for the corresponding image unit.
2171 GLenum16 ImageAccess
[MAX_IMAGE_UNIFORMS
];
2173 struct gl_uniform_block
**UniformBlocks
;
2174 struct gl_uniform_block
**ShaderStorageBlocks
;
2177 * Bitmask of shader storage blocks not declared as read-only.
2179 unsigned ShaderStorageBlocksWriteAccess
;
2181 /** Which texture target is being sampled
2182 * (TEXTURE_1D/2D/3D/etc_INDEX)
2184 GLubyte SamplerTargets
[MAX_SAMPLERS
];
2187 * Number of samplers declared with the bindless_sampler layout
2188 * qualifier as specified by ARB_bindless_texture.
2190 GLuint NumBindlessSamplers
;
2191 GLboolean HasBoundBindlessSampler
;
2192 struct gl_bindless_sampler
*BindlessSamplers
;
2195 * Number of images declared with the bindless_image layout qualifier
2196 * as specified by ARB_bindless_texture.
2198 GLuint NumBindlessImages
;
2199 GLboolean HasBoundBindlessImage
;
2200 struct gl_bindless_image
*BindlessImages
;
2205 * A bitmask of gl_advanced_blend_mode values
2207 GLbitfield BlendSupport
;
2212 /** ARB assembly-style program fields */
2214 struct prog_instruction
*Instructions
;
2217 * Local parameters used by the program.
2219 * It's dynamically allocated because it is rarely used (just
2220 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2221 * once it's allocated.
2223 GLfloat (*LocalParams
)[4];
2225 /** Bitmask of which register files are read/written with indirect
2226 * addressing. Mask of (1 << PROGRAM_x) bits.
2228 GLbitfield IndirectRegisterFiles
;
2230 /** Logical counts */
2232 GLuint NumInstructions
;
2233 GLuint NumTemporaries
;
2234 GLuint NumParameters
;
2235 GLuint NumAttributes
;
2236 GLuint NumAddressRegs
;
2237 GLuint NumAluInstructions
;
2238 GLuint NumTexInstructions
;
2239 GLuint NumTexIndirections
;
2241 /** Native, actual h/w counts */
2243 GLuint NumNativeInstructions
;
2244 GLuint NumNativeTemporaries
;
2245 GLuint NumNativeParameters
;
2246 GLuint NumNativeAttributes
;
2247 GLuint NumNativeAddressRegs
;
2248 GLuint NumNativeAluInstructions
;
2249 GLuint NumNativeTexInstructions
;
2250 GLuint NumNativeTexIndirections
;
2253 /** Used by ARB assembly-style programs. Can only be true for vertex
2256 GLboolean IsPositionInvariant
;
2263 * State common to vertex and fragment programs.
2265 struct gl_program_state
2267 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2268 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2273 * Context state for vertex programs.
2275 struct gl_vertex_program_state
2277 GLboolean Enabled
; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2278 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2279 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2280 /** Should fixed-function T&L be implemented with a vertex prog? */
2281 GLboolean _MaintainTnlProgram
;
2283 struct gl_program
*Current
; /**< User-bound vertex program */
2285 /** Currently enabled and valid vertex program (including internal
2286 * programs, user-defined vertex programs and GLSL vertex shaders).
2287 * This is the program we must use when rendering.
2289 struct gl_program
*_Current
;
2291 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2293 /** Program to emulate fixed-function T&L (see above) */
2294 struct gl_program
*_TnlProgram
;
2296 /** Cache of fixed-function programs */
2297 struct gl_program_cache
*Cache
;
2299 GLboolean _Overriden
;
2302 * If we have a vertex program, a TNL program or no program at all.
2303 * Note that this value should be kept up to date all the time,
2304 * nevertheless its correctness is asserted in _mesa_update_state.
2305 * The reason is to avoid calling _mesa_update_state twice we need
2306 * this value on draw *before* actually calling _mesa_update_state.
2307 * Also it should need to get recomputed only on changes to the
2308 * vertex program which are heavyweight already.
2310 gl_vertex_processing_mode _VPMode
;
2314 * Context state for tessellation control programs.
2316 struct gl_tess_ctrl_program_state
2318 /** Currently bound and valid shader. */
2319 struct gl_program
*_Current
;
2321 GLint patch_vertices
;
2322 GLfloat patch_default_outer_level
[4];
2323 GLfloat patch_default_inner_level
[2];
2327 * Context state for tessellation evaluation programs.
2329 struct gl_tess_eval_program_state
2331 /** Currently bound and valid shader. */
2332 struct gl_program
*_Current
;
2336 * Context state for geometry programs.
2338 struct gl_geometry_program_state
2341 * Currently enabled and valid program (including internal programs
2342 * and compiled shader programs).
2344 struct gl_program
*_Current
;
2348 * Context state for fragment programs.
2350 struct gl_fragment_program_state
2352 GLboolean Enabled
; /**< User-set fragment program enable flag */
2353 /** Should fixed-function texturing be implemented with a fragment prog? */
2354 GLboolean _MaintainTexEnvProgram
;
2356 struct gl_program
*Current
; /**< User-bound fragment program */
2359 * Currently enabled and valid fragment program (including internal
2360 * programs, user-defined fragment programs and GLSL fragment shaders).
2361 * This is the program we must use when rendering.
2363 struct gl_program
*_Current
;
2365 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2367 /** Program to emulate fixed-function texture env/combine (see above) */
2368 struct gl_program
*_TexEnvProgram
;
2370 /** Cache of fixed-function programs */
2371 struct gl_program_cache
*Cache
;
2376 * Context state for compute programs.
2378 struct gl_compute_program_state
2380 /** Currently enabled and valid program (including internal programs
2381 * and compiled shader programs).
2383 struct gl_program
*_Current
;
2388 * ATI_fragment_shader runtime state
2391 struct atifs_instruction
;
2392 struct atifs_setupinst
;
2395 * ATI fragment shader
2397 struct ati_fragment_shader
2401 struct atifs_instruction
*Instructions
[2];
2402 struct atifs_setupinst
*SetupInst
[2];
2403 GLfloat Constants
[8][4];
2404 GLbitfield LocalConstDef
; /**< Indicates which constants have been set */
2405 GLubyte numArithInstr
[2];
2406 GLubyte regsAssigned
[2];
2407 GLubyte NumPasses
; /**< 1 or 2 */
2409 * Current compile stage: 0 setup pass1, 1 arith pass1,
2410 * 2 setup pass2, 3 arith pass2.
2413 GLubyte last_optype
;
2414 GLboolean interpinp1
;
2417 * Array of 2 bit values for each tex unit to remember whether
2418 * STR or STQ swizzle was used
2421 struct gl_program
*Program
;
2425 * Context state for GL_ATI_fragment_shader
2427 struct gl_ati_fragment_shader_state
2430 GLboolean Compiling
;
2431 GLfloat GlobalConstants
[8][4];
2432 struct ati_fragment_shader
*Current
;
2436 * Shader subroutine function definition
2438 struct gl_subroutine_function
2442 int num_compat_types
;
2443 const struct glsl_type
**types
;
2447 * Shader information needed by both gl_shader and gl_linked shader.
2449 struct gl_shader_info
2452 * Tessellation Control shader state from layout qualifiers.
2456 * 0 - vertices not declared in shader, or
2457 * 1 .. GL_MAX_PATCH_VERTICES
2463 * Tessellation Evaluation shader state from layout qualifiers.
2467 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2470 GLenum16 PrimitiveMode
;
2472 enum gl_tess_spacing Spacing
;
2475 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2477 GLenum16 VertexOrder
;
2479 * 1, 0, or -1 if it's not set in this shader.
2485 * Geometry shader state from GLSL 1.50 layout qualifiers.
2490 * 0 - Invocations count not declared in shader, or
2491 * 1 .. Const.MaxGeometryShaderInvocations
2495 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2496 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2501 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2502 * it's not set in this shader.
2504 GLenum16 OutputType
;
2508 * Compute shader state from ARB_compute_shader and
2509 * ARB_compute_variable_group_size layout qualifiers.
2513 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2514 * it's not set in this shader.
2516 unsigned LocalSize
[3];
2519 * Whether a variable work group size has been specified as defined by
2520 * ARB_compute_variable_group_size.
2522 bool LocalSizeVariable
;
2525 * Arrangement of invocations used to calculate derivatives in a compute
2526 * shader. From NV_compute_shader_derivatives.
2528 enum gl_derivative_group DerivativeGroup
;
2533 * A linked GLSL shader object.
2535 struct gl_linked_shader
2537 gl_shader_stage Stage
;
2540 unsigned SourceChecksum
;
2543 struct gl_program
*Program
; /**< Post-compile assembly code */
2546 * \name Sampler tracking
2548 * \note Each of these fields is only set post-linking.
2551 GLbitfield shadow_samplers
; /**< Samplers used for shadow sampling. */
2555 * Number of default uniform block components used by this shader.
2557 * This field is only set post-linking.
2559 unsigned num_uniform_components
;
2562 * Number of combined uniform components used by this shader.
2564 * This field is only set post-linking. It is the sum of the uniform block
2565 * sizes divided by sizeof(float), and num_uniform_compoennts.
2567 unsigned num_combined_uniform_components
;
2569 struct exec_list
*ir
;
2570 struct exec_list
*packed_varyings
;
2571 struct exec_list
*fragdata_arrays
;
2572 struct glsl_symbol_table
*symbols
;
2575 * ARB_gl_spirv related data.
2577 * This is actually a reference to the gl_shader::spirv_data, which
2578 * stores information that is also needed during linking.
2580 struct gl_shader_spirv_data
*spirv_data
;
2585 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2586 * was skipped due to the shader matching one that's been seen before by
2587 * the on-disk cache.
2589 enum gl_compile_status
2591 COMPILE_FAILURE
= 0,
2597 * A GLSL shader object.
2601 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2602 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2603 * Must be the first field.
2606 gl_shader_stage Stage
;
2607 GLuint Name
; /**< AKA the handle */
2608 GLint RefCount
; /**< Reference count */
2609 GLchar
*Label
; /**< GL_KHR_debug */
2610 unsigned char sha1
[20]; /**< SHA1 hash of pre-processed source */
2611 GLboolean DeletePending
;
2612 bool IsES
; /**< True if this shader uses GLSL ES */
2614 enum gl_compile_status CompileStatus
;
2617 unsigned SourceChecksum
; /**< for debug/logging purposes */
2619 const GLchar
*Source
; /**< Source code string */
2621 const GLchar
*FallbackSource
; /**< Fallback string used by on-disk cache*/
2625 unsigned Version
; /**< GLSL version used for linking */
2628 * A bitmask of gl_advanced_blend_mode values
2630 GLbitfield BlendSupport
;
2632 struct exec_list
*ir
;
2633 struct glsl_symbol_table
*symbols
;
2636 * Whether early fragment tests are enabled as defined by
2637 * ARB_shader_image_load_store.
2639 bool EarlyFragmentTests
;
2641 bool ARB_fragment_coord_conventions_enable
;
2643 bool redeclares_gl_fragcoord
;
2644 bool uses_gl_fragcoord
;
2646 bool PostDepthCoverage
;
2647 bool PixelInterlockOrdered
;
2648 bool PixelInterlockUnordered
;
2649 bool SampleInterlockOrdered
;
2650 bool SampleInterlockUnordered
;
2654 * Fragment shader state from GLSL 1.50 layout qualifiers.
2656 bool origin_upper_left
;
2657 bool pixel_center_integer
;
2660 * Whether bindless_sampler/bindless_image, and respectively
2661 * bound_sampler/bound_image are declared at global scope as defined by
2662 * ARB_bindless_texture.
2664 bool bindless_sampler
;
2665 bool bindless_image
;
2669 /** Global xfb_stride out qualifier if any */
2670 GLuint TransformFeedbackBufferStride
[MAX_FEEDBACK_BUFFERS
];
2672 struct gl_shader_info info
;
2674 /* ARB_gl_spirv related data */
2675 struct gl_shader_spirv_data
*spirv_data
;
2679 struct gl_uniform_buffer_variable
2684 * Name of the uniform as seen by glGetUniformIndices.
2686 * glGetUniformIndices requires that the block instance index \b not be
2687 * present in the name of queried uniforms.
2690 * \c gl_uniform_buffer_variable::IndexName and
2691 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2695 const struct glsl_type
*Type
;
2696 unsigned int Offset
;
2701 struct gl_uniform_block
2703 /** Declared name of the uniform block */
2706 /** Array of supplemental information about UBO ir_variables. */
2707 struct gl_uniform_buffer_variable
*Uniforms
;
2711 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2712 * with glBindBufferBase to bind a buffer object to this uniform block.
2717 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2718 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2720 GLuint UniformBufferSize
;
2722 /** Stages that reference this block */
2726 * Linearized array index for uniform block instance arrays
2728 * Given a uniform block instance array declared with size
2729 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2730 * have the linearized array index
2733 * i_m + ∑ i_j * ∏ s_k
2736 * For a uniform block instance that is not an array, this is always 0.
2738 uint8_t linearized_array_index
;
2741 * Layout specified in the shader
2743 * This isn't accessible through the API, but it is used while
2744 * cross-validating uniform blocks.
2746 enum glsl_interface_packing _Packing
;
2747 GLboolean _RowMajor
;
2751 * Structure that represents a reference to an atomic buffer from some
2754 struct gl_active_atomic_buffer
2756 /** Uniform indices of the atomic counters declared within it. */
2760 /** Binding point index associated with it. */
2763 /** Minimum reasonable size it is expected to have. */
2766 /** Shader stages making use of it. */
2767 GLboolean StageReferences
[MESA_SHADER_STAGES
];
2771 * Data container for shader queries. This holds only the minimal
2772 * amount of required information for resource queries to work.
2774 struct gl_shader_variable
2777 * Declared type of the variable
2779 const struct glsl_type
*type
;
2782 * If the variable is in an interface block, this is the type of the block.
2784 const struct glsl_type
*interface_type
;
2787 * For variables inside structs (possibly recursively), this is the
2788 * outermost struct type.
2790 const struct glsl_type
*outermost_struct_type
;
2793 * Declared name of the variable
2798 * Storage location of the base of this variable
2800 * The precise meaning of this field depends on the nature of the variable.
2802 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2803 * - Vertex shader output: one of the values from \c gl_varying_slot.
2804 * - Geometry shader input: one of the values from \c gl_varying_slot.
2805 * - Geometry shader output: one of the values from \c gl_varying_slot.
2806 * - Fragment shader input: one of the values from \c gl_varying_slot.
2807 * - Fragment shader output: one of the values from \c gl_frag_result.
2808 * - Uniforms: Per-stage uniform slot number for default uniform block.
2809 * - Uniforms: Index within the uniform block definition for UBO members.
2810 * - Non-UBO Uniforms: explicit location until linking then reused to
2811 * store uniform slot number.
2812 * - Other: This field is not currently used.
2814 * If the variable is a uniform, shader input, or shader output, and the
2815 * slot has not been assigned, the value will be -1.
2820 * Specifies the first component the variable is stored in as per
2821 * ARB_enhanced_layouts.
2823 unsigned component
:2;
2826 * Output index for dual source blending.
2829 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2835 * Specifies whether a shader input/output is per-patch in tessellation
2841 * Storage class of the variable.
2843 * \sa (n)ir_variable_mode
2848 * Interpolation mode for shader inputs / outputs
2850 * \sa glsl_interp_mode
2852 unsigned interpolation
:2;
2855 * Was the location explicitly set in the shader?
2857 * If the location is explicitly set in the shader, it \b cannot be changed
2858 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2861 unsigned explicit_location
:1;
2864 * Precision qualifier.
2866 unsigned precision
:2;
2870 * Active resource in a gl_shader_program
2872 struct gl_program_resource
2874 GLenum16 Type
; /** Program interface type. */
2875 const void *Data
; /** Pointer to resource associated data structure. */
2876 uint8_t StageReferences
; /** Bitmask of shader stage references. */
2880 * Link status enum. LINKING_SKIPPED is used to indicate linking
2881 * was skipped due to the shader being loaded from the on-disk cache.
2885 LINKING_FAILURE
= 0,
2891 * A data structure to be shared by gl_shader_program and gl_program.
2893 struct gl_shader_program_data
2895 GLint RefCount
; /**< Reference count */
2897 /** SHA1 hash of linked shader program */
2898 unsigned char sha1
[20];
2900 unsigned NumUniformStorage
;
2901 unsigned NumHiddenUniforms
;
2902 struct gl_uniform_storage
*UniformStorage
;
2904 unsigned NumUniformBlocks
;
2905 unsigned NumShaderStorageBlocks
;
2907 struct gl_uniform_block
*UniformBlocks
;
2908 struct gl_uniform_block
*ShaderStorageBlocks
;
2910 struct gl_active_atomic_buffer
*AtomicBuffers
;
2911 unsigned NumAtomicBuffers
;
2913 /* Shader cache variables used during restore */
2914 unsigned NumUniformDataSlots
;
2915 union gl_constant_value
*UniformDataSlots
;
2917 /* Used to hold initial uniform values for program binary restores.
2919 * From the ARB_get_program_binary spec:
2921 * "A successful call to ProgramBinary will reset all uniform
2922 * variables to their initial values. The initial value is either
2923 * the value of the variable's initializer as specified in the
2924 * original shader source, or 0 if no initializer was present.
2926 union gl_constant_value
*UniformDataDefaults
;
2928 /** Hash for quick search by name. */
2929 struct hash_table_u64
*ProgramResourceHash
;
2931 GLboolean Validated
;
2933 /** List of all active resources after linking. */
2934 struct gl_program_resource
*ProgramResourceList
;
2935 unsigned NumProgramResourceList
;
2937 enum gl_link_status LinkStatus
; /**< GL_LINK_STATUS */
2940 unsigned Version
; /**< GLSL version used for linking */
2942 /* Mask of stages this program was linked against */
2943 unsigned linked_stages
;
2945 /* Whether the shaders of this program are loaded from SPIR-V binaries
2946 * (all have the SPIR_V_BINARY_ARB state). This was introduced by the
2947 * ARB_gl_spirv extension.
2953 * A GLSL program object.
2954 * Basically a linked collection of vertex and fragment shaders.
2956 struct gl_shader_program
2958 GLenum16 Type
; /**< Always GL_SHADER_PROGRAM (internal token) */
2959 GLuint Name
; /**< aka handle or ID */
2960 GLchar
*Label
; /**< GL_KHR_debug */
2961 GLint RefCount
; /**< Reference count */
2962 GLboolean DeletePending
;
2965 * Is the application intending to glGetProgramBinary this program?
2967 * BinaryRetrievableHint is the currently active hint that gets set
2968 * during initialization and after linking and BinaryRetrievableHintPending
2969 * is the hint set by the user to be active when program is linked next time.
2971 GLboolean BinaryRetrievableHint
;
2972 GLboolean BinaryRetrievableHintPending
;
2975 * Indicates whether program can be bound for individual pipeline stages
2976 * using UseProgramStages after it is next linked.
2978 GLboolean SeparateShader
;
2980 GLuint NumShaders
; /**< number of attached shaders */
2981 struct gl_shader
**Shaders
; /**< List of attached the shaders */
2984 * User-defined attribute bindings
2986 * These are set via \c glBindAttribLocation and are used to direct the
2987 * GLSL linker. These are \b not the values used in the compiled shader,
2988 * and they are \b not the values returned by \c glGetAttribLocation.
2990 struct string_to_uint_map
*AttributeBindings
;
2993 * User-defined fragment data bindings
2995 * These are set via \c glBindFragDataLocation and are used to direct the
2996 * GLSL linker. These are \b not the values used in the compiled shader,
2997 * and they are \b not the values returned by \c glGetFragDataLocation.
2999 struct string_to_uint_map
*FragDataBindings
;
3000 struct string_to_uint_map
*FragDataIndexBindings
;
3003 * Transform feedback varyings last specified by
3004 * glTransformFeedbackVaryings().
3006 * For the current set of transform feedback varyings used for transform
3007 * feedback output, see LinkedTransformFeedback.
3010 GLenum16 BufferMode
;
3011 /** Global xfb_stride out qualifier if any */
3012 GLuint BufferStride
[MAX_FEEDBACK_BUFFERS
];
3014 GLchar
**VaryingNames
; /**< Array [NumVarying] of char * */
3015 } TransformFeedback
;
3017 struct gl_program
*last_vert_prog
;
3019 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3020 enum gl_frag_depth_layout FragDepthLayout
;
3023 * Geometry shader state - copied into gl_program by
3024 * _mesa_copy_linked_program_data().
3029 bool UsesEndPrimitive
;
3034 * Compute shader state - copied into gl_program by
3035 * _mesa_copy_linked_program_data().
3039 * Size of shared variables accessed by the compute shader.
3041 unsigned SharedSize
;
3044 /** Data shared by gl_program and gl_shader_program */
3045 struct gl_shader_program_data
*data
;
3048 * Mapping from GL uniform locations returned by \c glUniformLocation to
3049 * UniformStorage entries. Arrays will have multiple contiguous slots
3050 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3052 unsigned NumUniformRemapTable
;
3053 struct gl_uniform_storage
**UniformRemapTable
;
3056 * Sometimes there are empty slots left over in UniformRemapTable after we
3057 * allocate slots to explicit locations. This list stores the blocks of
3058 * continuous empty slots inside UniformRemapTable.
3060 struct exec_list EmptyUniformLocations
;
3063 * Total number of explicit uniform location including inactive uniforms.
3065 unsigned NumExplicitUniformLocations
;
3068 * Map of active uniform names to locations
3070 * Maps any active uniform that is not an array element to a location.
3071 * Each active uniform, including individual structure members will appear
3072 * in this map. This roughly corresponds to the set of names that would be
3073 * enumerated by \c glGetActiveUniform.
3075 struct string_to_uint_map
*UniformHash
;
3077 GLboolean SamplersValidated
; /**< Samplers validated against texture units? */
3079 bool IsES
; /**< True if this program uses GLSL ES */
3082 * Per-stage shaders resulting from the first stage of linking.
3084 * Set of linked shaders for this program. The array is accessed using the
3085 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3088 struct gl_linked_shader
*_LinkedShaders
[MESA_SHADER_STAGES
];
3091 * True if any of the fragment shaders attached to this program use:
3092 * #extension ARB_fragment_coord_conventions: enable
3094 GLboolean ARB_fragment_coord_conventions_enable
;
3098 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3099 #define GLSL_LOG 0x2 /**< Write shaders to files */
3100 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3101 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3102 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3103 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3104 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3105 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3106 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3107 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3111 * Context state for GLSL vertex/fragment shaders.
3112 * Extended to support pipeline object
3114 struct gl_pipeline_object
3116 /** Name of the pipeline object as received from glGenProgramPipelines.
3117 * It would be 0 for shaders without separate shader objects.
3123 GLchar
*Label
; /**< GL_KHR_debug */
3126 * Programs used for rendering
3128 * There is a separate program set for each shader stage.
3130 struct gl_program
*CurrentProgram
[MESA_SHADER_STAGES
];
3132 struct gl_shader_program
*ReferencedPrograms
[MESA_SHADER_STAGES
];
3135 * Program used by glUniform calls.
3137 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3139 struct gl_shader_program
*ActiveProgram
;
3141 GLbitfield Flags
; /**< Mask of GLSL_x flags */
3142 GLboolean EverBound
; /**< Has the pipeline object been created */
3143 GLboolean Validated
; /**< Pipeline Validation status */
3149 * Context state for GLSL pipeline shaders.
3151 struct gl_pipeline_shader_state
3153 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3154 struct gl_pipeline_object
*Current
;
3156 /** Default Object to ensure that _Shader is never NULL */
3157 struct gl_pipeline_object
*Default
;
3159 /** Pipeline objects */
3160 struct _mesa_HashTable
*Objects
;
3164 * Compiler options for a single GLSL shaders type
3166 struct gl_shader_compiler_options
3168 /** Driver-selectable options: */
3169 GLboolean EmitNoLoops
;
3170 GLboolean EmitNoCont
; /**< Emit CONT opcode? */
3171 GLboolean EmitNoMainReturn
; /**< Emit CONT/RET opcodes? */
3172 GLboolean EmitNoPow
; /**< Emit POW opcodes? */
3173 GLboolean EmitNoSat
; /**< Emit SAT opcodes? */
3174 GLboolean LowerCombinedClipCullDistance
; /** Lower gl_ClipDistance and
3175 * gl_CullDistance together from
3176 * float[8] to vec4[2]
3178 GLbitfield LowerBuiltinVariablesXfb
; /**< Which builtin variables should
3179 * be lowered for transform feedback
3183 * \name Forms of indirect addressing the driver cannot do.
3186 GLboolean EmitNoIndirectInput
; /**< No indirect addressing of inputs */
3187 GLboolean EmitNoIndirectOutput
; /**< No indirect addressing of outputs */
3188 GLboolean EmitNoIndirectTemp
; /**< No indirect addressing of temps */
3189 GLboolean EmitNoIndirectUniform
; /**< No indirect addressing of constants */
3190 GLboolean EmitNoIndirectSampler
; /**< No indirect addressing of samplers */
3193 GLuint MaxIfDepth
; /**< Maximum nested IF blocks */
3194 GLuint MaxUnrollIterations
;
3197 * Optimize code for array of structures backends.
3199 * This is a proxy for:
3200 * - preferring DP4 instructions (rather than MUL/MAD) for
3201 * matrix * vector operations, such as position transformation.
3203 GLboolean OptimizeForAOS
;
3205 /** Lower UBO and SSBO access to intrinsics. */
3206 GLboolean LowerBufferInterfaceBlocks
;
3208 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3209 GLboolean ClampBlockIndicesToArrayBounds
;
3211 /** (driconf) Force gl_Position to be considered invariant */
3212 GLboolean PositionAlwaysInvariant
;
3214 const struct nir_shader_compiler_options
*NirOptions
;
3219 * Occlusion/timer query object.
3221 struct gl_query_object
3223 GLenum16 Target
; /**< The query target, when active */
3224 GLuint Id
; /**< hash table ID/name */
3225 GLchar
*Label
; /**< GL_KHR_debug */
3226 GLuint64EXT Result
; /**< the counter */
3227 GLboolean Active
; /**< inside Begin/EndQuery */
3228 GLboolean Ready
; /**< result is ready? */
3229 GLboolean EverBound
;/**< has query object ever been bound */
3230 GLuint Stream
; /**< The stream */
3235 * Context state for query objects.
3237 struct gl_query_state
3239 struct _mesa_HashTable
*QueryObjects
;
3240 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
3241 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
3243 /** GL_NV_conditional_render */
3244 struct gl_query_object
*CondRenderQuery
;
3246 /** GL_EXT_transform_feedback */
3247 struct gl_query_object
*PrimitivesGenerated
[MAX_VERTEX_STREAMS
];
3248 struct gl_query_object
*PrimitivesWritten
[MAX_VERTEX_STREAMS
];
3250 /** GL_ARB_transform_feedback_overflow_query */
3251 struct gl_query_object
*TransformFeedbackOverflow
[MAX_VERTEX_STREAMS
];
3252 struct gl_query_object
*TransformFeedbackOverflowAny
;
3254 /** GL_ARB_timer_query */
3255 struct gl_query_object
*TimeElapsed
;
3257 /** GL_ARB_pipeline_statistics_query */
3258 struct gl_query_object
*pipeline_stats
[MAX_PIPELINE_STATISTICS
];
3260 GLenum16 CondRenderMode
;
3264 /** Sync object state */
3265 struct gl_sync_object
3267 GLuint Name
; /**< Fence name */
3268 GLint RefCount
; /**< Reference count */
3269 GLchar
*Label
; /**< GL_KHR_debug */
3270 GLboolean DeletePending
; /**< Object was deleted while there were still
3271 * live references (e.g., sync not yet finished)
3273 GLenum16 SyncCondition
;
3274 GLbitfield Flags
; /**< Flags passed to glFenceSync */
3275 GLuint StatusFlag
:1; /**< Has the sync object been signaled? */
3280 * State which can be shared by multiple contexts:
3282 struct gl_shared_state
3284 simple_mtx_t Mutex
; /**< for thread safety */
3285 GLint RefCount
; /**< Reference count */
3286 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
3287 struct _mesa_HashTable
*BitmapAtlas
; /**< For optimized glBitmap text */
3288 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
3290 /** Default texture objects (shared by all texture units) */
3291 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
3293 /** Fallback texture used when a bound texture is incomplete */
3294 struct gl_texture_object
*FallbackTex
[NUM_TEXTURE_TARGETS
];
3297 * \name Thread safety and statechange notification for texture
3300 * \todo Improve the granularity of locking.
3303 mtx_t TexMutex
; /**< texobj thread safety */
3304 GLuint TextureStateStamp
; /**< state notification for shared tex */
3307 /** Default buffer object for vertex arrays that aren't in VBOs */
3308 struct gl_buffer_object
*NullBufferObj
;
3311 * \name Vertex/geometry/fragment programs
3314 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
3315 struct gl_program
*DefaultVertexProgram
;
3316 struct gl_program
*DefaultFragmentProgram
;
3319 /* GL_ATI_fragment_shader */
3320 struct _mesa_HashTable
*ATIShaders
;
3321 struct ati_fragment_shader
*DefaultFragmentShader
;
3323 struct _mesa_HashTable
*BufferObjects
;
3325 /** Table of both gl_shader and gl_shader_program objects */
3326 struct _mesa_HashTable
*ShaderObjects
;
3328 /* GL_EXT_framebuffer_object */
3329 struct _mesa_HashTable
*RenderBuffers
;
3330 struct _mesa_HashTable
*FrameBuffers
;
3333 struct set
*SyncObjects
;
3335 /** GL_ARB_sampler_objects */
3336 struct _mesa_HashTable
*SamplerObjects
;
3338 /* GL_ARB_bindless_texture */
3339 struct hash_table_u64
*TextureHandles
;
3340 struct hash_table_u64
*ImageHandles
;
3341 mtx_t HandlesMutex
; /**< For texture/image handles safety */
3343 /* GL_ARB_shading_language_include */
3344 struct shader_includes
*ShaderIncludes
;
3345 /* glCompileShaderInclude expects ShaderIncludes not to change while it is
3348 mtx_t ShaderIncludeMutex
;
3351 * Some context in this share group was affected by a GPU reset
3353 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3354 * been affected by a GPU reset must also return
3355 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3357 * Once this field becomes true, it is never reset to false.
3359 bool ShareGroupReset
;
3361 /** EXT_external_objects */
3362 struct _mesa_HashTable
*MemoryObjects
;
3364 /** EXT_semaphore */
3365 struct _mesa_HashTable
*SemaphoreObjects
;
3368 * Some context in this share group was affected by a disjoint
3369 * operation. This operation can be anything that has effects on
3370 * values of timer queries in such manner that they become invalid for
3371 * performance metrics. As example gpu reset, counter overflow or gpu
3372 * frequency changes.
3374 bool DisjointOperation
;
3380 * Renderbuffers represent drawing surfaces such as color, depth and/or
3381 * stencil. A framebuffer object has a set of renderbuffers.
3382 * Drivers will typically derive subclasses of this type.
3384 struct gl_renderbuffer
3386 simple_mtx_t Mutex
; /**< for thread safety */
3387 GLuint ClassID
; /**< Useful for drivers */
3389 GLchar
*Label
; /**< GL_KHR_debug */
3391 GLuint Width
, Height
;
3393 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
3394 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
3396 * True for renderbuffers that wrap textures, giving the driver a chance to
3397 * flush render caches through the FinishRenderTexture hook.
3399 * Drivers may also set this on renderbuffers other than those generated by
3400 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3401 * called without a rb->TexImage.
3403 GLboolean NeedsFinishRenderTexture
;
3404 GLubyte NumSamples
; /**< zero means not multisampled */
3405 GLubyte NumStorageSamples
; /**< for AMD_framebuffer_multisample_advanced */
3406 GLenum16 InternalFormat
; /**< The user-specified format */
3407 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3408 GL_STENCIL_INDEX. */
3409 mesa_format Format
; /**< The actual renderbuffer memory format */
3411 * Pointer to the texture image if this renderbuffer wraps a texture,
3414 * Note that the reference on the gl_texture_object containing this
3415 * TexImage is held by the gl_renderbuffer_attachment.
3417 struct gl_texture_image
*TexImage
;
3419 /** Delete this renderbuffer */
3420 void (*Delete
)(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
);
3422 /** Allocate new storage for this renderbuffer */
3423 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
3424 struct gl_renderbuffer
*rb
,
3425 GLenum internalFormat
,
3426 GLuint width
, GLuint height
);
3431 * A renderbuffer attachment points to either a texture object (and specifies
3432 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3434 struct gl_renderbuffer_attachment
3436 GLenum16 Type
; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3440 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3441 * application supplied renderbuffer object.
3443 struct gl_renderbuffer
*Renderbuffer
;
3446 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3447 * supplied texture object.
3449 struct gl_texture_object
*Texture
;
3450 GLuint TextureLevel
; /**< Attached mipmap level. */
3451 GLsizei NumSamples
; /**< from FramebufferTexture2DMultisampleEXT */
3452 GLuint CubeMapFace
; /**< 0 .. 5, for cube map textures. */
3453 GLuint Zoffset
; /**< Slice for 3D textures, or layer for both 1D
3454 * and 2D array textures */
3460 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3461 * In C++ terms, think of this as a base class from which device drivers
3462 * will make derived classes.
3464 struct gl_framebuffer
3466 simple_mtx_t Mutex
; /**< for thread safety */
3468 * If zero, this is a window system framebuffer. If non-zero, this
3469 * is a FBO framebuffer; note that for some devices (i.e. those with
3470 * a natural pixel coordinate system for FBOs that differs from the
3471 * OpenGL/Mesa coordinate system), this means that the viewport,
3472 * polygon face orientation, and polygon stipple will have to be inverted.
3477 GLchar
*Label
; /**< GL_KHR_debug */
3479 GLboolean DeletePending
;
3482 * The framebuffer's visual. Immutable if this is a window system buffer.
3483 * Computed from attachments if user-made FBO.
3485 struct gl_config Visual
;
3488 * Size of frame buffer in pixels. If there are no attachments, then both
3491 GLuint Width
, Height
;
3494 * In the case that the framebuffer has no attachment (i.e.
3495 * GL_ARB_framebuffer_no_attachments) then the geometry of
3496 * the framebuffer is specified by the default values.
3499 GLuint Width
, Height
, Layers
, NumSamples
;
3500 GLboolean FixedSampleLocations
;
3501 /* Derived from NumSamples by the driver so that it can choose a valid
3502 * value for the hardware.
3507 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3508 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3509 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3516 /** \name Derived Z buffer stuff */
3518 GLuint _DepthMax
; /**< Max depth buffer value */
3519 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
3520 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
3523 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3526 /** Whether one of Attachment has Type != GL_NONE
3527 * NOTE: the values for Width and Height are set to 0 in case of having
3528 * no attachments, a backend driver supporting the extension
3529 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3530 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3531 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3532 * _Ymax do NOT take into account _HasAttachments being false). To get the
3533 * geometry of the framebuffer, the helper functions
3534 * _mesa_geometric_width(),
3535 * _mesa_geometric_height(),
3536 * _mesa_geometric_samples() and
3537 * _mesa_geometric_layers()
3538 * are available that check _HasAttachments.
3540 bool _HasAttachments
;
3542 GLbitfield _IntegerBuffers
; /**< Which color buffers are integer valued */
3543 GLbitfield _RGBBuffers
; /**< Which color buffers have baseformat == RGB */
3544 GLbitfield _FP32Buffers
; /**< Which color buffers are FP32 */
3546 /* ARB_color_buffer_float */
3547 GLboolean _AllColorBuffersFixedPoint
; /* no integer, no float */
3548 GLboolean _HasSNormOrFloatColorBuffer
;
3551 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3552 * is not layered. For cube maps and cube map arrays, each cube face
3553 * counts as a layer. As the case for Width, Height a backend driver
3554 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3555 * in the case that _HasAttachments is false
3557 GLuint MaxNumLayers
;
3559 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3560 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
3562 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3563 * attribute group and GL_PIXEL attribute group, respectively.
3565 GLenum16 ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
3566 GLenum16 ColorReadBuffer
;
3568 /* GL_ARB_sample_locations */
3569 GLfloat
*SampleLocationTable
; /**< If NULL, no table has been specified */
3570 GLboolean ProgrammableSampleLocations
;
3571 GLboolean SampleLocationPixelGrid
;
3573 /** Computed from ColorDraw/ReadBuffer above */
3574 GLuint _NumColorDrawBuffers
;
3575 gl_buffer_index _ColorDrawBufferIndexes
[MAX_DRAW_BUFFERS
];
3576 gl_buffer_index _ColorReadBufferIndex
;
3577 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
];
3578 struct gl_renderbuffer
*_ColorReadBuffer
;
3580 /* GL_MESA_framebuffer_flip_y */
3583 /** Delete this framebuffer */
3584 void (*Delete
)(struct gl_framebuffer
*fb
);
3589 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3593 GLushort RangeMin
; /**< min value exponent */
3594 GLushort RangeMax
; /**< max value exponent */
3595 GLushort Precision
; /**< number of mantissa bits */
3600 * Limits for vertex, geometry and fragment programs/shaders.
3602 struct gl_program_constants
3604 /* logical limits */
3605 GLuint MaxInstructions
;
3606 GLuint MaxAluInstructions
;
3607 GLuint MaxTexInstructions
;
3608 GLuint MaxTexIndirections
;
3611 GLuint MaxAddressRegs
;
3612 GLuint MaxAddressOffset
; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3613 GLuint MaxParameters
;
3614 GLuint MaxLocalParams
;
3615 GLuint MaxEnvParams
;
3616 /* native/hardware limits */
3617 GLuint MaxNativeInstructions
;
3618 GLuint MaxNativeAluInstructions
;
3619 GLuint MaxNativeTexInstructions
;
3620 GLuint MaxNativeTexIndirections
;
3621 GLuint MaxNativeAttribs
;
3622 GLuint MaxNativeTemps
;
3623 GLuint MaxNativeAddressRegs
;
3624 GLuint MaxNativeParameters
;
3626 GLuint MaxUniformComponents
; /**< Usually == MaxParameters * 4 */
3629 * \name Per-stage input / output limits
3631 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3632 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3633 * ES). This is stored as \c gl_constants::MaxVarying.
3635 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3636 * variables. Each stage as a certain number of outputs that it can feed
3637 * to the next stage and a certain number inputs that it can consume from
3638 * the previous stage.
3640 * Vertex shader inputs do not participate this in this accounting.
3641 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3643 * Fragment shader outputs do not participate this in this accounting.
3644 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3647 GLuint MaxInputComponents
;
3648 GLuint MaxOutputComponents
;
3651 /* ES 2.0 and GL_ARB_ES2_compatibility */
3652 struct gl_precision LowFloat
, MediumFloat
, HighFloat
;
3653 struct gl_precision LowInt
, MediumInt
, HighInt
;
3654 /* GL_ARB_uniform_buffer_object */
3655 GLuint MaxUniformBlocks
;
3656 uint64_t MaxCombinedUniformComponents
;
3657 GLuint MaxTextureImageUnits
;
3659 /* GL_ARB_shader_atomic_counters */
3660 GLuint MaxAtomicBuffers
;
3661 GLuint MaxAtomicCounters
;
3663 /* GL_ARB_shader_image_load_store */
3664 GLuint MaxImageUniforms
;
3666 /* GL_ARB_shader_storage_buffer_object */
3667 GLuint MaxShaderStorageBlocks
;
3671 * Constants which may be overridden by device driver during context creation
3672 * but are never changed after that.
3676 GLuint MaxTextureMbytes
; /**< Max memory per image, in MB */
3677 GLuint MaxTextureSize
; /**< Max 1D/2D texture size, in pixels*/
3678 GLuint Max3DTextureLevels
; /**< Max mipmap levels for 3D textures */
3679 GLuint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
3680 GLuint MaxArrayTextureLayers
; /**< Max layers in array textures */
3681 GLuint MaxTextureRectSize
; /**< Max rectangle texture size, in pixes */
3682 GLuint MaxTextureCoordUnits
;
3683 GLuint MaxCombinedTextureImageUnits
;
3684 GLuint MaxTextureUnits
; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3685 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
3686 GLfloat MaxTextureLodBias
; /**< GL_EXT_texture_lod_bias */
3687 GLuint MaxTextureBufferSize
; /**< GL_ARB_texture_buffer_object */
3689 GLuint TextureBufferOffsetAlignment
; /**< GL_ARB_texture_buffer_range */
3691 GLuint MaxArrayLockSize
;
3695 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
3696 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
3697 GLfloat PointSizeGranularity
;
3698 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
3699 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
3700 GLfloat LineWidthGranularity
;
3702 GLuint MaxClipPlanes
;
3704 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
3705 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
3707 GLuint MaxViewportWidth
, MaxViewportHeight
;
3708 GLuint MaxViewports
; /**< GL_ARB_viewport_array */
3709 GLuint ViewportSubpixelBits
; /**< GL_ARB_viewport_array */
3713 } ViewportBounds
; /**< GL_ARB_viewport_array */
3714 GLuint MaxWindowRectangles
; /**< GL_EXT_window_rectangles */
3716 struct gl_program_constants Program
[MESA_SHADER_STAGES
];
3717 GLuint MaxProgramMatrices
;
3718 GLuint MaxProgramMatrixStackDepth
;
3721 GLuint SamplesPassed
;
3724 GLuint PrimitivesGenerated
;
3725 GLuint PrimitivesWritten
;
3726 GLuint VerticesSubmitted
;
3727 GLuint PrimitivesSubmitted
;
3728 GLuint VsInvocations
;
3730 GLuint TessInvocations
;
3731 GLuint GsInvocations
;
3732 GLuint GsPrimitives
;
3733 GLuint FsInvocations
;
3734 GLuint ComputeInvocations
;
3735 GLuint ClInPrimitives
;
3736 GLuint ClOutPrimitives
;
3739 GLuint MaxDrawBuffers
; /**< GL_ARB_draw_buffers */
3741 GLuint MaxColorAttachments
; /**< GL_EXT_framebuffer_object */
3742 GLuint MaxRenderbufferSize
; /**< GL_EXT_framebuffer_object */
3743 GLuint MaxSamples
; /**< GL_ARB_framebuffer_object */
3746 * GL_ARB_framebuffer_no_attachments
3748 GLuint MaxFramebufferWidth
;
3749 GLuint MaxFramebufferHeight
;
3750 GLuint MaxFramebufferLayers
;
3751 GLuint MaxFramebufferSamples
;
3753 /** Number of varying vectors between any two shader stages. */
3757 * GL_ARB_uniform_buffer_object
3759 GLuint MaxCombinedUniformBlocks
;
3760 GLuint MaxUniformBufferBindings
;
3761 GLuint MaxUniformBlockSize
;
3762 GLuint UniformBufferOffsetAlignment
;
3766 * GL_ARB_shader_storage_buffer_object
3768 GLuint MaxCombinedShaderStorageBlocks
;
3769 GLuint MaxShaderStorageBufferBindings
;
3770 GLuint MaxShaderStorageBlockSize
;
3771 GLuint ShaderStorageBufferOffsetAlignment
;
3775 * GL_ARB_explicit_uniform_location
3777 GLuint MaxUserAssignableUniformLocations
;
3779 /** geometry shader */
3780 GLuint MaxGeometryOutputVertices
;
3781 GLuint MaxGeometryTotalOutputComponents
;
3782 GLuint MaxGeometryShaderInvocations
;
3784 GLuint GLSLVersion
; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3785 GLuint GLSLVersionCompat
; /**< Desktop compat GLSL version supported */
3788 * Changes default GLSL extension behavior from "error" to "warn". It's out
3789 * of spec, but it can make some apps work that otherwise wouldn't.
3791 GLboolean ForceGLSLExtensionsWarn
;
3794 * If non-zero, forces GLSL shaders to behave as if they began
3795 * with "#version ForceGLSLVersion".
3797 GLuint ForceGLSLVersion
;
3800 * Allow GLSL #extension directives in the middle of shaders.
3802 GLboolean AllowGLSLExtensionDirectiveMidShader
;
3805 * Allow builtins as part of constant expressions. This was not allowed
3806 * until GLSL 1.20 this allows it everywhere.
3808 GLboolean AllowGLSLBuiltinConstantExpression
;
3811 * Allow some relaxation of GLSL ES shader restrictions. This encompasses
3812 * a number of relaxations to the ES shader rules.
3814 GLboolean AllowGLSLRelaxedES
;
3817 * Allow GLSL built-in variables to be redeclared verbatim
3819 GLboolean AllowGLSLBuiltinVariableRedeclaration
;
3822 * Allow GLSL interpolation qualifier mismatch across shader stages.
3824 GLboolean AllowGLSLCrossStageInterpolationMismatch
;
3827 * Allow creating a higher compat profile (version 3.1+) for apps that
3828 * request it. Be careful when adding that driconf option because some
3829 * features are unimplemented and might not work correctly.
3831 GLboolean AllowHigherCompatVersion
;
3834 * Allow layout qualifiers on function parameters.
3836 GLboolean AllowLayoutQualifiersOnFunctionParameters
;
3839 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3840 * D3D9 when apps rely on this behaviour.
3842 GLboolean ForceGLSLAbsSqrt
;
3845 * Force uninitialized variables to default to zero.
3847 GLboolean GLSLZeroInit
;
3850 * Does the driver support real 32-bit integers? (Otherwise, integers are
3851 * simulated via floats.)
3853 GLboolean NativeIntegers
;
3856 * Does VertexID count from zero or from base vertex?
3859 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3860 * ignored and need not be set.
3862 bool VertexID_is_zero_based
;
3865 * If the driver supports real 32-bit integers, what integer value should be
3866 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3868 GLuint UniformBooleanTrue
;
3871 * Maximum amount of time, measured in nanseconds, that the server can wait.
3873 GLuint64 MaxServerWaitTimeout
;
3875 /** GL_EXT_provoking_vertex */
3876 GLboolean QuadsFollowProvokingVertexConvention
;
3878 /** GL_ARB_viewport_array */
3879 GLenum16 LayerAndVPIndexProvokingVertex
;
3881 /** OpenGL version 3.0 */
3882 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3884 /** OpenGL version 3.2 */
3885 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
3887 /** OpenGL version 4.4 */
3888 GLuint MaxVertexAttribStride
;
3890 /** GL_EXT_transform_feedback */
3891 GLuint MaxTransformFeedbackBuffers
;
3892 GLuint MaxTransformFeedbackSeparateComponents
;
3893 GLuint MaxTransformFeedbackInterleavedComponents
;
3894 GLuint MaxVertexStreams
;
3896 /** GL_EXT_gpu_shader4 */
3897 GLint MinProgramTexelOffset
, MaxProgramTexelOffset
;
3899 /** GL_ARB_texture_gather */
3900 GLuint MinProgramTextureGatherOffset
;
3901 GLuint MaxProgramTextureGatherOffset
;
3902 GLuint MaxProgramTextureGatherComponents
;
3904 /* GL_ARB_robustness */
3905 GLenum16 ResetStrategy
;
3907 /* GL_KHR_robustness */
3908 GLboolean RobustAccess
;
3910 /* GL_ARB_blend_func_extended */
3911 GLuint MaxDualSourceDrawBuffers
;
3914 * Whether the implementation strips out and ignores texture borders.
3916 * Many GPU hardware implementations don't support rendering with texture
3917 * borders and mipmapped textures. (Note: not static border color, but the
3918 * old 1-pixel border around each edge). Implementations then have to do
3919 * slow fallbacks to be correct, or just ignore the border and be fast but
3920 * wrong. Setting the flag strips the border off of TexImage calls,
3921 * providing "fast but wrong" at significantly reduced driver complexity.
3923 * Texture borders are deprecated in GL 3.0.
3925 GLboolean StripTextureBorder
;
3928 * For drivers which can do a better job at eliminating unused uniforms
3929 * than the GLSL compiler.
3931 * XXX Remove these as soon as a better solution is available.
3933 GLboolean GLSLSkipStrictMaxUniformLimitCheck
;
3936 * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
3937 * are system values.
3939 bool GLSLFragCoordIsSysVal
;
3940 bool GLSLPointCoordIsSysVal
;
3941 bool GLSLFrontFacingIsSysVal
;
3944 * Run the minimum amount of GLSL optimizations to be able to link
3945 * shaders optimally (eliminate dead varyings and uniforms) and just do
3946 * all the necessary lowering.
3948 bool GLSLOptimizeConservatively
;
3951 * Whether to call lower_const_arrays_to_uniforms() during linking.
3953 bool GLSLLowerConstArrays
;
3956 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3957 * (otherwise, they're system values).
3959 bool GLSLTessLevelsAsInputs
;
3962 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3963 * than passing the transform feedback object to the drawing function.
3965 GLboolean AlwaysUseGetTransformFeedbackVertexCount
;
3967 /** GL_ARB_map_buffer_alignment */
3968 GLuint MinMapBufferAlignment
;
3971 * Disable varying packing. This is out of spec, but potentially useful
3972 * for older platforms that supports a limited number of texture
3973 * indirections--on these platforms, unpacking the varyings in the fragment
3974 * shader increases the number of texture indirections by 1, which might
3975 * make some shaders not executable at all.
3977 * Drivers that support transform feedback must set this value to GL_FALSE.
3979 GLboolean DisableVaryingPacking
;
3982 * Disable varying packing if used for transform feedback. This is needed
3983 * for some drivers (e.g. Panfrost) where transform feedback requires
3984 * unpacked varyings.
3986 * This variable is mutually exlusive with DisableVaryingPacking.
3988 GLboolean DisableTransformFeedbackPacking
;
3991 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3992 * layout is set as shared (the default) or packed. However most Mesa drivers
3993 * just use STD140 for these layouts. This flag allows drivers to use STD430
3994 * for packed and shared layouts which allows arrays to be packed more
3997 bool UseSTD430AsDefaultPacking
;
4000 * Should meaningful names be generated for compiler temporary variables?
4002 * Generally, it is not useful to have the compiler generate "meaningful"
4003 * names for temporary variables that it creates. This can, however, be a
4004 * useful debugging aid. In Mesa debug builds or release builds when
4005 * MESA_GLSL is set at run-time, meaningful names will be generated.
4006 * Drivers can also force names to be generated by setting this field.
4007 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
4008 * vertex shader assembly) is set at run-time.
4010 bool GenerateTemporaryNames
;
4013 * Maximum value supported for an index in DrawElements and friends.
4015 * This must be at least (1ull<<24)-1. The default value is
4018 * \since ES 3.0 or GL_ARB_ES3_compatibility
4019 * \sa _mesa_init_constants
4021 GLuint64 MaxElementIndex
;
4024 * Disable interpretation of line continuations (lines ending with a
4025 * backslash character ('\') in GLSL source.
4027 GLboolean DisableGLSLLineContinuations
;
4029 /** GL_ARB_texture_multisample */
4030 GLint MaxColorTextureSamples
;
4031 GLint MaxDepthTextureSamples
;
4032 GLint MaxIntegerSamples
;
4034 /** GL_AMD_framebuffer_multisample_advanced */
4035 GLint MaxColorFramebufferSamples
;
4036 GLint MaxColorFramebufferStorageSamples
;
4037 GLint MaxDepthStencilFramebufferSamples
;
4039 /* An array of supported MSAA modes allowing different sample
4040 * counts per attachment type.
4043 GLint NumColorSamples
;
4044 GLint NumColorStorageSamples
;
4045 GLint NumDepthStencilSamples
;
4046 } SupportedMultisampleModes
[40];
4047 GLint NumSupportedMultisampleModes
;
4050 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
4051 * samples are laid out in a rectangular grid roughly corresponding to
4052 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
4053 * are used to map indices of rectangular grid to sample numbers within
4054 * a pixel. This mapping of indices to sample numbers must be initialized
4055 * by the driver for the target hardware. For example, if we have the 8X
4056 * MSAA sample number layout (sample positions) for XYZ hardware:
4058 * sample indices layout sample number layout
4059 * --------- ---------
4060 * | 0 | 1 | | a | b |
4061 * --------- ---------
4062 * | 2 | 3 | | c | d |
4063 * --------- ---------
4064 * | 4 | 5 | | e | f |
4065 * --------- ---------
4066 * | 6 | 7 | | g | h |
4067 * --------- ---------
4069 * Where a,b,c,d,e,f,g,h are integers between [0-7].
4071 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
4073 * SampleMap8x = {a, b, c, d, e, f, g, h};
4075 * Follow the logic for sample counts 2-8.
4077 * For 16x the sample indices layout as a 4x4 grid as follows:
4089 uint8_t SampleMap2x
[2];
4090 uint8_t SampleMap4x
[4];
4091 uint8_t SampleMap8x
[8];
4092 uint8_t SampleMap16x
[16];
4094 /** GL_ARB_shader_atomic_counters */
4095 GLuint MaxAtomicBufferBindings
;
4096 GLuint MaxAtomicBufferSize
;
4097 GLuint MaxCombinedAtomicBuffers
;
4098 GLuint MaxCombinedAtomicCounters
;
4100 /** GL_ARB_vertex_attrib_binding */
4101 GLint MaxVertexAttribRelativeOffset
;
4102 GLint MaxVertexAttribBindings
;
4104 /* GL_ARB_shader_image_load_store */
4105 GLuint MaxImageUnits
;
4106 GLuint MaxCombinedShaderOutputResources
;
4107 GLuint MaxImageSamples
;
4108 GLuint MaxCombinedImageUniforms
;
4110 /** GL_ARB_compute_shader */
4111 GLuint MaxComputeWorkGroupCount
[3]; /* Array of x, y, z dimensions */
4112 GLuint MaxComputeWorkGroupSize
[3]; /* Array of x, y, z dimensions */
4113 GLuint MaxComputeWorkGroupInvocations
;
4114 GLuint MaxComputeSharedMemorySize
;
4116 /** GL_ARB_compute_variable_group_size */
4117 GLuint MaxComputeVariableGroupSize
[3]; /* Array of x, y, z dimensions */
4118 GLuint MaxComputeVariableGroupInvocations
;
4120 /** GL_ARB_gpu_shader5 */
4121 GLfloat MinFragmentInterpolationOffset
;
4122 GLfloat MaxFragmentInterpolationOffset
;
4124 GLboolean FakeSWMSAA
;
4126 /** GL_KHR_context_flush_control */
4127 GLenum16 ContextReleaseBehavior
;
4129 struct gl_shader_compiler_options ShaderCompilerOptions
[MESA_SHADER_STAGES
];
4131 /** GL_ARB_tessellation_shader */
4132 GLuint MaxPatchVertices
;
4133 GLuint MaxTessGenLevel
;
4134 GLuint MaxTessPatchComponents
;
4135 GLuint MaxTessControlTotalOutputComponents
;
4136 bool LowerTessLevel
; /**< Lower gl_TessLevel* from float[n] to vecn? */
4137 bool PrimitiveRestartForPatches
;
4138 bool LowerCsDerivedVariables
; /**< Lower gl_GlobalInvocationID and
4139 * gl_LocalInvocationIndex based on
4140 * other builtin variables. */
4142 /** GL_OES_primitive_bounding_box */
4143 bool NoPrimitiveBoundingBoxOutput
;
4145 /** GL_ARB_sparse_buffer */
4146 GLuint SparseBufferPageSize
;
4148 /** Used as an input for sha1 generation in the on-disk shader cache */
4149 unsigned char *dri_config_options_sha1
;
4151 /** When drivers are OK with mapped buffers during draw and other calls. */
4152 bool AllowMappedBuffersDuringExecution
;
4154 /** GL_ARB_get_program_binary */
4155 GLuint NumProgramBinaryFormats
;
4157 /** GL_NV_conservative_raster */
4158 GLuint MaxSubpixelPrecisionBiasBits
;
4160 /** GL_NV_conservative_raster_dilate */
4161 GLfloat ConservativeRasterDilateRange
[2];
4162 GLfloat ConservativeRasterDilateGranularity
;
4164 /** Is the drivers uniform storage packed or padded to 16 bytes. */
4165 bool PackedDriverUniformStorage
;
4167 /** Does the driver make use of the NIR based GLSL linker */
4168 bool UseNIRGLSLLinker
;
4170 /** Wether or not glBitmap uses red textures rather than alpha */
4173 /** Whether the vertex buffer offset is a signed 32-bit integer. */
4174 bool VertexBufferOffsetIsInt32
;
4176 /** Whether the driver can handle MultiDrawElements with non-VBO indices. */
4177 bool MultiDrawWithUserIndices
;
4179 /** GL_ARB_gl_spirv */
4180 struct spirv_supported_capabilities SpirVCapabilities
;
4182 /** GL_ARB_spirv_extensions */
4183 struct spirv_supported_extensions
*SpirVExtensions
;
4185 char *VendorOverride
;
4190 * Enable flag for each OpenGL extension. Different device drivers will
4191 * enable different extensions at runtime.
4193 struct gl_extensions
4195 GLboolean dummy
; /* don't remove this! */
4196 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
4197 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
4198 GLboolean ANGLE_texture_compression_dxt
;
4199 GLboolean ARB_ES2_compatibility
;
4200 GLboolean ARB_ES3_compatibility
;
4201 GLboolean ARB_ES3_1_compatibility
;
4202 GLboolean ARB_ES3_2_compatibility
;
4203 GLboolean ARB_arrays_of_arrays
;
4204 GLboolean ARB_base_instance
;
4205 GLboolean ARB_bindless_texture
;
4206 GLboolean ARB_blend_func_extended
;
4207 GLboolean ARB_buffer_storage
;
4208 GLboolean ARB_clear_texture
;
4209 GLboolean ARB_clip_control
;
4210 GLboolean ARB_color_buffer_float
;
4211 GLboolean ARB_compatibility
;
4212 GLboolean ARB_compute_shader
;
4213 GLboolean ARB_compute_variable_group_size
;
4214 GLboolean ARB_conditional_render_inverted
;
4215 GLboolean ARB_conservative_depth
;
4216 GLboolean ARB_copy_image
;
4217 GLboolean ARB_cull_distance
;
4218 GLboolean ARB_depth_buffer_float
;
4219 GLboolean ARB_depth_clamp
;
4220 GLboolean ARB_depth_texture
;
4221 GLboolean ARB_derivative_control
;
4222 GLboolean ARB_draw_buffers_blend
;
4223 GLboolean ARB_draw_elements_base_vertex
;
4224 GLboolean ARB_draw_indirect
;
4225 GLboolean ARB_draw_instanced
;
4226 GLboolean ARB_fragment_coord_conventions
;
4227 GLboolean ARB_fragment_layer_viewport
;
4228 GLboolean ARB_fragment_program
;
4229 GLboolean ARB_fragment_program_shadow
;
4230 GLboolean ARB_fragment_shader
;
4231 GLboolean ARB_framebuffer_no_attachments
;
4232 GLboolean ARB_framebuffer_object
;
4233 GLboolean ARB_fragment_shader_interlock
;
4234 GLboolean ARB_enhanced_layouts
;
4235 GLboolean ARB_explicit_attrib_location
;
4236 GLboolean ARB_explicit_uniform_location
;
4237 GLboolean ARB_gl_spirv
;
4238 GLboolean ARB_gpu_shader5
;
4239 GLboolean ARB_gpu_shader_fp64
;
4240 GLboolean ARB_gpu_shader_int64
;
4241 GLboolean ARB_half_float_vertex
;
4242 GLboolean ARB_indirect_parameters
;
4243 GLboolean ARB_instanced_arrays
;
4244 GLboolean ARB_internalformat_query
;
4245 GLboolean ARB_internalformat_query2
;
4246 GLboolean ARB_map_buffer_range
;
4247 GLboolean ARB_occlusion_query
;
4248 GLboolean ARB_occlusion_query2
;
4249 GLboolean ARB_pipeline_statistics_query
;
4250 GLboolean ARB_point_sprite
;
4251 GLboolean ARB_polygon_offset_clamp
;
4252 GLboolean ARB_post_depth_coverage
;
4253 GLboolean ARB_query_buffer_object
;
4254 GLboolean ARB_robust_buffer_access_behavior
;
4255 GLboolean ARB_sample_locations
;
4256 GLboolean ARB_sample_shading
;
4257 GLboolean ARB_seamless_cube_map
;
4258 GLboolean ARB_shader_atomic_counter_ops
;
4259 GLboolean ARB_shader_atomic_counters
;
4260 GLboolean ARB_shader_ballot
;
4261 GLboolean ARB_shader_bit_encoding
;
4262 GLboolean ARB_shader_clock
;
4263 GLboolean ARB_shader_draw_parameters
;
4264 GLboolean ARB_shader_group_vote
;
4265 GLboolean ARB_shader_image_load_store
;
4266 GLboolean ARB_shader_image_size
;
4267 GLboolean ARB_shader_precision
;
4268 GLboolean ARB_shader_stencil_export
;
4269 GLboolean ARB_shader_storage_buffer_object
;
4270 GLboolean ARB_shader_texture_image_samples
;
4271 GLboolean ARB_shader_texture_lod
;
4272 GLboolean ARB_shader_viewport_layer_array
;
4273 GLboolean ARB_shading_language_packing
;
4274 GLboolean ARB_shading_language_420pack
;
4275 GLboolean ARB_shadow
;
4276 GLboolean ARB_sparse_buffer
;
4277 GLboolean ARB_stencil_texturing
;
4278 GLboolean ARB_spirv_extensions
;
4280 GLboolean ARB_tessellation_shader
;
4281 GLboolean ARB_texture_border_clamp
;
4282 GLboolean ARB_texture_buffer_object
;
4283 GLboolean ARB_texture_buffer_object_rgb32
;
4284 GLboolean ARB_texture_buffer_range
;
4285 GLboolean ARB_texture_compression_bptc
;
4286 GLboolean ARB_texture_compression_rgtc
;
4287 GLboolean ARB_texture_cube_map
;
4288 GLboolean ARB_texture_cube_map_array
;
4289 GLboolean ARB_texture_env_combine
;
4290 GLboolean ARB_texture_env_crossbar
;
4291 GLboolean ARB_texture_env_dot3
;
4292 GLboolean ARB_texture_filter_anisotropic
;
4293 GLboolean ARB_texture_float
;
4294 GLboolean ARB_texture_gather
;
4295 GLboolean ARB_texture_mirror_clamp_to_edge
;
4296 GLboolean ARB_texture_multisample
;
4297 GLboolean ARB_texture_non_power_of_two
;
4298 GLboolean ARB_texture_stencil8
;
4299 GLboolean ARB_texture_query_levels
;
4300 GLboolean ARB_texture_query_lod
;
4301 GLboolean ARB_texture_rg
;
4302 GLboolean ARB_texture_rgb10_a2ui
;
4303 GLboolean ARB_texture_view
;
4304 GLboolean ARB_timer_query
;
4305 GLboolean ARB_transform_feedback2
;
4306 GLboolean ARB_transform_feedback3
;
4307 GLboolean ARB_transform_feedback_instanced
;
4308 GLboolean ARB_transform_feedback_overflow_query
;
4309 GLboolean ARB_uniform_buffer_object
;
4310 GLboolean ARB_vertex_attrib_64bit
;
4311 GLboolean ARB_vertex_program
;
4312 GLboolean ARB_vertex_shader
;
4313 GLboolean ARB_vertex_type_10f_11f_11f_rev
;
4314 GLboolean ARB_vertex_type_2_10_10_10_rev
;
4315 GLboolean ARB_viewport_array
;
4316 GLboolean EXT_blend_color
;
4317 GLboolean EXT_blend_equation_separate
;
4318 GLboolean EXT_blend_func_separate
;
4319 GLboolean EXT_blend_minmax
;
4320 GLboolean EXT_demote_to_helper_invocation
;
4321 GLboolean EXT_depth_bounds_test
;
4322 GLboolean EXT_disjoint_timer_query
;
4323 GLboolean EXT_draw_buffers2
;
4324 GLboolean EXT_EGL_image_storage
;
4325 GLboolean EXT_float_blend
;
4326 GLboolean EXT_framebuffer_multisample
;
4327 GLboolean EXT_framebuffer_multisample_blit_scaled
;
4328 GLboolean EXT_framebuffer_sRGB
;
4329 GLboolean EXT_gpu_program_parameters
;
4330 GLboolean EXT_gpu_shader4
;
4331 GLboolean EXT_memory_object
;
4332 GLboolean EXT_memory_object_fd
;
4333 GLboolean EXT_multisampled_render_to_texture
;
4334 GLboolean EXT_packed_float
;
4335 GLboolean EXT_pixel_buffer_object
;
4336 GLboolean EXT_point_parameters
;
4337 GLboolean EXT_provoking_vertex
;
4338 GLboolean EXT_render_snorm
;
4339 GLboolean EXT_semaphore
;
4340 GLboolean EXT_semaphore_fd
;
4341 GLboolean EXT_shader_image_load_formatted
;
4342 GLboolean EXT_shader_image_load_store
;
4343 GLboolean EXT_shader_integer_mix
;
4344 GLboolean EXT_shader_samples_identical
;
4346 GLboolean EXT_stencil_two_side
;
4347 GLboolean EXT_texture_array
;
4348 GLboolean EXT_texture_buffer_object
;
4349 GLboolean EXT_texture_compression_latc
;
4350 GLboolean EXT_texture_compression_s3tc
;
4351 GLboolean EXT_texture_compression_s3tc_srgb
;
4352 GLboolean EXT_texture_env_dot3
;
4353 GLboolean EXT_texture_filter_anisotropic
;
4354 GLboolean EXT_texture_integer
;
4355 GLboolean EXT_texture_mirror_clamp
;
4356 GLboolean EXT_texture_norm16
;
4357 GLboolean EXT_texture_shadow_lod
;
4358 GLboolean EXT_texture_shared_exponent
;
4359 GLboolean EXT_texture_snorm
;
4360 GLboolean EXT_texture_sRGB
;
4361 GLboolean EXT_texture_sRGB_R8
;
4362 GLboolean EXT_texture_sRGB_decode
;
4363 GLboolean EXT_texture_swizzle
;
4364 GLboolean EXT_texture_type_2_10_10_10_REV
;
4365 GLboolean EXT_transform_feedback
;
4366 GLboolean EXT_timer_query
;
4367 GLboolean EXT_vertex_array_bgra
;
4368 GLboolean EXT_window_rectangles
;
4369 GLboolean OES_copy_image
;
4370 GLboolean OES_primitive_bounding_box
;
4371 GLboolean OES_sample_variables
;
4372 GLboolean OES_standard_derivatives
;
4373 GLboolean OES_texture_buffer
;
4374 GLboolean OES_texture_cube_map_array
;
4375 GLboolean OES_texture_view
;
4376 GLboolean OES_viewport_array
;
4377 /* vendor extensions */
4378 GLboolean AMD_compressed_ATC_texture
;
4379 GLboolean AMD_framebuffer_multisample_advanced
;
4380 GLboolean AMD_depth_clamp_separate
;
4381 GLboolean AMD_performance_monitor
;
4382 GLboolean AMD_pinned_memory
;
4383 GLboolean AMD_seamless_cubemap_per_texture
;
4384 GLboolean AMD_vertex_shader_layer
;
4385 GLboolean AMD_vertex_shader_viewport_index
;
4386 GLboolean ANDROID_extension_pack_es31a
;
4387 GLboolean APPLE_object_purgeable
;
4388 GLboolean ATI_meminfo
;
4389 GLboolean ATI_texture_compression_3dc
;
4390 GLboolean ATI_texture_mirror_once
;
4391 GLboolean ATI_texture_env_combine3
;
4392 GLboolean ATI_fragment_shader
;
4393 GLboolean GREMEDY_string_marker
;
4394 GLboolean INTEL_blackhole_render
;
4395 GLboolean INTEL_conservative_rasterization
;
4396 GLboolean INTEL_performance_query
;
4397 GLboolean INTEL_shader_atomic_float_minmax
;
4398 GLboolean INTEL_shader_integer_functions2
;
4399 GLboolean KHR_blend_equation_advanced
;
4400 GLboolean KHR_blend_equation_advanced_coherent
;
4401 GLboolean KHR_robustness
;
4402 GLboolean KHR_texture_compression_astc_hdr
;
4403 GLboolean KHR_texture_compression_astc_ldr
;
4404 GLboolean KHR_texture_compression_astc_sliced_3d
;
4405 GLboolean MESA_framebuffer_flip_y
;
4406 GLboolean MESA_tile_raster_order
;
4407 GLboolean MESA_pack_invert
;
4408 GLboolean EXT_shader_framebuffer_fetch
;
4409 GLboolean EXT_shader_framebuffer_fetch_non_coherent
;
4410 GLboolean MESA_shader_integer_functions
;
4411 GLboolean MESA_ycbcr_texture
;
4412 GLboolean NV_compute_shader_derivatives
;
4413 GLboolean NV_conditional_render
;
4414 GLboolean NV_copy_image
;
4415 GLboolean NV_fill_rectangle
;
4416 GLboolean NV_fog_distance
;
4417 GLboolean NV_point_sprite
;
4418 GLboolean NV_primitive_restart
;
4419 GLboolean NV_shader_atomic_float
;
4420 GLboolean NV_texture_barrier
;
4421 GLboolean NV_texture_env_combine4
;
4422 GLboolean NV_texture_rectangle
;
4423 GLboolean NV_vdpau_interop
;
4424 GLboolean NV_conservative_raster
;
4425 GLboolean NV_conservative_raster_dilate
;
4426 GLboolean NV_conservative_raster_pre_snap_triangles
;
4427 GLboolean NV_conservative_raster_pre_snap
;
4428 GLboolean NVX_gpu_memory_info
;
4429 GLboolean TDFX_texture_compression_FXT1
;
4430 GLboolean OES_EGL_image
;
4431 GLboolean OES_draw_texture
;
4432 GLboolean OES_depth_texture_cube_map
;
4433 GLboolean OES_EGL_image_external
;
4434 GLboolean OES_texture_float
;
4435 GLboolean OES_texture_float_linear
;
4436 GLboolean OES_texture_half_float
;
4437 GLboolean OES_texture_half_float_linear
;
4438 GLboolean OES_compressed_ETC1_RGB8_texture
;
4439 GLboolean OES_geometry_shader
;
4440 GLboolean OES_texture_compression_astc
;
4441 GLboolean extension_sentinel
;
4442 /** The extension string */
4443 const GLubyte
*String
;
4444 /** Number of supported extensions */
4447 * The context version which extension helper functions compare against.
4448 * By default, the value is equal to ctx->Version. This changes to ~0
4449 * while meta is in progress.
4453 * Force-enabled, yet unrecognized, extensions.
4454 * See _mesa_one_time_init_extension_overrides()
4456 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4457 const char *unrecognized_extensions
[MAX_UNRECOGNIZED_EXTENSIONS
];
4462 * A stack of matrices (projection, modelview, color, texture, etc).
4464 struct gl_matrix_stack
4466 GLmatrix
*Top
; /**< points into Stack */
4467 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
4468 unsigned StackSize
; /**< Number of elements in Stack */
4469 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
4470 GLuint MaxDepth
; /**< size of Stack[] array */
4471 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4476 * \name Bits for image transfer operations
4477 * \sa __struct gl_contextRec::ImageTransferState.
4480 #define IMAGE_SCALE_BIAS_BIT 0x1
4481 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4482 #define IMAGE_MAP_COLOR_BIT 0x4
4483 #define IMAGE_CLAMP_BIT 0x800
4486 /** Pixel Transfer ops */
4487 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4488 IMAGE_SHIFT_OFFSET_BIT | \
4489 IMAGE_MAP_COLOR_BIT)
4493 * \name Bits to indicate what state has changed.
4496 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4497 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4498 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4499 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4500 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4501 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4502 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4503 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4504 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4505 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4506 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4507 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4508 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4509 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4510 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4511 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4512 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4513 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4514 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4515 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4517 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4518 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4519 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4520 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4521 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4522 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4523 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4525 #define _NEW_FRAG_CLAMP (1u << 29)
4526 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4527 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4533 * Composite state flags
4536 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4538 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4539 _NEW_TEXTURE_STATE | \
4544 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4554 /* This has to be included here. */
4558 /** Opaque declaration of display list payload data type */
4559 union gl_dlist_node
;
4563 * Per-display list information.
4565 struct gl_display_list
4568 GLbitfield Flags
; /**< DLIST_x flags */
4569 GLchar
*Label
; /**< GL_KHR_debug */
4570 /** The dlist commands are in a linked list of nodes */
4571 union gl_dlist_node
*Head
;
4576 * State used during display list compilation and execution.
4578 struct gl_dlist_state
4580 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
4581 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
4582 GLuint CurrentPos
; /**< Index into current block of nodes */
4583 GLuint CallDepth
; /**< Current recursion calling depth */
4585 GLvertexformat ListVtxfmt
;
4587 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
4588 uint32_t CurrentAttrib
[VERT_ATTRIB_MAX
][8];
4590 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
4591 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
4594 /* State known to have been set by the currently-compiling display
4595 * list. Used to eliminate some redundant state changes.
4597 GLenum16 ShadeModel
;
4602 * Driver-specific state flags.
4604 * These are or'd with gl_context::NewDriverState to notify a driver about
4605 * a state change. The driver sets the flags at context creation and
4606 * the meaning of the bits set is opaque to core Mesa.
4608 struct gl_driver_flags
4610 /** gl_context::Array::_DrawArrays (vertex array state) */
4613 /** gl_context::TransformFeedback::CurrentObject */
4614 uint64_t NewTransformFeedback
;
4616 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4617 uint64_t NewTransformFeedbackProg
;
4619 /** gl_context::RasterDiscard */
4620 uint64_t NewRasterizerDiscard
;
4622 /** gl_context::TileRasterOrder* */
4623 uint64_t NewTileRasterOrder
;
4626 * gl_context::UniformBufferBindings
4627 * gl_shader_program::UniformBlocks
4629 uint64_t NewUniformBuffer
;
4632 * gl_context::ShaderStorageBufferBindings
4633 * gl_shader_program::ShaderStorageBlocks
4635 uint64_t NewShaderStorageBuffer
;
4637 uint64_t NewTextureBuffer
;
4640 * gl_context::AtomicBufferBindings
4642 uint64_t NewAtomicBuffer
;
4645 * gl_context::ImageUnits
4647 uint64_t NewImageUnits
;
4650 * gl_context::TessCtrlProgram::patch_default_*
4652 uint64_t NewDefaultTessLevels
;
4655 * gl_context::IntelConservativeRasterization
4657 uint64_t NewIntelConservativeRasterization
;
4660 * gl_context::NvConservativeRasterization
4662 uint64_t NewNvConservativeRasterization
;
4665 * gl_context::ConservativeRasterMode/ConservativeRasterDilate
4666 * gl_context::SubpixelPrecisionBias
4668 uint64_t NewNvConservativeRasterizationParams
;
4671 * gl_context::Scissor::WindowRects
4673 uint64_t NewWindowRectangles
;
4675 /** gl_context::Color::sRGBEnabled */
4676 uint64_t NewFramebufferSRGB
;
4678 /** gl_context::Scissor::EnableFlags */
4679 uint64_t NewScissorTest
;
4681 /** gl_context::Scissor::ScissorArray */
4682 uint64_t NewScissorRect
;
4684 /** gl_context::Color::Alpha* */
4685 uint64_t NewAlphaTest
;
4687 /** gl_context::Color::Blend/Dither */
4690 /** gl_context::Color::BlendColor */
4691 uint64_t NewBlendColor
;
4693 /** gl_context::Color::Color/Index */
4694 uint64_t NewColorMask
;
4696 /** gl_context::Depth */
4699 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4700 uint64_t NewLogicOp
;
4702 /** gl_context::Multisample::Enabled */
4703 uint64_t NewMultisampleEnable
;
4705 /** gl_context::Multisample::SampleAlphaTo* */
4706 uint64_t NewSampleAlphaToXEnable
;
4708 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4709 uint64_t NewSampleMask
;
4711 /** gl_context::Multisample::(Min)SampleShading */
4712 uint64_t NewSampleShading
;
4714 /** gl_context::Stencil */
4715 uint64_t NewStencil
;
4717 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4718 uint64_t NewClipControl
;
4720 /** gl_context::Transform::EyeUserPlane */
4721 uint64_t NewClipPlane
;
4723 /** gl_context::Transform::ClipPlanesEnabled */
4724 uint64_t NewClipPlaneEnable
;
4726 /** gl_context::Transform::DepthClamp */
4727 uint64_t NewDepthClamp
;
4729 /** gl_context::Line */
4730 uint64_t NewLineState
;
4732 /** gl_context::Polygon */
4733 uint64_t NewPolygonState
;
4735 /** gl_context::PolygonStipple */
4736 uint64_t NewPolygonStipple
;
4738 /** gl_context::ViewportArray */
4739 uint64_t NewViewport
;
4741 /** Shader constants (uniforms, program parameters, state constants) */
4742 uint64_t NewShaderConstants
[MESA_SHADER_STAGES
];
4744 /** Programmable sample location state for gl_context::DrawBuffer */
4745 uint64_t NewSampleLocations
;
4748 struct gl_buffer_binding
4750 struct gl_buffer_object
*BufferObject
;
4751 /** Start of uniform block data in the buffer */
4753 /** Size of data allowed to be referenced from the buffer (in bytes) */
4756 * glBindBufferBase() indicates that the Size should be ignored and only
4757 * limited by the current size of the BufferObject.
4759 GLboolean AutomaticSize
;
4763 * ARB_shader_image_load_store image unit.
4765 struct gl_image_unit
4768 * Texture object bound to this unit.
4770 struct gl_texture_object
*TexObj
;
4773 * Level of the texture object bound to this unit.
4778 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4779 * GL_FALSE if only some specific layer of the texture is bound.
4785 * Layer of the texture object bound to this unit as specified by the
4791 * Layer of the texture object bound to this unit, or zero if
4797 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4798 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4803 * GL internal format that determines the interpretation of the
4804 * image memory when shader image operations are performed through
4810 * Mesa format corresponding to \c Format.
4812 mesa_format _ActualFormat
:16;
4816 * Shader subroutines storage
4818 struct gl_subroutine_index_binding
4824 struct gl_texture_handle_object
4826 struct gl_texture_object
*texObj
;
4827 struct gl_sampler_object
*sampObj
;
4831 struct gl_image_handle_object
4833 struct gl_image_unit imgObj
;
4837 struct gl_memory_object
4839 GLuint Name
; /**< hash table ID/name */
4840 GLboolean Immutable
; /**< denotes mutability state of parameters */
4841 GLboolean Dedicated
; /**< import memory from a dedicated allocation */
4844 struct gl_semaphore_object
4846 GLuint Name
; /**< hash table ID/name */
4850 * Mesa rendering context.
4852 * This is the central context data structure for Mesa. Almost all
4853 * OpenGL state is contained in this structure.
4854 * Think of this as a base class from which device drivers will derive
4859 /** State possibly shared with other contexts in the address space */
4860 struct gl_shared_state
*Shared
;
4862 /** \name API function pointer tables */
4867 * The current dispatch table for non-displaylist-saving execution, either
4868 * BeginEnd or OutsideBeginEnd
4870 struct _glapi_table
*Exec
;
4872 * The normal dispatch table for non-displaylist-saving, non-begin/end
4874 struct _glapi_table
*OutsideBeginEnd
;
4875 /** The dispatch table used between glNewList() and glEndList() */
4876 struct _glapi_table
*Save
;
4878 * The dispatch table used between glBegin() and glEnd() (outside of a
4879 * display list). Only valid functions between those two are set, which is
4880 * mostly just the set in a GLvertexformat struct.
4882 struct _glapi_table
*BeginEnd
;
4884 * Dispatch table for when a graphics reset has happened.
4886 struct _glapi_table
*ContextLost
;
4888 * Dispatch table used to marshal API calls from the client program to a
4889 * separate server thread. NULL if API calls are not being marshalled to
4892 struct _glapi_table
*MarshalExec
;
4894 * Dispatch table currently in use for fielding API calls from the client
4895 * program. If API calls are being marshalled to another thread, this ==
4896 * MarshalExec. Otherwise it == CurrentServerDispatch.
4898 struct _glapi_table
*CurrentClientDispatch
;
4901 * Dispatch table currently in use for performing API calls. == Save or
4904 struct _glapi_table
*CurrentServerDispatch
;
4908 struct glthread_state GLThread
;
4910 struct gl_config Visual
;
4911 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
4912 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
4913 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
4914 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
4917 * Device driver function pointer table
4919 struct dd_function_table Driver
;
4921 /** Core/Driver constants */
4922 struct gl_constants Const
;
4924 /** \name The various 4x4 matrix stacks */
4926 struct gl_matrix_stack ModelviewMatrixStack
;
4927 struct gl_matrix_stack ProjectionMatrixStack
;
4928 struct gl_matrix_stack TextureMatrixStack
[MAX_TEXTURE_UNITS
];
4929 struct gl_matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
4930 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
4933 /** Combined modelview and projection matrix */
4934 GLmatrix _ModelProjectMatrix
;
4936 /** \name Display lists */
4937 struct gl_dlist_state ListState
;
4939 GLboolean ExecuteFlag
; /**< Execute GL commands? */
4940 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
4942 /** Extension information */
4943 struct gl_extensions Extensions
;
4945 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4947 char *VersionString
;
4949 /** \name State attribute stack (for glPush/PopAttrib) */
4951 GLuint AttribStackDepth
;
4952 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
4955 /** \name Renderer attribute groups
4957 * We define a struct for each attribute group to make pushing and popping
4958 * attributes easy. Also it's a good organization.
4961 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
4962 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
4963 struct gl_current_attrib Current
; /**< Current attributes */
4964 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
4965 struct gl_eval_attrib Eval
; /**< Eval attributes */
4966 struct gl_fog_attrib Fog
; /**< Fog attributes */
4967 struct gl_hint_attrib Hint
; /**< Hint attributes */
4968 struct gl_light_attrib Light
; /**< Light attributes */
4969 struct gl_line_attrib Line
; /**< Line attributes */
4970 struct gl_list_attrib List
; /**< List attributes */
4971 struct gl_multisample_attrib Multisample
;
4972 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
4973 struct gl_point_attrib Point
; /**< Point attributes */
4974 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
4975 GLuint PolygonStipple
[32]; /**< Polygon stipple */
4976 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
4977 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
4978 struct gl_texture_attrib Texture
; /**< Texture attributes */
4979 struct gl_transform_attrib Transform
; /**< Transformation attributes */
4980 struct gl_viewport_attrib ViewportArray
[MAX_VIEWPORTS
]; /**< Viewport attributes */
4981 GLuint SubpixelPrecisionBias
[2]; /**< Viewport attributes */
4984 /** \name Client attribute stack */
4986 GLuint ClientAttribStackDepth
;
4987 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
4990 /** \name Client attribute groups */
4992 struct gl_array_attrib Array
; /**< Vertex arrays */
4993 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
4994 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
4995 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
4998 /** \name Other assorted state (not pushed/popped on attribute stack) */
5000 struct gl_pixelmaps PixelMaps
;
5002 struct gl_evaluators EvalMap
; /**< All evaluators */
5003 struct gl_feedback Feedback
; /**< Feedback */
5004 struct gl_selection Select
; /**< Selection */
5006 struct gl_program_state Program
; /**< general program state */
5007 struct gl_vertex_program_state VertexProgram
;
5008 struct gl_fragment_program_state FragmentProgram
;
5009 struct gl_geometry_program_state GeometryProgram
;
5010 struct gl_compute_program_state ComputeProgram
;
5011 struct gl_tess_ctrl_program_state TessCtrlProgram
;
5012 struct gl_tess_eval_program_state TessEvalProgram
;
5013 struct gl_ati_fragment_shader_state ATIFragmentShader
;
5015 struct gl_pipeline_shader_state Pipeline
; /**< GLSL pipeline shader object state */
5016 struct gl_pipeline_object Shader
; /**< GLSL shader object state */
5019 * Current active shader pipeline state
5021 * Almost all internal users want ::_Shader instead of ::Shader. The
5022 * exceptions are bits of legacy GLSL API that do not know about separate
5025 * If a program is active via \c glUseProgram, this will point to
5028 * If a program pipeline is active via \c glBindProgramPipeline, this will
5029 * point to \c ::Pipeline.Current.
5031 * If neither a program nor a program pipeline is active, this will point to
5032 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
5035 struct gl_pipeline_object
*_Shader
;
5038 * NIR containing the functions that implement software fp64 support.
5040 struct nir_shader
*SoftFP64
;
5042 struct gl_query_state Query
; /**< occlusion, timer queries */
5044 struct gl_transform_feedback_state TransformFeedback
;
5046 struct gl_perf_monitor_state PerfMonitor
;
5047 struct gl_perf_query_state PerfQuery
;
5049 struct gl_buffer_object
*DrawIndirectBuffer
; /** < GL_ARB_draw_indirect */
5050 struct gl_buffer_object
*ParameterBuffer
; /** < GL_ARB_indirect_parameters */
5051 struct gl_buffer_object
*DispatchIndirectBuffer
; /** < GL_ARB_compute_shader */
5053 struct gl_buffer_object
*CopyReadBuffer
; /**< GL_ARB_copy_buffer */
5054 struct gl_buffer_object
*CopyWriteBuffer
; /**< GL_ARB_copy_buffer */
5056 struct gl_buffer_object
*QueryBuffer
; /**< GL_ARB_query_buffer_object */
5059 * Current GL_ARB_uniform_buffer_object binding referenced by
5060 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
5062 struct gl_buffer_object
*UniformBuffer
;
5065 * Current GL_ARB_shader_storage_buffer_object binding referenced by
5066 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
5068 struct gl_buffer_object
*ShaderStorageBuffer
;
5071 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
5072 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
5073 * associated with uniform blocks by glUniformBlockBinding()'s state in the
5076 struct gl_buffer_binding
5077 UniformBufferBindings
[MAX_COMBINED_UNIFORM_BUFFERS
];
5080 * Array of shader storage buffers for ARB_shader_storage_buffer_object
5081 * and GL 4.3. This is set up using glBindBufferRange() or
5082 * glBindBufferBase(). They are associated with shader storage blocks by
5083 * glShaderStorageBlockBinding()'s state in the shader program.
5085 struct gl_buffer_binding
5086 ShaderStorageBufferBindings
[MAX_COMBINED_SHADER_STORAGE_BUFFERS
];
5089 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
5092 struct gl_buffer_object
*AtomicBuffer
;
5095 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
5098 struct gl_buffer_object
*ExternalVirtualMemoryBuffer
;
5101 * Array of atomic counter buffer binding points.
5103 struct gl_buffer_binding
5104 AtomicBufferBindings
[MAX_COMBINED_ATOMIC_BUFFERS
];
5107 * Array of image units for ARB_shader_image_load_store.
5109 struct gl_image_unit ImageUnits
[MAX_IMAGE_UNITS
];
5111 struct gl_subroutine_index_binding SubroutineIndex
[MESA_SHADER_STAGES
];
5114 struct gl_meta_state
*Meta
; /**< for "meta" operations */
5116 /* GL_EXT_framebuffer_object */
5117 struct gl_renderbuffer
*CurrentRenderbuffer
;
5119 GLenum16 ErrorValue
; /**< Last error code */
5122 * Recognize and silence repeated error debug messages in buggy apps.
5124 const char *ErrorDebugFmtString
;
5125 GLuint ErrorDebugCount
;
5127 /* GL_ARB_debug_output/GL_KHR_debug */
5128 simple_mtx_t DebugMutex
;
5129 struct gl_debug_state
*Debug
;
5131 GLenum16 RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5132 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
5133 uint64_t NewDriverState
; /**< bitwise-or of flags from DriverFlags */
5135 struct gl_driver_flags DriverFlags
;
5137 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
5139 GLbitfield varying_vp_inputs
; /**< mask of VERT_BIT_* flags */
5141 /** \name Derived state */
5142 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
5143 GLfloat _EyeZDir
[3];
5144 GLfloat _ModelViewInvScale
; /* may be for model- or eyespace lighting */
5145 GLfloat _ModelViewInvScaleEyespace
; /* always factor defined in spec */
5146 GLboolean _NeedEyeCoords
;
5147 GLboolean _ForceEyeCoords
;
5149 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
5151 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
5153 /** \name For debugging/development only */
5155 GLboolean FirstTimeCurrent
;
5159 * False if this context was created without a config. This is needed
5160 * because the initial state of glDrawBuffers depends on this
5162 GLboolean HasConfig
;
5164 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
5166 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
5167 GLboolean IntelConservativeRasterization
; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */
5168 GLboolean ConservativeRasterization
; /**< GL_CONSERVATIVE_RASTERIZATION_NV */
5169 GLfloat ConservativeRasterDilate
;
5170 GLenum16 ConservativeRasterMode
;
5172 GLboolean IntelBlackholeRender
; /**< GL_INTEL_blackhole_render */
5174 /** Does glVertexAttrib(0) alias glVertex()? */
5175 bool _AttribZeroAliasesVertex
;
5178 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5179 * renderer's tiles should be excecuted, to meet the requirements of
5180 * GL_MESA_tile_raster_order.
5182 GLboolean TileRasterOrderFixed
;
5183 GLboolean TileRasterOrderIncreasingX
;
5184 GLboolean TileRasterOrderIncreasingY
;
5187 * \name Hooks for module contexts.
5189 * These will eventually live in the driver or elsewhere.
5192 void *swrast_context
;
5193 void *swsetup_context
;
5194 void *swtnl_context
;
5195 struct vbo_context
*vbo_context
;
5196 struct st_context
*st
;
5200 * \name NV_vdpau_interop
5203 const void *vdpDevice
;
5204 const void *vdpGetProcAddress
;
5205 struct set
*vdpSurfaces
;
5209 * Has this context observed a GPU reset in any context in the share group?
5211 * Once this field becomes true, it is never reset to false.
5213 GLboolean ShareGroupReset
;
5216 * \name OES_primitive_bounding_box
5218 * Stores the arguments to glPrimitiveBoundingBox
5220 GLfloat PrimitiveBoundingBox
[8];
5222 struct disk_cache
*Cache
;
5225 * \name GL_ARB_bindless_texture
5228 struct hash_table_u64
*ResidentTextureHandles
;
5229 struct hash_table_u64
*ResidentImageHandles
;
5232 bool shader_builtin_ref
;
5236 * Information about memory usage. All sizes are in kilobytes.
5238 struct gl_memory_info
5240 unsigned total_device_memory
; /**< size of device memory, e.g. VRAM */
5241 unsigned avail_device_memory
; /**< free device memory at the moment */
5242 unsigned total_staging_memory
; /**< size of staging memory, e.g. GART */
5243 unsigned avail_staging_memory
; /**< free staging memory at the moment */
5244 unsigned device_memory_evicted
; /**< size of memory evicted (monotonic counter) */
5245 unsigned nr_device_memory_evictions
; /**< # of evictions (monotonic counter) */
5249 extern int MESA_VERBOSE
;
5250 extern int MESA_DEBUG_FLAGS
;
5252 # define MESA_VERBOSE 0
5253 # define MESA_DEBUG_FLAGS 0
5257 /** The MESA_VERBOSE var is a bitmask of these flags */
5260 VERBOSE_VARRAY
= 0x0001,
5261 VERBOSE_TEXTURE
= 0x0002,
5262 VERBOSE_MATERIAL
= 0x0004,
5263 VERBOSE_PIPELINE
= 0x0008,
5264 VERBOSE_DRIVER
= 0x0010,
5265 VERBOSE_STATE
= 0x0020,
5266 VERBOSE_API
= 0x0040,
5267 VERBOSE_DISPLAY_LIST
= 0x0100,
5268 VERBOSE_LIGHTING
= 0x0200,
5269 VERBOSE_PRIMS
= 0x0400,
5270 VERBOSE_VERTS
= 0x0800,
5271 VERBOSE_DISASSEM
= 0x1000,
5272 VERBOSE_DRAW
= 0x2000,
5273 VERBOSE_SWAPBUFFERS
= 0x4000
5277 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5280 DEBUG_SILENT
= (1 << 0),
5281 DEBUG_ALWAYS_FLUSH
= (1 << 1),
5282 DEBUG_INCOMPLETE_TEXTURE
= (1 << 2),
5283 DEBUG_INCOMPLETE_FBO
= (1 << 3),
5284 DEBUG_CONTEXT
= (1 << 4)
5291 #endif /* MTYPES_H */