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"
60 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
61 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
65 * \name Some forward type declarations
68 struct _mesa_HashTable
;
69 struct gl_attrib_node
;
70 struct gl_list_extensions
;
72 struct gl_program_cache
;
73 struct gl_texture_object
;
74 struct gl_debug_state
;
77 struct gl_uniform_storage
;
78 struct prog_instruction
;
79 struct gl_program_parameter_list
;
80 struct gl_shader_spirv_data
;
82 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
:
108 case VARYING_SLOT_VIEWPORT_MASK
:
116 * Bit flags for all renderbuffers
118 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
119 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
120 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
121 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
122 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
123 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
124 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
125 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
126 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
127 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
128 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
129 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
130 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
131 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
132 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
133 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
134 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
135 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
136 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
139 * Mask of all the color buffer bits (but not accum).
141 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
142 BUFFER_BIT_BACK_LEFT | \
143 BUFFER_BIT_FRONT_RIGHT | \
144 BUFFER_BIT_BACK_RIGHT | \
146 BUFFER_BIT_COLOR0 | \
147 BUFFER_BIT_COLOR1 | \
148 BUFFER_BIT_COLOR2 | \
149 BUFFER_BIT_COLOR3 | \
150 BUFFER_BIT_COLOR4 | \
151 BUFFER_BIT_COLOR5 | \
152 BUFFER_BIT_COLOR6 | \
155 /* Mask of bits for depth+stencil buffers */
156 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
159 * Framebuffer configuration (aka visual / pixelformat)
160 * Note: some of these fields should be boolean, but it appears that
161 * code in drivers/dri/common/util.c requires int-sized fields.
166 GLuint doubleBufferMode
;
169 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
170 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
171 GLint redShift
, greenShift
, blueShift
, alphaShift
;
172 GLint rgbBits
; /* total bits for rgb */
174 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
182 /* EXT_visual_rating / GLX 1.2 */
185 /* EXT_visual_info / GLX 1.2 */
186 GLint transparentPixel
;
187 /* colors are floats scaled to ints */
188 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
189 GLint transparentIndex
;
191 /* ARB_multisample / SGIS_multisample */
195 /* SGIX_pbuffer / GLX 1.3 */
196 GLint maxPbufferWidth
;
197 GLint maxPbufferHeight
;
198 GLint maxPbufferPixels
;
199 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
200 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
202 /* OML_swap_method */
205 /* EXT_texture_from_pixmap */
206 GLint bindToTextureRgb
;
207 GLint bindToTextureRgba
;
208 GLint bindToMipmapTexture
;
209 GLint bindToTextureTargets
;
212 /* EXT_framebuffer_sRGB */
215 /* EGL_KHR_mutable_render_buffer */
216 GLuint mutableRenderBuffer
; /* bool */
221 * \name Bit flags used for updating material values.
224 #define MAT_ATTRIB_FRONT_AMBIENT 0
225 #define MAT_ATTRIB_BACK_AMBIENT 1
226 #define MAT_ATTRIB_FRONT_DIFFUSE 2
227 #define MAT_ATTRIB_BACK_DIFFUSE 3
228 #define MAT_ATTRIB_FRONT_SPECULAR 4
229 #define MAT_ATTRIB_BACK_SPECULAR 5
230 #define MAT_ATTRIB_FRONT_EMISSION 6
231 #define MAT_ATTRIB_BACK_EMISSION 7
232 #define MAT_ATTRIB_FRONT_SHININESS 8
233 #define MAT_ATTRIB_BACK_SHININESS 9
234 #define MAT_ATTRIB_FRONT_INDEXES 10
235 #define MAT_ATTRIB_BACK_INDEXES 11
236 #define MAT_ATTRIB_MAX 12
238 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
239 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
240 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
241 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
242 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
243 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
245 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
246 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
247 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
248 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
249 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
250 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
251 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
252 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
253 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
254 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
255 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
256 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
259 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
260 MAT_BIT_FRONT_AMBIENT | \
261 MAT_BIT_FRONT_DIFFUSE | \
262 MAT_BIT_FRONT_SPECULAR | \
263 MAT_BIT_FRONT_SHININESS | \
264 MAT_BIT_FRONT_INDEXES)
266 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
267 MAT_BIT_BACK_AMBIENT | \
268 MAT_BIT_BACK_DIFFUSE | \
269 MAT_BIT_BACK_SPECULAR | \
270 MAT_BIT_BACK_SHININESS | \
271 MAT_BIT_BACK_INDEXES)
273 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
282 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
290 #define LIGHT_SPOT 0x1
291 #define LIGHT_LOCAL_VIEWER 0x2
292 #define LIGHT_POSITIONAL 0x4
293 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
298 * Light source state.
302 GLfloat Ambient
[4]; /**< ambient color */
303 GLfloat Diffuse
[4]; /**< diffuse color */
304 GLfloat Specular
[4]; /**< specular color */
305 GLfloat EyePosition
[4]; /**< position in eye coordinates */
306 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
307 GLfloat SpotExponent
;
308 GLfloat SpotCutoff
; /**< in degrees */
309 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
310 GLfloat ConstantAttenuation
;
311 GLfloat LinearAttenuation
;
312 GLfloat QuadraticAttenuation
;
313 GLboolean Enabled
; /**< On/off flag */
316 * \name Derived fields
319 GLbitfield _Flags
; /**< Mask of LIGHT_x bits defined above */
321 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
322 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
323 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
324 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
325 GLfloat _VP_inf_spot_attenuation
;
327 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
328 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
329 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
339 GLfloat Ambient
[4]; /**< ambient color */
340 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
341 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
342 GLenum16 ColorControl
; /**< either GL_SINGLE_COLOR
343 or GL_SEPARATE_SPECULAR_COLOR */
348 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
350 struct gl_accum_attrib
352 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
357 * Used for storing clear color, texture border color, etc.
358 * The float values are typically unclamped.
369 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
371 struct gl_colorbuffer_attrib
373 GLuint ClearIndex
; /**< Index for glClear */
374 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
375 GLuint IndexMask
; /**< Color index write mask */
377 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
378 GLbitfield ColorMask
;
380 GLenum16 DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
383 * \name alpha testing
386 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
387 GLenum16 AlphaFunc
; /**< Alpha test function */
388 GLfloat AlphaRefUnclamped
;
389 GLclampf AlphaRef
; /**< Alpha reference value */
396 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
398 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
399 * control, only on the fixed-pointness of the render target.
400 * The query does however depend on fragment color clamping.
402 GLfloat BlendColorUnclamped
[4]; /**< Blending color */
403 GLfloat BlendColor
[4]; /**< Blending color */
407 GLenum16 SrcRGB
; /**< RGB blend source term */
408 GLenum16 DstRGB
; /**< RGB blend dest term */
409 GLenum16 SrcA
; /**< Alpha blend source term */
410 GLenum16 DstA
; /**< Alpha blend dest term */
411 GLenum16 EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
412 GLenum16 EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
414 * Set if any blend factor uses SRC1. Computed at the time blend factors
417 GLboolean _UsesDualSrc
;
418 } Blend
[MAX_DRAW_BUFFERS
];
419 /** Are the blend func terms currently different for each buffer/target? */
420 GLboolean _BlendFuncPerBuffer
;
421 /** Are the blend equations currently different for each buffer/target? */
422 GLboolean _BlendEquationPerBuffer
;
425 * Which advanced blending mode is in use (or BLEND_NONE).
427 * KHR_blend_equation_advanced only allows advanced blending with a single
428 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
429 * requires all draw buffers to match, so we only need a single value.
431 enum gl_advanced_blend_mode _AdvancedBlendMode
;
433 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
441 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
442 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
443 GLenum16 LogicOp
; /**< Logic operator */
444 enum gl_logicop_mode _LogicOp
;
447 GLboolean DitherFlag
; /**< Dither enable flag */
449 GLboolean _ClampFragmentColor
; /** < with GL_FIXED_ONLY_ARB resolved */
450 GLenum16 ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
451 GLenum16 ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
453 GLboolean sRGBEnabled
; /**< Framebuffer sRGB blending/updating requested */
458 * Vertex format to describe a vertex element.
460 struct gl_vertex_format
462 GLenum16 Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
463 GLenum16 Format
; /**< default: GL_RGBA, but may be GL_BGRA */
464 enum pipe_format _PipeFormat
:16; /**< pipe_format for Gallium */
465 GLubyte Size
:5; /**< components per element (1,2,3,4) */
466 GLubyte Normalized
:1; /**< GL_ARB_vertex_program */
467 GLubyte Integer
:1; /**< Integer-valued? */
468 GLubyte Doubles
:1; /**< double values are not converted to floats */
469 GLubyte _ElementSize
; /**< Size of each element in bytes */
474 * Current attribute group (GL_CURRENT_BIT).
476 struct gl_current_attrib
479 * \name Current vertex attributes (color, texcoords, etc).
480 * \note Values are valid only after FLUSH_VERTICES has been called.
481 * \note Index and Edgeflag current values are stored as floats in the
482 * SIX and SEVEN attribute slots.
483 * \note We need double storage for 64-bit vertex attributes
485 GLfloat Attrib
[VERT_ATTRIB_MAX
][4*2];
488 * \name Current raster position attributes (always up to date after a
491 GLfloat RasterPos
[4];
492 GLfloat RasterDistance
;
493 GLfloat RasterColor
[4];
494 GLfloat RasterSecondaryColor
[4];
495 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
496 GLboolean RasterPosValid
;
501 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
503 struct gl_depthbuffer_attrib
505 GLenum16 Func
; /**< Function for depth buffer compare */
506 GLclampd Clear
; /**< Value to clear depth buffer to */
507 GLboolean Test
; /**< Depth buffering enabled flag */
508 GLboolean Mask
; /**< Depth buffer writable? */
509 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
510 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
515 * Evaluator attribute group (GL_EVAL_BIT).
517 struct gl_eval_attrib
523 GLboolean Map1Color4
;
525 GLboolean Map1Normal
;
526 GLboolean Map1TextureCoord1
;
527 GLboolean Map1TextureCoord2
;
528 GLboolean Map1TextureCoord3
;
529 GLboolean Map1TextureCoord4
;
530 GLboolean Map1Vertex3
;
531 GLboolean Map1Vertex4
;
532 GLboolean Map2Color4
;
534 GLboolean Map2Normal
;
535 GLboolean Map2TextureCoord1
;
536 GLboolean Map2TextureCoord2
;
537 GLboolean Map2TextureCoord3
;
538 GLboolean Map2TextureCoord4
;
539 GLboolean Map2Vertex3
;
540 GLboolean Map2Vertex4
;
541 GLboolean AutoNormal
;
545 * \name Map Grid endpoints and divisions and calculated du values
549 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
550 GLint MapGrid2un
, MapGrid2vn
;
551 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
552 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
558 * Compressed fog mode.
570 * Fog attribute group (GL_FOG_BIT).
574 GLboolean Enabled
; /**< Fog enabled flag */
575 GLboolean ColorSumEnabled
;
576 uint8_t _PackedMode
; /**< Fog mode as 2 bits */
577 uint8_t _PackedEnabledMode
; /**< Masked CompressedMode */
578 GLfloat ColorUnclamped
[4]; /**< Fog color */
579 GLfloat Color
[4]; /**< Fog color */
580 GLfloat Density
; /**< Density >= 0.0 */
581 GLfloat Start
; /**< Start distance in eye coords */
582 GLfloat End
; /**< End distance in eye coords */
583 GLfloat Index
; /**< Fog index */
584 GLenum16 Mode
; /**< Fog mode */
585 GLenum16 FogCoordinateSource
;/**< GL_EXT_fog_coord */
586 GLenum16 FogDistanceMode
; /**< GL_NV_fog_distance */
591 * Hint attribute group (GL_HINT_BIT).
593 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
595 struct gl_hint_attrib
597 GLenum16 PerspectiveCorrection
;
598 GLenum16 PointSmooth
;
600 GLenum16 PolygonSmooth
;
602 GLenum16 TextureCompression
; /**< GL_ARB_texture_compression */
603 GLenum16 GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
604 GLenum16 FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
605 GLuint MaxShaderCompilerThreads
; /**< GL_ARB_parallel_shader_compile */
610 * Lighting attribute group (GL_LIGHT_BIT).
612 struct gl_light_attrib
614 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
615 struct gl_lightmodel Model
; /**< Lighting model */
618 * Front and back material values.
619 * Note: must call FLUSH_VERTICES() before using.
621 struct gl_material Material
;
623 GLboolean Enabled
; /**< Lighting enabled flag */
624 GLboolean ColorMaterialEnabled
;
626 GLenum16 ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
627 GLenum16 ProvokingVertex
; /**< GL_EXT_provoking_vertex */
628 GLenum16 ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
629 GLenum16 ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
630 GLbitfield _ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
633 GLboolean _ClampVertexColor
;
634 GLenum16 ClampVertexColor
; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
637 * Derived state for optimizations:
640 GLbitfield _EnabledLights
; /**< bitmask containing enabled lights */
642 GLboolean _NeedEyeCoords
;
643 GLboolean _NeedVertices
; /**< Use fast shader? */
645 GLfloat _BaseColor
[2][3];
651 * Line attribute group (GL_LINE_BIT).
653 struct gl_line_attrib
655 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
656 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
657 GLushort StipplePattern
; /**< Stipple pattern */
658 GLint StippleFactor
; /**< Stipple repeat factor */
659 GLfloat Width
; /**< Line width */
664 * Display list attribute group (GL_LIST_BIT).
666 struct gl_list_attrib
673 * Multisample attribute group (GL_MULTISAMPLE_BIT).
675 struct gl_multisample_attrib
678 GLboolean SampleAlphaToCoverage
;
679 GLboolean SampleAlphaToOne
;
680 GLboolean SampleCoverage
;
681 GLboolean SampleCoverageInvert
;
682 GLboolean SampleShading
;
684 /* ARB_texture_multisample / GL3.2 additions */
685 GLboolean SampleMask
;
687 GLfloat SampleCoverageValue
; /**< In range [0, 1] */
688 GLfloat MinSampleShadingValue
; /**< In range [0, 1] */
690 /** The GL spec defines this as an array but >32x MSAA is madness */
691 GLbitfield SampleMaskValue
;
693 /* NV_alpha_to_coverage_dither_control */
694 GLenum SampleAlphaToCoverageDitherControl
;
699 * A pixelmap (see glPixelMap)
704 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
709 * Collection of all pixelmaps
713 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
714 struct gl_pixelmap GtoG
;
715 struct gl_pixelmap BtoB
;
716 struct gl_pixelmap AtoA
;
717 struct gl_pixelmap ItoR
;
718 struct gl_pixelmap ItoG
;
719 struct gl_pixelmap ItoB
;
720 struct gl_pixelmap ItoA
;
721 struct gl_pixelmap ItoI
;
722 struct gl_pixelmap StoS
;
727 * Pixel attribute group (GL_PIXEL_MODE_BIT).
729 struct gl_pixel_attrib
731 GLenum16 ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
733 /*--- Begin Pixel Transfer State ---*/
734 /* Fields are in the order in which they're applied... */
736 /** Scale & Bias (index shift, offset) */
738 GLfloat RedBias
, RedScale
;
739 GLfloat GreenBias
, GreenScale
;
740 GLfloat BlueBias
, BlueScale
;
741 GLfloat AlphaBias
, AlphaScale
;
742 GLfloat DepthBias
, DepthScale
;
743 GLint IndexShift
, IndexOffset
;
747 /* Note: actual pixel maps are not part of this attrib group */
748 GLboolean MapColorFlag
;
749 GLboolean MapStencilFlag
;
751 /*--- End Pixel Transfer State ---*/
754 GLfloat ZoomX
, ZoomY
;
759 * Point attribute group (GL_POINT_BIT).
761 struct gl_point_attrib
763 GLfloat Size
; /**< User-specified point size */
764 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
765 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
766 GLfloat Threshold
; /**< GL_EXT_point_parameters */
767 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
768 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
769 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
770 GLbitfield CoordReplace
; /**< GL_ARB_point_sprite*/
771 GLenum16 SpriteRMode
; /**< GL_NV_point_sprite (only!) */
772 GLenum16 SpriteOrigin
; /**< GL_ARB_point_sprite */
777 * Polygon attribute group (GL_POLYGON_BIT).
779 struct gl_polygon_attrib
781 GLenum16 FrontFace
; /**< Either GL_CW or GL_CCW */
782 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
783 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
784 GLboolean CullFlag
; /**< Culling on/off flag */
785 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
786 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
787 GLenum16 CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
788 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
789 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
790 GLfloat OffsetClamp
; /**< Polygon offset clamp, from user */
791 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
792 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
793 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
798 * Scissor attributes (GL_SCISSOR_BIT).
800 struct gl_scissor_rect
802 GLint X
, Y
; /**< Lower left corner of box */
803 GLsizei Width
, Height
; /**< Size of box */
807 struct gl_scissor_attrib
809 GLbitfield EnableFlags
; /**< Scissor test enabled? */
810 struct gl_scissor_rect ScissorArray
[MAX_VIEWPORTS
];
811 GLint NumWindowRects
; /**< Count of enabled window rectangles */
812 GLenum16 WindowRectMode
; /**< Whether to include or exclude the rects */
813 struct gl_scissor_rect WindowRects
[MAX_WINDOW_RECTANGLES
];
818 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
820 * Three sets of stencil data are tracked so that OpenGL 2.0,
821 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
822 * simultaneously. In each of the stencil state arrays, element 0 corresponds
823 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
824 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
825 * GL_EXT_stencil_two_side GL_BACK state.
827 * The derived value \c _BackFace is either 1 or 2 depending on whether or
828 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
830 * The derived value \c _TestTwoSide is set when the front-face and back-face
831 * stencil state are different.
833 struct gl_stencil_attrib
835 GLboolean Enabled
; /**< Enabled flag */
836 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
837 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 2) */
838 GLubyte _BackFace
; /**< Current back stencil state (1 or 2) */
839 GLenum16 Function
[3]; /**< Stencil function */
840 GLenum16 FailFunc
[3]; /**< Fail function */
841 GLenum16 ZPassFunc
[3]; /**< Depth buffer pass function */
842 GLenum16 ZFailFunc
[3]; /**< Depth buffer fail function */
843 GLint Ref
[3]; /**< Reference value */
844 GLuint ValueMask
[3]; /**< Value mask */
845 GLuint WriteMask
[3]; /**< Write mask */
846 GLuint Clear
; /**< Clear value */
851 * Bit flags for each type of texture object
854 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
855 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
856 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
857 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
858 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
859 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
860 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
861 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
862 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
863 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
864 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
865 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
870 * Texture image state. Drivers will typically create a subclass of this
871 * with extra fields for memory buffers, etc.
873 struct gl_texture_image
875 GLint InternalFormat
; /**< Internal format as given by the user */
876 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
877 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
878 * GL_INTENSITY, GL_DEPTH_COMPONENT or
879 * GL_DEPTH_STENCIL_EXT only. Used for
880 * choosing TexEnv arithmetic.
882 mesa_format TexFormat
; /**< The actual texture memory format */
884 GLuint Border
; /**< 0 or 1 */
885 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
886 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
887 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
888 GLuint Width2
; /**< = Width - 2*Border */
889 GLuint Height2
; /**< = Height - 2*Border */
890 GLuint Depth2
; /**< = Depth - 2*Border */
891 GLuint WidthLog2
; /**< = log2(Width2) */
892 GLuint HeightLog2
; /**< = log2(Height2) */
893 GLuint DepthLog2
; /**< = log2(Depth2) */
894 GLuint MaxNumLevels
; /**< = maximum possible number of mipmap
895 levels, computed from the dimensions */
897 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
898 GLuint Level
; /**< Which mipmap level am I? */
899 /** Cube map face: index into gl_texture_object::Image[] array */
902 /** GL_ARB_texture_multisample */
903 GLuint NumSamples
; /**< Sample count, or 0 for non-multisample */
904 GLboolean FixedSampleLocations
; /**< Same sample locations for all pixels? */
909 * Indexes for cube map faces.
924 * Sampler object state. These objects are new with GL_ARB_sampler_objects
925 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
927 struct gl_sampler_object
931 GLchar
*Label
; /**< GL_KHR_debug */
934 GLenum16 WrapS
; /**< S-axis texture image wrap mode */
935 GLenum16 WrapT
; /**< T-axis texture image wrap mode */
936 GLenum16 WrapR
; /**< R-axis texture image wrap mode */
937 GLenum16 MinFilter
; /**< minification filter */
938 GLenum16 MagFilter
; /**< magnification filter */
939 GLenum16 sRGBDecode
; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
940 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
941 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
942 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
943 GLfloat LodBias
; /**< OpenGL 1.4 */
944 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
945 GLenum16 CompareMode
; /**< GL_ARB_shadow */
946 GLenum16 CompareFunc
; /**< GL_ARB_shadow */
947 GLboolean CubeMapSeamless
; /**< GL_AMD_seamless_cubemap_per_texture */
949 /** GL_ARB_bindless_texture */
950 bool HandleAllocated
;
951 struct util_dynarray Handles
;
956 * Texture object state. Contains the array of mipmap images, border color,
957 * wrap modes, filter modes, and shadow/texcompare state.
959 struct gl_texture_object
961 simple_mtx_t Mutex
; /**< for thread safety */
962 GLint RefCount
; /**< reference count */
963 GLuint Name
; /**< the user-visible texture object ID */
964 GLenum16 Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
965 GLenum16 DepthMode
; /**< GL_ARB_depth_texture */
966 GLchar
*Label
; /**< GL_KHR_debug */
968 struct gl_sampler_object Sampler
;
970 gl_texture_index TargetIndex
; /**< The gl_texture_unit::CurrentTex index.
971 Only valid when Target is valid. */
972 GLfloat Priority
; /**< in [0,1] */
973 GLint MaxLevel
; /**< max mipmap level (max=1000), OpenGL 1.2 */
974 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
975 GLbyte _MaxLevel
; /**< actual max mipmap level (q in the spec) */
976 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - p in spec) */
977 GLint CropRect
[4]; /**< GL_OES_draw_texture */
978 GLenum Swizzle
[4]; /**< GL_EXT_texture_swizzle */
979 GLushort _Swizzle
; /**< same as Swizzle, but SWIZZLE_* format */
980 GLbyte ImmutableLevels
; /**< ES 3.0 / ARB_texture_view */
981 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
982 GLboolean _BaseComplete
; /**< Is the base texture level valid? */
983 GLboolean _MipmapComplete
; /**< Is the whole mipmap valid? */
984 GLboolean _IsIntegerFormat
; /**< Does the texture store integer values? */
985 GLboolean _RenderToTexture
; /**< Any rendering to this texture? */
986 GLboolean Purgeable
; /**< Is the buffer purgeable under memory
988 GLboolean Immutable
; /**< GL_ARB_texture_storage */
989 GLboolean _IsFloat
; /**< GL_OES_float_texture */
990 GLboolean _IsHalfFloat
; /**< GL_OES_half_float_texture */
991 bool StencilSampling
; /**< Should we sample stencil instead of depth? */
992 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
994 /** GL_OES_EGL_image_external */
995 GLubyte RequiredTextureImageUnits
;
997 GLubyte MinLevel
; /**< GL_ARB_texture_view */
998 GLubyte NumLevels
; /**< GL_ARB_texture_view */
999 GLushort MinLayer
; /**< GL_ARB_texture_view */
1000 GLushort NumLayers
; /**< GL_ARB_texture_view */
1002 /** GL_EXT_memory_object */
1003 GLenum16 TextureTiling
;
1005 /** GL_ARB_shader_image_load_store */
1006 GLenum16 ImageFormatCompatibilityType
;
1008 /** GL_ARB_texture_buffer_object */
1009 GLenum16 BufferObjectFormat
;
1010 /** Equivalent Mesa format for BufferObjectFormat. */
1011 mesa_format _BufferObjectFormat
;
1012 struct gl_buffer_object
*BufferObject
;
1014 /** GL_ARB_texture_buffer_range */
1015 GLintptr BufferOffset
;
1016 GLsizeiptr BufferSize
; /**< if this is -1, use BufferObject->Size instead */
1018 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1019 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1021 /** GL_ARB_bindless_texture */
1022 struct util_dynarray SamplerHandles
;
1023 struct util_dynarray ImageHandles
;
1027 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1028 #define MAX_COMBINER_TERMS 4
1032 * Texture combine environment state.
1034 struct gl_tex_env_combine_state
1036 GLenum16 ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1037 GLenum16 ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1038 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1039 GLenum16 SourceRGB
[MAX_COMBINER_TERMS
];
1040 GLenum16 SourceA
[MAX_COMBINER_TERMS
];
1041 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1042 GLenum16 OperandRGB
[MAX_COMBINER_TERMS
];
1043 GLenum16 OperandA
[MAX_COMBINER_TERMS
];
1044 GLubyte ScaleShiftRGB
; /**< 0, 1 or 2 */
1045 GLubyte ScaleShiftA
; /**< 0, 1 or 2 */
1046 GLubyte _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1047 GLubyte _NumArgsA
; /**< Number of inputs used for the A combiner */
1051 /** Compressed TexEnv effective Combine mode */
1052 enum gl_tex_env_mode
1054 TEXENV_MODE_REPLACE
, /* r = a0 */
1055 TEXENV_MODE_MODULATE
, /* r = a0 * a1 */
1056 TEXENV_MODE_ADD
, /* r = a0 + a1 */
1057 TEXENV_MODE_ADD_SIGNED
, /* r = a0 + a1 - 0.5 */
1058 TEXENV_MODE_INTERPOLATE
, /* r = a0 * a2 + a1 * (1 - a2) */
1059 TEXENV_MODE_SUBTRACT
, /* r = a0 - a1 */
1060 TEXENV_MODE_DOT3_RGB
, /* r = a0 . a1 */
1061 TEXENV_MODE_DOT3_RGB_EXT
, /* r = a0 . a1 */
1062 TEXENV_MODE_DOT3_RGBA
, /* r = a0 . a1 */
1063 TEXENV_MODE_DOT3_RGBA_EXT
, /* r = a0 . a1 */
1064 TEXENV_MODE_MODULATE_ADD_ATI
, /* r = a0 * a2 + a1 */
1065 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI
, /* r = a0 * a2 + a1 - 0.5 */
1066 TEXENV_MODE_MODULATE_SUBTRACT_ATI
, /* r = a0 * a2 - a1 */
1067 TEXENV_MODE_ADD_PRODUCTS_NV
, /* r = a0 * a1 + a2 * a3 */
1068 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV
, /* r = a0 * a1 + a2 * a3 - 0.5 */
1072 /** Compressed TexEnv Combine source */
1073 enum gl_tex_env_source
1075 TEXENV_SRC_TEXTURE0
,
1076 TEXENV_SRC_TEXTURE1
,
1077 TEXENV_SRC_TEXTURE2
,
1078 TEXENV_SRC_TEXTURE3
,
1079 TEXENV_SRC_TEXTURE4
,
1080 TEXENV_SRC_TEXTURE5
,
1081 TEXENV_SRC_TEXTURE6
,
1082 TEXENV_SRC_TEXTURE7
,
1084 TEXENV_SRC_PREVIOUS
,
1085 TEXENV_SRC_PRIMARY_COLOR
,
1086 TEXENV_SRC_CONSTANT
,
1092 /** Compressed TexEnv Combine operand */
1093 enum gl_tex_env_operand
1096 TEXENV_OPR_ONE_MINUS_COLOR
,
1098 TEXENV_OPR_ONE_MINUS_ALPHA
,
1102 /** Compressed TexEnv Combine argument */
1103 struct gl_tex_env_argument
1106 __extension__
uint8_t Source
:4; /**< TEXENV_SRC_x */
1107 __extension__
uint8_t Operand
:2; /**< TEXENV_OPR_x */
1109 uint8_t Source
; /**< SRC_x */
1110 uint8_t Operand
; /**< OPR_x */
1116 * Compressed TexEnv Combine state.
1118 struct gl_tex_env_combine_packed
1120 uint32_t ModeRGB
:4; /**< Effective mode for RGB as 4 bits */
1121 uint32_t ModeA
:4; /**< Effective mode for RGB as 4 bits */
1122 uint32_t ScaleShiftRGB
:2; /**< 0, 1 or 2 */
1123 uint32_t ScaleShiftA
:2; /**< 0, 1 or 2 */
1124 uint32_t NumArgsRGB
:3; /**< Number of inputs used for the RGB combiner */
1125 uint32_t NumArgsA
:3; /**< Number of inputs used for the A combiner */
1126 /** Source arguments in a packed manner */
1127 struct gl_tex_env_argument ArgsRGB
[MAX_COMBINER_TERMS
];
1128 struct gl_tex_env_argument ArgsA
[MAX_COMBINER_TERMS
];
1133 * TexGenEnabled flags.
1140 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1145 * Bit flag versions of the corresponding GL_ constants.
1148 #define TEXGEN_SPHERE_MAP 0x1
1149 #define TEXGEN_OBJ_LINEAR 0x2
1150 #define TEXGEN_EYE_LINEAR 0x4
1151 #define TEXGEN_REFLECTION_MAP_NV 0x8
1152 #define TEXGEN_NORMAL_MAP_NV 0x10
1154 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1155 TEXGEN_REFLECTION_MAP_NV | \
1156 TEXGEN_NORMAL_MAP_NV)
1157 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1158 TEXGEN_REFLECTION_MAP_NV | \
1159 TEXGEN_NORMAL_MAP_NV | \
1165 /** Tex-gen enabled for texture unit? */
1166 #define ENABLE_TEXGEN(unit) (1 << (unit))
1168 /** Non-identity texture matrix for texture unit? */
1169 #define ENABLE_TEXMAT(unit) (1 << (unit))
1173 * Texture coord generation state.
1177 GLenum16 Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1178 GLbitfield8 _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1179 GLfloat ObjectPlane
[4];
1180 GLfloat EyePlane
[4];
1185 * Sampler-related subset of a texture unit, like current texture objects.
1187 struct gl_texture_unit
1189 GLfloat LodBias
; /**< for biasing mipmap levels */
1191 /** Texture targets that have a non-default texture bound */
1192 GLbitfield _BoundTextures
;
1194 /** Current sampler object (GL_ARB_sampler_objects) */
1195 struct gl_sampler_object
*Sampler
;
1197 /** Current texture object pointers */
1198 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1200 /** Points to highest priority, complete and enabled texture object */
1201 struct gl_texture_object
*_Current
;
1206 * Fixed-function-related subset of a texture unit, like enable flags,
1207 * texture environment/function/combiners, and texgen state.
1209 struct gl_fixedfunc_texture_unit
1211 GLbitfield16 Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1213 GLenum16 EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1214 GLclampf EnvColor
[4];
1215 GLfloat EnvColorUnclamped
[4];
1217 struct gl_texgen GenS
;
1218 struct gl_texgen GenT
;
1219 struct gl_texgen GenR
;
1220 struct gl_texgen GenQ
;
1221 GLbitfield8 TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1222 GLbitfield8 _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1225 * \name GL_EXT_texture_env_combine
1227 struct gl_tex_env_combine_state Combine
;
1230 * Derived state based on \c EnvMode and the \c BaseFormat of the
1231 * currently enabled texture.
1233 struct gl_tex_env_combine_state _EnvMode
;
1235 /** Current compressed TexEnv & Combine state */
1236 struct gl_tex_env_combine_packed _CurrentCombinePacked
;
1239 * Currently enabled combiner state. This will point to either
1240 * \c Combine or \c _EnvMode.
1242 struct gl_tex_env_combine_state
*_CurrentCombine
;
1247 * Texture attribute group (GL_TEXTURE_BIT).
1249 struct gl_texture_attrib
1251 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1253 /** GL_ARB_texture_buffer_object */
1254 struct gl_buffer_object
*BufferObject
;
1256 GLuint CurrentUnit
; /**< GL_ACTIVE_TEXTURE */
1258 /** Texture coord units/sets used for fragment texturing */
1259 GLbitfield8 _EnabledCoordUnits
;
1261 /** Texture coord units that have texgen enabled */
1262 GLbitfield8 _TexGenEnabled
;
1264 /** Texture coord units that have non-identity matrices */
1265 GLbitfield8 _TexMatEnabled
;
1267 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1268 GLbitfield8 _GenFlags
;
1270 /** Largest index of a texture unit with _Current != NULL. */
1271 GLshort _MaxEnabledTexImageUnit
;
1273 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1274 GLubyte NumCurrentTexUsed
;
1276 /** GL_ARB_seamless_cubemap */
1277 GLboolean CubeMapSeamless
;
1279 struct gl_texture_unit Unit
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
1280 struct gl_fixedfunc_texture_unit FixedFuncUnit
[MAX_TEXTURE_COORD_UNITS
];
1285 * Data structure representing a single clip plane (e.g. one of the elements
1286 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1288 typedef GLfloat gl_clip_plane
[4];
1292 * Transformation attribute group (GL_TRANSFORM_BIT).
1294 struct gl_transform_attrib
1296 GLenum16 MatrixMode
; /**< Matrix mode */
1297 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1298 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1299 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1300 GLboolean Normalize
; /**< Normalize all normals? */
1301 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1302 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1303 GLboolean DepthClampNear
; /**< GL_AMD_depth_clamp_separate */
1304 GLboolean DepthClampFar
; /**< GL_AMD_depth_clamp_separate */
1305 /** GL_ARB_clip_control */
1306 GLenum16 ClipOrigin
; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1307 GLenum16 ClipDepthMode
;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1312 * Viewport attribute group (GL_VIEWPORT_BIT).
1314 struct gl_viewport_attrib
1316 GLfloat X
, Y
; /**< position */
1317 GLfloat Width
, Height
; /**< size */
1318 GLfloat Near
, Far
; /**< Depth buffer range */
1320 /**< GL_NV_viewport_swizzle */
1321 GLenum16 SwizzleX
, SwizzleY
, SwizzleZ
, SwizzleW
;
1326 * Fields describing a mapped buffer range.
1328 struct gl_buffer_mapping
1330 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1331 GLvoid
*Pointer
; /**< User-space address of mapping */
1332 GLintptr Offset
; /**< Mapped offset */
1333 GLsizeiptr Length
; /**< Mapped length */
1338 * Usages we've seen for a buffer object.
1342 USAGE_UNIFORM_BUFFER
= 0x1,
1343 USAGE_TEXTURE_BUFFER
= 0x2,
1344 USAGE_ATOMIC_COUNTER_BUFFER
= 0x4,
1345 USAGE_SHADER_STORAGE_BUFFER
= 0x8,
1346 USAGE_TRANSFORM_FEEDBACK_BUFFER
= 0x10,
1347 USAGE_PIXEL_PACK_BUFFER
= 0x20,
1348 USAGE_ARRAY_BUFFER
= 0x40,
1349 USAGE_ELEMENT_ARRAY_BUFFER
= 0x80,
1350 USAGE_DISABLE_MINMAX_CACHE
= 0x100,
1355 * GL_ARB_vertex/pixel_buffer_object buffer object
1357 struct gl_buffer_object
1361 GLchar
*Label
; /**< GL_KHR_debug */
1362 GLenum16 Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1363 GLbitfield StorageFlags
; /**< GL_MAP_PERSISTENT_BIT, etc. */
1364 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1365 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1366 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1367 GLboolean Written
; /**< Ever written to? (for debugging) */
1368 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1369 GLboolean Immutable
; /**< GL_ARB_buffer_storage */
1370 gl_buffer_usage UsageHistory
; /**< How has this buffer been used so far? */
1372 /** Counters used for buffer usage warnings */
1373 GLuint NumSubDataCalls
;
1374 GLuint NumMapBufferWriteCalls
;
1376 struct gl_buffer_mapping Mappings
[MAP_COUNT
];
1378 /** Memoization of min/max index computations for static index buffers */
1379 simple_mtx_t MinMaxCacheMutex
;
1380 struct hash_table
*MinMaxCache
;
1381 unsigned MinMaxCacheHitIndices
;
1382 unsigned MinMaxCacheMissIndices
;
1383 bool MinMaxCacheDirty
;
1385 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1390 * Client pixel packing/unpacking attributes
1392 struct gl_pixelstore_attrib
1400 GLboolean SwapBytes
;
1402 GLboolean Invert
; /**< GL_MESA_pack_invert */
1403 GLint CompressedBlockWidth
; /**< GL_ARB_compressed_texture_pixel_storage */
1404 GLint CompressedBlockHeight
;
1405 GLint CompressedBlockDepth
;
1406 GLint CompressedBlockSize
;
1407 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1412 * Enum for defining the mapping for the position/generic0 attribute.
1414 * Do not change the order of the values as these are used as
1419 ATTRIBUTE_MAP_MODE_IDENTITY
, /**< 1:1 mapping */
1420 ATTRIBUTE_MAP_MODE_POSITION
, /**< get position and generic0 from position */
1421 ATTRIBUTE_MAP_MODE_GENERIC0
, /**< get position and generic0 from generic0 */
1422 ATTRIBUTE_MAP_MODE_MAX
/**< for sizing arrays */
1423 } gl_attribute_map_mode
;
1427 * Attributes to describe a vertex array.
1429 * Contains the size, type, format and normalization flag,
1430 * along with the index of a vertex buffer binding point.
1432 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1433 * and is only present for backwards compatibility reasons.
1434 * Rendering always uses VERTEX_BINDING_STRIDE.
1435 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1436 * and VERTEX_BINDING_STRIDE to the same value, while
1437 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1439 struct gl_array_attributes
1441 /** Points to client array data. Not used when a VBO is bound */
1443 /** Offset of the first element relative to the binding offset */
1444 GLuint RelativeOffset
;
1445 /** Vertex format */
1446 struct gl_vertex_format Format
;
1447 /** Stride as specified with gl*Pointer() */
1449 /** Index into gl_vertex_array_object::BufferBinding[] array */
1450 GLubyte BufferBindingIndex
;
1453 * Derived effective buffer binding index
1455 * Index into the gl_vertex_buffer_binding array of the vao.
1456 * Similar to BufferBindingIndex, but with the mapping of the
1457 * position/generic0 attributes applied and with identical
1458 * gl_vertex_buffer_binding entries collapsed to a single
1459 * entry within the vao.
1461 * The value is valid past calling _mesa_update_vao_derived_arrays.
1462 * Note that _mesa_update_vao_derived_arrays is called when binding
1463 * the VAO to Array._DrawVAO.
1465 GLubyte _EffBufferBindingIndex
;
1467 * Derived effective relative offset.
1469 * Relative offset to the effective buffers offset in
1470 * gl_vertex_buffer_binding::_EffOffset.
1472 * The value is valid past calling _mesa_update_vao_derived_arrays.
1473 * Note that _mesa_update_vao_derived_arrays is called when binding
1474 * the VAO to Array._DrawVAO.
1476 GLushort _EffRelativeOffset
;
1481 * This describes the buffer object used for a vertex array (or
1482 * multiple vertex arrays). If BufferObj points to the default/null
1483 * buffer object, then the vertex array lives in user memory and not a VBO.
1485 struct gl_vertex_buffer_binding
1487 GLintptr Offset
; /**< User-specified offset */
1488 GLsizei Stride
; /**< User-specified stride */
1489 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1490 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_vertex_buffer_object */
1491 GLbitfield _BoundArrays
; /**< Arrays bound to this binding point */
1494 * Derived effective bound arrays.
1496 * The effective binding handles enabled arrays past the
1497 * position/generic0 attribute mapping and reduces the refered
1498 * gl_vertex_buffer_binding entries to a unique subset.
1500 * The value is valid past calling _mesa_update_vao_derived_arrays.
1501 * Note that _mesa_update_vao_derived_arrays is called when binding
1502 * the VAO to Array._DrawVAO.
1504 GLbitfield _EffBoundArrays
;
1508 * The absolute offset to that we can collapse some attributes
1509 * to this unique effective binding.
1510 * For user space array bindings this contains the smallest pointer value
1511 * in the bound and interleaved arrays.
1512 * For VBO bindings this contains an offset that lets the attributes
1513 * _EffRelativeOffset stay positive and in bounds with
1514 * Const.MaxVertexAttribRelativeOffset
1516 * The value is valid past calling _mesa_update_vao_derived_arrays.
1517 * Note that _mesa_update_vao_derived_arrays is called when binding
1518 * the VAO to Array._DrawVAO.
1520 GLintptr _EffOffset
;
1525 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1526 * the GL_ARB_vertex_array_object extension.
1528 struct gl_vertex_array_object
1530 /** Name of the VAO as received from glGenVertexArray. */
1535 GLchar
*Label
; /**< GL_KHR_debug */
1538 * Has this array object been bound?
1540 GLboolean EverBound
;
1543 * Whether the VAO is changed by the application so often that some of
1544 * the derived fields are not updated at all to decrease overhead.
1545 * Also, interleaved arrays are not detected, because it's too expensive
1546 * to do that before every draw call.
1551 * Marked to true if the object is shared between contexts and immutable.
1552 * Then reference counting is done using atomics and thread safe.
1553 * Is used for dlist VAOs.
1555 bool SharedAndImmutable
;
1558 * Number of updates that were done by the application. This is used to
1559 * decide whether the VAO is static or dynamic.
1561 unsigned NumUpdates
;
1563 /** Vertex attribute arrays */
1564 struct gl_array_attributes VertexAttrib
[VERT_ATTRIB_MAX
];
1566 /** Vertex buffer bindings */
1567 struct gl_vertex_buffer_binding BufferBinding
[VERT_ATTRIB_MAX
];
1569 /** Mask indicating which vertex arrays have vertex buffer associated. */
1570 GLbitfield VertexAttribBufferMask
;
1572 /** Mask indicating which vertex arrays have a non-zero instance divisor. */
1573 GLbitfield NonZeroDivisorMask
;
1575 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1579 * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
1581 * The value is valid past calling _mesa_update_vao_derived_arrays.
1582 * Note that _mesa_update_vao_derived_arrays is called when binding
1583 * the VAO to Array._DrawVAO.
1585 GLbitfield _EffEnabledVBO
;
1587 /** Same as _EffEnabledVBO, but for instance divisors. */
1588 GLbitfield _EffEnabledNonZeroDivisor
;
1590 /** Denotes the way the position/generic0 attribute is mapped */
1591 gl_attribute_map_mode _AttributeMapMode
;
1593 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1594 GLbitfield NewArrays
;
1596 /** The index buffer (also known as the element array buffer in OpenGL). */
1597 struct gl_buffer_object
*IndexBufferObj
;
1602 * Vertex array state
1604 struct gl_array_attrib
1606 /** Currently bound array object. */
1607 struct gl_vertex_array_object
*VAO
;
1609 /** The default vertex array object */
1610 struct gl_vertex_array_object
*DefaultVAO
;
1612 /** The last VAO accessed by a DSA function */
1613 struct gl_vertex_array_object
*LastLookedUpVAO
;
1615 /** These contents are copied to newly created VAOs. */
1616 struct gl_vertex_array_object DefaultVAOState
;
1618 /** Array objects (GL_ARB_vertex_array_object) */
1619 struct _mesa_HashTable
*Objects
;
1621 GLint ActiveTexture
; /**< Client Active Texture */
1622 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1623 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1626 * \name Primitive restart controls
1628 * Primitive restart is enabled if either \c PrimitiveRestart or
1629 * \c PrimitiveRestartFixedIndex is set.
1632 GLboolean PrimitiveRestart
;
1633 GLboolean PrimitiveRestartFixedIndex
;
1634 GLboolean _PrimitiveRestart
;
1635 GLuint RestartIndex
;
1636 GLuint _RestartIndex
[4]; /**< Restart indices for index_size - 1. */
1639 /* GL_ARB_vertex_buffer_object */
1640 struct gl_buffer_object
*ArrayBufferObj
;
1643 * Vertex array object that is used with the currently active draw command.
1644 * The _DrawVAO is either set to the currently bound VAO for array type
1645 * draws or to internal VAO's set up by the vbo module to execute immediate
1646 * mode or display list draws.
1648 struct gl_vertex_array_object
*_DrawVAO
;
1650 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
1651 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
1652 * but may omit those arrays that shall not be referenced by the current
1653 * gl_vertex_program_state::_VPMode. For example the generic attributes are
1654 * maked out form the _DrawVAO's enabled arrays when a fixed function
1655 * array draw is executed.
1657 GLbitfield _DrawVAOEnabledAttribs
;
1659 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
1660 * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
1662 struct gl_vertex_array_object
*_EmptyVAO
;
1664 /** Legal array datatypes and the API for which they have been computed */
1665 GLbitfield LegalTypesMask
;
1666 gl_api LegalTypesMaskAPI
;
1671 * Feedback buffer state
1676 GLbitfield _Mask
; /**< FB_* bits */
1684 * Selection buffer state
1688 GLuint
*Buffer
; /**< selection buffer */
1689 GLuint BufferSize
; /**< size of the selection buffer */
1690 GLuint BufferCount
; /**< number of values in the selection buffer */
1691 GLuint Hits
; /**< number of records in the selection buffer */
1692 GLuint NameStackDepth
; /**< name stack depth */
1693 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1694 GLboolean HitFlag
; /**< hit flag */
1695 GLfloat HitMinZ
; /**< minimum hit depth */
1696 GLfloat HitMaxZ
; /**< maximum hit depth */
1701 * 1-D Evaluator control points
1705 GLuint Order
; /**< Number of control points */
1706 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1707 GLfloat
*Points
; /**< Points to contiguous control points */
1712 * 2-D Evaluator control points
1716 GLuint Uorder
; /**< Number of control points in U dimension */
1717 GLuint Vorder
; /**< Number of control points in V dimension */
1720 GLfloat
*Points
; /**< Points to contiguous control points */
1725 * All evaluator control point state
1727 struct gl_evaluators
1733 struct gl_1d_map Map1Vertex3
;
1734 struct gl_1d_map Map1Vertex4
;
1735 struct gl_1d_map Map1Index
;
1736 struct gl_1d_map Map1Color4
;
1737 struct gl_1d_map Map1Normal
;
1738 struct gl_1d_map Map1Texture1
;
1739 struct gl_1d_map Map1Texture2
;
1740 struct gl_1d_map Map1Texture3
;
1741 struct gl_1d_map Map1Texture4
;
1748 struct gl_2d_map Map2Vertex3
;
1749 struct gl_2d_map Map2Vertex4
;
1750 struct gl_2d_map Map2Index
;
1751 struct gl_2d_map Map2Color4
;
1752 struct gl_2d_map Map2Normal
;
1753 struct gl_2d_map Map2Texture1
;
1754 struct gl_2d_map Map2Texture2
;
1755 struct gl_2d_map Map2Texture3
;
1756 struct gl_2d_map Map2Texture4
;
1761 struct gl_transform_feedback_varying_info
1772 * Per-output info vertex shaders for transform feedback.
1774 struct gl_transform_feedback_output
1776 uint32_t OutputRegister
;
1777 uint32_t OutputBuffer
;
1778 uint32_t NumComponents
;
1781 /** offset (in DWORDs) of this output within the interleaved structure */
1785 * Offset into the output register of the data to output. For example,
1786 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1787 * offset is in the y and z components of the output register.
1789 uint32_t ComponentOffset
;
1793 struct gl_transform_feedback_buffer
1797 uint32_t NumVaryings
;
1800 * Total number of components stored in each buffer. This may be used by
1801 * hardware back-ends to determine the correct stride when interleaving
1802 * multiple transform feedback outputs in the same buffer.
1807 * Which transform feedback stream this buffer binding is associated with.
1813 /** Post-link transform feedback info. */
1814 struct gl_transform_feedback_info
1816 unsigned NumOutputs
;
1818 /* Bitmask of active buffer indices. */
1819 unsigned ActiveBuffers
;
1821 struct gl_transform_feedback_output
*Outputs
;
1823 /** Transform feedback varyings used for the linking of this shader program.
1825 * Use for glGetTransformFeedbackVarying().
1827 struct gl_transform_feedback_varying_info
*Varyings
;
1830 struct gl_transform_feedback_buffer Buffers
[MAX_FEEDBACK_BUFFERS
];
1835 * Transform feedback object state
1837 struct gl_transform_feedback_object
1839 GLuint Name
; /**< AKA the object ID */
1841 GLchar
*Label
; /**< GL_KHR_debug */
1842 GLboolean Active
; /**< Is transform feedback enabled? */
1843 GLboolean Paused
; /**< Is transform feedback paused? */
1844 GLboolean EndedAnytime
; /**< Has EndTransformFeedback been called
1846 GLboolean EverBound
; /**< Has this object been bound? */
1849 * GLES: if Active is true, remaining number of primitives which can be
1850 * rendered without overflow. This is necessary to track because GLES
1851 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1852 * glDrawArraysInstanced would overflow transform feedback buffers.
1853 * Undefined if Active is false.
1855 * Not tracked for desktop GL since it's unnecessary.
1857 unsigned GlesRemainingPrims
;
1860 * The program active when BeginTransformFeedback() was called.
1861 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1862 * where stage is the pipeline stage that is the source of data for
1863 * transform feedback.
1865 struct gl_program
*program
;
1867 /** The feedback buffers */
1868 GLuint BufferNames
[MAX_FEEDBACK_BUFFERS
];
1869 struct gl_buffer_object
*Buffers
[MAX_FEEDBACK_BUFFERS
];
1871 /** Start of feedback data in dest buffer */
1872 GLintptr Offset
[MAX_FEEDBACK_BUFFERS
];
1875 * Max data to put into dest buffer (in bytes). Computed based on
1876 * RequestedSize and the actual size of the buffer.
1878 GLsizeiptr Size
[MAX_FEEDBACK_BUFFERS
];
1881 * Size that was specified when the buffer was bound. If the buffer was
1882 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1885 GLsizeiptr RequestedSize
[MAX_FEEDBACK_BUFFERS
];
1890 * Context state for transform feedback.
1892 struct gl_transform_feedback_state
1894 GLenum16 Mode
; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1896 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1897 struct gl_buffer_object
*CurrentBuffer
;
1899 /** The table of all transform feedback objects */
1900 struct _mesa_HashTable
*Objects
;
1902 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1903 struct gl_transform_feedback_object
*CurrentObject
;
1905 /** The default xform-fb object (Name==0) */
1906 struct gl_transform_feedback_object
*DefaultObject
;
1911 * A "performance monitor" as described in AMD_performance_monitor.
1913 struct gl_perf_monitor_object
1917 /** True if the monitor is currently active (Begin called but not End). */
1921 * True if the monitor has ended.
1923 * This is distinct from !Active because it may never have began.
1928 * A list of groups with currently active counters.
1930 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1932 unsigned *ActiveGroups
;
1935 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1937 * Checking whether counter 'c' in group 'g' is active can be done via:
1939 * BITSET_TEST(ActiveCounters[g], c)
1941 GLuint
**ActiveCounters
;
1945 union gl_perf_monitor_counter_value
1953 struct gl_perf_monitor_counter
1955 /** Human readable name for the counter. */
1959 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1960 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1964 /** Minimum counter value. */
1965 union gl_perf_monitor_counter_value Minimum
;
1967 /** Maximum counter value. */
1968 union gl_perf_monitor_counter_value Maximum
;
1972 struct gl_perf_monitor_group
1974 /** Human readable name for the group. */
1978 * Maximum number of counters in this group which can be active at the
1981 GLuint MaxActiveCounters
;
1983 /** Array of counters within this group. */
1984 const struct gl_perf_monitor_counter
*Counters
;
1990 * A query object instance as described in INTEL_performance_query.
1992 * NB: We want to keep this and the corresponding backend structure
1993 * relatively lean considering that applications may expect to
1994 * allocate enough objects to be able to query around all draw calls
1997 struct gl_perf_query_object
1999 GLuint Id
; /**< hash table ID/name */
2000 unsigned Used
:1; /**< has been used for 1 or more queries */
2001 unsigned Active
:1; /**< inside Begin/EndPerfQuery */
2002 unsigned Ready
:1; /**< result is ready? */
2007 * Context state for AMD_performance_monitor.
2009 struct gl_perf_monitor_state
2011 /** Array of performance monitor groups (indexed by group ID) */
2012 const struct gl_perf_monitor_group
*Groups
;
2015 /** The table of all performance monitors. */
2016 struct _mesa_HashTable
*Monitors
;
2021 * Context state for INTEL_performance_query.
2023 struct gl_perf_query_state
2025 struct _mesa_HashTable
*Objects
; /**< The table of all performance query objects */
2030 * A bindless sampler object.
2032 struct gl_bindless_sampler
2034 /** Texture unit (set by glUniform1()). */
2037 /** Whether this bindless sampler is bound to a unit. */
2040 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2041 gl_texture_index target
;
2043 /** Pointer to the base of the data. */
2049 * A bindless image object.
2051 struct gl_bindless_image
2053 /** Image unit (set by glUniform1()). */
2056 /** Whether this bindless image is bound to a unit. */
2059 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
2060 * GL_NONE to indicate both read-only and write-only)
2064 /** Pointer to the base of the data. */
2070 * Base class for any kind of program object
2074 /** FIXME: This must be first until we split shader_info from nir_shader */
2075 struct shader_info info
;
2079 GLubyte
*String
; /**< Null-terminated program text */
2081 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2083 GLenum16 Format
; /**< String encoding format */
2085 GLboolean _Used
; /**< Ever used for drawing? Used for debugging */
2087 struct nir_shader
*nir
;
2089 /* Saved and restored with metadata. Freed with ralloc. */
2090 void *driver_cache_blob
;
2091 size_t driver_cache_blob_size
;
2093 bool is_arb_asm
; /** Is this an ARB assembly-style program */
2095 /** Is this program written to on disk shader cache */
2096 bool program_written_to_cache
;
2098 /** A bitfield indicating which vertex shader inputs consume two slots
2100 * This is used for mapping from single-slot input locations in the GL API
2101 * to dual-slot double input locations in the shader. This field is set
2102 * once as part of linking and never updated again to ensure the mapping
2103 * remains consistent.
2105 * Note: There may be dual-slot variables in the original shader source
2106 * which do not appear in this bitfield due to having been eliminated by
2107 * the compiler prior to DualSlotInputs being calculated. There may also
2108 * be bits set in this bitfield which are set but which the shader never
2109 * reads due to compiler optimizations eliminating such variables after
2110 * DualSlotInputs is calculated.
2112 GLbitfield64 DualSlotInputs
;
2113 /** Subset of OutputsWritten outputs written with non-zero index. */
2114 GLbitfield64 SecondaryOutputsWritten
;
2115 /** TEXTURE_x_BIT bitmask */
2116 GLbitfield16 TexturesUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
2117 /** Bitfield of which samplers are used */
2118 GLbitfield SamplersUsed
;
2119 /** Texture units used for shadow sampling. */
2120 GLbitfield ShadowSamplers
;
2121 /** Texture units used for samplerExternalOES */
2122 GLbitfield ExternalSamplersUsed
;
2124 /** Named parameters, constants, etc. from program text */
2125 struct gl_program_parameter_list
*Parameters
;
2127 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2128 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2130 /* FIXME: We should be able to make this struct a union. However some
2131 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2132 * these fields, we should fix this.
2135 /** Fields used by GLSL programs */
2137 /** Data shared by gl_program and gl_shader_program */
2138 struct gl_shader_program_data
*data
;
2140 struct gl_active_atomic_buffer
**AtomicBuffers
;
2142 /** Post-link transform feedback info. */
2143 struct gl_transform_feedback_info
*LinkedTransformFeedback
;
2146 * Number of types for subroutine uniforms.
2148 GLuint NumSubroutineUniformTypes
;
2151 * Subroutine uniform remap table
2152 * based on the program level uniform remap table.
2154 GLuint NumSubroutineUniforms
; /* non-sparse total */
2155 GLuint NumSubroutineUniformRemapTable
;
2156 struct gl_uniform_storage
**SubroutineUniformRemapTable
;
2159 * Num of subroutine functions for this stage and storage for them.
2161 GLuint NumSubroutineFunctions
;
2162 GLuint MaxSubroutineFunctionIndex
;
2163 struct gl_subroutine_function
*SubroutineFunctions
;
2166 * Map from image uniform index to image unit (set by glUniform1i())
2168 * An image uniform index is associated with each image uniform by
2169 * the linker. The image index associated with each uniform is
2170 * stored in the \c gl_uniform_storage::image field.
2172 GLubyte ImageUnits
[MAX_IMAGE_UNIFORMS
];
2175 * Access qualifier specified in the shader for each image uniform
2176 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY, \c
2177 * GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
2180 * It may be different, though only more strict than the value of
2181 * \c gl_image_unit::Access for the corresponding image unit.
2183 GLenum16 ImageAccess
[MAX_IMAGE_UNIFORMS
];
2185 GLuint NumUniformBlocks
;
2186 struct gl_uniform_block
**UniformBlocks
;
2187 struct gl_uniform_block
**ShaderStorageBlocks
;
2190 * Bitmask of shader storage blocks not declared as read-only.
2192 unsigned ShaderStorageBlocksWriteAccess
;
2194 /** Which texture target is being sampled
2195 * (TEXTURE_1D/2D/3D/etc_INDEX)
2197 GLubyte SamplerTargets
[MAX_SAMPLERS
];
2200 * Number of samplers declared with the bindless_sampler layout
2201 * qualifier as specified by ARB_bindless_texture.
2203 GLuint NumBindlessSamplers
;
2204 GLboolean HasBoundBindlessSampler
;
2205 struct gl_bindless_sampler
*BindlessSamplers
;
2208 * Number of images declared with the bindless_image layout qualifier
2209 * as specified by ARB_bindless_texture.
2211 GLuint NumBindlessImages
;
2212 GLboolean HasBoundBindlessImage
;
2213 struct gl_bindless_image
*BindlessImages
;
2218 * A bitmask of gl_advanced_blend_mode values
2220 GLbitfield BlendSupport
;
2225 /** ARB assembly-style program fields */
2227 struct prog_instruction
*Instructions
;
2230 * Local parameters used by the program.
2232 * It's dynamically allocated because it is rarely used (just
2233 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2234 * once it's allocated.
2236 GLfloat (*LocalParams
)[4];
2238 /** Bitmask of which register files are read/written with indirect
2239 * addressing. Mask of (1 << PROGRAM_x) bits.
2241 GLbitfield IndirectRegisterFiles
;
2243 /** Logical counts */
2245 GLuint NumInstructions
;
2246 GLuint NumTemporaries
;
2247 GLuint NumParameters
;
2248 GLuint NumAttributes
;
2249 GLuint NumAddressRegs
;
2250 GLuint NumAluInstructions
;
2251 GLuint NumTexInstructions
;
2252 GLuint NumTexIndirections
;
2254 /** Native, actual h/w counts */
2256 GLuint NumNativeInstructions
;
2257 GLuint NumNativeTemporaries
;
2258 GLuint NumNativeParameters
;
2259 GLuint NumNativeAttributes
;
2260 GLuint NumNativeAddressRegs
;
2261 GLuint NumNativeAluInstructions
;
2262 GLuint NumNativeTexInstructions
;
2263 GLuint NumNativeTexIndirections
;
2266 /** Used by ARB assembly-style programs. Can only be true for vertex
2269 GLboolean IsPositionInvariant
;
2276 * State common to vertex and fragment programs.
2278 struct gl_program_state
2280 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2281 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2286 * Context state for vertex programs.
2288 struct gl_vertex_program_state
2290 GLboolean Enabled
; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2291 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2292 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2293 /** Should fixed-function T&L be implemented with a vertex prog? */
2294 GLboolean _MaintainTnlProgram
;
2295 /** Whether the fixed-func program is being used right now. */
2296 GLboolean _UsesTnlProgram
;
2298 struct gl_program
*Current
; /**< User-bound vertex program */
2300 /** Currently enabled and valid vertex program (including internal
2301 * programs, user-defined vertex programs and GLSL vertex shaders).
2302 * This is the program we must use when rendering.
2304 struct gl_program
*_Current
;
2306 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2308 /** Program to emulate fixed-function T&L (see above) */
2309 struct gl_program
*_TnlProgram
;
2311 /** Cache of fixed-function programs */
2312 struct gl_program_cache
*Cache
;
2314 GLboolean _Overriden
;
2317 * If we have a vertex program, a TNL program or no program at all.
2318 * Note that this value should be kept up to date all the time,
2319 * nevertheless its correctness is asserted in _mesa_update_state.
2320 * The reason is to avoid calling _mesa_update_state twice we need
2321 * this value on draw *before* actually calling _mesa_update_state.
2322 * Also it should need to get recomputed only on changes to the
2323 * vertex program which are heavyweight already.
2325 gl_vertex_processing_mode _VPMode
;
2329 * Context state for tessellation control programs.
2331 struct gl_tess_ctrl_program_state
2333 /** Currently bound and valid shader. */
2334 struct gl_program
*_Current
;
2336 GLint patch_vertices
;
2337 GLfloat patch_default_outer_level
[4];
2338 GLfloat patch_default_inner_level
[2];
2342 * Context state for tessellation evaluation programs.
2344 struct gl_tess_eval_program_state
2346 /** Currently bound and valid shader. */
2347 struct gl_program
*_Current
;
2351 * Context state for geometry programs.
2353 struct gl_geometry_program_state
2356 * Currently enabled and valid program (including internal programs
2357 * and compiled shader programs).
2359 struct gl_program
*_Current
;
2363 * Context state for fragment programs.
2365 struct gl_fragment_program_state
2367 GLboolean Enabled
; /**< User-set fragment program enable flag */
2368 /** Should fixed-function texturing be implemented with a fragment prog? */
2369 GLboolean _MaintainTexEnvProgram
;
2370 /** Whether the fixed-func program is being used right now. */
2371 GLboolean _UsesTexEnvProgram
;
2373 struct gl_program
*Current
; /**< User-bound fragment program */
2376 * Currently enabled and valid fragment program (including internal
2377 * programs, user-defined fragment programs and GLSL fragment shaders).
2378 * This is the program we must use when rendering.
2380 struct gl_program
*_Current
;
2382 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2384 /** Program to emulate fixed-function texture env/combine (see above) */
2385 struct gl_program
*_TexEnvProgram
;
2387 /** Cache of fixed-function programs */
2388 struct gl_program_cache
*Cache
;
2393 * Context state for compute programs.
2395 struct gl_compute_program_state
2397 /** Currently enabled and valid program (including internal programs
2398 * and compiled shader programs).
2400 struct gl_program
*_Current
;
2405 * ATI_fragment_shader runtime state
2408 struct atifs_instruction
;
2409 struct atifs_setupinst
;
2412 * ATI fragment shader
2414 struct ati_fragment_shader
2418 struct atifs_instruction
*Instructions
[2];
2419 struct atifs_setupinst
*SetupInst
[2];
2420 GLfloat Constants
[8][4];
2421 GLbitfield LocalConstDef
; /**< Indicates which constants have been set */
2422 GLubyte numArithInstr
[2];
2423 GLubyte regsAssigned
[2];
2424 GLubyte NumPasses
; /**< 1 or 2 */
2426 * Current compile stage: 0 setup pass1, 1 arith pass1,
2427 * 2 setup pass2, 3 arith pass2.
2430 GLubyte last_optype
;
2431 GLboolean interpinp1
;
2434 * Array of 2 bit values for each tex unit to remember whether
2435 * STR or STQ swizzle was used
2438 struct gl_program
*Program
;
2442 * Context state for GL_ATI_fragment_shader
2444 struct gl_ati_fragment_shader_state
2447 GLboolean Compiling
;
2448 GLfloat GlobalConstants
[8][4];
2449 struct ati_fragment_shader
*Current
;
2453 * Shader subroutine function definition
2455 struct gl_subroutine_function
2459 int num_compat_types
;
2460 const struct glsl_type
**types
;
2464 * Shader information needed by both gl_shader and gl_linked shader.
2466 struct gl_shader_info
2469 * Tessellation Control shader state from layout qualifiers.
2473 * 0 - vertices not declared in shader, or
2474 * 1 .. GL_MAX_PATCH_VERTICES
2480 * Tessellation Evaluation shader state from layout qualifiers.
2484 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2487 GLenum16 PrimitiveMode
;
2489 enum gl_tess_spacing Spacing
;
2492 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2494 GLenum16 VertexOrder
;
2496 * 1, 0, or -1 if it's not set in this shader.
2502 * Geometry shader state from GLSL 1.50 layout qualifiers.
2507 * 0 - Invocations count not declared in shader, or
2508 * 1 .. Const.MaxGeometryShaderInvocations
2512 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2513 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2518 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2519 * it's not set in this shader.
2521 GLenum16 OutputType
;
2525 * Compute shader state from ARB_compute_shader and
2526 * ARB_compute_variable_group_size layout qualifiers.
2530 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2531 * it's not set in this shader.
2533 unsigned LocalSize
[3];
2536 * Whether a variable work group size has been specified as defined by
2537 * ARB_compute_variable_group_size.
2539 bool LocalSizeVariable
;
2542 * Arrangement of invocations used to calculate derivatives in a compute
2543 * shader. From NV_compute_shader_derivatives.
2545 enum gl_derivative_group DerivativeGroup
;
2550 * A linked GLSL shader object.
2552 struct gl_linked_shader
2554 gl_shader_stage Stage
;
2557 unsigned SourceChecksum
;
2560 struct gl_program
*Program
; /**< Post-compile assembly code */
2563 * \name Sampler tracking
2565 * \note Each of these fields is only set post-linking.
2568 GLbitfield shadow_samplers
; /**< Samplers used for shadow sampling. */
2572 * Number of default uniform block components used by this shader.
2574 * This field is only set post-linking.
2576 unsigned num_uniform_components
;
2579 * Number of combined uniform components used by this shader.
2581 * This field is only set post-linking. It is the sum of the uniform block
2582 * sizes divided by sizeof(float), and num_uniform_compoennts.
2584 unsigned num_combined_uniform_components
;
2586 struct exec_list
*ir
;
2587 struct exec_list
*packed_varyings
;
2588 struct exec_list
*fragdata_arrays
;
2589 struct glsl_symbol_table
*symbols
;
2592 * ARB_gl_spirv related data.
2594 * This is actually a reference to the gl_shader::spirv_data, which
2595 * stores information that is also needed during linking.
2597 struct gl_shader_spirv_data
*spirv_data
;
2602 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2603 * was skipped due to the shader matching one that's been seen before by
2604 * the on-disk cache.
2606 enum gl_compile_status
2608 COMPILE_FAILURE
= 0,
2614 * A GLSL shader object.
2618 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2619 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2620 * Must be the first field.
2623 gl_shader_stage Stage
;
2624 GLuint Name
; /**< AKA the handle */
2625 GLint RefCount
; /**< Reference count */
2626 GLchar
*Label
; /**< GL_KHR_debug */
2627 unsigned char sha1
[20]; /**< SHA1 hash of pre-processed source */
2628 GLboolean DeletePending
;
2629 bool IsES
; /**< True if this shader uses GLSL ES */
2631 enum gl_compile_status CompileStatus
;
2634 unsigned SourceChecksum
; /**< for debug/logging purposes */
2636 const GLchar
*Source
; /**< Source code string */
2638 const GLchar
*FallbackSource
; /**< Fallback string used by on-disk cache*/
2642 unsigned Version
; /**< GLSL version used for linking */
2645 * A bitmask of gl_advanced_blend_mode values
2647 GLbitfield BlendSupport
;
2649 struct exec_list
*ir
;
2650 struct glsl_symbol_table
*symbols
;
2653 * Whether early fragment tests are enabled as defined by
2654 * ARB_shader_image_load_store.
2656 bool EarlyFragmentTests
;
2658 bool ARB_fragment_coord_conventions_enable
;
2660 bool redeclares_gl_fragcoord
;
2661 bool uses_gl_fragcoord
;
2663 bool PostDepthCoverage
;
2664 bool PixelInterlockOrdered
;
2665 bool PixelInterlockUnordered
;
2666 bool SampleInterlockOrdered
;
2667 bool SampleInterlockUnordered
;
2671 * Fragment shader state from GLSL 1.50 layout qualifiers.
2673 bool origin_upper_left
;
2674 bool pixel_center_integer
;
2677 * Whether bindless_sampler/bindless_image, and respectively
2678 * bound_sampler/bound_image are declared at global scope as defined by
2679 * ARB_bindless_texture.
2681 bool bindless_sampler
;
2682 bool bindless_image
;
2687 * Whether layer output is viewport-relative.
2689 bool redeclares_gl_layer
;
2690 bool layer_viewport_relative
;
2692 /** Global xfb_stride out qualifier if any */
2693 GLuint TransformFeedbackBufferStride
[MAX_FEEDBACK_BUFFERS
];
2695 struct gl_shader_info info
;
2697 /* ARB_gl_spirv related data */
2698 struct gl_shader_spirv_data
*spirv_data
;
2702 struct gl_uniform_buffer_variable
2707 * Name of the uniform as seen by glGetUniformIndices.
2709 * glGetUniformIndices requires that the block instance index \b not be
2710 * present in the name of queried uniforms.
2713 * \c gl_uniform_buffer_variable::IndexName and
2714 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2718 const struct glsl_type
*Type
;
2719 unsigned int Offset
;
2724 struct gl_uniform_block
2726 /** Declared name of the uniform block */
2729 /** Array of supplemental information about UBO ir_variables. */
2730 struct gl_uniform_buffer_variable
*Uniforms
;
2734 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2735 * with glBindBufferBase to bind a buffer object to this uniform block.
2740 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2741 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2743 GLuint UniformBufferSize
;
2745 /** Stages that reference this block */
2749 * Linearized array index for uniform block instance arrays
2751 * Given a uniform block instance array declared with size
2752 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2753 * have the linearized array index
2756 * i_m + ∑ i_j * ∏ s_k
2759 * For a uniform block instance that is not an array, this is always 0.
2761 uint8_t linearized_array_index
;
2764 * Layout specified in the shader
2766 * This isn't accessible through the API, but it is used while
2767 * cross-validating uniform blocks.
2769 enum glsl_interface_packing _Packing
;
2770 GLboolean _RowMajor
;
2774 * Structure that represents a reference to an atomic buffer from some
2777 struct gl_active_atomic_buffer
2779 /** Uniform indices of the atomic counters declared within it. */
2783 /** Binding point index associated with it. */
2786 /** Minimum reasonable size it is expected to have. */
2789 /** Shader stages making use of it. */
2790 GLboolean StageReferences
[MESA_SHADER_STAGES
];
2794 * Data container for shader queries. This holds only the minimal
2795 * amount of required information for resource queries to work.
2797 struct gl_shader_variable
2800 * Declared type of the variable
2802 const struct glsl_type
*type
;
2805 * If the variable is in an interface block, this is the type of the block.
2807 const struct glsl_type
*interface_type
;
2810 * For variables inside structs (possibly recursively), this is the
2811 * outermost struct type.
2813 const struct glsl_type
*outermost_struct_type
;
2816 * Declared name of the variable
2821 * Storage location of the base of this variable
2823 * The precise meaning of this field depends on the nature of the variable.
2825 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2826 * - Vertex shader output: one of the values from \c gl_varying_slot.
2827 * - Geometry shader input: one of the values from \c gl_varying_slot.
2828 * - Geometry shader output: one of the values from \c gl_varying_slot.
2829 * - Fragment shader input: one of the values from \c gl_varying_slot.
2830 * - Fragment shader output: one of the values from \c gl_frag_result.
2831 * - Uniforms: Per-stage uniform slot number for default uniform block.
2832 * - Uniforms: Index within the uniform block definition for UBO members.
2833 * - Non-UBO Uniforms: explicit location until linking then reused to
2834 * store uniform slot number.
2835 * - Other: This field is not currently used.
2837 * If the variable is a uniform, shader input, or shader output, and the
2838 * slot has not been assigned, the value will be -1.
2843 * Specifies the first component the variable is stored in as per
2844 * ARB_enhanced_layouts.
2846 unsigned component
:2;
2849 * Output index for dual source blending.
2852 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2858 * Specifies whether a shader input/output is per-patch in tessellation
2864 * Storage class of the variable.
2866 * \sa (n)ir_variable_mode
2871 * Interpolation mode for shader inputs / outputs
2873 * \sa glsl_interp_mode
2875 unsigned interpolation
:2;
2878 * Was the location explicitly set in the shader?
2880 * If the location is explicitly set in the shader, it \b cannot be changed
2881 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2884 unsigned explicit_location
:1;
2887 * Precision qualifier.
2889 unsigned precision
:2;
2893 * Active resource in a gl_shader_program
2895 struct gl_program_resource
2897 GLenum16 Type
; /** Program interface type. */
2898 const void *Data
; /** Pointer to resource associated data structure. */
2899 uint8_t StageReferences
; /** Bitmask of shader stage references. */
2903 * Link status enum. LINKING_SKIPPED is used to indicate linking
2904 * was skipped due to the shader being loaded from the on-disk cache.
2908 LINKING_FAILURE
= 0,
2914 * A data structure to be shared by gl_shader_program and gl_program.
2916 struct gl_shader_program_data
2918 GLint RefCount
; /**< Reference count */
2920 /** SHA1 hash of linked shader program */
2921 unsigned char sha1
[20];
2923 unsigned NumUniformStorage
;
2924 unsigned NumHiddenUniforms
;
2925 struct gl_uniform_storage
*UniformStorage
;
2927 unsigned NumUniformBlocks
;
2928 unsigned NumShaderStorageBlocks
;
2930 struct gl_uniform_block
*UniformBlocks
;
2931 struct gl_uniform_block
*ShaderStorageBlocks
;
2933 struct gl_active_atomic_buffer
*AtomicBuffers
;
2934 unsigned NumAtomicBuffers
;
2936 /* Shader cache variables used during restore */
2937 unsigned NumUniformDataSlots
;
2938 union gl_constant_value
*UniformDataSlots
;
2940 /* Used to hold initial uniform values for program binary restores.
2942 * From the ARB_get_program_binary spec:
2944 * "A successful call to ProgramBinary will reset all uniform
2945 * variables to their initial values. The initial value is either
2946 * the value of the variable's initializer as specified in the
2947 * original shader source, or 0 if no initializer was present.
2949 union gl_constant_value
*UniformDataDefaults
;
2951 /** Hash for quick search by name. */
2952 struct hash_table_u64
*ProgramResourceHash
;
2954 GLboolean Validated
;
2956 /** List of all active resources after linking. */
2957 struct gl_program_resource
*ProgramResourceList
;
2958 unsigned NumProgramResourceList
;
2960 enum gl_link_status LinkStatus
; /**< GL_LINK_STATUS */
2963 unsigned Version
; /**< GLSL version used for linking */
2965 /* Mask of stages this program was linked against */
2966 unsigned linked_stages
;
2968 /* Whether the shaders of this program are loaded from SPIR-V binaries
2969 * (all have the SPIR_V_BINARY_ARB state). This was introduced by the
2970 * ARB_gl_spirv extension.
2976 * A GLSL program object.
2977 * Basically a linked collection of vertex and fragment shaders.
2979 struct gl_shader_program
2981 GLenum16 Type
; /**< Always GL_SHADER_PROGRAM (internal token) */
2982 GLuint Name
; /**< aka handle or ID */
2983 GLchar
*Label
; /**< GL_KHR_debug */
2984 GLint RefCount
; /**< Reference count */
2985 GLboolean DeletePending
;
2988 * Is the application intending to glGetProgramBinary this program?
2990 * BinaryRetrievableHint is the currently active hint that gets set
2991 * during initialization and after linking and BinaryRetrievableHintPending
2992 * is the hint set by the user to be active when program is linked next time.
2994 GLboolean BinaryRetrievableHint
;
2995 GLboolean BinaryRetrievableHintPending
;
2998 * Indicates whether program can be bound for individual pipeline stages
2999 * using UseProgramStages after it is next linked.
3001 GLboolean SeparateShader
;
3003 GLuint NumShaders
; /**< number of attached shaders */
3004 struct gl_shader
**Shaders
; /**< List of attached the shaders */
3007 * User-defined attribute bindings
3009 * These are set via \c glBindAttribLocation and are used to direct the
3010 * GLSL linker. These are \b not the values used in the compiled shader,
3011 * and they are \b not the values returned by \c glGetAttribLocation.
3013 struct string_to_uint_map
*AttributeBindings
;
3016 * User-defined fragment data bindings
3018 * These are set via \c glBindFragDataLocation and are used to direct the
3019 * GLSL linker. These are \b not the values used in the compiled shader,
3020 * and they are \b not the values returned by \c glGetFragDataLocation.
3022 struct string_to_uint_map
*FragDataBindings
;
3023 struct string_to_uint_map
*FragDataIndexBindings
;
3026 * Transform feedback varyings last specified by
3027 * glTransformFeedbackVaryings().
3029 * For the current set of transform feedback varyings used for transform
3030 * feedback output, see LinkedTransformFeedback.
3033 GLenum16 BufferMode
;
3034 /** Global xfb_stride out qualifier if any */
3035 GLuint BufferStride
[MAX_FEEDBACK_BUFFERS
];
3037 GLchar
**VaryingNames
; /**< Array [NumVarying] of char * */
3038 } TransformFeedback
;
3040 struct gl_program
*last_vert_prog
;
3042 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3043 enum gl_frag_depth_layout FragDepthLayout
;
3046 * Geometry shader state - copied into gl_program by
3047 * _mesa_copy_linked_program_data().
3052 bool UsesEndPrimitive
;
3053 unsigned ActiveStreamMask
;
3057 * Compute shader state - copied into gl_program by
3058 * _mesa_copy_linked_program_data().
3062 * Size of shared variables accessed by the compute shader.
3064 unsigned SharedSize
;
3067 /** Data shared by gl_program and gl_shader_program */
3068 struct gl_shader_program_data
*data
;
3071 * Mapping from GL uniform locations returned by \c glUniformLocation to
3072 * UniformStorage entries. Arrays will have multiple contiguous slots
3073 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3075 unsigned NumUniformRemapTable
;
3076 struct gl_uniform_storage
**UniformRemapTable
;
3079 * Sometimes there are empty slots left over in UniformRemapTable after we
3080 * allocate slots to explicit locations. This list stores the blocks of
3081 * continuous empty slots inside UniformRemapTable.
3083 struct exec_list EmptyUniformLocations
;
3086 * Total number of explicit uniform location including inactive uniforms.
3088 unsigned NumExplicitUniformLocations
;
3091 * Map of active uniform names to locations
3093 * Maps any active uniform that is not an array element to a location.
3094 * Each active uniform, including individual structure members will appear
3095 * in this map. This roughly corresponds to the set of names that would be
3096 * enumerated by \c glGetActiveUniform.
3098 struct string_to_uint_map
*UniformHash
;
3100 GLboolean SamplersValidated
; /**< Samplers validated against texture units? */
3102 bool IsES
; /**< True if this program uses GLSL ES */
3105 * Per-stage shaders resulting from the first stage of linking.
3107 * Set of linked shaders for this program. The array is accessed using the
3108 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3111 struct gl_linked_shader
*_LinkedShaders
[MESA_SHADER_STAGES
];
3114 * True if any of the fragment shaders attached to this program use:
3115 * #extension ARB_fragment_coord_conventions: enable
3117 GLboolean ARB_fragment_coord_conventions_enable
;
3121 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3122 #define GLSL_LOG 0x2 /**< Write shaders to files */
3123 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3124 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3125 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3126 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3127 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3128 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3129 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3130 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3134 * Context state for GLSL vertex/fragment shaders.
3135 * Extended to support pipeline object
3137 struct gl_pipeline_object
3139 /** Name of the pipeline object as received from glGenProgramPipelines.
3140 * It would be 0 for shaders without separate shader objects.
3146 GLchar
*Label
; /**< GL_KHR_debug */
3149 * Programs used for rendering
3151 * There is a separate program set for each shader stage.
3153 struct gl_program
*CurrentProgram
[MESA_SHADER_STAGES
];
3155 struct gl_shader_program
*ReferencedPrograms
[MESA_SHADER_STAGES
];
3158 * Program used by glUniform calls.
3160 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3162 struct gl_shader_program
*ActiveProgram
;
3164 GLbitfield Flags
; /**< Mask of GLSL_x flags */
3165 GLboolean EverBound
; /**< Has the pipeline object been created */
3166 GLboolean Validated
; /**< Pipeline Validation status */
3172 * Context state for GLSL pipeline shaders.
3174 struct gl_pipeline_shader_state
3176 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3177 struct gl_pipeline_object
*Current
;
3179 /** Default Object to ensure that _Shader is never NULL */
3180 struct gl_pipeline_object
*Default
;
3182 /** Pipeline objects */
3183 struct _mesa_HashTable
*Objects
;
3187 * Compiler options for a single GLSL shaders type
3189 struct gl_shader_compiler_options
3191 /** Driver-selectable options: */
3192 GLboolean EmitNoLoops
;
3193 GLboolean EmitNoCont
; /**< Emit CONT opcode? */
3194 GLboolean EmitNoMainReturn
; /**< Emit CONT/RET opcodes? */
3195 GLboolean EmitNoPow
; /**< Emit POW opcodes? */
3196 GLboolean EmitNoSat
; /**< Emit SAT opcodes? */
3197 GLboolean LowerCombinedClipCullDistance
; /** Lower gl_ClipDistance and
3198 * gl_CullDistance together from
3199 * float[8] to vec4[2]
3201 GLbitfield LowerBuiltinVariablesXfb
; /**< Which builtin variables should
3202 * be lowered for transform feedback
3206 * If we can lower the precision of variables based on precision
3209 GLboolean LowerPrecisionFloat16
;
3210 GLboolean LowerPrecisionInt16
;
3211 GLboolean LowerPrecisionDerivatives
;
3214 * This enables lowering of 16b constants. Some drivers may not
3215 * to lower constants to 16b (ie. if the hw can do automatic
3216 * narrowing on constant load)
3218 GLboolean LowerPrecisionConstants
;
3221 * \name Forms of indirect addressing the driver cannot do.
3224 GLboolean EmitNoIndirectInput
; /**< No indirect addressing of inputs */
3225 GLboolean EmitNoIndirectOutput
; /**< No indirect addressing of outputs */
3226 GLboolean EmitNoIndirectTemp
; /**< No indirect addressing of temps */
3227 GLboolean EmitNoIndirectUniform
; /**< No indirect addressing of constants */
3228 GLboolean EmitNoIndirectSampler
; /**< No indirect addressing of samplers */
3231 GLuint MaxIfDepth
; /**< Maximum nested IF blocks */
3232 GLuint MaxUnrollIterations
;
3235 * Optimize code for array of structures backends.
3237 * This is a proxy for:
3238 * - preferring DP4 instructions (rather than MUL/MAD) for
3239 * matrix * vector operations, such as position transformation.
3241 GLboolean OptimizeForAOS
;
3243 /** Lower UBO and SSBO access to intrinsics. */
3244 GLboolean LowerBufferInterfaceBlocks
;
3246 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3247 GLboolean ClampBlockIndicesToArrayBounds
;
3249 /** (driconf) Force gl_Position to be considered invariant */
3250 GLboolean PositionAlwaysInvariant
;
3252 const struct nir_shader_compiler_options
*NirOptions
;
3257 * Occlusion/timer query object.
3259 struct gl_query_object
3261 GLenum16 Target
; /**< The query target, when active */
3262 GLuint Id
; /**< hash table ID/name */
3263 GLchar
*Label
; /**< GL_KHR_debug */
3264 GLuint64EXT Result
; /**< the counter */
3265 GLboolean Active
; /**< inside Begin/EndQuery */
3266 GLboolean Ready
; /**< result is ready? */
3267 GLboolean EverBound
;/**< has query object ever been bound */
3268 GLuint Stream
; /**< The stream */
3273 * Context state for query objects.
3275 struct gl_query_state
3277 struct _mesa_HashTable
*QueryObjects
;
3278 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
3279 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
3281 /** GL_NV_conditional_render */
3282 struct gl_query_object
*CondRenderQuery
;
3284 /** GL_EXT_transform_feedback */
3285 struct gl_query_object
*PrimitivesGenerated
[MAX_VERTEX_STREAMS
];
3286 struct gl_query_object
*PrimitivesWritten
[MAX_VERTEX_STREAMS
];
3288 /** GL_ARB_transform_feedback_overflow_query */
3289 struct gl_query_object
*TransformFeedbackOverflow
[MAX_VERTEX_STREAMS
];
3290 struct gl_query_object
*TransformFeedbackOverflowAny
;
3292 /** GL_ARB_timer_query */
3293 struct gl_query_object
*TimeElapsed
;
3295 /** GL_ARB_pipeline_statistics_query */
3296 struct gl_query_object
*pipeline_stats
[MAX_PIPELINE_STATISTICS
];
3298 GLenum16 CondRenderMode
;
3302 /** Sync object state */
3303 struct gl_sync_object
3305 GLuint Name
; /**< Fence name */
3306 GLint RefCount
; /**< Reference count */
3307 GLchar
*Label
; /**< GL_KHR_debug */
3308 GLboolean DeletePending
; /**< Object was deleted while there were still
3309 * live references (e.g., sync not yet finished)
3311 GLenum16 SyncCondition
;
3312 GLbitfield Flags
; /**< Flags passed to glFenceSync */
3313 GLuint StatusFlag
:1; /**< Has the sync object been signaled? */
3318 * State which can be shared by multiple contexts:
3320 struct gl_shared_state
3322 simple_mtx_t Mutex
; /**< for thread safety */
3323 GLint RefCount
; /**< Reference count */
3324 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
3325 struct _mesa_HashTable
*BitmapAtlas
; /**< For optimized glBitmap text */
3326 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
3328 /** Default texture objects (shared by all texture units) */
3329 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
3331 /** Fallback texture used when a bound texture is incomplete */
3332 struct gl_texture_object
*FallbackTex
[NUM_TEXTURE_TARGETS
];
3335 * \name Thread safety and statechange notification for texture
3338 * \todo Improve the granularity of locking.
3341 mtx_t TexMutex
; /**< texobj thread safety */
3342 GLuint TextureStateStamp
; /**< state notification for shared tex */
3346 * \name Vertex/geometry/fragment programs
3349 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
3350 struct gl_program
*DefaultVertexProgram
;
3351 struct gl_program
*DefaultFragmentProgram
;
3354 /* GL_ATI_fragment_shader */
3355 struct _mesa_HashTable
*ATIShaders
;
3356 struct ati_fragment_shader
*DefaultFragmentShader
;
3358 struct _mesa_HashTable
*BufferObjects
;
3360 /** Table of both gl_shader and gl_shader_program objects */
3361 struct _mesa_HashTable
*ShaderObjects
;
3363 /* GL_EXT_framebuffer_object */
3364 struct _mesa_HashTable
*RenderBuffers
;
3365 struct _mesa_HashTable
*FrameBuffers
;
3368 struct set
*SyncObjects
;
3370 /** GL_ARB_sampler_objects */
3371 struct _mesa_HashTable
*SamplerObjects
;
3373 /* GL_ARB_bindless_texture */
3374 struct hash_table_u64
*TextureHandles
;
3375 struct hash_table_u64
*ImageHandles
;
3376 mtx_t HandlesMutex
; /**< For texture/image handles safety */
3378 /* GL_ARB_shading_language_include */
3379 struct shader_includes
*ShaderIncludes
;
3380 /* glCompileShaderInclude expects ShaderIncludes not to change while it is
3383 mtx_t ShaderIncludeMutex
;
3386 * Some context in this share group was affected by a GPU reset
3388 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3389 * been affected by a GPU reset must also return
3390 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3392 * Once this field becomes true, it is never reset to false.
3394 bool ShareGroupReset
;
3396 /** EXT_external_objects */
3397 struct _mesa_HashTable
*MemoryObjects
;
3399 /** EXT_semaphore */
3400 struct _mesa_HashTable
*SemaphoreObjects
;
3403 * Some context in this share group was affected by a disjoint
3404 * operation. This operation can be anything that has effects on
3405 * values of timer queries in such manner that they become invalid for
3406 * performance metrics. As example gpu reset, counter overflow or gpu
3407 * frequency changes.
3409 bool DisjointOperation
;
3415 * Renderbuffers represent drawing surfaces such as color, depth and/or
3416 * stencil. A framebuffer object has a set of renderbuffers.
3417 * Drivers will typically derive subclasses of this type.
3419 struct gl_renderbuffer
3421 simple_mtx_t Mutex
; /**< for thread safety */
3422 GLuint ClassID
; /**< Useful for drivers */
3424 GLchar
*Label
; /**< GL_KHR_debug */
3426 GLuint Width
, Height
;
3428 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
3429 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
3431 * True for renderbuffers that wrap textures, giving the driver a chance to
3432 * flush render caches through the FinishRenderTexture hook.
3434 * Drivers may also set this on renderbuffers other than those generated by
3435 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3436 * called without a rb->TexImage.
3438 GLboolean NeedsFinishRenderTexture
;
3439 GLubyte NumSamples
; /**< zero means not multisampled */
3440 GLubyte NumStorageSamples
; /**< for AMD_framebuffer_multisample_advanced */
3441 GLenum16 InternalFormat
; /**< The user-specified format */
3442 GLenum16 _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3443 GL_STENCIL_INDEX. */
3444 mesa_format Format
; /**< The actual renderbuffer memory format */
3446 * Pointer to the texture image if this renderbuffer wraps a texture,
3449 * Note that the reference on the gl_texture_object containing this
3450 * TexImage is held by the gl_renderbuffer_attachment.
3452 struct gl_texture_image
*TexImage
;
3454 /** Delete this renderbuffer */
3455 void (*Delete
)(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
);
3457 /** Allocate new storage for this renderbuffer */
3458 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
3459 struct gl_renderbuffer
*rb
,
3460 GLenum internalFormat
,
3461 GLuint width
, GLuint height
);
3466 * A renderbuffer attachment points to either a texture object (and specifies
3467 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3469 struct gl_renderbuffer_attachment
3471 GLenum16 Type
; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3475 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3476 * application supplied renderbuffer object.
3478 struct gl_renderbuffer
*Renderbuffer
;
3481 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3482 * supplied texture object.
3484 struct gl_texture_object
*Texture
;
3485 GLuint TextureLevel
; /**< Attached mipmap level. */
3486 GLsizei NumSamples
; /**< from FramebufferTexture2DMultisampleEXT */
3487 GLuint CubeMapFace
; /**< 0 .. 5, for cube map textures. */
3488 GLuint Zoffset
; /**< Slice for 3D textures, or layer for both 1D
3489 * and 2D array textures */
3495 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3496 * In C++ terms, think of this as a base class from which device drivers
3497 * will make derived classes.
3499 struct gl_framebuffer
3501 simple_mtx_t Mutex
; /**< for thread safety */
3503 * If zero, this is a window system framebuffer. If non-zero, this
3504 * is a FBO framebuffer; note that for some devices (i.e. those with
3505 * a natural pixel coordinate system for FBOs that differs from the
3506 * OpenGL/Mesa coordinate system), this means that the viewport,
3507 * polygon face orientation, and polygon stipple will have to be inverted.
3512 GLchar
*Label
; /**< GL_KHR_debug */
3514 GLboolean DeletePending
;
3517 * The framebuffer's visual. Immutable if this is a window system buffer.
3518 * Computed from attachments if user-made FBO.
3520 struct gl_config Visual
;
3523 * Size of frame buffer in pixels. If there are no attachments, then both
3526 GLuint Width
, Height
;
3529 * In the case that the framebuffer has no attachment (i.e.
3530 * GL_ARB_framebuffer_no_attachments) then the geometry of
3531 * the framebuffer is specified by the default values.
3534 GLuint Width
, Height
, Layers
, NumSamples
;
3535 GLboolean FixedSampleLocations
;
3536 /* Derived from NumSamples by the driver so that it can choose a valid
3537 * value for the hardware.
3542 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3543 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3544 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3551 /** \name Derived Z buffer stuff */
3553 GLuint _DepthMax
; /**< Max depth buffer value */
3554 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
3555 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
3558 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3561 /** Whether one of Attachment has Type != GL_NONE
3562 * NOTE: the values for Width and Height are set to 0 in case of having
3563 * no attachments, a backend driver supporting the extension
3564 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3565 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3566 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3567 * _Ymax do NOT take into account _HasAttachments being false). To get the
3568 * geometry of the framebuffer, the helper functions
3569 * _mesa_geometric_width(),
3570 * _mesa_geometric_height(),
3571 * _mesa_geometric_samples() and
3572 * _mesa_geometric_layers()
3573 * are available that check _HasAttachments.
3575 bool _HasAttachments
;
3577 GLbitfield _IntegerBuffers
; /**< Which color buffers are integer valued */
3578 GLbitfield _RGBBuffers
; /**< Which color buffers have baseformat == RGB */
3579 GLbitfield _FP32Buffers
; /**< Which color buffers are FP32 */
3581 /* ARB_color_buffer_float */
3582 GLboolean _AllColorBuffersFixedPoint
; /* no integer, no float */
3583 GLboolean _HasSNormOrFloatColorBuffer
;
3586 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3587 * is not layered. For cube maps and cube map arrays, each cube face
3588 * counts as a layer. As the case for Width, Height a backend driver
3589 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3590 * in the case that _HasAttachments is false
3592 GLuint MaxNumLayers
;
3594 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3595 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
3597 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3598 * attribute group and GL_PIXEL attribute group, respectively.
3600 GLenum16 ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
3601 GLenum16 ColorReadBuffer
;
3603 /* GL_ARB_sample_locations */
3604 GLfloat
*SampleLocationTable
; /**< If NULL, no table has been specified */
3605 GLboolean ProgrammableSampleLocations
;
3606 GLboolean SampleLocationPixelGrid
;
3608 /** Computed from ColorDraw/ReadBuffer above */
3609 GLuint _NumColorDrawBuffers
;
3610 gl_buffer_index _ColorDrawBufferIndexes
[MAX_DRAW_BUFFERS
];
3611 gl_buffer_index _ColorReadBufferIndex
;
3612 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
];
3613 struct gl_renderbuffer
*_ColorReadBuffer
;
3615 /* GL_MESA_framebuffer_flip_y */
3618 /** Delete this framebuffer */
3619 void (*Delete
)(struct gl_framebuffer
*fb
);
3624 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3628 GLushort RangeMin
; /**< min value exponent */
3629 GLushort RangeMax
; /**< max value exponent */
3630 GLushort Precision
; /**< number of mantissa bits */
3635 * Limits for vertex, geometry and fragment programs/shaders.
3637 struct gl_program_constants
3639 /* logical limits */
3640 GLuint MaxInstructions
;
3641 GLuint MaxAluInstructions
;
3642 GLuint MaxTexInstructions
;
3643 GLuint MaxTexIndirections
;
3646 GLuint MaxAddressRegs
;
3647 GLuint MaxAddressOffset
; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3648 GLuint MaxParameters
;
3649 GLuint MaxLocalParams
;
3650 GLuint MaxEnvParams
;
3651 /* native/hardware limits */
3652 GLuint MaxNativeInstructions
;
3653 GLuint MaxNativeAluInstructions
;
3654 GLuint MaxNativeTexInstructions
;
3655 GLuint MaxNativeTexIndirections
;
3656 GLuint MaxNativeAttribs
;
3657 GLuint MaxNativeTemps
;
3658 GLuint MaxNativeAddressRegs
;
3659 GLuint MaxNativeParameters
;
3661 GLuint MaxUniformComponents
; /**< Usually == MaxParameters * 4 */
3664 * \name Per-stage input / output limits
3666 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3667 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3668 * ES). This is stored as \c gl_constants::MaxVarying.
3670 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3671 * variables. Each stage as a certain number of outputs that it can feed
3672 * to the next stage and a certain number inputs that it can consume from
3673 * the previous stage.
3675 * Vertex shader inputs do not participate this in this accounting.
3676 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3678 * Fragment shader outputs do not participate this in this accounting.
3679 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3682 GLuint MaxInputComponents
;
3683 GLuint MaxOutputComponents
;
3686 /* ES 2.0 and GL_ARB_ES2_compatibility */
3687 struct gl_precision LowFloat
, MediumFloat
, HighFloat
;
3688 struct gl_precision LowInt
, MediumInt
, HighInt
;
3689 /* GL_ARB_uniform_buffer_object */
3690 GLuint MaxUniformBlocks
;
3691 uint64_t MaxCombinedUniformComponents
;
3692 GLuint MaxTextureImageUnits
;
3694 /* GL_ARB_shader_atomic_counters */
3695 GLuint MaxAtomicBuffers
;
3696 GLuint MaxAtomicCounters
;
3698 /* GL_ARB_shader_image_load_store */
3699 GLuint MaxImageUniforms
;
3701 /* GL_ARB_shader_storage_buffer_object */
3702 GLuint MaxShaderStorageBlocks
;
3706 * Constants which may be overridden by device driver during context creation
3707 * but are never changed after that.
3711 GLuint MaxTextureMbytes
; /**< Max memory per image, in MB */
3712 GLuint MaxTextureSize
; /**< Max 1D/2D texture size, in pixels*/
3713 GLuint Max3DTextureLevels
; /**< Max mipmap levels for 3D textures */
3714 GLuint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
3715 GLuint MaxArrayTextureLayers
; /**< Max layers in array textures */
3716 GLuint MaxTextureRectSize
; /**< Max rectangle texture size, in pixes */
3717 GLuint MaxTextureCoordUnits
;
3718 GLuint MaxCombinedTextureImageUnits
;
3719 GLuint MaxTextureUnits
; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3720 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
3721 GLfloat MaxTextureLodBias
; /**< GL_EXT_texture_lod_bias */
3722 GLuint MaxTextureBufferSize
; /**< GL_ARB_texture_buffer_object */
3724 GLuint TextureBufferOffsetAlignment
; /**< GL_ARB_texture_buffer_range */
3726 GLuint MaxArrayLockSize
;
3730 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
3731 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
3732 GLfloat PointSizeGranularity
;
3733 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
3734 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
3735 GLfloat LineWidthGranularity
;
3737 GLuint MaxClipPlanes
;
3739 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
3740 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
3742 GLuint MaxViewportWidth
, MaxViewportHeight
;
3743 GLuint MaxViewports
; /**< GL_ARB_viewport_array */
3744 GLuint ViewportSubpixelBits
; /**< GL_ARB_viewport_array */
3748 } ViewportBounds
; /**< GL_ARB_viewport_array */
3749 GLuint MaxWindowRectangles
; /**< GL_EXT_window_rectangles */
3751 struct gl_program_constants Program
[MESA_SHADER_STAGES
];
3752 GLuint MaxProgramMatrices
;
3753 GLuint MaxProgramMatrixStackDepth
;
3756 GLuint SamplesPassed
;
3759 GLuint PrimitivesGenerated
;
3760 GLuint PrimitivesWritten
;
3761 GLuint VerticesSubmitted
;
3762 GLuint PrimitivesSubmitted
;
3763 GLuint VsInvocations
;
3765 GLuint TessInvocations
;
3766 GLuint GsInvocations
;
3767 GLuint GsPrimitives
;
3768 GLuint FsInvocations
;
3769 GLuint ComputeInvocations
;
3770 GLuint ClInPrimitives
;
3771 GLuint ClOutPrimitives
;
3774 GLuint MaxDrawBuffers
; /**< GL_ARB_draw_buffers */
3776 GLuint MaxColorAttachments
; /**< GL_EXT_framebuffer_object */
3777 GLuint MaxRenderbufferSize
; /**< GL_EXT_framebuffer_object */
3778 GLuint MaxSamples
; /**< GL_ARB_framebuffer_object */
3781 * GL_ARB_framebuffer_no_attachments
3783 GLuint MaxFramebufferWidth
;
3784 GLuint MaxFramebufferHeight
;
3785 GLuint MaxFramebufferLayers
;
3786 GLuint MaxFramebufferSamples
;
3788 /** Number of varying vectors between any two shader stages. */
3792 * GL_ARB_uniform_buffer_object
3794 GLuint MaxCombinedUniformBlocks
;
3795 GLuint MaxUniformBufferBindings
;
3796 GLuint MaxUniformBlockSize
;
3797 GLuint UniformBufferOffsetAlignment
;
3801 * GL_ARB_shader_storage_buffer_object
3803 GLuint MaxCombinedShaderStorageBlocks
;
3804 GLuint MaxShaderStorageBufferBindings
;
3805 GLuint MaxShaderStorageBlockSize
;
3806 GLuint ShaderStorageBufferOffsetAlignment
;
3810 * GL_ARB_explicit_uniform_location
3812 GLuint MaxUserAssignableUniformLocations
;
3814 /** geometry shader */
3815 GLuint MaxGeometryOutputVertices
;
3816 GLuint MaxGeometryTotalOutputComponents
;
3817 GLuint MaxGeometryShaderInvocations
;
3819 GLuint GLSLVersion
; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3820 GLuint GLSLVersionCompat
; /**< Desktop compat GLSL version supported */
3823 * Changes default GLSL extension behavior from "error" to "warn". It's out
3824 * of spec, but it can make some apps work that otherwise wouldn't.
3826 GLboolean ForceGLSLExtensionsWarn
;
3829 * If non-zero, forces GLSL shaders to behave as if they began
3830 * with "#version ForceGLSLVersion".
3832 GLuint ForceGLSLVersion
;
3835 * Allow GLSL #extension directives in the middle of shaders.
3837 GLboolean AllowGLSLExtensionDirectiveMidShader
;
3840 * Allow a subset of GLSL 1.20 in GLSL 1.10 as needed by SPECviewperf13.
3842 GLboolean AllowGLSL120SubsetIn110
;
3845 * Allow builtins as part of constant expressions. This was not allowed
3846 * until GLSL 1.20 this allows it everywhere.
3848 GLboolean AllowGLSLBuiltinConstantExpression
;
3851 * Allow some relaxation of GLSL ES shader restrictions. This encompasses
3852 * a number of relaxations to the ES shader rules.
3854 GLboolean AllowGLSLRelaxedES
;
3857 * Allow GLSL built-in variables to be redeclared verbatim
3859 GLboolean AllowGLSLBuiltinVariableRedeclaration
;
3862 * Allow GLSL interpolation qualifier mismatch across shader stages.
3864 GLboolean AllowGLSLCrossStageInterpolationMismatch
;
3867 * Allow creating a higher compat profile (version 3.1+) for apps that
3868 * request it. Be careful when adding that driconf option because some
3869 * features are unimplemented and might not work correctly.
3871 GLboolean AllowHigherCompatVersion
;
3874 * Allow layout qualifiers on function parameters.
3876 GLboolean AllowLayoutQualifiersOnFunctionParameters
;
3879 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3880 * D3D9 when apps rely on this behaviour.
3882 GLboolean ForceGLSLAbsSqrt
;
3885 * Types of variable to default initialized to zero. Supported values are:
3886 * - 0: no zero initialization
3887 * - 1: all shader variables and gl_FragColor are initialiazed to 0
3888 * - 2: same as 1, but shader out variables are *not* initialized, while
3889 * function out variables are now initialized.
3891 GLchar GLSLZeroInit
;
3894 * Treat integer textures using GL_LINEAR filters as GL_NEAREST.
3896 GLboolean ForceIntegerTexNearest
;
3899 * Does the driver support real 32-bit integers? (Otherwise, integers are
3900 * simulated via floats.)
3902 GLboolean NativeIntegers
;
3905 * Does VertexID count from zero or from base vertex?
3908 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3909 * ignored and need not be set.
3911 bool VertexID_is_zero_based
;
3914 * If the driver supports real 32-bit integers, what integer value should be
3915 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3917 GLuint UniformBooleanTrue
;
3920 * Maximum amount of time, measured in nanseconds, that the server can wait.
3922 GLuint64 MaxServerWaitTimeout
;
3924 /** GL_EXT_provoking_vertex */
3925 GLboolean QuadsFollowProvokingVertexConvention
;
3927 /** GL_ARB_viewport_array */
3928 GLenum16 LayerAndVPIndexProvokingVertex
;
3930 /** OpenGL version 3.0 */
3931 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3933 /** OpenGL version 3.2 */
3934 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
3936 /** OpenGL version 4.4 */
3937 GLuint MaxVertexAttribStride
;
3939 /** GL_EXT_transform_feedback */
3940 GLuint MaxTransformFeedbackBuffers
;
3941 GLuint MaxTransformFeedbackSeparateComponents
;
3942 GLuint MaxTransformFeedbackInterleavedComponents
;
3943 GLuint MaxVertexStreams
;
3945 /** GL_EXT_gpu_shader4 */
3946 GLint MinProgramTexelOffset
, MaxProgramTexelOffset
;
3948 /** GL_ARB_texture_gather */
3949 GLuint MinProgramTextureGatherOffset
;
3950 GLuint MaxProgramTextureGatherOffset
;
3951 GLuint MaxProgramTextureGatherComponents
;
3953 /* GL_ARB_robustness */
3954 GLenum16 ResetStrategy
;
3956 /* GL_KHR_robustness */
3957 GLboolean RobustAccess
;
3959 /* GL_ARB_blend_func_extended */
3960 GLuint MaxDualSourceDrawBuffers
;
3963 * Whether the implementation strips out and ignores texture borders.
3965 * Many GPU hardware implementations don't support rendering with texture
3966 * borders and mipmapped textures. (Note: not static border color, but the
3967 * old 1-pixel border around each edge). Implementations then have to do
3968 * slow fallbacks to be correct, or just ignore the border and be fast but
3969 * wrong. Setting the flag strips the border off of TexImage calls,
3970 * providing "fast but wrong" at significantly reduced driver complexity.
3972 * Texture borders are deprecated in GL 3.0.
3974 GLboolean StripTextureBorder
;
3977 * For drivers which can do a better job at eliminating unused uniforms
3978 * than the GLSL compiler.
3980 * XXX Remove these as soon as a better solution is available.
3982 GLboolean GLSLSkipStrictMaxUniformLimitCheck
;
3985 * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
3986 * are system values.
3988 bool GLSLFragCoordIsSysVal
;
3989 bool GLSLPointCoordIsSysVal
;
3990 bool GLSLFrontFacingIsSysVal
;
3993 * Run the minimum amount of GLSL optimizations to be able to link
3994 * shaders optimally (eliminate dead varyings and uniforms) and just do
3995 * all the necessary lowering.
3997 bool GLSLOptimizeConservatively
;
4000 * Whether to call lower_const_arrays_to_uniforms() during linking.
4002 bool GLSLLowerConstArrays
;
4005 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
4006 * (otherwise, they're system values).
4008 bool GLSLTessLevelsAsInputs
;
4011 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
4012 * than passing the transform feedback object to the drawing function.
4014 GLboolean AlwaysUseGetTransformFeedbackVertexCount
;
4016 /** GL_ARB_map_buffer_alignment */
4017 GLuint MinMapBufferAlignment
;
4020 * Disable varying packing. This is out of spec, but potentially useful
4021 * for older platforms that supports a limited number of texture
4022 * indirections--on these platforms, unpacking the varyings in the fragment
4023 * shader increases the number of texture indirections by 1, which might
4024 * make some shaders not executable at all.
4026 * Drivers that support transform feedback must set this value to GL_FALSE.
4028 GLboolean DisableVaryingPacking
;
4031 * Disable varying packing if used for transform feedback. This is needed
4032 * for some drivers (e.g. Panfrost) where transform feedback requires
4033 * unpacked varyings.
4035 * This variable is mutually exlusive with DisableVaryingPacking.
4037 GLboolean DisableTransformFeedbackPacking
;
4040 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
4041 * layout is set as shared (the default) or packed. However most Mesa drivers
4042 * just use STD140 for these layouts. This flag allows drivers to use STD430
4043 * for packed and shared layouts which allows arrays to be packed more
4046 bool UseSTD430AsDefaultPacking
;
4049 * Should meaningful names be generated for compiler temporary variables?
4051 * Generally, it is not useful to have the compiler generate "meaningful"
4052 * names for temporary variables that it creates. This can, however, be a
4053 * useful debugging aid. In Mesa debug builds or release builds when
4054 * MESA_GLSL is set at run-time, meaningful names will be generated.
4055 * Drivers can also force names to be generated by setting this field.
4056 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
4057 * vertex shader assembly) is set at run-time.
4059 bool GenerateTemporaryNames
;
4062 * Maximum value supported for an index in DrawElements and friends.
4064 * This must be at least (1ull<<24)-1. The default value is
4067 * \since ES 3.0 or GL_ARB_ES3_compatibility
4068 * \sa _mesa_init_constants
4070 GLuint64 MaxElementIndex
;
4073 * Disable interpretation of line continuations (lines ending with a
4074 * backslash character ('\') in GLSL source.
4076 GLboolean DisableGLSLLineContinuations
;
4078 /** GL_ARB_texture_multisample */
4079 GLint MaxColorTextureSamples
;
4080 GLint MaxDepthTextureSamples
;
4081 GLint MaxIntegerSamples
;
4083 /** GL_AMD_framebuffer_multisample_advanced */
4084 GLint MaxColorFramebufferSamples
;
4085 GLint MaxColorFramebufferStorageSamples
;
4086 GLint MaxDepthStencilFramebufferSamples
;
4088 /* An array of supported MSAA modes allowing different sample
4089 * counts per attachment type.
4092 GLint NumColorSamples
;
4093 GLint NumColorStorageSamples
;
4094 GLint NumDepthStencilSamples
;
4095 } SupportedMultisampleModes
[40];
4096 GLint NumSupportedMultisampleModes
;
4098 /** GL_ARB_shader_atomic_counters */
4099 GLuint MaxAtomicBufferBindings
;
4100 GLuint MaxAtomicBufferSize
;
4101 GLuint MaxCombinedAtomicBuffers
;
4102 GLuint MaxCombinedAtomicCounters
;
4104 /** GL_ARB_vertex_attrib_binding */
4105 GLint MaxVertexAttribRelativeOffset
;
4106 GLint MaxVertexAttribBindings
;
4108 /* GL_ARB_shader_image_load_store */
4109 GLuint MaxImageUnits
;
4110 GLuint MaxCombinedShaderOutputResources
;
4111 GLuint MaxImageSamples
;
4112 GLuint MaxCombinedImageUniforms
;
4114 /** GL_ARB_compute_shader */
4115 GLuint MaxComputeWorkGroupCount
[3]; /* Array of x, y, z dimensions */
4116 GLuint MaxComputeWorkGroupSize
[3]; /* Array of x, y, z dimensions */
4117 GLuint MaxComputeWorkGroupInvocations
;
4118 GLuint MaxComputeSharedMemorySize
;
4120 /** GL_ARB_compute_variable_group_size */
4121 GLuint MaxComputeVariableGroupSize
[3]; /* Array of x, y, z dimensions */
4122 GLuint MaxComputeVariableGroupInvocations
;
4124 /** GL_ARB_gpu_shader5 */
4125 GLfloat MinFragmentInterpolationOffset
;
4126 GLfloat MaxFragmentInterpolationOffset
;
4128 GLboolean FakeSWMSAA
;
4130 /** GL_KHR_context_flush_control */
4131 GLenum16 ContextReleaseBehavior
;
4133 struct gl_shader_compiler_options ShaderCompilerOptions
[MESA_SHADER_STAGES
];
4135 /** GL_ARB_tessellation_shader */
4136 GLuint MaxPatchVertices
;
4137 GLuint MaxTessGenLevel
;
4138 GLuint MaxTessPatchComponents
;
4139 GLuint MaxTessControlTotalOutputComponents
;
4140 bool LowerTessLevel
; /**< Lower gl_TessLevel* from float[n] to vecn? */
4141 bool PrimitiveRestartForPatches
;
4142 bool LowerCsDerivedVariables
; /**< Lower gl_GlobalInvocationID and
4143 * gl_LocalInvocationIndex based on
4144 * other builtin variables. */
4146 /** GL_OES_primitive_bounding_box */
4147 bool NoPrimitiveBoundingBoxOutput
;
4149 /** GL_ARB_sparse_buffer */
4150 GLuint SparseBufferPageSize
;
4152 /** Used as an input for sha1 generation in the on-disk shader cache */
4153 unsigned char *dri_config_options_sha1
;
4155 /** When drivers are OK with mapped buffers during draw and other calls. */
4156 bool AllowMappedBuffersDuringExecution
;
4159 * Whether buffer creation, unsynchronized mapping, unmapping, and
4160 * deletion is thread-safe.
4162 bool BufferCreateMapUnsynchronizedThreadSafe
;
4164 /** GL_ARB_get_program_binary */
4165 GLuint NumProgramBinaryFormats
;
4167 /** GL_NV_conservative_raster */
4168 GLuint MaxSubpixelPrecisionBiasBits
;
4170 /** GL_NV_conservative_raster_dilate */
4171 GLfloat ConservativeRasterDilateRange
[2];
4172 GLfloat ConservativeRasterDilateGranularity
;
4174 /** Is the drivers uniform storage packed or padded to 16 bytes. */
4175 bool PackedDriverUniformStorage
;
4177 /** Does the driver make use of the NIR based GLSL linker */
4178 bool UseNIRGLSLLinker
;
4180 /** Wether or not glBitmap uses red textures rather than alpha */
4183 /** Whether the vertex buffer offset is a signed 32-bit integer. */
4184 bool VertexBufferOffsetIsInt32
;
4186 /** Whether the driver can handle MultiDrawElements with non-VBO indices. */
4187 bool MultiDrawWithUserIndices
;
4189 /** Whether out-of-order draw (Begin/End) optimizations are allowed. */
4190 bool AllowDrawOutOfOrder
;
4192 /** Whether to allow the fast path for frequently updated VAOs. */
4193 bool AllowDynamicVAOFastPath
;
4195 /** Whether the driver can support primitive restart with a fixed index.
4196 * This is essentially a subset of NV_primitive_restart with enough support
4197 * to be able to enable GLES 3.1. Some hardware can support this but not the
4198 * full NV extension with arbitrary restart indices.
4200 bool PrimitiveRestartFixedIndex
;
4202 /** GL_ARB_gl_spirv */
4203 struct spirv_supported_capabilities SpirVCapabilities
;
4205 /** GL_ARB_spirv_extensions */
4206 struct spirv_supported_extensions
*SpirVExtensions
;
4208 char *VendorOverride
;
4210 /** Buffer size used to upload vertices from glBegin/glEnd. */
4211 unsigned glBeginEndBufferSize
;
4213 /** Whether the driver doesn't want x/y/width/height clipped based on src size
4214 * when doing a copy texture operation (eg: may want out-of-bounds reads that
4215 * produce 0 instead of leaving the texture content undefined).
4217 bool NoClippingOnCopyTex
;
4222 * Enable flag for each OpenGL extension. Different device drivers will
4223 * enable different extensions at runtime.
4225 struct gl_extensions
4227 GLboolean dummy
; /* don't remove this! */
4228 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
4229 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
4230 GLboolean ANGLE_texture_compression_dxt
;
4231 GLboolean ARB_ES2_compatibility
;
4232 GLboolean ARB_ES3_compatibility
;
4233 GLboolean ARB_ES3_1_compatibility
;
4234 GLboolean ARB_ES3_2_compatibility
;
4235 GLboolean ARB_arrays_of_arrays
;
4236 GLboolean ARB_base_instance
;
4237 GLboolean ARB_bindless_texture
;
4238 GLboolean ARB_blend_func_extended
;
4239 GLboolean ARB_buffer_storage
;
4240 GLboolean ARB_clear_texture
;
4241 GLboolean ARB_clip_control
;
4242 GLboolean ARB_color_buffer_float
;
4243 GLboolean ARB_compatibility
;
4244 GLboolean ARB_compute_shader
;
4245 GLboolean ARB_compute_variable_group_size
;
4246 GLboolean ARB_conditional_render_inverted
;
4247 GLboolean ARB_conservative_depth
;
4248 GLboolean ARB_copy_image
;
4249 GLboolean ARB_cull_distance
;
4250 GLboolean ARB_depth_buffer_float
;
4251 GLboolean ARB_depth_clamp
;
4252 GLboolean ARB_depth_texture
;
4253 GLboolean ARB_derivative_control
;
4254 GLboolean ARB_draw_buffers_blend
;
4255 GLboolean ARB_draw_elements_base_vertex
;
4256 GLboolean ARB_draw_indirect
;
4257 GLboolean ARB_draw_instanced
;
4258 GLboolean ARB_fragment_coord_conventions
;
4259 GLboolean ARB_fragment_layer_viewport
;
4260 GLboolean ARB_fragment_program
;
4261 GLboolean ARB_fragment_program_shadow
;
4262 GLboolean ARB_fragment_shader
;
4263 GLboolean ARB_framebuffer_no_attachments
;
4264 GLboolean ARB_framebuffer_object
;
4265 GLboolean ARB_fragment_shader_interlock
;
4266 GLboolean ARB_enhanced_layouts
;
4267 GLboolean ARB_explicit_attrib_location
;
4268 GLboolean ARB_explicit_uniform_location
;
4269 GLboolean ARB_gl_spirv
;
4270 GLboolean ARB_gpu_shader5
;
4271 GLboolean ARB_gpu_shader_fp64
;
4272 GLboolean ARB_gpu_shader_int64
;
4273 GLboolean ARB_half_float_vertex
;
4274 GLboolean ARB_indirect_parameters
;
4275 GLboolean ARB_instanced_arrays
;
4276 GLboolean ARB_internalformat_query
;
4277 GLboolean ARB_internalformat_query2
;
4278 GLboolean ARB_map_buffer_range
;
4279 GLboolean ARB_occlusion_query
;
4280 GLboolean ARB_occlusion_query2
;
4281 GLboolean ARB_pipeline_statistics_query
;
4282 GLboolean ARB_point_sprite
;
4283 GLboolean ARB_polygon_offset_clamp
;
4284 GLboolean ARB_post_depth_coverage
;
4285 GLboolean ARB_query_buffer_object
;
4286 GLboolean ARB_robust_buffer_access_behavior
;
4287 GLboolean ARB_sample_locations
;
4288 GLboolean ARB_sample_shading
;
4289 GLboolean ARB_seamless_cube_map
;
4290 GLboolean ARB_shader_atomic_counter_ops
;
4291 GLboolean ARB_shader_atomic_counters
;
4292 GLboolean ARB_shader_ballot
;
4293 GLboolean ARB_shader_bit_encoding
;
4294 GLboolean ARB_shader_clock
;
4295 GLboolean ARB_shader_draw_parameters
;
4296 GLboolean ARB_shader_group_vote
;
4297 GLboolean ARB_shader_image_load_store
;
4298 GLboolean ARB_shader_image_size
;
4299 GLboolean ARB_shader_precision
;
4300 GLboolean ARB_shader_stencil_export
;
4301 GLboolean ARB_shader_storage_buffer_object
;
4302 GLboolean ARB_shader_texture_image_samples
;
4303 GLboolean ARB_shader_texture_lod
;
4304 GLboolean ARB_shader_viewport_layer_array
;
4305 GLboolean ARB_shading_language_packing
;
4306 GLboolean ARB_shading_language_420pack
;
4307 GLboolean ARB_shadow
;
4308 GLboolean ARB_sparse_buffer
;
4309 GLboolean ARB_stencil_texturing
;
4310 GLboolean ARB_spirv_extensions
;
4312 GLboolean ARB_tessellation_shader
;
4313 GLboolean ARB_texture_border_clamp
;
4314 GLboolean ARB_texture_buffer_object
;
4315 GLboolean ARB_texture_buffer_object_rgb32
;
4316 GLboolean ARB_texture_buffer_range
;
4317 GLboolean ARB_texture_compression_bptc
;
4318 GLboolean ARB_texture_compression_rgtc
;
4319 GLboolean ARB_texture_cube_map
;
4320 GLboolean ARB_texture_cube_map_array
;
4321 GLboolean ARB_texture_env_combine
;
4322 GLboolean ARB_texture_env_crossbar
;
4323 GLboolean ARB_texture_env_dot3
;
4324 GLboolean ARB_texture_filter_anisotropic
;
4325 GLboolean ARB_texture_float
;
4326 GLboolean ARB_texture_gather
;
4327 GLboolean ARB_texture_mirror_clamp_to_edge
;
4328 GLboolean ARB_texture_multisample
;
4329 GLboolean ARB_texture_non_power_of_two
;
4330 GLboolean ARB_texture_stencil8
;
4331 GLboolean ARB_texture_query_levels
;
4332 GLboolean ARB_texture_query_lod
;
4333 GLboolean ARB_texture_rg
;
4334 GLboolean ARB_texture_rgb10_a2ui
;
4335 GLboolean ARB_texture_view
;
4336 GLboolean ARB_timer_query
;
4337 GLboolean ARB_transform_feedback2
;
4338 GLboolean ARB_transform_feedback3
;
4339 GLboolean ARB_transform_feedback_instanced
;
4340 GLboolean ARB_transform_feedback_overflow_query
;
4341 GLboolean ARB_uniform_buffer_object
;
4342 GLboolean ARB_vertex_attrib_64bit
;
4343 GLboolean ARB_vertex_program
;
4344 GLboolean ARB_vertex_shader
;
4345 GLboolean ARB_vertex_type_10f_11f_11f_rev
;
4346 GLboolean ARB_vertex_type_2_10_10_10_rev
;
4347 GLboolean ARB_viewport_array
;
4348 GLboolean EXT_blend_color
;
4349 GLboolean EXT_blend_equation_separate
;
4350 GLboolean EXT_blend_func_separate
;
4351 GLboolean EXT_blend_minmax
;
4352 GLboolean EXT_demote_to_helper_invocation
;
4353 GLboolean EXT_depth_bounds_test
;
4354 GLboolean EXT_disjoint_timer_query
;
4355 GLboolean EXT_draw_buffers2
;
4356 GLboolean EXT_EGL_image_storage
;
4357 GLboolean EXT_float_blend
;
4358 GLboolean EXT_framebuffer_multisample
;
4359 GLboolean EXT_framebuffer_multisample_blit_scaled
;
4360 GLboolean EXT_framebuffer_sRGB
;
4361 GLboolean EXT_gpu_program_parameters
;
4362 GLboolean EXT_gpu_shader4
;
4363 GLboolean EXT_memory_object
;
4364 GLboolean EXT_memory_object_fd
;
4365 GLboolean EXT_multisampled_render_to_texture
;
4366 GLboolean EXT_packed_float
;
4367 GLboolean EXT_pixel_buffer_object
;
4368 GLboolean EXT_point_parameters
;
4369 GLboolean EXT_provoking_vertex
;
4370 GLboolean EXT_render_snorm
;
4371 GLboolean EXT_semaphore
;
4372 GLboolean EXT_semaphore_fd
;
4373 GLboolean EXT_shader_image_load_formatted
;
4374 GLboolean EXT_shader_image_load_store
;
4375 GLboolean EXT_shader_integer_mix
;
4376 GLboolean EXT_shader_samples_identical
;
4378 GLboolean EXT_stencil_two_side
;
4379 GLboolean EXT_texture_array
;
4380 GLboolean EXT_texture_buffer_object
;
4381 GLboolean EXT_texture_compression_latc
;
4382 GLboolean EXT_texture_compression_s3tc
;
4383 GLboolean EXT_texture_compression_s3tc_srgb
;
4384 GLboolean EXT_texture_env_dot3
;
4385 GLboolean EXT_texture_filter_anisotropic
;
4386 GLboolean EXT_texture_integer
;
4387 GLboolean EXT_texture_mirror_clamp
;
4388 GLboolean EXT_texture_norm16
;
4389 GLboolean EXT_texture_shadow_lod
;
4390 GLboolean EXT_texture_shared_exponent
;
4391 GLboolean EXT_texture_snorm
;
4392 GLboolean EXT_texture_sRGB
;
4393 GLboolean EXT_texture_sRGB_R8
;
4394 GLboolean EXT_texture_sRGB_decode
;
4395 GLboolean EXT_texture_swizzle
;
4396 GLboolean EXT_texture_type_2_10_10_10_REV
;
4397 GLboolean EXT_transform_feedback
;
4398 GLboolean EXT_timer_query
;
4399 GLboolean EXT_vertex_array_bgra
;
4400 GLboolean EXT_window_rectangles
;
4401 GLboolean OES_copy_image
;
4402 GLboolean OES_primitive_bounding_box
;
4403 GLboolean OES_sample_variables
;
4404 GLboolean OES_standard_derivatives
;
4405 GLboolean OES_texture_buffer
;
4406 GLboolean OES_texture_cube_map_array
;
4407 GLboolean OES_texture_view
;
4408 GLboolean OES_viewport_array
;
4409 /* vendor extensions */
4410 GLboolean AMD_compressed_ATC_texture
;
4411 GLboolean AMD_framebuffer_multisample_advanced
;
4412 GLboolean AMD_depth_clamp_separate
;
4413 GLboolean AMD_performance_monitor
;
4414 GLboolean AMD_pinned_memory
;
4415 GLboolean AMD_seamless_cubemap_per_texture
;
4416 GLboolean AMD_vertex_shader_layer
;
4417 GLboolean AMD_vertex_shader_viewport_index
;
4418 GLboolean ANDROID_extension_pack_es31a
;
4419 GLboolean APPLE_object_purgeable
;
4420 GLboolean ATI_meminfo
;
4421 GLboolean ATI_texture_compression_3dc
;
4422 GLboolean ATI_texture_mirror_once
;
4423 GLboolean ATI_texture_env_combine3
;
4424 GLboolean ATI_fragment_shader
;
4425 GLboolean GREMEDY_string_marker
;
4426 GLboolean INTEL_blackhole_render
;
4427 GLboolean INTEL_conservative_rasterization
;
4428 GLboolean INTEL_performance_query
;
4429 GLboolean INTEL_shader_atomic_float_minmax
;
4430 GLboolean INTEL_shader_integer_functions2
;
4431 GLboolean KHR_blend_equation_advanced
;
4432 GLboolean KHR_blend_equation_advanced_coherent
;
4433 GLboolean KHR_robustness
;
4434 GLboolean KHR_texture_compression_astc_hdr
;
4435 GLboolean KHR_texture_compression_astc_ldr
;
4436 GLboolean KHR_texture_compression_astc_sliced_3d
;
4437 GLboolean MESA_framebuffer_flip_y
;
4438 GLboolean MESA_tile_raster_order
;
4439 GLboolean MESA_pack_invert
;
4440 GLboolean EXT_shader_framebuffer_fetch
;
4441 GLboolean EXT_shader_framebuffer_fetch_non_coherent
;
4442 GLboolean MESA_shader_integer_functions
;
4443 GLboolean MESA_ycbcr_texture
;
4444 GLboolean NV_alpha_to_coverage_dither_control
;
4445 GLboolean NV_compute_shader_derivatives
;
4446 GLboolean NV_conditional_render
;
4447 GLboolean NV_copy_depth_to_color
;
4448 GLboolean NV_copy_image
;
4449 GLboolean NV_fill_rectangle
;
4450 GLboolean NV_fog_distance
;
4451 GLboolean NV_point_sprite
;
4452 GLboolean NV_primitive_restart
;
4453 GLboolean NV_shader_atomic_float
;
4454 GLboolean NV_texture_barrier
;
4455 GLboolean NV_texture_env_combine4
;
4456 GLboolean NV_texture_rectangle
;
4457 GLboolean NV_vdpau_interop
;
4458 GLboolean NV_conservative_raster
;
4459 GLboolean NV_conservative_raster_dilate
;
4460 GLboolean NV_conservative_raster_pre_snap_triangles
;
4461 GLboolean NV_conservative_raster_pre_snap
;
4462 GLboolean NV_viewport_array2
;
4463 GLboolean NV_viewport_swizzle
;
4464 GLboolean NVX_gpu_memory_info
;
4465 GLboolean TDFX_texture_compression_FXT1
;
4466 GLboolean OES_EGL_image
;
4467 GLboolean OES_draw_texture
;
4468 GLboolean OES_depth_texture_cube_map
;
4469 GLboolean OES_EGL_image_external
;
4470 GLboolean OES_texture_float
;
4471 GLboolean OES_texture_float_linear
;
4472 GLboolean OES_texture_half_float
;
4473 GLboolean OES_texture_half_float_linear
;
4474 GLboolean OES_compressed_ETC1_RGB8_texture
;
4475 GLboolean OES_geometry_shader
;
4476 GLboolean OES_texture_compression_astc
;
4477 GLboolean extension_sentinel
;
4478 /** The extension string */
4479 const GLubyte
*String
;
4480 /** Number of supported extensions */
4483 * The context version which extension helper functions compare against.
4484 * By default, the value is equal to ctx->Version. This changes to ~0
4485 * while meta is in progress.
4492 * A stack of matrices (projection, modelview, color, texture, etc).
4494 struct gl_matrix_stack
4496 GLmatrix
*Top
; /**< points into Stack */
4497 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
4498 unsigned StackSize
; /**< Number of elements in Stack */
4499 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
4500 GLuint MaxDepth
; /**< size of Stack[] array */
4501 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4506 * \name Bits for image transfer operations
4507 * \sa __struct gl_contextRec::ImageTransferState.
4510 #define IMAGE_SCALE_BIAS_BIT 0x1
4511 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4512 #define IMAGE_MAP_COLOR_BIT 0x4
4513 #define IMAGE_CLAMP_BIT 0x800
4516 /** Pixel Transfer ops */
4517 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4518 IMAGE_SHIFT_OFFSET_BIT | \
4519 IMAGE_MAP_COLOR_BIT)
4523 * \name Bits to indicate what state has changed.
4526 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4527 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4528 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4529 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4530 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4532 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4533 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4534 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4535 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4536 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4537 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4538 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4539 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4540 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4541 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4542 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4543 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4544 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4545 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4547 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4548 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4549 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4550 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4551 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4552 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4553 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4555 #define _NEW_FRAG_CLAMP (1u << 29)
4556 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4557 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4563 * Composite state flags
4566 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4568 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4569 _NEW_TEXTURE_STATE | \
4574 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4584 /* This has to be included here. */
4588 /** Opaque declaration of display list payload data type */
4589 union gl_dlist_node
;
4593 * Per-display list information.
4595 struct gl_display_list
4598 GLbitfield Flags
; /**< DLIST_x flags */
4599 GLchar
*Label
; /**< GL_KHR_debug */
4600 /** The dlist commands are in a linked list of nodes */
4601 union gl_dlist_node
*Head
;
4606 * State used during display list compilation and execution.
4608 struct gl_dlist_state
4610 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
4611 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
4612 GLuint CurrentPos
; /**< Index into current block of nodes */
4613 GLuint CallDepth
; /**< Current recursion calling depth */
4615 GLvertexformat ListVtxfmt
;
4617 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
4618 uint32_t CurrentAttrib
[VERT_ATTRIB_MAX
][8];
4620 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
4621 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
4624 /* State known to have been set by the currently-compiling display
4625 * list. Used to eliminate some redundant state changes.
4627 GLenum16 ShadeModel
;
4632 * Driver-specific state flags.
4634 * These are or'd with gl_context::NewDriverState to notify a driver about
4635 * a state change. The driver sets the flags at context creation and
4636 * the meaning of the bits set is opaque to core Mesa.
4638 struct gl_driver_flags
4640 /** gl_context::Array::_DrawArrays (vertex array state) */
4643 /** gl_context::TransformFeedback::CurrentObject */
4644 uint64_t NewTransformFeedback
;
4646 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4647 uint64_t NewTransformFeedbackProg
;
4649 /** gl_context::RasterDiscard */
4650 uint64_t NewRasterizerDiscard
;
4652 /** gl_context::TileRasterOrder* */
4653 uint64_t NewTileRasterOrder
;
4656 * gl_context::UniformBufferBindings
4657 * gl_shader_program::UniformBlocks
4659 uint64_t NewUniformBuffer
;
4662 * gl_context::ShaderStorageBufferBindings
4663 * gl_shader_program::ShaderStorageBlocks
4665 uint64_t NewShaderStorageBuffer
;
4667 uint64_t NewTextureBuffer
;
4670 * gl_context::AtomicBufferBindings
4672 uint64_t NewAtomicBuffer
;
4675 * gl_context::ImageUnits
4677 uint64_t NewImageUnits
;
4680 * gl_context::TessCtrlProgram::patch_default_*
4682 uint64_t NewDefaultTessLevels
;
4685 * gl_context::IntelConservativeRasterization
4687 uint64_t NewIntelConservativeRasterization
;
4690 * gl_context::NvConservativeRasterization
4692 uint64_t NewNvConservativeRasterization
;
4695 * gl_context::ConservativeRasterMode/ConservativeRasterDilate
4696 * gl_context::SubpixelPrecisionBias
4698 uint64_t NewNvConservativeRasterizationParams
;
4701 * gl_context::Scissor::WindowRects
4703 uint64_t NewWindowRectangles
;
4705 /** gl_context::Color::sRGBEnabled */
4706 uint64_t NewFramebufferSRGB
;
4708 /** gl_context::Scissor::EnableFlags */
4709 uint64_t NewScissorTest
;
4711 /** gl_context::Scissor::ScissorArray */
4712 uint64_t NewScissorRect
;
4714 /** gl_context::Color::Alpha* */
4715 uint64_t NewAlphaTest
;
4717 /** gl_context::Color::Blend/Dither */
4720 /** gl_context::Color::BlendColor */
4721 uint64_t NewBlendColor
;
4723 /** gl_context::Color::Color/Index */
4724 uint64_t NewColorMask
;
4726 /** gl_context::Depth */
4729 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4730 uint64_t NewLogicOp
;
4732 /** gl_context::Multisample::Enabled */
4733 uint64_t NewMultisampleEnable
;
4735 /** gl_context::Multisample::SampleAlphaTo* */
4736 uint64_t NewSampleAlphaToXEnable
;
4738 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4739 uint64_t NewSampleMask
;
4741 /** gl_context::Multisample::(Min)SampleShading */
4742 uint64_t NewSampleShading
;
4744 /** gl_context::Stencil */
4745 uint64_t NewStencil
;
4747 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4748 uint64_t NewClipControl
;
4750 /** gl_context::Transform::EyeUserPlane */
4751 uint64_t NewClipPlane
;
4753 /** gl_context::Transform::ClipPlanesEnabled */
4754 uint64_t NewClipPlaneEnable
;
4756 /** gl_context::Color::ClampFragmentColor */
4757 uint64_t NewFragClamp
;
4759 /** gl_context::Transform::DepthClamp */
4760 uint64_t NewDepthClamp
;
4762 /** gl_context::Line */
4763 uint64_t NewLineState
;
4765 /** gl_context::Polygon */
4766 uint64_t NewPolygonState
;
4768 /** gl_context::PolygonStipple */
4769 uint64_t NewPolygonStipple
;
4771 /** gl_context::ViewportArray */
4772 uint64_t NewViewport
;
4774 /** Shader constants (uniforms, program parameters, state constants) */
4775 uint64_t NewShaderConstants
[MESA_SHADER_STAGES
];
4777 /** Programmable sample location state for gl_context::DrawBuffer */
4778 uint64_t NewSampleLocations
;
4781 struct gl_buffer_binding
4783 struct gl_buffer_object
*BufferObject
;
4784 /** Start of uniform block data in the buffer */
4786 /** Size of data allowed to be referenced from the buffer (in bytes) */
4789 * glBindBufferBase() indicates that the Size should be ignored and only
4790 * limited by the current size of the BufferObject.
4792 GLboolean AutomaticSize
;
4796 * ARB_shader_image_load_store image unit.
4798 struct gl_image_unit
4801 * Texture object bound to this unit.
4803 struct gl_texture_object
*TexObj
;
4806 * Level of the texture object bound to this unit.
4811 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4812 * GL_FALSE if only some specific layer of the texture is bound.
4818 * Layer of the texture object bound to this unit as specified by the
4824 * Layer of the texture object bound to this unit, or zero if
4830 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4831 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4836 * GL internal format that determines the interpretation of the
4837 * image memory when shader image operations are performed through
4843 * Mesa format corresponding to \c Format.
4845 mesa_format _ActualFormat
:16;
4849 * Shader subroutines storage
4851 struct gl_subroutine_index_binding
4857 struct gl_texture_handle_object
4859 struct gl_texture_object
*texObj
;
4860 struct gl_sampler_object
*sampObj
;
4864 struct gl_image_handle_object
4866 struct gl_image_unit imgObj
;
4870 struct gl_memory_object
4872 GLuint Name
; /**< hash table ID/name */
4873 GLboolean Immutable
; /**< denotes mutability state of parameters */
4874 GLboolean Dedicated
; /**< import memory from a dedicated allocation */
4877 struct gl_semaphore_object
4879 GLuint Name
; /**< hash table ID/name */
4883 * One element of the client attrib stack.
4885 struct gl_client_attrib_node
4888 struct gl_array_attrib Array
;
4889 struct gl_vertex_array_object VAO
;
4890 struct gl_pixelstore_attrib Pack
;
4891 struct gl_pixelstore_attrib Unpack
;
4895 * The VBO module implemented in src/vbo.
4897 struct vbo_context
{
4898 struct gl_vertex_buffer_binding binding
;
4899 struct gl_array_attributes current
[VBO_ATTRIB_MAX
];
4901 struct gl_vertex_array_object
*VAO
;
4903 struct vbo_exec_context exec
;
4904 struct vbo_save_context save
;
4908 * Mesa rendering context.
4910 * This is the central context data structure for Mesa. Almost all
4911 * OpenGL state is contained in this structure.
4912 * Think of this as a base class from which device drivers will derive
4917 /** State possibly shared with other contexts in the address space */
4918 struct gl_shared_state
*Shared
;
4920 /** \name API function pointer tables */
4925 * The current dispatch table for non-displaylist-saving execution, either
4926 * BeginEnd or OutsideBeginEnd
4928 struct _glapi_table
*Exec
;
4930 * The normal dispatch table for non-displaylist-saving, non-begin/end
4932 struct _glapi_table
*OutsideBeginEnd
;
4933 /** The dispatch table used between glNewList() and glEndList() */
4934 struct _glapi_table
*Save
;
4936 * The dispatch table used between glBegin() and glEnd() (outside of a
4937 * display list). Only valid functions between those two are set, which is
4938 * mostly just the set in a GLvertexformat struct.
4940 struct _glapi_table
*BeginEnd
;
4942 * Dispatch table for when a graphics reset has happened.
4944 struct _glapi_table
*ContextLost
;
4946 * Dispatch table used to marshal API calls from the client program to a
4947 * separate server thread. NULL if API calls are not being marshalled to
4950 struct _glapi_table
*MarshalExec
;
4952 * Dispatch table currently in use for fielding API calls from the client
4953 * program. If API calls are being marshalled to another thread, this ==
4954 * MarshalExec. Otherwise it == CurrentServerDispatch.
4956 struct _glapi_table
*CurrentClientDispatch
;
4959 * Dispatch table currently in use for performing API calls. == Save or
4962 struct _glapi_table
*CurrentServerDispatch
;
4966 struct glthread_state GLThread
;
4968 struct gl_config Visual
;
4969 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
4970 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
4971 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
4972 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
4975 * Device driver function pointer table
4977 struct dd_function_table Driver
;
4979 /** Core/Driver constants */
4980 struct gl_constants Const
;
4982 /** \name The various 4x4 matrix stacks */
4984 struct gl_matrix_stack ModelviewMatrixStack
;
4985 struct gl_matrix_stack ProjectionMatrixStack
;
4986 struct gl_matrix_stack TextureMatrixStack
[MAX_TEXTURE_UNITS
];
4987 struct gl_matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
4988 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
4991 /** Combined modelview and projection matrix */
4992 GLmatrix _ModelProjectMatrix
;
4994 /** \name Display lists */
4995 struct gl_dlist_state ListState
;
4997 GLboolean ExecuteFlag
; /**< Execute GL commands? */
4998 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
5000 /** Extension information */
5001 struct gl_extensions Extensions
;
5003 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
5005 char *VersionString
;
5007 /** \name State attribute stack (for glPush/PopAttrib) */
5009 GLuint AttribStackDepth
;
5010 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
5013 /** \name Renderer attribute groups
5015 * We define a struct for each attribute group to make pushing and popping
5016 * attributes easy. Also it's a good organization.
5019 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
5020 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
5021 struct gl_current_attrib Current
; /**< Current attributes */
5022 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
5023 struct gl_eval_attrib Eval
; /**< Eval attributes */
5024 struct gl_fog_attrib Fog
; /**< Fog attributes */
5025 struct gl_hint_attrib Hint
; /**< Hint attributes */
5026 struct gl_light_attrib Light
; /**< Light attributes */
5027 struct gl_line_attrib Line
; /**< Line attributes */
5028 struct gl_list_attrib List
; /**< List attributes */
5029 struct gl_multisample_attrib Multisample
;
5030 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
5031 struct gl_point_attrib Point
; /**< Point attributes */
5032 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
5033 GLuint PolygonStipple
[32]; /**< Polygon stipple */
5034 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
5035 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
5036 struct gl_texture_attrib Texture
; /**< Texture attributes */
5037 struct gl_transform_attrib Transform
; /**< Transformation attributes */
5038 struct gl_viewport_attrib ViewportArray
[MAX_VIEWPORTS
]; /**< Viewport attributes */
5039 GLuint SubpixelPrecisionBias
[2]; /**< Viewport attributes */
5042 /** \name Client attribute stack */
5044 GLuint ClientAttribStackDepth
;
5045 struct gl_client_attrib_node ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
5048 /** \name Client attribute groups */
5050 struct gl_array_attrib Array
; /**< Vertex arrays */
5051 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
5052 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
5053 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
5056 /** \name Other assorted state (not pushed/popped on attribute stack) */
5058 struct gl_pixelmaps PixelMaps
;
5060 struct gl_evaluators EvalMap
; /**< All evaluators */
5061 struct gl_feedback Feedback
; /**< Feedback */
5062 struct gl_selection Select
; /**< Selection */
5064 struct gl_program_state Program
; /**< general program state */
5065 struct gl_vertex_program_state VertexProgram
;
5066 struct gl_fragment_program_state FragmentProgram
;
5067 struct gl_geometry_program_state GeometryProgram
;
5068 struct gl_compute_program_state ComputeProgram
;
5069 struct gl_tess_ctrl_program_state TessCtrlProgram
;
5070 struct gl_tess_eval_program_state TessEvalProgram
;
5071 struct gl_ati_fragment_shader_state ATIFragmentShader
;
5073 struct gl_pipeline_shader_state Pipeline
; /**< GLSL pipeline shader object state */
5074 struct gl_pipeline_object Shader
; /**< GLSL shader object state */
5077 * Current active shader pipeline state
5079 * Almost all internal users want ::_Shader instead of ::Shader. The
5080 * exceptions are bits of legacy GLSL API that do not know about separate
5083 * If a program is active via \c glUseProgram, this will point to
5086 * If a program pipeline is active via \c glBindProgramPipeline, this will
5087 * point to \c ::Pipeline.Current.
5089 * If neither a program nor a program pipeline is active, this will point to
5090 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
5093 struct gl_pipeline_object
*_Shader
;
5096 * NIR containing the functions that implement software fp64 support.
5098 struct nir_shader
*SoftFP64
;
5100 struct gl_query_state Query
; /**< occlusion, timer queries */
5102 struct gl_transform_feedback_state TransformFeedback
;
5104 struct gl_perf_monitor_state PerfMonitor
;
5105 struct gl_perf_query_state PerfQuery
;
5107 struct gl_buffer_object
*DrawIndirectBuffer
; /** < GL_ARB_draw_indirect */
5108 struct gl_buffer_object
*ParameterBuffer
; /** < GL_ARB_indirect_parameters */
5109 struct gl_buffer_object
*DispatchIndirectBuffer
; /** < GL_ARB_compute_shader */
5111 struct gl_buffer_object
*CopyReadBuffer
; /**< GL_ARB_copy_buffer */
5112 struct gl_buffer_object
*CopyWriteBuffer
; /**< GL_ARB_copy_buffer */
5114 struct gl_buffer_object
*QueryBuffer
; /**< GL_ARB_query_buffer_object */
5117 * Current GL_ARB_uniform_buffer_object binding referenced by
5118 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
5120 struct gl_buffer_object
*UniformBuffer
;
5123 * Current GL_ARB_shader_storage_buffer_object binding referenced by
5124 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
5126 struct gl_buffer_object
*ShaderStorageBuffer
;
5129 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
5130 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
5131 * associated with uniform blocks by glUniformBlockBinding()'s state in the
5134 struct gl_buffer_binding
5135 UniformBufferBindings
[MAX_COMBINED_UNIFORM_BUFFERS
];
5138 * Array of shader storage buffers for ARB_shader_storage_buffer_object
5139 * and GL 4.3. This is set up using glBindBufferRange() or
5140 * glBindBufferBase(). They are associated with shader storage blocks by
5141 * glShaderStorageBlockBinding()'s state in the shader program.
5143 struct gl_buffer_binding
5144 ShaderStorageBufferBindings
[MAX_COMBINED_SHADER_STORAGE_BUFFERS
];
5147 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
5150 struct gl_buffer_object
*AtomicBuffer
;
5153 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
5156 struct gl_buffer_object
*ExternalVirtualMemoryBuffer
;
5159 * Array of atomic counter buffer binding points.
5161 struct gl_buffer_binding
5162 AtomicBufferBindings
[MAX_COMBINED_ATOMIC_BUFFERS
];
5165 * Array of image units for ARB_shader_image_load_store.
5167 struct gl_image_unit ImageUnits
[MAX_IMAGE_UNITS
];
5169 struct gl_subroutine_index_binding SubroutineIndex
[MESA_SHADER_STAGES
];
5172 struct gl_meta_state
*Meta
; /**< for "meta" operations */
5174 /* GL_EXT_framebuffer_object */
5175 struct gl_renderbuffer
*CurrentRenderbuffer
;
5177 GLenum16 ErrorValue
; /**< Last error code */
5180 * Recognize and silence repeated error debug messages in buggy apps.
5182 const char *ErrorDebugFmtString
;
5183 GLuint ErrorDebugCount
;
5185 /* GL_ARB_debug_output/GL_KHR_debug */
5186 simple_mtx_t DebugMutex
;
5187 struct gl_debug_state
*Debug
;
5189 GLenum16 RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5190 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
5191 uint64_t NewDriverState
; /**< bitwise-or of flags from DriverFlags */
5193 struct gl_driver_flags DriverFlags
;
5195 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
5196 GLboolean _AllowDrawOutOfOrder
;
5198 GLbitfield varying_vp_inputs
; /**< mask of VERT_BIT_* flags */
5200 /** \name Derived state */
5201 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
5202 GLfloat _EyeZDir
[3];
5203 GLfloat _ModelViewInvScale
; /* may be for model- or eyespace lighting */
5204 GLfloat _ModelViewInvScaleEyespace
; /* always factor defined in spec */
5205 GLboolean _NeedEyeCoords
;
5206 GLboolean _ForceEyeCoords
;
5208 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
5210 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
5212 /** \name For debugging/development only */
5214 GLboolean FirstTimeCurrent
;
5218 * False if this context was created without a config. This is needed
5219 * because the initial state of glDrawBuffers depends on this
5221 GLboolean HasConfig
;
5223 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
5225 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
5226 GLboolean IntelConservativeRasterization
; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */
5227 GLboolean ConservativeRasterization
; /**< GL_CONSERVATIVE_RASTERIZATION_NV */
5228 GLfloat ConservativeRasterDilate
;
5229 GLenum16 ConservativeRasterMode
;
5231 GLboolean IntelBlackholeRender
; /**< GL_INTEL_blackhole_render */
5233 /** Does glVertexAttrib(0) alias glVertex()? */
5234 bool _AttribZeroAliasesVertex
;
5237 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5238 * renderer's tiles should be excecuted, to meet the requirements of
5239 * GL_MESA_tile_raster_order.
5241 GLboolean TileRasterOrderFixed
;
5242 GLboolean TileRasterOrderIncreasingX
;
5243 GLboolean TileRasterOrderIncreasingY
;
5246 * \name Hooks for module contexts.
5248 * These will eventually live in the driver or elsewhere.
5251 void *swrast_context
;
5252 void *swsetup_context
;
5253 void *swtnl_context
;
5254 struct vbo_context vbo_context
;
5255 struct st_context
*st
;
5259 * \name NV_vdpau_interop
5262 const void *vdpDevice
;
5263 const void *vdpGetProcAddress
;
5264 struct set
*vdpSurfaces
;
5268 * Has this context observed a GPU reset in any context in the share group?
5270 * Once this field becomes true, it is never reset to false.
5272 GLboolean ShareGroupReset
;
5275 * \name OES_primitive_bounding_box
5277 * Stores the arguments to glPrimitiveBoundingBox
5279 GLfloat PrimitiveBoundingBox
[8];
5281 struct disk_cache
*Cache
;
5284 * \name GL_ARB_bindless_texture
5287 struct hash_table_u64
*ResidentTextureHandles
;
5288 struct hash_table_u64
*ResidentImageHandles
;
5291 bool shader_builtin_ref
;
5295 * Information about memory usage. All sizes are in kilobytes.
5297 struct gl_memory_info
5299 unsigned total_device_memory
; /**< size of device memory, e.g. VRAM */
5300 unsigned avail_device_memory
; /**< free device memory at the moment */
5301 unsigned total_staging_memory
; /**< size of staging memory, e.g. GART */
5302 unsigned avail_staging_memory
; /**< free staging memory at the moment */
5303 unsigned device_memory_evicted
; /**< size of memory evicted (monotonic counter) */
5304 unsigned nr_device_memory_evictions
; /**< # of evictions (monotonic counter) */
5308 extern int MESA_VERBOSE
;
5309 extern int MESA_DEBUG_FLAGS
;
5311 # define MESA_VERBOSE 0
5312 # define MESA_DEBUG_FLAGS 0
5316 /** The MESA_VERBOSE var is a bitmask of these flags */
5319 VERBOSE_VARRAY
= 0x0001,
5320 VERBOSE_TEXTURE
= 0x0002,
5321 VERBOSE_MATERIAL
= 0x0004,
5322 VERBOSE_PIPELINE
= 0x0008,
5323 VERBOSE_DRIVER
= 0x0010,
5324 VERBOSE_STATE
= 0x0020,
5325 VERBOSE_API
= 0x0040,
5326 VERBOSE_DISPLAY_LIST
= 0x0100,
5327 VERBOSE_LIGHTING
= 0x0200,
5328 VERBOSE_PRIMS
= 0x0400,
5329 VERBOSE_VERTS
= 0x0800,
5330 VERBOSE_DISASSEM
= 0x1000,
5331 VERBOSE_DRAW
= 0x2000,
5332 VERBOSE_SWAPBUFFERS
= 0x4000
5336 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5339 DEBUG_SILENT
= (1 << 0),
5340 DEBUG_ALWAYS_FLUSH
= (1 << 1),
5341 DEBUG_INCOMPLETE_TEXTURE
= (1 << 2),
5342 DEBUG_INCOMPLETE_FBO
= (1 << 3),
5343 DEBUG_CONTEXT
= (1 << 4)
5350 #endif /* MTYPES_H */