2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 * Main Mesa data structures.
30 * Please try to mark derived values with a leading underscore ('_').
37 #include <stdint.h> /* uint32_t */
39 #include "c11/threads.h"
41 #include "main/glheader.h"
42 #include "main/config.h"
43 #include "glapi/glapi.h"
44 #include "math/m_matrix.h" /* GLmatrix */
45 #include "compiler/shader_enums.h"
46 #include "compiler/shader_info.h"
47 #include "main/formats.h" /* MESA_FORMAT_COUNT */
48 #include "compiler/glsl/list.h"
49 #include "util/simple_mtx.h"
50 #include "util/u_dynarray.h"
58 /** Set a single bit */
59 #define BITFIELD_BIT(b) ((GLbitfield)1 << (b))
60 /** Set all bits up to excluding bit b */
61 #define BITFIELD_MASK(b) \
62 ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
63 /** Set count bits starting from bit b */
64 #define BITFIELD_RANGE(b, count) \
65 (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))
69 * \name 64-bit extension of GLbitfield.
72 typedef GLuint64 GLbitfield64
;
74 /** Set a single bit */
75 #define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
76 /** Set all bits up to excluding bit b */
77 #define BITFIELD64_MASK(b) \
78 ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
79 /** Set count bits starting from bit b */
80 #define BITFIELD64_RANGE(b, count) \
81 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
85 * \name Some forward type declarations
88 struct _mesa_HashTable
;
89 struct gl_attrib_node
;
90 struct gl_list_extensions
;
92 struct gl_program_cache
;
93 struct gl_texture_object
;
94 struct gl_debug_state
;
97 struct gl_uniform_storage
;
98 struct prog_instruction
;
99 struct gl_program_parameter_list
;
100 struct gl_shader_spirv_data
;
106 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
107 #define PRIM_MAX GL_PATCHES
108 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
109 #define PRIM_UNKNOWN (PRIM_MAX + 2)
112 * Determine if the given gl_varying_slot appears in the fragment shader.
114 static inline GLboolean
115 _mesa_varying_slot_in_fs(gl_varying_slot slot
)
118 case VARYING_SLOT_PSIZ
:
119 case VARYING_SLOT_BFC0
:
120 case VARYING_SLOT_BFC1
:
121 case VARYING_SLOT_EDGE
:
122 case VARYING_SLOT_CLIP_VERTEX
:
123 case VARYING_SLOT_LAYER
:
124 case VARYING_SLOT_TESS_LEVEL_OUTER
:
125 case VARYING_SLOT_TESS_LEVEL_INNER
:
126 case VARYING_SLOT_BOUNDING_BOX0
:
127 case VARYING_SLOT_BOUNDING_BOX1
:
135 * Indexes for all renderbuffers
139 /* the four standard color buffers */
147 /* optional aux buffer */
149 /* generic renderbuffers */
163 * Bit flags for all renderbuffers
165 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
166 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
167 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
168 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
169 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
170 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
171 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
172 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
173 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
174 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
175 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
176 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
177 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
178 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
179 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
180 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
181 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
182 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
183 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
186 * Mask of all the color buffer bits (but not accum).
188 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
189 BUFFER_BIT_BACK_LEFT | \
190 BUFFER_BIT_FRONT_RIGHT | \
191 BUFFER_BIT_BACK_RIGHT | \
193 BUFFER_BIT_COLOR0 | \
194 BUFFER_BIT_COLOR1 | \
195 BUFFER_BIT_COLOR2 | \
196 BUFFER_BIT_COLOR3 | \
197 BUFFER_BIT_COLOR4 | \
198 BUFFER_BIT_COLOR5 | \
199 BUFFER_BIT_COLOR6 | \
202 /* Mask of bits for depth+stencil buffers */
203 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
206 * Framebuffer configuration (aka visual / pixelformat)
207 * Note: some of these fields should be boolean, but it appears that
208 * code in drivers/dri/common/util.c requires int-sized fields.
214 GLuint doubleBufferMode
;
217 GLboolean haveAccumBuffer
;
218 GLboolean haveDepthBuffer
;
219 GLboolean haveStencilBuffer
;
221 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
222 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
223 GLint rgbBits
; /* total bits for rgb */
224 GLint indexBits
; /* total bits for colorindex */
226 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
234 /* EXT_visual_rating / GLX 1.2 */
237 /* EXT_visual_info / GLX 1.2 */
238 GLint transparentPixel
;
239 /* colors are floats scaled to ints */
240 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
241 GLint transparentIndex
;
243 /* ARB_multisample / SGIS_multisample */
247 /* SGIX_pbuffer / GLX 1.3 */
248 GLint maxPbufferWidth
;
249 GLint maxPbufferHeight
;
250 GLint maxPbufferPixels
;
251 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
252 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
254 /* OML_swap_method */
257 /* EXT_texture_from_pixmap */
258 GLint bindToTextureRgb
;
259 GLint bindToTextureRgba
;
260 GLint bindToMipmapTexture
;
261 GLint bindToTextureTargets
;
264 /* EXT_framebuffer_sRGB */
270 * \name Bit flags used for updating material values.
273 #define MAT_ATTRIB_FRONT_AMBIENT 0
274 #define MAT_ATTRIB_BACK_AMBIENT 1
275 #define MAT_ATTRIB_FRONT_DIFFUSE 2
276 #define MAT_ATTRIB_BACK_DIFFUSE 3
277 #define MAT_ATTRIB_FRONT_SPECULAR 4
278 #define MAT_ATTRIB_BACK_SPECULAR 5
279 #define MAT_ATTRIB_FRONT_EMISSION 6
280 #define MAT_ATTRIB_BACK_EMISSION 7
281 #define MAT_ATTRIB_FRONT_SHININESS 8
282 #define MAT_ATTRIB_BACK_SHININESS 9
283 #define MAT_ATTRIB_FRONT_INDEXES 10
284 #define MAT_ATTRIB_BACK_INDEXES 11
285 #define MAT_ATTRIB_MAX 12
287 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
288 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
289 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
290 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
291 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
292 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
294 #define MAT_INDEX_AMBIENT 0
295 #define MAT_INDEX_DIFFUSE 1
296 #define MAT_INDEX_SPECULAR 2
298 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
299 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
300 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
301 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
302 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
303 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
304 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
305 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
306 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
307 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
308 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
309 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
312 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
313 MAT_BIT_FRONT_AMBIENT | \
314 MAT_BIT_FRONT_DIFFUSE | \
315 MAT_BIT_FRONT_SPECULAR | \
316 MAT_BIT_FRONT_SHININESS | \
317 MAT_BIT_FRONT_INDEXES)
319 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
320 MAT_BIT_BACK_AMBIENT | \
321 MAT_BIT_BACK_DIFFUSE | \
322 MAT_BIT_BACK_SPECULAR | \
323 MAT_BIT_BACK_SHININESS | \
324 MAT_BIT_BACK_INDEXES)
326 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
335 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
343 #define LIGHT_SPOT 0x1
344 #define LIGHT_LOCAL_VIEWER 0x2
345 #define LIGHT_POSITIONAL 0x4
346 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
351 * Light source state.
355 GLfloat Ambient
[4]; /**< ambient color */
356 GLfloat Diffuse
[4]; /**< diffuse color */
357 GLfloat Specular
[4]; /**< specular color */
358 GLfloat EyePosition
[4]; /**< position in eye coordinates */
359 GLfloat SpotDirection
[4]; /**< spotlight direction in eye coordinates */
360 GLfloat SpotExponent
;
361 GLfloat SpotCutoff
; /**< in degrees */
362 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
363 GLfloat ConstantAttenuation
;
364 GLfloat LinearAttenuation
;
365 GLfloat QuadraticAttenuation
;
366 GLboolean Enabled
; /**< On/off flag */
369 * \name Derived fields
372 GLbitfield _Flags
; /**< Mask of LIGHT_x bits defined above */
374 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
375 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
376 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
377 GLfloat _NormSpotDirection
[4]; /**< normalized spotlight direction */
378 GLfloat _VP_inf_spot_attenuation
;
380 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
381 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
382 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
392 GLfloat Ambient
[4]; /**< ambient color */
393 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
394 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
395 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
396 * or GL_SEPARATE_SPECULAR_COLOR */
401 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
403 struct gl_accum_attrib
405 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
410 * Used for storing clear color, texture border color, etc.
411 * The float values are typically unclamped.
422 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
424 struct gl_colorbuffer_attrib
426 GLuint ClearIndex
; /**< Index for glClear */
427 union gl_color_union ClearColor
; /**< Color for glClear, unclamped */
428 GLuint IndexMask
; /**< Color index write mask */
429 GLubyte ColorMask
[MAX_DRAW_BUFFERS
][4]; /**< Each flag is 0xff or 0x0 */
431 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
434 * \name alpha testing
437 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
438 GLenum AlphaFunc
; /**< Alpha test function */
439 GLfloat AlphaRefUnclamped
;
440 GLclampf AlphaRef
; /**< Alpha reference value */
447 GLbitfield BlendEnabled
; /**< Per-buffer blend enable flags */
449 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
450 * control, only on the fixed-pointness of the render target.
451 * The query does however depend on fragment color clamping.
453 GLfloat BlendColorUnclamped
[4]; /**< Blending color */
454 GLfloat BlendColor
[4]; /**< Blending color */
458 GLenum SrcRGB
; /**< RGB blend source term */
459 GLenum DstRGB
; /**< RGB blend dest term */
460 GLenum SrcA
; /**< Alpha blend source term */
461 GLenum DstA
; /**< Alpha blend dest term */
462 GLenum EquationRGB
; /**< GL_ADD, GL_SUBTRACT, etc. */
463 GLenum EquationA
; /**< GL_ADD, GL_SUBTRACT, etc. */
465 * Set if any blend factor uses SRC1. Computed at the time blend factors
468 GLboolean _UsesDualSrc
;
469 } Blend
[MAX_DRAW_BUFFERS
];
470 /** Are the blend func terms currently different for each buffer/target? */
471 GLboolean _BlendFuncPerBuffer
;
472 /** Are the blend equations currently different for each buffer/target? */
473 GLboolean _BlendEquationPerBuffer
;
476 * Which advanced blending mode is in use (or BLEND_NONE).
478 * KHR_blend_equation_advanced only allows advanced blending with a single
479 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
480 * requires all draw buffers to match, so we only need a single value.
482 enum gl_advanced_blend_mode _AdvancedBlendMode
;
484 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
492 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
493 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
494 GLenum LogicOp
; /**< Logic operator */
498 GLboolean DitherFlag
; /**< Dither enable flag */
500 GLboolean _ClampFragmentColor
; /** < with GL_FIXED_ONLY_ARB resolved */
501 GLenum ClampFragmentColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
502 GLenum ClampReadColor
; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
504 GLboolean sRGBEnabled
; /**< Framebuffer sRGB blending/updating requested */
509 * Current attribute group (GL_CURRENT_BIT).
511 struct gl_current_attrib
514 * \name Current vertex attributes (color, texcoords, etc).
515 * \note Values are valid only after FLUSH_VERTICES has been called.
516 * \note Index and Edgeflag current values are stored as floats in the
517 * SIX and SEVEN attribute slots.
518 * \note We need double storage for 64-bit vertex attributes
520 GLfloat Attrib
[VERT_ATTRIB_MAX
][4*2];
523 * \name Current raster position attributes (always up to date after a
526 GLfloat RasterPos
[4];
527 GLfloat RasterDistance
;
528 GLfloat RasterColor
[4];
529 GLfloat RasterSecondaryColor
[4];
530 GLfloat RasterTexCoords
[MAX_TEXTURE_COORD_UNITS
][4];
531 GLboolean RasterPosValid
;
536 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
538 struct gl_depthbuffer_attrib
540 GLenum Func
; /**< Function for depth buffer compare */
541 GLclampd Clear
; /**< Value to clear depth buffer to */
542 GLboolean Test
; /**< Depth buffering enabled flag */
543 GLboolean Mask
; /**< Depth buffer writable? */
544 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
545 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
550 * Evaluator attribute group (GL_EVAL_BIT).
552 struct gl_eval_attrib
558 GLboolean Map1Color4
;
560 GLboolean Map1Normal
;
561 GLboolean Map1TextureCoord1
;
562 GLboolean Map1TextureCoord2
;
563 GLboolean Map1TextureCoord3
;
564 GLboolean Map1TextureCoord4
;
565 GLboolean Map1Vertex3
;
566 GLboolean Map1Vertex4
;
567 GLboolean Map2Color4
;
569 GLboolean Map2Normal
;
570 GLboolean Map2TextureCoord1
;
571 GLboolean Map2TextureCoord2
;
572 GLboolean Map2TextureCoord3
;
573 GLboolean Map2TextureCoord4
;
574 GLboolean Map2Vertex3
;
575 GLboolean Map2Vertex4
;
576 GLboolean AutoNormal
;
580 * \name Map Grid endpoints and divisions and calculated du values
584 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
585 GLint MapGrid2un
, MapGrid2vn
;
586 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
587 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
593 * Compressed fog mode.
605 * Fog attribute group (GL_FOG_BIT).
609 GLboolean Enabled
; /**< Fog enabled flag */
610 GLboolean ColorSumEnabled
;
611 uint8_t _PackedMode
; /**< Fog mode as 2 bits */
612 uint8_t _PackedEnabledMode
; /**< Masked CompressedMode */
613 GLfloat ColorUnclamped
[4]; /**< Fog color */
614 GLfloat Color
[4]; /**< Fog color */
615 GLfloat Density
; /**< Density >= 0.0 */
616 GLfloat Start
; /**< Start distance in eye coords */
617 GLfloat End
; /**< End distance in eye coords */
618 GLfloat Index
; /**< Fog index */
619 GLenum Mode
; /**< Fog mode */
620 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
621 GLfloat _Scale
; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
622 GLenum FogDistanceMode
; /**< GL_NV_fog_distance */
627 * Hint attribute group (GL_HINT_BIT).
629 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
631 struct gl_hint_attrib
633 GLenum PerspectiveCorrection
;
636 GLenum PolygonSmooth
;
638 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
639 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
640 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
645 * Lighting attribute group (GL_LIGHT_BIT).
647 struct gl_light_attrib
649 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
650 struct gl_lightmodel Model
; /**< Lighting model */
653 * Front and back material values.
654 * Note: must call FLUSH_VERTICES() before using.
656 struct gl_material Material
;
658 GLboolean Enabled
; /**< Lighting enabled flag */
659 GLboolean ColorMaterialEnabled
;
661 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
662 GLenum ProvokingVertex
; /**< GL_EXT_provoking_vertex */
663 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
664 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
665 GLbitfield _ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
668 GLboolean _ClampVertexColor
;
669 GLenum ClampVertexColor
; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
672 * Derived state for optimizations:
675 GLbitfield _EnabledLights
; /**< bitmask containing enabled lights */
677 GLboolean _NeedEyeCoords
;
678 GLboolean _NeedVertices
; /**< Use fast shader? */
680 GLfloat _BaseColor
[2][3];
686 * Line attribute group (GL_LINE_BIT).
688 struct gl_line_attrib
690 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
691 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
692 GLushort StipplePattern
; /**< Stipple pattern */
693 GLint StippleFactor
; /**< Stipple repeat factor */
694 GLfloat Width
; /**< Line width */
699 * Display list attribute group (GL_LIST_BIT).
701 struct gl_list_attrib
708 * Multisample attribute group (GL_MULTISAMPLE_BIT).
710 struct gl_multisample_attrib
713 GLboolean SampleAlphaToCoverage
;
714 GLboolean SampleAlphaToOne
;
715 GLboolean SampleCoverage
;
716 GLboolean SampleCoverageInvert
;
717 GLboolean SampleShading
;
719 /* ARB_texture_multisample / GL3.2 additions */
720 GLboolean SampleMask
;
722 GLfloat SampleCoverageValue
; /**< In range [0, 1] */
723 GLfloat MinSampleShadingValue
; /**< In range [0, 1] */
725 /** The GL spec defines this as an array but >32x MSAA is madness */
726 GLbitfield SampleMaskValue
;
731 * A pixelmap (see glPixelMap)
736 GLfloat Map
[MAX_PIXEL_MAP_TABLE
];
741 * Collection of all pixelmaps
745 struct gl_pixelmap RtoR
; /**< i.e. GL_PIXEL_MAP_R_TO_R */
746 struct gl_pixelmap GtoG
;
747 struct gl_pixelmap BtoB
;
748 struct gl_pixelmap AtoA
;
749 struct gl_pixelmap ItoR
;
750 struct gl_pixelmap ItoG
;
751 struct gl_pixelmap ItoB
;
752 struct gl_pixelmap ItoA
;
753 struct gl_pixelmap ItoI
;
754 struct gl_pixelmap StoS
;
759 * Pixel attribute group (GL_PIXEL_MODE_BIT).
761 struct gl_pixel_attrib
763 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
765 /*--- Begin Pixel Transfer State ---*/
766 /* Fields are in the order in which they're applied... */
768 /** Scale & Bias (index shift, offset) */
770 GLfloat RedBias
, RedScale
;
771 GLfloat GreenBias
, GreenScale
;
772 GLfloat BlueBias
, BlueScale
;
773 GLfloat AlphaBias
, AlphaScale
;
774 GLfloat DepthBias
, DepthScale
;
775 GLint IndexShift
, IndexOffset
;
779 /* Note: actual pixel maps are not part of this attrib group */
780 GLboolean MapColorFlag
;
781 GLboolean MapStencilFlag
;
783 /*--- End Pixel Transfer State ---*/
786 GLfloat ZoomX
, ZoomY
;
791 * Point attribute group (GL_POINT_BIT).
793 struct gl_point_attrib
795 GLfloat Size
; /**< User-specified point size */
796 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
797 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
798 GLfloat Threshold
; /**< GL_EXT_point_parameters */
799 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
800 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
801 GLboolean PointSprite
; /**< GL_NV/ARB_point_sprite */
802 GLbitfield CoordReplace
; /**< GL_ARB_point_sprite*/
803 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
804 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
809 * Polygon attribute group (GL_POLYGON_BIT).
811 struct gl_polygon_attrib
813 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
814 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
815 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
816 GLboolean CullFlag
; /**< Culling on/off flag */
817 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
818 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
819 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
820 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
821 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
822 GLfloat OffsetClamp
; /**< Polygon offset clamp, from user */
823 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
824 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
825 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
830 * Scissor attributes (GL_SCISSOR_BIT).
832 struct gl_scissor_rect
834 GLint X
, Y
; /**< Lower left corner of box */
835 GLsizei Width
, Height
; /**< Size of box */
837 struct gl_scissor_attrib
839 GLbitfield EnableFlags
; /**< Scissor test enabled? */
840 struct gl_scissor_rect ScissorArray
[MAX_VIEWPORTS
];
841 GLint NumWindowRects
; /**< Count of enabled window rectangles */
842 GLenum WindowRectMode
; /**< Whether to include or exclude the rects */
843 struct gl_scissor_rect WindowRects
[MAX_WINDOW_RECTANGLES
];
848 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
850 * Three sets of stencil data are tracked so that OpenGL 2.0,
851 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
852 * simultaneously. In each of the stencil state arrays, element 0 corresponds
853 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
854 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
855 * GL_EXT_stencil_two_side GL_BACK state.
857 * The derived value \c _BackFace is either 1 or 2 depending on whether or
858 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
860 * The derived value \c _TestTwoSide is set when the front-face and back-face
861 * stencil state are different.
863 struct gl_stencil_attrib
865 GLboolean Enabled
; /**< Enabled flag */
866 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
867 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 2) */
868 GLubyte _BackFace
; /**< Current back stencil state (1 or 2) */
869 GLenum Function
[3]; /**< Stencil function */
870 GLenum FailFunc
[3]; /**< Fail function */
871 GLenum ZPassFunc
[3]; /**< Depth buffer pass function */
872 GLenum ZFailFunc
[3]; /**< Depth buffer fail function */
873 GLint Ref
[3]; /**< Reference value */
874 GLuint ValueMask
[3]; /**< Value mask */
875 GLuint WriteMask
[3]; /**< Write mask */
876 GLuint Clear
; /**< Clear value */
881 * An index for each type of texture object. These correspond to the GL
882 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
883 * Note: the order is from highest priority to lowest priority.
887 TEXTURE_2D_MULTISAMPLE_INDEX
,
888 TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
,
889 TEXTURE_CUBE_ARRAY_INDEX
,
890 TEXTURE_BUFFER_INDEX
,
891 TEXTURE_2D_ARRAY_INDEX
,
892 TEXTURE_1D_ARRAY_INDEX
,
893 TEXTURE_EXTERNAL_INDEX
,
904 * Bit flags for each type of texture object
907 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
908 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
909 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
910 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
911 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
912 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
913 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
914 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
915 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
916 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
917 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
918 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
923 * Texture image state. Drivers will typically create a subclass of this
924 * with extra fields for memory buffers, etc.
926 struct gl_texture_image
928 GLint InternalFormat
; /**< Internal format as given by the user */
929 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
930 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
931 * GL_INTENSITY, GL_DEPTH_COMPONENT or
932 * GL_DEPTH_STENCIL_EXT only. Used for
933 * choosing TexEnv arithmetic.
935 mesa_format TexFormat
; /**< The actual texture memory format */
937 GLuint Border
; /**< 0 or 1 */
938 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
939 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
940 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
941 GLuint Width2
; /**< = Width - 2*Border */
942 GLuint Height2
; /**< = Height - 2*Border */
943 GLuint Depth2
; /**< = Depth - 2*Border */
944 GLuint WidthLog2
; /**< = log2(Width2) */
945 GLuint HeightLog2
; /**< = log2(Height2) */
946 GLuint DepthLog2
; /**< = log2(Depth2) */
947 GLuint MaxNumLevels
; /**< = maximum possible number of mipmap
948 levels, computed from the dimensions */
950 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
951 GLuint Level
; /**< Which mipmap level am I? */
952 /** Cube map face: index into gl_texture_object::Image[] array */
955 /** GL_ARB_texture_multisample */
956 GLuint NumSamples
; /**< Sample count, or 0 for non-multisample */
957 GLboolean FixedSampleLocations
; /**< Same sample locations for all pixels? */
962 * Indexes for cube map faces.
977 * Sampler object state. These objects are new with GL_ARB_sampler_objects
978 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
980 struct gl_sampler_object
985 GLchar
*Label
; /**< GL_KHR_debug */
987 GLenum WrapS
; /**< S-axis texture image wrap mode */
988 GLenum WrapT
; /**< T-axis texture image wrap mode */
989 GLenum WrapR
; /**< R-axis texture image wrap mode */
990 GLenum MinFilter
; /**< minification filter */
991 GLenum MagFilter
; /**< magnification filter */
992 union gl_color_union BorderColor
; /**< Interpreted according to texture format */
993 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
994 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
995 GLfloat LodBias
; /**< OpenGL 1.4 */
996 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
997 GLenum CompareMode
; /**< GL_ARB_shadow */
998 GLenum CompareFunc
; /**< GL_ARB_shadow */
999 GLenum sRGBDecode
; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
1000 GLboolean CubeMapSeamless
; /**< GL_AMD_seamless_cubemap_per_texture */
1002 /** GL_ARB_bindless_texture */
1003 bool HandleAllocated
;
1004 struct util_dynarray Handles
;
1009 * Texture object state. Contains the array of mipmap images, border color,
1010 * wrap modes, filter modes, and shadow/texcompare state.
1012 struct gl_texture_object
1014 simple_mtx_t Mutex
; /**< for thread safety */
1015 GLint RefCount
; /**< reference count */
1016 GLuint Name
; /**< the user-visible texture object ID */
1017 GLchar
*Label
; /**< GL_KHR_debug */
1018 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1019 gl_texture_index TargetIndex
; /**< The gl_texture_unit::CurrentTex index.
1020 Only valid when Target is valid. */
1022 struct gl_sampler_object Sampler
;
1024 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1026 GLfloat Priority
; /**< in [0,1] */
1027 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1028 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1029 GLint ImmutableLevels
; /**< ES 3.0 / ARB_texture_view */
1030 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1031 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - p in spec) */
1032 GLint CropRect
[4]; /**< GL_OES_draw_texture */
1033 GLenum Swizzle
[4]; /**< GL_EXT_texture_swizzle */
1034 GLuint _Swizzle
; /**< same as Swizzle, but SWIZZLE_* format */
1035 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1036 GLboolean _BaseComplete
; /**< Is the base texture level valid? */
1037 GLboolean _MipmapComplete
; /**< Is the whole mipmap valid? */
1038 GLboolean _IsIntegerFormat
; /**< Does the texture store integer values? */
1039 GLboolean _RenderToTexture
; /**< Any rendering to this texture? */
1040 GLboolean Purgeable
; /**< Is the buffer purgeable under memory
1042 GLboolean Immutable
; /**< GL_ARB_texture_storage */
1043 GLboolean _IsFloat
; /**< GL_OES_float_texture */
1044 GLboolean _IsHalfFloat
; /**< GL_OES_half_float_texture */
1045 bool StencilSampling
; /**< Should we sample stencil instead of depth? */
1046 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1048 GLuint MinLevel
; /**< GL_ARB_texture_view */
1049 GLuint MinLayer
; /**< GL_ARB_texture_view */
1050 GLuint NumLevels
; /**< GL_ARB_texture_view */
1051 GLuint NumLayers
; /**< GL_ARB_texture_view */
1053 /** GL_EXT_memory_object */
1054 GLenum TextureTiling
;
1056 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1057 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1059 /** GL_ARB_texture_buffer_object */
1060 struct gl_buffer_object
*BufferObject
;
1061 GLenum BufferObjectFormat
;
1062 /** Equivalent Mesa format for BufferObjectFormat. */
1063 mesa_format _BufferObjectFormat
;
1064 /** GL_ARB_texture_buffer_range */
1065 GLintptr BufferOffset
;
1066 GLsizeiptr BufferSize
; /**< if this is -1, use BufferObject->Size instead */
1068 /** GL_OES_EGL_image_external */
1069 GLint RequiredTextureImageUnits
;
1071 /** GL_ARB_shader_image_load_store */
1072 GLenum ImageFormatCompatibilityType
;
1074 /** GL_ARB_bindless_texture */
1075 struct util_dynarray SamplerHandles
;
1076 struct util_dynarray ImageHandles
;
1080 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1081 #define MAX_COMBINER_TERMS 4
1085 * Texture combine environment state.
1087 struct gl_tex_env_combine_state
1089 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1090 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1091 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1092 GLenum SourceRGB
[MAX_COMBINER_TERMS
];
1093 GLenum SourceA
[MAX_COMBINER_TERMS
];
1094 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1095 GLenum OperandRGB
[MAX_COMBINER_TERMS
];
1096 GLenum OperandA
[MAX_COMBINER_TERMS
];
1097 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1098 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1099 GLuint _NumArgsRGB
; /**< Number of inputs used for the RGB combiner */
1100 GLuint _NumArgsA
; /**< Number of inputs used for the A combiner */
1104 /** Compressed TexEnv effective Combine mode */
1105 enum gl_tex_env_mode
1107 TEXENV_MODE_REPLACE
, /* r = a0 */
1108 TEXENV_MODE_MODULATE
, /* r = a0 * a1 */
1109 TEXENV_MODE_ADD
, /* r = a0 + a1 */
1110 TEXENV_MODE_ADD_SIGNED
, /* r = a0 + a1 - 0.5 */
1111 TEXENV_MODE_INTERPOLATE
, /* r = a0 * a2 + a1 * (1 - a2) */
1112 TEXENV_MODE_SUBTRACT
, /* r = a0 - a1 */
1113 TEXENV_MODE_DOT3_RGB
, /* r = a0 . a1 */
1114 TEXENV_MODE_DOT3_RGB_EXT
, /* r = a0 . a1 */
1115 TEXENV_MODE_DOT3_RGBA
, /* r = a0 . a1 */
1116 TEXENV_MODE_DOT3_RGBA_EXT
, /* r = a0 . a1 */
1117 TEXENV_MODE_MODULATE_ADD_ATI
, /* r = a0 * a2 + a1 */
1118 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI
, /* r = a0 * a2 + a1 - 0.5 */
1119 TEXENV_MODE_MODULATE_SUBTRACT_ATI
, /* r = a0 * a2 - a1 */
1120 TEXENV_MODE_ADD_PRODUCTS_NV
, /* r = a0 * a1 + a2 * a3 */
1121 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV
, /* r = a0 * a1 + a2 * a3 - 0.5 */
1125 /** Compressed TexEnv Combine source */
1126 enum gl_tex_env_source
1128 TEXENV_SRC_TEXTURE0
,
1129 TEXENV_SRC_TEXTURE1
,
1130 TEXENV_SRC_TEXTURE2
,
1131 TEXENV_SRC_TEXTURE3
,
1132 TEXENV_SRC_TEXTURE4
,
1133 TEXENV_SRC_TEXTURE5
,
1134 TEXENV_SRC_TEXTURE6
,
1135 TEXENV_SRC_TEXTURE7
,
1137 TEXENV_SRC_PREVIOUS
,
1138 TEXENV_SRC_PRIMARY_COLOR
,
1139 TEXENV_SRC_CONSTANT
,
1145 /** Compressed TexEnv Combine operand */
1146 enum gl_tex_env_operand
1149 TEXENV_OPR_ONE_MINUS_COLOR
,
1151 TEXENV_OPR_ONE_MINUS_ALPHA
,
1155 /** Compressed TexEnv Combine argument */
1156 struct gl_tex_env_argument
1159 __extension__
uint8_t Source
:4; /**< TEXENV_SRC_x */
1160 __extension__
uint8_t Operand
:2; /**< TEXENV_OPR_x */
1162 uint8_t Source
; /**< SRC_x */
1163 uint8_t Operand
; /**< OPR_x */
1169 * Compressed TexEnv Combine state.
1171 struct gl_tex_env_combine_packed
1173 uint32_t ModeRGB
:4; /**< Effective mode for RGB as 4 bits */
1174 uint32_t ModeA
:4; /**< Effective mode for RGB as 4 bits */
1175 uint32_t ScaleShiftRGB
:2; /**< 0, 1 or 2 */
1176 uint32_t ScaleShiftA
:2; /**< 0, 1 or 2 */
1177 uint32_t NumArgsRGB
:3; /**< Number of inputs used for the RGB combiner */
1178 uint32_t NumArgsA
:3; /**< Number of inputs used for the A combiner */
1179 /** Source arguments in a packed manner */
1180 struct gl_tex_env_argument ArgsRGB
[MAX_COMBINER_TERMS
];
1181 struct gl_tex_env_argument ArgsA
[MAX_COMBINER_TERMS
];
1186 * TexGenEnabled flags.
1193 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1198 * Bit flag versions of the corresponding GL_ constants.
1201 #define TEXGEN_SPHERE_MAP 0x1
1202 #define TEXGEN_OBJ_LINEAR 0x2
1203 #define TEXGEN_EYE_LINEAR 0x4
1204 #define TEXGEN_REFLECTION_MAP_NV 0x8
1205 #define TEXGEN_NORMAL_MAP_NV 0x10
1207 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1208 TEXGEN_REFLECTION_MAP_NV | \
1209 TEXGEN_NORMAL_MAP_NV)
1210 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1211 TEXGEN_REFLECTION_MAP_NV | \
1212 TEXGEN_NORMAL_MAP_NV | \
1218 /** Tex-gen enabled for texture unit? */
1219 #define ENABLE_TEXGEN(unit) (1 << (unit))
1221 /** Non-identity texture matrix for texture unit? */
1222 #define ENABLE_TEXMAT(unit) (1 << (unit))
1226 * Texture coord generation state.
1230 GLenum Mode
; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1231 GLbitfield _ModeBit
; /**< TEXGEN_x bit corresponding to Mode */
1232 GLfloat ObjectPlane
[4];
1233 GLfloat EyePlane
[4];
1238 * Texture unit state. Contains enable flags, texture environment/function/
1239 * combiners, texgen state, and pointers to current texture objects.
1241 struct gl_texture_unit
1243 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1245 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1246 GLclampf EnvColor
[4];
1247 GLfloat EnvColorUnclamped
[4];
1249 struct gl_texgen GenS
;
1250 struct gl_texgen GenT
;
1251 struct gl_texgen GenR
;
1252 struct gl_texgen GenQ
;
1253 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1254 GLbitfield _GenFlags
; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1256 GLfloat LodBias
; /**< for biasing mipmap levels */
1258 /** Texture targets that have a non-default texture bound */
1259 GLbitfield _BoundTextures
;
1261 /** Current sampler object (GL_ARB_sampler_objects) */
1262 struct gl_sampler_object
*Sampler
;
1265 * \name GL_EXT_texture_env_combine
1267 struct gl_tex_env_combine_state Combine
;
1270 * Derived state based on \c EnvMode and the \c BaseFormat of the
1271 * currently enabled texture.
1273 struct gl_tex_env_combine_state _EnvMode
;
1276 * Currently enabled combiner state. This will point to either
1277 * \c Combine or \c _EnvMode.
1279 struct gl_tex_env_combine_state
*_CurrentCombine
;
1281 /** Current texture object pointers */
1282 struct gl_texture_object
*CurrentTex
[NUM_TEXTURE_TARGETS
];
1284 /** Points to highest priority, complete and enabled texture object */
1285 struct gl_texture_object
*_Current
;
1287 /** Current compressed TexEnv & Combine state */
1288 struct gl_tex_env_combine_packed _CurrentCombinePacked
;
1293 * Texture attribute group (GL_TEXTURE_BIT).
1295 struct gl_texture_attrib
1297 GLuint CurrentUnit
; /**< GL_ACTIVE_TEXTURE */
1299 /** GL_ARB_seamless_cubemap */
1300 GLboolean CubeMapSeamless
;
1302 struct gl_texture_object
*ProxyTex
[NUM_TEXTURE_TARGETS
];
1304 /** GL_ARB_texture_buffer_object */
1305 struct gl_buffer_object
*BufferObject
;
1307 /** Texture coord units/sets used for fragment texturing */
1308 GLbitfield _EnabledCoordUnits
;
1310 /** Texture coord units that have texgen enabled */
1311 GLbitfield _TexGenEnabled
;
1313 /** Texture coord units that have non-identity matrices */
1314 GLbitfield _TexMatEnabled
;
1316 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1317 GLbitfield _GenFlags
;
1319 /** Largest index of a texture unit with _Current != NULL. */
1320 GLint _MaxEnabledTexImageUnit
;
1322 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1323 GLint NumCurrentTexUsed
;
1325 struct gl_texture_unit Unit
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
1330 * Data structure representing a single clip plane (e.g. one of the elements
1331 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1333 typedef GLfloat gl_clip_plane
[4];
1337 * Transformation attribute group (GL_TRANSFORM_BIT).
1339 struct gl_transform_attrib
1341 GLenum MatrixMode
; /**< Matrix mode */
1342 gl_clip_plane EyeUserPlane
[MAX_CLIP_PLANES
]; /**< User clip planes */
1343 gl_clip_plane _ClipUserPlane
[MAX_CLIP_PLANES
]; /**< derived */
1344 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1345 GLboolean Normalize
; /**< Normalize all normals? */
1346 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1347 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1348 GLboolean DepthClamp
; /**< GL_ARB_depth_clamp */
1349 /** GL_ARB_clip_control */
1350 GLenum ClipOrigin
; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1351 GLenum ClipDepthMode
; /**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1356 * Viewport attribute group (GL_VIEWPORT_BIT).
1358 struct gl_viewport_attrib
1360 GLfloat X
, Y
; /**< position */
1361 GLfloat Width
, Height
; /**< size */
1362 GLdouble Near
, Far
; /**< Depth buffer range */
1371 } gl_map_buffer_index
;
1375 * Fields describing a mapped buffer range.
1377 struct gl_buffer_mapping
{
1378 GLbitfield AccessFlags
; /**< Mask of GL_MAP_x_BIT flags */
1379 GLvoid
*Pointer
; /**< User-space address of mapping */
1380 GLintptr Offset
; /**< Mapped offset */
1381 GLsizeiptr Length
; /**< Mapped length */
1386 * Usages we've seen for a buffer object.
1389 USAGE_UNIFORM_BUFFER
= 0x1,
1390 USAGE_TEXTURE_BUFFER
= 0x2,
1391 USAGE_ATOMIC_COUNTER_BUFFER
= 0x4,
1392 USAGE_SHADER_STORAGE_BUFFER
= 0x8,
1393 USAGE_TRANSFORM_FEEDBACK_BUFFER
= 0x10,
1394 USAGE_PIXEL_PACK_BUFFER
= 0x20,
1395 USAGE_DISABLE_MINMAX_CACHE
= 0x40,
1400 * GL_ARB_vertex/pixel_buffer_object buffer object
1402 struct gl_buffer_object
1407 GLchar
*Label
; /**< GL_KHR_debug */
1408 GLenum Usage
; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1409 GLbitfield StorageFlags
; /**< GL_MAP_PERSISTENT_BIT, etc. */
1410 GLsizeiptrARB Size
; /**< Size of buffer storage in bytes */
1411 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1412 GLboolean DeletePending
; /**< true if buffer object is removed from the hash */
1413 GLboolean Written
; /**< Ever written to? (for debugging) */
1414 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
1415 GLboolean Immutable
; /**< GL_ARB_buffer_storage */
1416 gl_buffer_usage UsageHistory
; /**< How has this buffer been used so far? */
1418 /** Counters used for buffer usage warnings */
1419 GLuint NumSubDataCalls
;
1420 GLuint NumMapBufferWriteCalls
;
1422 struct gl_buffer_mapping Mappings
[MAP_COUNT
];
1424 /** Memoization of min/max index computations for static index buffers */
1425 struct hash_table
*MinMaxCache
;
1426 unsigned MinMaxCacheHitIndices
;
1427 unsigned MinMaxCacheMissIndices
;
1428 bool MinMaxCacheDirty
;
1430 bool HandleAllocated
; /**< GL_ARB_bindless_texture */
1435 * Client pixel packing/unpacking attributes
1437 struct gl_pixelstore_attrib
1445 GLboolean SwapBytes
;
1447 GLboolean Invert
; /**< GL_MESA_pack_invert */
1448 GLint CompressedBlockWidth
; /**< GL_ARB_compressed_texture_pixel_storage */
1449 GLint CompressedBlockHeight
;
1450 GLint CompressedBlockDepth
;
1451 GLint CompressedBlockSize
;
1452 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1457 * Vertex array information which is derived from gl_array_attributes
1458 * and gl_vertex_buffer_binding information. Used by the VBO module and
1461 struct gl_vertex_array
1463 GLint Size
; /**< components per element (1,2,3,4) */
1464 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1465 GLenum Format
; /**< default: GL_RGBA, but may be GL_BGRA */
1466 GLsizei StrideB
; /**< actual stride in bytes */
1467 GLuint _ElementSize
; /**< size of each element in bytes */
1468 const GLubyte
*Ptr
; /**< Points to array data */
1469 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1470 GLboolean Integer
; /**< Integer-valued? */
1471 GLboolean Doubles
; /**< double precision values are not converted to floats */
1472 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1474 struct gl_buffer_object
*BufferObj
;/**< GL_ARB_vertex_buffer_object */
1479 * Attributes to describe a vertex array.
1481 * Contains the size, type, format and normalization flag,
1482 * along with the index of a vertex buffer binding point.
1484 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1485 * and is only present for backwards compatibility reasons.
1486 * Rendering always uses VERTEX_BINDING_STRIDE.
1487 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1488 * and VERTEX_BINDING_STRIDE to the same value, while
1489 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1491 struct gl_array_attributes
1493 GLint Size
; /**< Components per element (1,2,3,4) */
1494 GLenum Type
; /**< Datatype: GL_FLOAT, GL_INT, etc */
1495 GLenum Format
; /**< Default: GL_RGBA, but may be GL_BGRA */
1496 GLsizei Stride
; /**< Stride as specified with gl*Pointer() */
1497 const GLubyte
*Ptr
; /**< Points to client array data. Not used when a VBO is bound */
1498 GLintptr RelativeOffset
; /**< Offset of the first element relative to the binding offset */
1499 GLboolean Enabled
; /**< Whether the array is enabled */
1500 GLboolean Normalized
; /**< Fixed-point values are normalized when converted to floats */
1501 GLboolean Integer
; /**< Fixed-point values are not converted to floats */
1502 GLboolean Doubles
; /**< double precision values are not converted to floats */
1503 GLuint _ElementSize
; /**< Size of each element in bytes */
1504 GLuint BufferBindingIndex
; /**< Vertex buffer binding */
1509 * This describes the buffer object used for a vertex array (or
1510 * multiple vertex arrays). If BufferObj points to the default/null
1511 * buffer object, then the vertex array lives in user memory and not a VBO.
1513 struct gl_vertex_buffer_binding
1515 GLintptr Offset
; /**< User-specified offset */
1516 GLsizei Stride
; /**< User-specified stride */
1517 GLuint InstanceDivisor
; /**< GL_ARB_instanced_arrays */
1518 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_vertex_buffer_object */
1519 GLbitfield _BoundArrays
; /**< Arrays bound to this binding point */
1524 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1525 * the GL_ARB_vertex_array_object extension.
1527 struct gl_vertex_array_object
1529 /** Name of the VAO as received from glGenVertexArray. */
1534 GLchar
*Label
; /**< GL_KHR_debug */
1537 * Has this array object been bound?
1539 GLboolean EverBound
;
1542 * Derived vertex attribute arrays
1544 * This is a legacy data structure created from gl_vertex_attrib_array and
1545 * gl_vertex_buffer_binding, for compatibility with existing driver code.
1547 struct gl_vertex_array _VertexAttrib
[VERT_ATTRIB_MAX
];
1549 /** Vertex attribute arrays */
1550 struct gl_array_attributes VertexAttrib
[VERT_ATTRIB_MAX
];
1552 /** Vertex buffer bindings */
1553 struct gl_vertex_buffer_binding BufferBinding
[VERT_ATTRIB_MAX
];
1555 /** Mask indicating which vertex arrays have vertex buffer associated. */
1556 GLbitfield VertexAttribBufferMask
;
1558 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1559 GLbitfield _Enabled
;
1561 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1562 GLbitfield NewArrays
;
1564 /** The index buffer (also known as the element array buffer in OpenGL). */
1565 struct gl_buffer_object
*IndexBufferObj
;
1569 /** Used to signal when transitioning from one kind of drawing method
1573 DRAW_NONE
, /**< Initial value only */
1580 * Enum for the OpenGL APIs we know about and may support.
1582 * NOTE: This must match the api_enum table in
1583 * src/mesa/main/get_hash_generator.py
1587 API_OPENGL_COMPAT
, /* legacy / compatibility contexts */
1591 API_OPENGL_LAST
= API_OPENGL_CORE
1595 * Vertex array state
1597 struct gl_array_attrib
1599 /** Currently bound array object. */
1600 struct gl_vertex_array_object
*VAO
;
1602 /** The default vertex array object */
1603 struct gl_vertex_array_object
*DefaultVAO
;
1605 /** The last VAO accessed by a DSA function */
1606 struct gl_vertex_array_object
*LastLookedUpVAO
;
1608 /** Array objects (GL_ARB_vertex_array_object) */
1609 struct _mesa_HashTable
*Objects
;
1611 GLint ActiveTexture
; /**< Client Active Texture */
1612 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1613 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1616 * \name Primitive restart controls
1618 * Primitive restart is enabled if either \c PrimitiveRestart or
1619 * \c PrimitiveRestartFixedIndex is set.
1622 GLboolean PrimitiveRestart
;
1623 GLboolean PrimitiveRestartFixedIndex
;
1624 GLboolean _PrimitiveRestart
;
1625 GLuint RestartIndex
;
1628 /** One of the DRAW_xxx flags, not consumed by drivers */
1629 gl_draw_method DrawMethod
;
1631 /* GL_ARB_vertex_buffer_object */
1632 struct gl_buffer_object
*ArrayBufferObj
;
1635 * Vertex arrays as consumed by a driver.
1636 * The array pointer is set up only by the VBO module.
1638 const struct gl_vertex_array
**_DrawArrays
; /**< 0..VERT_ATTRIB_MAX-1 */
1640 /** Legal array datatypes and the API for which they have been computed */
1641 GLbitfield LegalTypesMask
;
1642 gl_api LegalTypesMaskAPI
;
1647 * Feedback buffer state
1652 GLbitfield _Mask
; /**< FB_* bits */
1660 * Selection buffer state
1664 GLuint
*Buffer
; /**< selection buffer */
1665 GLuint BufferSize
; /**< size of the selection buffer */
1666 GLuint BufferCount
; /**< number of values in the selection buffer */
1667 GLuint Hits
; /**< number of records in the selection buffer */
1668 GLuint NameStackDepth
; /**< name stack depth */
1669 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1670 GLboolean HitFlag
; /**< hit flag */
1671 GLfloat HitMinZ
; /**< minimum hit depth */
1672 GLfloat HitMaxZ
; /**< maximum hit depth */
1677 * 1-D Evaluator control points
1681 GLuint Order
; /**< Number of control points */
1682 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1683 GLfloat
*Points
; /**< Points to contiguous control points */
1688 * 2-D Evaluator control points
1692 GLuint Uorder
; /**< Number of control points in U dimension */
1693 GLuint Vorder
; /**< Number of control points in V dimension */
1696 GLfloat
*Points
; /**< Points to contiguous control points */
1701 * All evaluator control point state
1703 struct gl_evaluators
1709 struct gl_1d_map Map1Vertex3
;
1710 struct gl_1d_map Map1Vertex4
;
1711 struct gl_1d_map Map1Index
;
1712 struct gl_1d_map Map1Color4
;
1713 struct gl_1d_map Map1Normal
;
1714 struct gl_1d_map Map1Texture1
;
1715 struct gl_1d_map Map1Texture2
;
1716 struct gl_1d_map Map1Texture3
;
1717 struct gl_1d_map Map1Texture4
;
1724 struct gl_2d_map Map2Vertex3
;
1725 struct gl_2d_map Map2Vertex4
;
1726 struct gl_2d_map Map2Index
;
1727 struct gl_2d_map Map2Color4
;
1728 struct gl_2d_map Map2Normal
;
1729 struct gl_2d_map Map2Texture1
;
1730 struct gl_2d_map Map2Texture2
;
1731 struct gl_2d_map Map2Texture3
;
1732 struct gl_2d_map Map2Texture4
;
1737 struct gl_transform_feedback_varying_info
1748 * Per-output info vertex shaders for transform feedback.
1750 struct gl_transform_feedback_output
1752 uint32_t OutputRegister
;
1753 uint32_t OutputBuffer
;
1754 uint32_t NumComponents
;
1757 /** offset (in DWORDs) of this output within the interleaved structure */
1761 * Offset into the output register of the data to output. For example,
1762 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1763 * offset is in the y and z components of the output register.
1765 uint32_t ComponentOffset
;
1769 struct gl_transform_feedback_buffer
1773 uint32_t NumVaryings
;
1776 * Total number of components stored in each buffer. This may be used by
1777 * hardware back-ends to determine the correct stride when interleaving
1778 * multiple transform feedback outputs in the same buffer.
1783 * Which transform feedback stream this buffer binding is associated with.
1789 /** Post-link transform feedback info. */
1790 struct gl_transform_feedback_info
1792 /* Was xfb enabled via the api or in shader layout qualifiers */
1795 unsigned NumOutputs
;
1797 /* Bitmask of active buffer indices. */
1798 unsigned ActiveBuffers
;
1800 struct gl_transform_feedback_output
*Outputs
;
1802 /** Transform feedback varyings used for the linking of this shader program.
1804 * Use for glGetTransformFeedbackVarying().
1806 struct gl_transform_feedback_varying_info
*Varyings
;
1809 struct gl_transform_feedback_buffer Buffers
[MAX_FEEDBACK_BUFFERS
];
1814 * Transform feedback object state
1816 struct gl_transform_feedback_object
1818 GLuint Name
; /**< AKA the object ID */
1820 GLchar
*Label
; /**< GL_KHR_debug */
1821 GLboolean Active
; /**< Is transform feedback enabled? */
1822 GLboolean Paused
; /**< Is transform feedback paused? */
1823 GLboolean EndedAnytime
; /**< Has EndTransformFeedback been called
1825 GLboolean EverBound
; /**< Has this object been bound? */
1828 * GLES: if Active is true, remaining number of primitives which can be
1829 * rendered without overflow. This is necessary to track because GLES
1830 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1831 * glDrawArraysInstanced would overflow transform feedback buffers.
1832 * Undefined if Active is false.
1834 * Not tracked for desktop GL since it's unnecessary.
1836 unsigned GlesRemainingPrims
;
1839 * The program active when BeginTransformFeedback() was called.
1840 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1841 * where stage is the pipeline stage that is the source of data for
1842 * transform feedback.
1844 struct gl_program
*program
;
1846 /** The feedback buffers */
1847 GLuint BufferNames
[MAX_FEEDBACK_BUFFERS
];
1848 struct gl_buffer_object
*Buffers
[MAX_FEEDBACK_BUFFERS
];
1850 /** Start of feedback data in dest buffer */
1851 GLintptr Offset
[MAX_FEEDBACK_BUFFERS
];
1854 * Max data to put into dest buffer (in bytes). Computed based on
1855 * RequestedSize and the actual size of the buffer.
1857 GLsizeiptr Size
[MAX_FEEDBACK_BUFFERS
];
1860 * Size that was specified when the buffer was bound. If the buffer was
1861 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1864 GLsizeiptr RequestedSize
[MAX_FEEDBACK_BUFFERS
];
1869 * Context state for transform feedback.
1871 struct gl_transform_feedback_state
1873 GLenum Mode
; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1875 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1876 struct gl_buffer_object
*CurrentBuffer
;
1878 /** The table of all transform feedback objects */
1879 struct _mesa_HashTable
*Objects
;
1881 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1882 struct gl_transform_feedback_object
*CurrentObject
;
1884 /** The default xform-fb object (Name==0) */
1885 struct gl_transform_feedback_object
*DefaultObject
;
1890 * A "performance monitor" as described in AMD_performance_monitor.
1892 struct gl_perf_monitor_object
1896 /** True if the monitor is currently active (Begin called but not End). */
1900 * True if the monitor has ended.
1902 * This is distinct from !Active because it may never have began.
1907 * A list of groups with currently active counters.
1909 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1911 unsigned *ActiveGroups
;
1914 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1916 * Checking whether counter 'c' in group 'g' is active can be done via:
1918 * BITSET_TEST(ActiveCounters[g], c)
1920 GLuint
**ActiveCounters
;
1924 union gl_perf_monitor_counter_value
1932 struct gl_perf_monitor_counter
1934 /** Human readable name for the counter. */
1938 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1939 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1943 /** Minimum counter value. */
1944 union gl_perf_monitor_counter_value Minimum
;
1946 /** Maximum counter value. */
1947 union gl_perf_monitor_counter_value Maximum
;
1951 struct gl_perf_monitor_group
1953 /** Human readable name for the group. */
1957 * Maximum number of counters in this group which can be active at the
1960 GLuint MaxActiveCounters
;
1962 /** Array of counters within this group. */
1963 const struct gl_perf_monitor_counter
*Counters
;
1969 * A query object instance as described in INTEL_performance_query.
1971 * NB: We want to keep this and the corresponding backend structure
1972 * relatively lean considering that applications may expect to
1973 * allocate enough objects to be able to query around all draw calls
1976 struct gl_perf_query_object
1978 GLuint Id
; /**< hash table ID/name */
1979 unsigned Used
:1; /**< has been used for 1 or more queries */
1980 unsigned Active
:1; /**< inside Begin/EndPerfQuery */
1981 unsigned Ready
:1; /**< result is ready? */
1986 * Context state for AMD_performance_monitor.
1988 struct gl_perf_monitor_state
1990 /** Array of performance monitor groups (indexed by group ID) */
1991 const struct gl_perf_monitor_group
*Groups
;
1994 /** The table of all performance monitors. */
1995 struct _mesa_HashTable
*Monitors
;
2000 * Context state for INTEL_performance_query.
2002 struct gl_perf_query_state
2004 struct _mesa_HashTable
*Objects
; /**< The table of all performance query objects */
2009 * A bindless sampler object.
2011 struct gl_bindless_sampler
2013 /** Texture unit (set by glUniform1()). */
2016 /** Whether this bindless sampler is bound to a unit. */
2019 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2020 gl_texture_index target
;
2022 /** Pointer to the base of the data. */
2027 * A bindless image object.
2029 struct gl_bindless_image
2031 /** Image unit (set by glUniform1()). */
2034 /** Whether this bindless image is bound to a unit. */
2037 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
2040 /** Pointer to the base of the data. */
2045 * Names of the various vertex/fragment program register files, etc.
2047 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
2048 * All values should fit in a 4-bit field.
2050 * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be
2051 * considered to be "uniform" variables since they can only be set outside
2052 * glBegin/End. They're also all stored in the same Parameters array.
2056 PROGRAM_TEMPORARY
, /**< machine->Temporary[] */
2057 PROGRAM_ARRAY
, /**< Arrays & Matrixes */
2058 PROGRAM_INPUT
, /**< machine->Inputs[] */
2059 PROGRAM_OUTPUT
, /**< machine->Outputs[] */
2060 PROGRAM_STATE_VAR
, /**< gl_program->Parameters[] */
2061 PROGRAM_CONSTANT
, /**< gl_program->Parameters[] */
2062 PROGRAM_UNIFORM
, /**< gl_program->Parameters[] */
2063 PROGRAM_WRITE_ONLY
, /**< A dummy, write-only register */
2064 PROGRAM_ADDRESS
, /**< machine->AddressReg */
2065 PROGRAM_SAMPLER
, /**< for shader samplers, compile-time only */
2066 PROGRAM_SYSTEM_VALUE
,/**< InstanceId, PrimitiveID, etc. */
2067 PROGRAM_UNDEFINED
, /**< Invalid/TBD value */
2068 PROGRAM_IMMEDIATE
, /**< Immediate value, used by TGSI */
2069 PROGRAM_BUFFER
, /**< for shader buffers, compile-time only */
2070 PROGRAM_MEMORY
, /**< for shared, global and local memory */
2071 PROGRAM_IMAGE
, /**< for shader images, compile-time only */
2072 PROGRAM_HW_ATOMIC
, /**< for hw atomic counters, compile-time only */
2078 * Base class for any kind of program object
2082 /** FIXME: This must be first until we split shader_info from nir_shader */
2083 struct shader_info info
;
2087 GLubyte
*String
; /**< Null-terminated program text */
2089 GLenum Target
; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2090 GLenum Format
; /**< String encoding format */
2092 GLboolean _Used
; /**< Ever used for drawing? Used for debugging */
2094 struct nir_shader
*nir
;
2096 /* Saved and restored with metadata. Freed with ralloc. */
2097 void *driver_cache_blob
;
2098 size_t driver_cache_blob_size
;
2100 bool is_arb_asm
; /** Is this an ARB assembly-style program */
2102 /** Is this program written to on disk shader cache */
2103 bool program_written_to_cache
;
2105 GLbitfield64 SecondaryOutputsWritten
; /**< Subset of OutputsWritten outputs written with non-zero index. */
2106 GLbitfield TexturesUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_BIT bitmask */
2107 GLbitfield SamplersUsed
; /**< Bitfield of which samplers are used */
2108 GLbitfield ShadowSamplers
; /**< Texture units used for shadow sampling. */
2109 GLbitfield ExternalSamplersUsed
; /**< Texture units used for samplerExternalOES */
2111 /* Fragement shader only fields */
2112 GLboolean OriginUpperLeft
;
2113 GLboolean PixelCenterInteger
;
2115 /** Named parameters, constants, etc. from program text */
2116 struct gl_program_parameter_list
*Parameters
;
2118 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2119 GLubyte SamplerUnits
[MAX_SAMPLERS
];
2121 /* FIXME: We should be able to make this struct a union. However some
2122 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2123 * these fields, we should fix this.
2126 /** Fields used by GLSL programs */
2128 /** Data shared by gl_program and gl_shader_program */
2129 struct gl_shader_program_data
*data
;
2131 struct gl_active_atomic_buffer
**AtomicBuffers
;
2133 /** Post-link transform feedback info. */
2134 struct gl_transform_feedback_info
*LinkedTransformFeedback
;
2137 * Number of types for subroutine uniforms.
2139 GLuint NumSubroutineUniformTypes
;
2142 * Subroutine uniform remap table
2143 * based on the program level uniform remap table.
2145 GLuint NumSubroutineUniforms
; /* non-sparse total */
2146 GLuint NumSubroutineUniformRemapTable
;
2147 struct gl_uniform_storage
**SubroutineUniformRemapTable
;
2150 * Num of subroutine functions for this stage and storage for them.
2152 GLuint NumSubroutineFunctions
;
2153 GLuint MaxSubroutineFunctionIndex
;
2154 struct gl_subroutine_function
*SubroutineFunctions
;
2157 * Map from image uniform index to image unit (set by glUniform1i())
2159 * An image uniform index is associated with each image uniform by
2160 * the linker. The image index associated with each uniform is
2161 * stored in the \c gl_uniform_storage::image field.
2163 GLubyte ImageUnits
[MAX_IMAGE_UNIFORMS
];
2166 * Access qualifier specified in the shader for each image uniform
2167 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
2170 * It may be different, though only more strict than the value of
2171 * \c gl_image_unit::Access for the corresponding image unit.
2173 GLenum ImageAccess
[MAX_IMAGE_UNIFORMS
];
2175 struct gl_uniform_block
**UniformBlocks
;
2176 struct gl_uniform_block
**ShaderStorageBlocks
;
2178 /** Which texture target is being sampled
2179 * (TEXTURE_1D/2D/3D/etc_INDEX)
2181 gl_texture_index SamplerTargets
[MAX_SAMPLERS
];
2184 * Number of samplers declared with the bindless_sampler layout
2185 * qualifier as specified by ARB_bindless_texture.
2187 GLuint NumBindlessSamplers
;
2188 GLboolean HasBoundBindlessSampler
;
2189 struct gl_bindless_sampler
*BindlessSamplers
;
2192 * Number of images declared with the bindless_image layout qualifier
2193 * as specified by ARB_bindless_texture.
2195 GLuint NumBindlessImages
;
2196 GLboolean HasBoundBindlessImage
;
2197 struct gl_bindless_image
*BindlessImages
;
2202 * A bitmask of gl_advanced_blend_mode values
2204 GLbitfield BlendSupport
;
2209 /** ARB assembly-style program fields */
2211 struct prog_instruction
*Instructions
;
2214 * Local parameters used by the program.
2216 * It's dynamically allocated because it is rarely used (just
2217 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2218 * once it's allocated.
2220 GLfloat (*LocalParams
)[4];
2222 /** Bitmask of which register files are read/written with indirect
2223 * addressing. Mask of (1 << PROGRAM_x) bits.
2225 GLbitfield IndirectRegisterFiles
;
2227 /** Logical counts */
2229 GLuint NumInstructions
;
2230 GLuint NumTemporaries
;
2231 GLuint NumParameters
;
2232 GLuint NumAttributes
;
2233 GLuint NumAddressRegs
;
2234 GLuint NumAluInstructions
;
2235 GLuint NumTexInstructions
;
2236 GLuint NumTexIndirections
;
2238 /** Native, actual h/w counts */
2240 GLuint NumNativeInstructions
;
2241 GLuint NumNativeTemporaries
;
2242 GLuint NumNativeParameters
;
2243 GLuint NumNativeAttributes
;
2244 GLuint NumNativeAddressRegs
;
2245 GLuint NumNativeAluInstructions
;
2246 GLuint NumNativeTexInstructions
;
2247 GLuint NumNativeTexIndirections
;
2250 /** Used by ARB assembly-style programs. Can only be true for vertex
2253 GLboolean IsPositionInvariant
;
2260 * State common to vertex and fragment programs.
2262 struct gl_program_state
2264 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2265 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2270 * Context state for vertex programs.
2272 struct gl_vertex_program_state
2274 GLboolean Enabled
; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2275 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2276 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2277 /** Should fixed-function T&L be implemented with a vertex prog? */
2278 GLboolean _MaintainTnlProgram
;
2280 struct gl_program
*Current
; /**< User-bound vertex program */
2282 /** Currently enabled and valid vertex program (including internal
2283 * programs, user-defined vertex programs and GLSL vertex shaders).
2284 * This is the program we must use when rendering.
2286 struct gl_program
*_Current
;
2288 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2290 /** Program to emulate fixed-function T&L (see above) */
2291 struct gl_program
*_TnlProgram
;
2293 /** Cache of fixed-function programs */
2294 struct gl_program_cache
*Cache
;
2296 GLboolean _Overriden
;
2300 * Context state for tessellation control programs.
2302 struct gl_tess_ctrl_program_state
2304 /** Currently bound and valid shader. */
2305 struct gl_program
*_Current
;
2307 GLint patch_vertices
;
2308 GLfloat patch_default_outer_level
[4];
2309 GLfloat patch_default_inner_level
[2];
2313 * Context state for tessellation evaluation programs.
2315 struct gl_tess_eval_program_state
2317 /** Currently bound and valid shader. */
2318 struct gl_program
*_Current
;
2322 * Context state for geometry programs.
2324 struct gl_geometry_program_state
2326 /** Currently enabled and valid program (including internal programs
2327 * and compiled shader programs).
2329 struct gl_program
*_Current
;
2333 * Context state for fragment programs.
2335 struct gl_fragment_program_state
2337 GLboolean Enabled
; /**< User-set fragment program enable flag */
2338 /** Should fixed-function texturing be implemented with a fragment prog? */
2339 GLboolean _MaintainTexEnvProgram
;
2341 struct gl_program
*Current
; /**< User-bound fragment program */
2343 /** Currently enabled and valid fragment program (including internal
2344 * programs, user-defined fragment programs and GLSL fragment shaders).
2345 * This is the program we must use when rendering.
2347 struct gl_program
*_Current
;
2349 GLfloat Parameters
[MAX_PROGRAM_ENV_PARAMS
][4]; /**< Env params */
2351 /** Program to emulate fixed-function texture env/combine (see above) */
2352 struct gl_program
*_TexEnvProgram
;
2354 /** Cache of fixed-function programs */
2355 struct gl_program_cache
*Cache
;
2360 * Context state for compute programs.
2362 struct gl_compute_program_state
2364 /** Currently enabled and valid program (including internal programs
2365 * and compiled shader programs).
2367 struct gl_program
*_Current
;
2372 * ATI_fragment_shader runtime state
2375 struct atifs_instruction
;
2376 struct atifs_setupinst
;
2379 * ATI fragment shader
2381 struct ati_fragment_shader
2385 struct atifs_instruction
*Instructions
[2];
2386 struct atifs_setupinst
*SetupInst
[2];
2387 GLfloat Constants
[8][4];
2388 GLbitfield LocalConstDef
; /**< Indicates which constants have been set */
2389 GLubyte numArithInstr
[2];
2390 GLubyte regsAssigned
[2];
2391 GLubyte NumPasses
; /**< 1 or 2 */
2392 /** Current compile stage: 0 setup pass1, 1 arith pass1, 2 setup pass2, 3 arith pass2 */
2394 GLubyte last_optype
;
2395 GLboolean interpinp1
;
2397 /** Array of 2 bit values for each tex unit to remember whether
2398 * STR or STQ swizzle was used
2401 struct gl_program
*Program
;
2405 * Context state for GL_ATI_fragment_shader
2407 struct gl_ati_fragment_shader_state
2410 GLboolean Compiling
;
2411 GLfloat GlobalConstants
[8][4];
2412 struct ati_fragment_shader
*Current
;
2416 * Shader subroutine function definition
2418 struct gl_subroutine_function
2422 int num_compat_types
;
2423 const struct glsl_type
**types
;
2427 * Shader information needed by both gl_shader and gl_linked shader.
2429 struct gl_shader_info
2432 * Tessellation Control shader state from layout qualifiers.
2436 * 0 - vertices not declared in shader, or
2437 * 1 .. GL_MAX_PATCH_VERTICES
2443 * Tessellation Evaluation shader state from layout qualifiers.
2447 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2450 GLenum PrimitiveMode
;
2452 enum gl_tess_spacing Spacing
;
2455 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2459 * 1, 0, or -1 if it's not set in this shader.
2465 * Geometry shader state from GLSL 1.50 layout qualifiers.
2470 * 0 - Invocations count not declared in shader, or
2471 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
2475 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2476 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2481 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2482 * it's not set in this shader.
2488 * Compute shader state from ARB_compute_shader and
2489 * ARB_compute_variable_group_size layout qualifiers.
2493 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2494 * it's not set in this shader.
2496 unsigned LocalSize
[3];
2499 * Whether a variable work group size has been specified as defined by
2500 * ARB_compute_variable_group_size.
2502 bool LocalSizeVariable
;
2507 * A linked GLSL shader object.
2509 struct gl_linked_shader
2511 gl_shader_stage Stage
;
2514 unsigned SourceChecksum
;
2517 struct gl_program
*Program
; /**< Post-compile assembly code */
2520 * \name Sampler tracking
2522 * \note Each of these fields is only set post-linking.
2525 GLbitfield shadow_samplers
; /**< Samplers used for shadow sampling. */
2529 * Number of default uniform block components used by this shader.
2531 * This field is only set post-linking.
2533 unsigned num_uniform_components
;
2536 * Number of combined uniform components used by this shader.
2538 * This field is only set post-linking. It is the sum of the uniform block
2539 * sizes divided by sizeof(float), and num_uniform_compoennts.
2541 unsigned num_combined_uniform_components
;
2543 struct exec_list
*ir
;
2544 struct exec_list
*packed_varyings
;
2545 struct exec_list
*fragdata_arrays
;
2546 struct glsl_symbol_table
*symbols
;
2551 * Compile status enum. compile_skipped is used to indicate the compile
2552 * was skipped due to the shader matching one that's been seen before by
2553 * the on-disk cache.
2555 enum gl_compile_status
2557 compile_failure
= 0,
2564 * A GLSL shader object.
2568 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2569 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2570 * Must be the first field.
2573 gl_shader_stage Stage
;
2574 GLuint Name
; /**< AKA the handle */
2575 GLint RefCount
; /**< Reference count */
2576 GLchar
*Label
; /**< GL_KHR_debug */
2577 unsigned char sha1
[20]; /**< SHA1 hash of pre-processed source */
2578 GLboolean DeletePending
;
2579 bool IsES
; /**< True if this shader uses GLSL ES */
2581 enum gl_compile_status CompileStatus
;
2584 unsigned SourceChecksum
; /**< for debug/logging purposes */
2586 const GLchar
*Source
; /**< Source code string */
2588 const GLchar
*FallbackSource
; /**< Fallback string used by on-disk cache*/
2592 unsigned Version
; /**< GLSL version used for linking */
2595 * A bitmask of gl_advanced_blend_mode values
2597 GLbitfield BlendSupport
;
2599 struct exec_list
*ir
;
2600 struct glsl_symbol_table
*symbols
;
2603 * Whether early fragment tests are enabled as defined by
2604 * ARB_shader_image_load_store.
2606 bool EarlyFragmentTests
;
2608 bool ARB_fragment_coord_conventions_enable
;
2610 bool redeclares_gl_fragcoord
;
2611 bool uses_gl_fragcoord
;
2613 bool PostDepthCoverage
;
2617 * Fragment shader state from GLSL 1.50 layout qualifiers.
2619 bool origin_upper_left
;
2620 bool pixel_center_integer
;
2623 * Whether bindless_sampler/bindless_image, and respectively
2624 * bound_sampler/bound_image are declared at global scope as defined by
2625 * ARB_bindless_texture.
2627 bool bindless_sampler
;
2628 bool bindless_image
;
2632 /** Global xfb_stride out qualifier if any */
2633 GLuint TransformFeedbackBufferStride
[MAX_FEEDBACK_BUFFERS
];
2635 struct gl_shader_info info
;
2637 /* ARB_gl_spirv related data */
2638 struct gl_shader_spirv_data
*spirv_data
;
2642 struct gl_uniform_buffer_variable
2647 * Name of the uniform as seen by glGetUniformIndices.
2649 * glGetUniformIndices requires that the block instance index \b not be
2650 * present in the name of queried uniforms.
2653 * \c gl_uniform_buffer_variable::IndexName and
2654 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2658 const struct glsl_type
*Type
;
2659 unsigned int Offset
;
2664 struct gl_uniform_block
2666 /** Declared name of the uniform block */
2669 /** Array of supplemental information about UBO ir_variables. */
2670 struct gl_uniform_buffer_variable
*Uniforms
;
2674 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2675 * with glBindBufferBase to bind a buffer object to this uniform block.
2680 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2681 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2683 GLuint UniformBufferSize
;
2685 /** Stages that reference this block */
2689 * Linearized array index for uniform block instance arrays
2691 * Given a uniform block instance array declared with size
2692 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2693 * have the linearized array index
2696 * i_m + ∑ i_j * ∏ s_k
2699 * For a uniform block instance that is not an array, this is always 0.
2701 uint8_t linearized_array_index
;
2704 * Layout specified in the shader
2706 * This isn't accessible through the API, but it is used while
2707 * cross-validating uniform blocks.
2709 enum glsl_interface_packing _Packing
;
2710 GLboolean _RowMajor
;
2714 * Structure that represents a reference to an atomic buffer from some
2717 struct gl_active_atomic_buffer
2719 /** Uniform indices of the atomic counters declared within it. */
2723 /** Binding point index associated with it. */
2726 /** Minimum reasonable size it is expected to have. */
2729 /** Shader stages making use of it. */
2730 GLboolean StageReferences
[MESA_SHADER_STAGES
];
2734 * Data container for shader queries. This holds only the minimal
2735 * amount of required information for resource queries to work.
2737 struct gl_shader_variable
2740 * Declared type of the variable
2742 const struct glsl_type
*type
;
2745 * If the variable is in an interface block, this is the type of the block.
2747 const struct glsl_type
*interface_type
;
2750 * For variables inside structs (possibly recursively), this is the
2751 * outermost struct type.
2753 const struct glsl_type
*outermost_struct_type
;
2756 * Declared name of the variable
2761 * Storage location of the base of this variable
2763 * The precise meaning of this field depends on the nature of the variable.
2765 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2766 * - Vertex shader output: one of the values from \c gl_varying_slot.
2767 * - Geometry shader input: one of the values from \c gl_varying_slot.
2768 * - Geometry shader output: one of the values from \c gl_varying_slot.
2769 * - Fragment shader input: one of the values from \c gl_varying_slot.
2770 * - Fragment shader output: one of the values from \c gl_frag_result.
2771 * - Uniforms: Per-stage uniform slot number for default uniform block.
2772 * - Uniforms: Index within the uniform block definition for UBO members.
2773 * - Non-UBO Uniforms: explicit location until linking then reused to
2774 * store uniform slot number.
2775 * - Other: This field is not currently used.
2777 * If the variable is a uniform, shader input, or shader output, and the
2778 * slot has not been assigned, the value will be -1.
2783 * Specifies the first component the variable is stored in as per
2784 * ARB_enhanced_layouts.
2786 unsigned component
:2;
2789 * Output index for dual source blending.
2792 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2798 * Specifies whether a shader input/output is per-patch in tessellation
2804 * Storage class of the variable.
2806 * \sa (n)ir_variable_mode
2811 * Interpolation mode for shader inputs / outputs
2813 * \sa glsl_interp_mode
2815 unsigned interpolation
:2;
2818 * Was the location explicitly set in the shader?
2820 * If the location is explicitly set in the shader, it \b cannot be changed
2821 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2824 unsigned explicit_location
:1;
2827 * Precision qualifier.
2829 unsigned precision
:2;
2833 * Active resource in a gl_shader_program
2835 struct gl_program_resource
2837 GLenum Type
; /** Program interface type. */
2838 const void *Data
; /** Pointer to resource associated data structure. */
2839 uint8_t StageReferences
; /** Bitmask of shader stage references. */
2843 * Link status enum. linking_skipped is used to indicate linking
2844 * was skipped due to the shader being loaded from the on-disk cache.
2848 linking_failure
= 0,
2854 * A data structure to be shared by gl_shader_program and gl_program.
2856 struct gl_shader_program_data
2858 GLint RefCount
; /**< Reference count */
2860 /** SHA1 hash of linked shader program */
2861 unsigned char sha1
[20];
2863 unsigned NumUniformStorage
;
2864 unsigned NumHiddenUniforms
;
2865 struct gl_uniform_storage
*UniformStorage
;
2867 unsigned NumUniformBlocks
;
2868 unsigned NumShaderStorageBlocks
;
2870 struct gl_uniform_block
*UniformBlocks
;
2871 struct gl_uniform_block
*ShaderStorageBlocks
;
2873 struct gl_active_atomic_buffer
*AtomicBuffers
;
2874 unsigned NumAtomicBuffers
;
2876 /* Shader cache variables used during restore */
2877 unsigned NumUniformDataSlots
;
2878 union gl_constant_value
*UniformDataSlots
;
2880 /* Used to hold initial uniform values for program binary restores.
2882 * From the ARB_get_program_binary spec:
2884 * "A successful call to ProgramBinary will reset all uniform
2885 * variables to their initial values. The initial value is either
2886 * the value of the variable's initializer as specified in the
2887 * original shader source, or 0 if no initializer was present.
2889 union gl_constant_value
*UniformDataDefaults
;
2891 GLboolean Validated
;
2893 /** List of all active resources after linking. */
2894 struct gl_program_resource
*ProgramResourceList
;
2895 unsigned NumProgramResourceList
;
2897 enum gl_link_status LinkStatus
; /**< GL_LINK_STATUS */
2900 unsigned Version
; /**< GLSL version used for linking */
2902 /* Mask of stages this program was linked against */
2903 unsigned linked_stages
;
2907 * A GLSL program object.
2908 * Basically a linked collection of vertex and fragment shaders.
2910 struct gl_shader_program
2912 GLenum Type
; /**< Always GL_SHADER_PROGRAM (internal token) */
2913 GLuint Name
; /**< aka handle or ID */
2914 GLchar
*Label
; /**< GL_KHR_debug */
2915 GLint RefCount
; /**< Reference count */
2916 GLboolean DeletePending
;
2919 * Is the application intending to glGetProgramBinary this program?
2921 GLboolean BinaryRetreivableHint
;
2924 * Indicates whether program can be bound for individual pipeline stages
2925 * using UseProgramStages after it is next linked.
2927 GLboolean SeparateShader
;
2929 GLuint NumShaders
; /**< number of attached shaders */
2930 struct gl_shader
**Shaders
; /**< List of attached the shaders */
2933 * User-defined attribute bindings
2935 * These are set via \c glBindAttribLocation and are used to direct the
2936 * GLSL linker. These are \b not the values used in the compiled shader,
2937 * and they are \b not the values returned by \c glGetAttribLocation.
2939 struct string_to_uint_map
*AttributeBindings
;
2942 * User-defined fragment data bindings
2944 * These are set via \c glBindFragDataLocation and are used to direct the
2945 * GLSL linker. These are \b not the values used in the compiled shader,
2946 * and they are \b not the values returned by \c glGetFragDataLocation.
2948 struct string_to_uint_map
*FragDataBindings
;
2949 struct string_to_uint_map
*FragDataIndexBindings
;
2952 * Transform feedback varyings last specified by
2953 * glTransformFeedbackVaryings().
2955 * For the current set of transform feedback varyings used for transform
2956 * feedback output, see LinkedTransformFeedback.
2960 /** Global xfb_stride out qualifier if any */
2961 GLuint BufferStride
[MAX_FEEDBACK_BUFFERS
];
2963 GLchar
**VaryingNames
; /**< Array [NumVarying] of char * */
2964 } TransformFeedback
;
2966 struct gl_program
*last_vert_prog
;
2968 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
2969 enum gl_frag_depth_layout FragDepthLayout
;
2972 * Geometry shader state - copied into gl_program by
2973 * _mesa_copy_linked_program_data().
2978 bool UsesEndPrimitive
;
2983 * Compute shader state - copied into gl_program by
2984 * _mesa_copy_linked_program_data().
2988 * Size of shared variables accessed by the compute shader.
2990 unsigned SharedSize
;
2993 /** Data shared by gl_program and gl_shader_program */
2994 struct gl_shader_program_data
*data
;
2997 * Mapping from GL uniform locations returned by \c glUniformLocation to
2998 * UniformStorage entries. Arrays will have multiple contiguous slots
2999 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3001 unsigned NumUniformRemapTable
;
3002 struct gl_uniform_storage
**UniformRemapTable
;
3005 * Sometimes there are empty slots left over in UniformRemapTable after we
3006 * allocate slots to explicit locations. This list stores the blocks of
3007 * continuous empty slots inside UniformRemapTable.
3009 struct exec_list EmptyUniformLocations
;
3012 * Total number of explicit uniform location including inactive uniforms.
3014 unsigned NumExplicitUniformLocations
;
3017 * Map of active uniform names to locations
3019 * Maps any active uniform that is not an array element to a location.
3020 * Each active uniform, including individual structure members will appear
3021 * in this map. This roughly corresponds to the set of names that would be
3022 * enumerated by \c glGetActiveUniform.
3024 struct string_to_uint_map
*UniformHash
;
3026 GLboolean SamplersValidated
; /**< Samplers validated against texture units? */
3028 bool IsES
; /**< True if this program uses GLSL ES */
3031 * Per-stage shaders resulting from the first stage of linking.
3033 * Set of linked shaders for this program. The array is accessed using the
3034 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3037 struct gl_linked_shader
*_LinkedShaders
[MESA_SHADER_STAGES
];
3039 /* True if any of the fragment shaders attached to this program use:
3040 * #extension ARB_fragment_coord_conventions: enable
3042 GLboolean ARB_fragment_coord_conventions_enable
;
3046 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3047 #define GLSL_LOG 0x2 /**< Write shaders to files */
3048 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3049 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3050 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3051 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3052 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3053 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3054 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3055 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3059 * Context state for GLSL vertex/fragment shaders.
3060 * Extended to support pipeline object
3062 struct gl_pipeline_object
3064 /** Name of the pipeline object as received from glGenProgramPipelines.
3065 * It would be 0 for shaders without separate shader objects.
3071 GLchar
*Label
; /**< GL_KHR_debug */
3074 * Programs used for rendering
3076 * There is a separate program set for each shader stage.
3078 struct gl_program
*CurrentProgram
[MESA_SHADER_STAGES
];
3080 struct gl_shader_program
*ReferencedPrograms
[MESA_SHADER_STAGES
];
3083 * Program used by glUniform calls.
3085 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3087 struct gl_shader_program
*ActiveProgram
;
3089 GLbitfield Flags
; /**< Mask of GLSL_x flags */
3091 GLboolean EverBound
; /**< Has the pipeline object been created */
3093 GLboolean Validated
; /**< Pipeline Validation status */
3099 * Context state for GLSL pipeline shaders.
3101 struct gl_pipeline_shader_state
3103 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3104 struct gl_pipeline_object
*Current
;
3106 /* Default Object to ensure that _Shader is never NULL */
3107 struct gl_pipeline_object
*Default
;
3109 /** Pipeline objects */
3110 struct _mesa_HashTable
*Objects
;
3114 * Compiler options for a single GLSL shaders type
3116 struct gl_shader_compiler_options
3118 /** Driver-selectable options: */
3119 GLboolean EmitNoLoops
;
3120 GLboolean EmitNoCont
; /**< Emit CONT opcode? */
3121 GLboolean EmitNoMainReturn
; /**< Emit CONT/RET opcodes? */
3122 GLboolean EmitNoPow
; /**< Emit POW opcodes? */
3123 GLboolean EmitNoSat
; /**< Emit SAT opcodes? */
3124 GLboolean LowerCombinedClipCullDistance
; /** Lower gl_ClipDistance and
3125 * gl_CullDistance together from
3126 * float[8] to vec4[2]
3130 * \name Forms of indirect addressing the driver cannot do.
3133 GLboolean EmitNoIndirectInput
; /**< No indirect addressing of inputs */
3134 GLboolean EmitNoIndirectOutput
; /**< No indirect addressing of outputs */
3135 GLboolean EmitNoIndirectTemp
; /**< No indirect addressing of temps */
3136 GLboolean EmitNoIndirectUniform
; /**< No indirect addressing of constants */
3137 GLboolean EmitNoIndirectSampler
; /**< No indirect addressing of samplers */
3140 GLuint MaxIfDepth
; /**< Maximum nested IF blocks */
3141 GLuint MaxUnrollIterations
;
3144 * Optimize code for array of structures backends.
3146 * This is a proxy for:
3147 * - preferring DP4 instructions (rather than MUL/MAD) for
3148 * matrix * vector operations, such as position transformation.
3150 GLboolean OptimizeForAOS
;
3152 GLboolean LowerBufferInterfaceBlocks
; /**< Lower UBO and SSBO access to intrinsics. */
3154 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3155 GLboolean ClampBlockIndicesToArrayBounds
;
3157 const struct nir_shader_compiler_options
*NirOptions
;
3162 * Occlusion/timer query object.
3164 struct gl_query_object
3166 GLenum Target
; /**< The query target, when active */
3167 GLuint Id
; /**< hash table ID/name */
3168 GLchar
*Label
; /**< GL_KHR_debug */
3169 GLuint64EXT Result
; /**< the counter */
3170 GLboolean Active
; /**< inside Begin/EndQuery */
3171 GLboolean Ready
; /**< result is ready? */
3172 GLboolean EverBound
;/**< has query object ever been bound */
3173 GLuint Stream
; /**< The stream */
3178 * Context state for query objects.
3180 struct gl_query_state
3182 struct _mesa_HashTable
*QueryObjects
;
3183 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
3184 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
3186 /** GL_NV_conditional_render */
3187 struct gl_query_object
*CondRenderQuery
;
3189 /** GL_EXT_transform_feedback */
3190 struct gl_query_object
*PrimitivesGenerated
[MAX_VERTEX_STREAMS
];
3191 struct gl_query_object
*PrimitivesWritten
[MAX_VERTEX_STREAMS
];
3193 /** GL_ARB_transform_feedback_overflow_query */
3194 struct gl_query_object
*TransformFeedbackOverflow
[MAX_VERTEX_STREAMS
];
3195 struct gl_query_object
*TransformFeedbackOverflowAny
;
3197 /** GL_ARB_timer_query */
3198 struct gl_query_object
*TimeElapsed
;
3200 /** GL_ARB_pipeline_statistics_query */
3201 struct gl_query_object
*pipeline_stats
[MAX_PIPELINE_STATISTICS
];
3203 GLenum CondRenderMode
;
3207 /** Sync object state */
3208 struct gl_sync_object
3210 GLuint Name
; /**< Fence name */
3211 GLint RefCount
; /**< Reference count */
3212 GLchar
*Label
; /**< GL_KHR_debug */
3213 GLboolean DeletePending
; /**< Object was deleted while there were still
3214 * live references (e.g., sync not yet finished)
3216 GLenum SyncCondition
;
3217 GLbitfield Flags
; /**< Flags passed to glFenceSync */
3218 GLuint StatusFlag
:1; /**< Has the sync object been signaled? */
3223 * State which can be shared by multiple contexts:
3225 struct gl_shared_state
3227 simple_mtx_t Mutex
; /**< for thread safety */
3228 GLint RefCount
; /**< Reference count */
3229 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
3230 struct _mesa_HashTable
*BitmapAtlas
; /**< For optimized glBitmap text */
3231 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
3233 /** Default texture objects (shared by all texture units) */
3234 struct gl_texture_object
*DefaultTex
[NUM_TEXTURE_TARGETS
];
3236 /** Fallback texture used when a bound texture is incomplete */
3237 struct gl_texture_object
*FallbackTex
[NUM_TEXTURE_TARGETS
];
3240 * \name Thread safety and statechange notification for texture
3243 * \todo Improve the granularity of locking.
3246 mtx_t TexMutex
; /**< texobj thread safety */
3247 GLuint TextureStateStamp
; /**< state notification for shared tex */
3250 /** Default buffer object for vertex arrays that aren't in VBOs */
3251 struct gl_buffer_object
*NullBufferObj
;
3254 * \name Vertex/geometry/fragment programs
3257 struct _mesa_HashTable
*Programs
; /**< All vertex/fragment programs */
3258 struct gl_program
*DefaultVertexProgram
;
3259 struct gl_program
*DefaultFragmentProgram
;
3262 /* GL_ATI_fragment_shader */
3263 struct _mesa_HashTable
*ATIShaders
;
3264 struct ati_fragment_shader
*DefaultFragmentShader
;
3266 struct _mesa_HashTable
*BufferObjects
;
3268 /** Table of both gl_shader and gl_shader_program objects */
3269 struct _mesa_HashTable
*ShaderObjects
;
3271 /* GL_EXT_framebuffer_object */
3272 struct _mesa_HashTable
*RenderBuffers
;
3273 struct _mesa_HashTable
*FrameBuffers
;
3276 struct set
*SyncObjects
;
3278 /** GL_ARB_sampler_objects */
3279 struct _mesa_HashTable
*SamplerObjects
;
3281 /* GL_ARB_bindless_texture */
3282 struct hash_table_u64
*TextureHandles
;
3283 struct hash_table_u64
*ImageHandles
;
3284 mtx_t HandlesMutex
; /**< For texture/image handles safety */
3287 * Some context in this share group was affected by a GPU reset
3289 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3290 * been affected by a GPU reset must also return
3291 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3293 * Once this field becomes true, it is never reset to false.
3295 bool ShareGroupReset
;
3297 /** EXT_external_objects */
3298 struct _mesa_HashTable
*MemoryObjects
;
3301 * Some context in this share group was affected by a disjoint
3302 * operation. This operation can be anything that has effects on
3303 * values of timer queries in such manner that they become invalid for
3304 * performance metrics. As example gpu reset, counter overflow or gpu
3305 * frequency changes.
3307 bool DisjointOperation
;
3313 * Renderbuffers represent drawing surfaces such as color, depth and/or
3314 * stencil. A framebuffer object has a set of renderbuffers.
3315 * Drivers will typically derive subclasses of this type.
3317 struct gl_renderbuffer
3319 simple_mtx_t Mutex
; /**< for thread safety */
3320 GLuint ClassID
; /**< Useful for drivers */
3322 GLchar
*Label
; /**< GL_KHR_debug */
3324 GLuint Width
, Height
;
3326 GLboolean Purgeable
; /**< Is the buffer purgeable under memory pressure? */
3327 GLboolean AttachedAnytime
; /**< TRUE if it was attached to a framebuffer */
3329 * True for renderbuffers that wrap textures, giving the driver a chance to
3330 * flush render caches through the FinishRenderTexture hook.
3332 * Drivers may also set this on renderbuffers other than those generated by
3333 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3334 * called without a rb->TexImage.
3336 GLboolean NeedsFinishRenderTexture
;
3337 GLubyte NumSamples
; /**< zero means not multisampled */
3338 GLenum InternalFormat
; /**< The user-specified format */
3339 GLenum _BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3340 GL_STENCIL_INDEX. */
3341 mesa_format Format
; /**< The actual renderbuffer memory format */
3343 * Pointer to the texture image if this renderbuffer wraps a texture,
3346 * Note that the reference on the gl_texture_object containing this
3347 * TexImage is held by the gl_renderbuffer_attachment.
3349 struct gl_texture_image
*TexImage
;
3351 /** Delete this renderbuffer */
3352 void (*Delete
)(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
);
3354 /** Allocate new storage for this renderbuffer */
3355 GLboolean (*AllocStorage
)(struct gl_context
*ctx
,
3356 struct gl_renderbuffer
*rb
,
3357 GLenum internalFormat
,
3358 GLuint width
, GLuint height
);
3363 * A renderbuffer attachment points to either a texture object (and specifies
3364 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3366 struct gl_renderbuffer_attachment
3368 GLenum Type
; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3372 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3373 * application supplied renderbuffer object.
3375 struct gl_renderbuffer
*Renderbuffer
;
3378 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3379 * supplied texture object.
3381 struct gl_texture_object
*Texture
;
3382 GLuint TextureLevel
; /**< Attached mipmap level. */
3383 GLuint CubeMapFace
; /**< 0 .. 5, for cube map textures. */
3384 GLuint Zoffset
; /**< Slice for 3D textures, or layer for both 1D
3385 * and 2D array textures */
3391 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3392 * In C++ terms, think of this as a base class from which device drivers
3393 * will make derived classes.
3395 struct gl_framebuffer
3397 simple_mtx_t Mutex
; /**< for thread safety */
3399 * If zero, this is a window system framebuffer. If non-zero, this
3400 * is a FBO framebuffer; note that for some devices (i.e. those with
3401 * a natural pixel coordinate system for FBOs that differs from the
3402 * OpenGL/Mesa coordinate system), this means that the viewport,
3403 * polygon face orientation, and polygon stipple will have to be inverted.
3408 GLchar
*Label
; /**< GL_KHR_debug */
3410 GLboolean DeletePending
;
3413 * The framebuffer's visual. Immutable if this is a window system buffer.
3414 * Computed from attachments if user-made FBO.
3416 struct gl_config Visual
;
3419 * Size of frame buffer in pixels. If there are no attachments, then both
3422 GLuint Width
, Height
;
3425 * In the case that the framebuffer has no attachment (i.e.
3426 * GL_ARB_framebuffer_no_attachments) then the geometry of
3427 * the framebuffer is specified by the default values.
3430 GLuint Width
, Height
, Layers
, NumSamples
;
3431 GLboolean FixedSampleLocations
;
3432 /* Derived from NumSamples by the driver so that it can choose a valid
3433 * value for the hardware.
3438 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3439 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3440 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3447 /** \name Derived Z buffer stuff */
3449 GLuint _DepthMax
; /**< Max depth buffer value */
3450 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
3451 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
3454 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3457 /** Whether one of Attachment has Type != GL_NONE
3458 * NOTE: the values for Width and Height are set to 0 in case of having
3459 * no attachments, a backend driver supporting the extension
3460 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3461 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3462 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3463 * _Ymax do NOT take into account _HasAttachments being false). To get the
3464 * geometry of the framebuffer, the helper functions
3465 * _mesa_geometric_width(),
3466 * _mesa_geometric_height(),
3467 * _mesa_geometric_samples() and
3468 * _mesa_geometric_layers()
3469 * are available that check _HasAttachments.
3471 bool _HasAttachments
;
3473 GLbitfield _IntegerBuffers
; /**< Which color buffers are integer valued */
3475 /* ARB_color_buffer_float */
3476 GLboolean _AllColorBuffersFixedPoint
; /* no integer, no float */
3477 GLboolean _HasSNormOrFloatColorBuffer
;
3480 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3481 * is not layered. For cube maps and cube map arrays, each cube face
3482 * counts as a layer. As the case for Width, Height a backend driver
3483 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3484 * in the case that _HasAttachments is false
3486 GLuint MaxNumLayers
;
3488 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3489 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
3491 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3492 * attribute group and GL_PIXEL attribute group, respectively.
3494 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
3495 GLenum ColorReadBuffer
;
3497 /** Computed from ColorDraw/ReadBuffer above */
3498 GLuint _NumColorDrawBuffers
;
3499 gl_buffer_index _ColorDrawBufferIndexes
[MAX_DRAW_BUFFERS
];
3500 gl_buffer_index _ColorReadBufferIndex
;
3501 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
];
3502 struct gl_renderbuffer
*_ColorReadBuffer
;
3504 /** Delete this framebuffer */
3505 void (*Delete
)(struct gl_framebuffer
*fb
);
3510 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3514 GLushort RangeMin
; /**< min value exponent */
3515 GLushort RangeMax
; /**< max value exponent */
3516 GLushort Precision
; /**< number of mantissa bits */
3521 * Limits for vertex, geometry and fragment programs/shaders.
3523 struct gl_program_constants
3525 /* logical limits */
3526 GLuint MaxInstructions
;
3527 GLuint MaxAluInstructions
;
3528 GLuint MaxTexInstructions
;
3529 GLuint MaxTexIndirections
;
3532 GLuint MaxAddressRegs
;
3533 GLuint MaxAddressOffset
; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3534 GLuint MaxParameters
;
3535 GLuint MaxLocalParams
;
3536 GLuint MaxEnvParams
;
3537 /* native/hardware limits */
3538 GLuint MaxNativeInstructions
;
3539 GLuint MaxNativeAluInstructions
;
3540 GLuint MaxNativeTexInstructions
;
3541 GLuint MaxNativeTexIndirections
;
3542 GLuint MaxNativeAttribs
;
3543 GLuint MaxNativeTemps
;
3544 GLuint MaxNativeAddressRegs
;
3545 GLuint MaxNativeParameters
;
3547 GLuint MaxUniformComponents
; /**< Usually == MaxParameters * 4 */
3550 * \name Per-stage input / output limits
3552 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3553 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3554 * ES). This is stored as \c gl_constants::MaxVarying.
3556 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3557 * variables. Each stage as a certain number of outputs that it can feed
3558 * to the next stage and a certain number inputs that it can consume from
3559 * the previous stage.
3561 * Vertex shader inputs do not participate this in this accounting.
3562 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3564 * Fragment shader outputs do not participate this in this accounting.
3565 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3568 GLuint MaxInputComponents
;
3569 GLuint MaxOutputComponents
;
3572 /* ES 2.0 and GL_ARB_ES2_compatibility */
3573 struct gl_precision LowFloat
, MediumFloat
, HighFloat
;
3574 struct gl_precision LowInt
, MediumInt
, HighInt
;
3575 /* GL_ARB_uniform_buffer_object */
3576 GLuint MaxUniformBlocks
;
3577 GLuint MaxCombinedUniformComponents
;
3578 GLuint MaxTextureImageUnits
;
3580 /* GL_ARB_shader_atomic_counters */
3581 GLuint MaxAtomicBuffers
;
3582 GLuint MaxAtomicCounters
;
3584 /* GL_ARB_shader_image_load_store */
3585 GLuint MaxImageUniforms
;
3587 /* GL_ARB_shader_storage_buffer_object */
3588 GLuint MaxShaderStorageBlocks
;
3592 * Constants which may be overridden by device driver during context creation
3593 * but are never changed after that.
3597 GLuint MaxTextureMbytes
; /**< Max memory per image, in MB */
3598 GLuint MaxTextureLevels
; /**< Max mipmap levels. */
3599 GLuint Max3DTextureLevels
; /**< Max mipmap levels for 3D textures */
3600 GLuint MaxCubeTextureLevels
; /**< Max mipmap levels for cube textures */
3601 GLuint MaxArrayTextureLayers
; /**< Max layers in array textures */
3602 GLuint MaxTextureRectSize
; /**< Max rectangle texture size, in pixes */
3603 GLuint MaxTextureCoordUnits
;
3604 GLuint MaxCombinedTextureImageUnits
;
3605 GLuint MaxTextureUnits
; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3606 GLfloat MaxTextureMaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
3607 GLfloat MaxTextureLodBias
; /**< GL_EXT_texture_lod_bias */
3608 GLuint MaxTextureBufferSize
; /**< GL_ARB_texture_buffer_object */
3610 GLuint TextureBufferOffsetAlignment
; /**< GL_ARB_texture_buffer_range */
3612 GLuint MaxArrayLockSize
;
3616 GLfloat MinPointSize
, MaxPointSize
; /**< aliased */
3617 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /**< antialiased */
3618 GLfloat PointSizeGranularity
;
3619 GLfloat MinLineWidth
, MaxLineWidth
; /**< aliased */
3620 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /**< antialiased */
3621 GLfloat LineWidthGranularity
;
3623 GLuint MaxClipPlanes
;
3625 GLfloat MaxShininess
; /**< GL_NV_light_max_exponent */
3626 GLfloat MaxSpotExponent
; /**< GL_NV_light_max_exponent */
3628 GLuint MaxViewportWidth
, MaxViewportHeight
;
3629 GLuint MaxViewports
; /**< GL_ARB_viewport_array */
3630 GLuint ViewportSubpixelBits
; /**< GL_ARB_viewport_array */
3634 } ViewportBounds
; /**< GL_ARB_viewport_array */
3635 GLuint MaxWindowRectangles
; /**< GL_EXT_window_rectangles */
3637 struct gl_program_constants Program
[MESA_SHADER_STAGES
];
3638 GLuint MaxProgramMatrices
;
3639 GLuint MaxProgramMatrixStackDepth
;
3642 GLuint SamplesPassed
;
3645 GLuint PrimitivesGenerated
;
3646 GLuint PrimitivesWritten
;
3647 GLuint VerticesSubmitted
;
3648 GLuint PrimitivesSubmitted
;
3649 GLuint VsInvocations
;
3651 GLuint TessInvocations
;
3652 GLuint GsInvocations
;
3653 GLuint GsPrimitives
;
3654 GLuint FsInvocations
;
3655 GLuint ComputeInvocations
;
3656 GLuint ClInPrimitives
;
3657 GLuint ClOutPrimitives
;
3660 GLuint MaxDrawBuffers
; /**< GL_ARB_draw_buffers */
3662 GLuint MaxColorAttachments
; /**< GL_EXT_framebuffer_object */
3663 GLuint MaxRenderbufferSize
; /**< GL_EXT_framebuffer_object */
3664 GLuint MaxSamples
; /**< GL_ARB_framebuffer_object */
3667 * GL_ARB_framebuffer_no_attachments
3669 GLuint MaxFramebufferWidth
;
3670 GLuint MaxFramebufferHeight
;
3671 GLuint MaxFramebufferLayers
;
3672 GLuint MaxFramebufferSamples
;
3674 /** Number of varying vectors between any two shader stages. */
3678 * GL_ARB_uniform_buffer_object
3680 GLuint MaxCombinedUniformBlocks
;
3681 GLuint MaxUniformBufferBindings
;
3682 GLuint MaxUniformBlockSize
;
3683 GLuint UniformBufferOffsetAlignment
;
3687 * GL_ARB_shader_storage_buffer_object
3689 GLuint MaxCombinedShaderStorageBlocks
;
3690 GLuint MaxShaderStorageBufferBindings
;
3691 GLuint MaxShaderStorageBlockSize
;
3692 GLuint ShaderStorageBufferOffsetAlignment
;
3696 * GL_ARB_explicit_uniform_location
3698 GLuint MaxUserAssignableUniformLocations
;
3700 /** geometry shader */
3701 GLuint MaxGeometryOutputVertices
;
3702 GLuint MaxGeometryTotalOutputComponents
;
3704 GLuint GLSLVersion
; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3707 * Changes default GLSL extension behavior from "error" to "warn". It's out
3708 * of spec, but it can make some apps work that otherwise wouldn't.
3710 GLboolean ForceGLSLExtensionsWarn
;
3713 * If non-zero, forces GLSL shaders to behave as if they began
3714 * with "#version ForceGLSLVersion".
3716 GLuint ForceGLSLVersion
;
3719 * Allow GLSL #extension directives in the middle of shaders.
3721 GLboolean AllowGLSLExtensionDirectiveMidShader
;
3724 * Allow GLSL built-in variables to be redeclared verbatim
3726 GLboolean AllowGLSLBuiltinVariableRedeclaration
;
3729 * Allow GLSL interpolation qualifier mismatch across shader stages.
3731 GLboolean AllowGLSLCrossStageInterpolationMismatch
;
3734 * Allow creating a higher compat profile (version 3.1+) for apps that
3735 * request it. Be careful when adding that driconf option because some
3736 * features are unimplemented and might not work correctly.
3738 GLboolean AllowHigherCompatVersion
;
3741 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3742 * D3D9 when apps rely on this behaviour.
3744 GLboolean ForceGLSLAbsSqrt
;
3747 * Force uninitialized variables to default to zero.
3749 GLboolean GLSLZeroInit
;
3752 * Does the driver support real 32-bit integers? (Otherwise, integers are
3753 * simulated via floats.)
3755 GLboolean NativeIntegers
;
3758 * Does VertexID count from zero or from base vertex?
3761 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3762 * ignored and need not be set.
3764 bool VertexID_is_zero_based
;
3767 * If the driver supports real 32-bit integers, what integer value should be
3768 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3770 GLuint UniformBooleanTrue
;
3773 * Maximum amount of time, measured in nanseconds, that the server can wait.
3775 GLuint64 MaxServerWaitTimeout
;
3777 /** GL_EXT_provoking_vertex */
3778 GLboolean QuadsFollowProvokingVertexConvention
;
3780 /** GL_ARB_viewport_array */
3781 GLenum LayerAndVPIndexProvokingVertex
;
3783 /** OpenGL version 3.0 */
3784 GLbitfield ContextFlags
; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3786 /** OpenGL version 3.2 */
3787 GLbitfield ProfileMask
; /**< Mask of CONTEXT_x_PROFILE_BIT */
3789 /** OpenGL version 4.4 */
3790 GLuint MaxVertexAttribStride
;
3792 /** GL_EXT_transform_feedback */
3793 GLuint MaxTransformFeedbackBuffers
;
3794 GLuint MaxTransformFeedbackSeparateComponents
;
3795 GLuint MaxTransformFeedbackInterleavedComponents
;
3796 GLuint MaxVertexStreams
;
3798 /** GL_EXT_gpu_shader4 */
3799 GLint MinProgramTexelOffset
, MaxProgramTexelOffset
;
3801 /** GL_ARB_texture_gather */
3802 GLuint MinProgramTextureGatherOffset
;
3803 GLuint MaxProgramTextureGatherOffset
;
3804 GLuint MaxProgramTextureGatherComponents
;
3806 /* GL_ARB_robustness */
3807 GLenum ResetStrategy
;
3809 /* GL_KHR_robustness */
3810 GLboolean RobustAccess
;
3812 /* GL_ARB_blend_func_extended */
3813 GLuint MaxDualSourceDrawBuffers
;
3816 * Whether the implementation strips out and ignores texture borders.
3818 * Many GPU hardware implementations don't support rendering with texture
3819 * borders and mipmapped textures. (Note: not static border color, but the
3820 * old 1-pixel border around each edge). Implementations then have to do
3821 * slow fallbacks to be correct, or just ignore the border and be fast but
3822 * wrong. Setting the flag strips the border off of TexImage calls,
3823 * providing "fast but wrong" at significantly reduced driver complexity.
3825 * Texture borders are deprecated in GL 3.0.
3827 GLboolean StripTextureBorder
;
3830 * For drivers which can do a better job at eliminating unused uniforms
3831 * than the GLSL compiler.
3833 * XXX Remove these as soon as a better solution is available.
3835 GLboolean GLSLSkipStrictMaxUniformLimitCheck
;
3837 /** Whether gl_FragCoord and gl_FrontFacing are system values. */
3838 bool GLSLFragCoordIsSysVal
;
3839 bool GLSLFrontFacingIsSysVal
;
3842 * Run the minimum amount of GLSL optimizations to be able to link
3843 * shaders optimally (eliminate dead varyings and uniforms) and just do
3844 * all the necessary lowering.
3846 bool GLSLOptimizeConservatively
;
3849 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3850 * (otherwise, they're system values).
3852 bool GLSLTessLevelsAsInputs
;
3855 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3856 * than passing the transform feedback object to the drawing function.
3858 GLboolean AlwaysUseGetTransformFeedbackVertexCount
;
3860 /** GL_ARB_map_buffer_alignment */
3861 GLuint MinMapBufferAlignment
;
3864 * Disable varying packing. This is out of spec, but potentially useful
3865 * for older platforms that supports a limited number of texture
3866 * indirections--on these platforms, unpacking the varyings in the fragment
3867 * shader increases the number of texture indirections by 1, which might
3868 * make some shaders not executable at all.
3870 * Drivers that support transform feedback must set this value to GL_FALSE.
3872 GLboolean DisableVaryingPacking
;
3875 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3876 * layout is set as shared (the default) or packed. However most Mesa drivers
3877 * just use STD140 for these layouts. This flag allows drivers to use STD430
3878 * for packed and shared layouts which allows arrays to be packed more
3881 bool UseSTD430AsDefaultPacking
;
3884 * Should meaningful names be generated for compiler temporary variables?
3886 * Generally, it is not useful to have the compiler generate "meaningful"
3887 * names for temporary variables that it creates. This can, however, be a
3888 * useful debugging aid. In Mesa debug builds or release builds when
3889 * MESA_GLSL is set at run-time, meaningful names will be generated.
3890 * Drivers can also force names to be generated by setting this field.
3891 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
3892 * vertex shader assembly) is set at run-time.
3894 bool GenerateTemporaryNames
;
3897 * Maximum value supported for an index in DrawElements and friends.
3899 * This must be at least (1ull<<24)-1. The default value is
3902 * \since ES 3.0 or GL_ARB_ES3_compatibility
3903 * \sa _mesa_init_constants
3905 GLuint64 MaxElementIndex
;
3908 * Disable interpretation of line continuations (lines ending with a
3909 * backslash character ('\') in GLSL source.
3911 GLboolean DisableGLSLLineContinuations
;
3913 /** GL_ARB_texture_multisample */
3914 GLint MaxColorTextureSamples
;
3915 GLint MaxDepthTextureSamples
;
3916 GLint MaxIntegerSamples
;
3919 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
3920 * samples are laid out in a rectangular grid roughly corresponding to
3921 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
3922 * are used to map indices of rectangular grid to sample numbers within
3923 * a pixel. This mapping of indices to sample numbers must be initialized
3924 * by the driver for the target hardware. For example, if we have the 8X
3925 * MSAA sample number layout (sample positions) for XYZ hardware:
3927 * sample indices layout sample number layout
3928 * --------- ---------
3929 * | 0 | 1 | | a | b |
3930 * --------- ---------
3931 * | 2 | 3 | | c | d |
3932 * --------- ---------
3933 * | 4 | 5 | | e | f |
3934 * --------- ---------
3935 * | 6 | 7 | | g | h |
3936 * --------- ---------
3938 * Where a,b,c,d,e,f,g,h are integers between [0-7].
3940 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
3942 * SampleMap8x = {a, b, c, d, e, f, g, h};
3944 * Follow the logic for sample counts 2-8.
3946 * For 16x the sample indices layout as a 4x4 grid as follows:
3958 uint8_t SampleMap2x
[2];
3959 uint8_t SampleMap4x
[4];
3960 uint8_t SampleMap8x
[8];
3961 uint8_t SampleMap16x
[16];
3963 /** GL_ARB_shader_atomic_counters */
3964 GLuint MaxAtomicBufferBindings
;
3965 GLuint MaxAtomicBufferSize
;
3966 GLuint MaxCombinedAtomicBuffers
;
3967 GLuint MaxCombinedAtomicCounters
;
3969 /** GL_ARB_vertex_attrib_binding */
3970 GLint MaxVertexAttribRelativeOffset
;
3971 GLint MaxVertexAttribBindings
;
3973 /* GL_ARB_shader_image_load_store */
3974 GLuint MaxImageUnits
;
3975 GLuint MaxCombinedShaderOutputResources
;
3976 GLuint MaxImageSamples
;
3977 GLuint MaxCombinedImageUniforms
;
3979 /** GL_ARB_compute_shader */
3980 GLuint MaxComputeWorkGroupCount
[3]; /* Array of x, y, z dimensions */
3981 GLuint MaxComputeWorkGroupSize
[3]; /* Array of x, y, z dimensions */
3982 GLuint MaxComputeWorkGroupInvocations
;
3983 GLuint MaxComputeSharedMemorySize
;
3985 /** GL_ARB_compute_variable_group_size */
3986 GLuint MaxComputeVariableGroupSize
[3]; /* Array of x, y, z dimensions */
3987 GLuint MaxComputeVariableGroupInvocations
;
3989 /** GL_ARB_gpu_shader5 */
3990 GLfloat MinFragmentInterpolationOffset
;
3991 GLfloat MaxFragmentInterpolationOffset
;
3993 GLboolean FakeSWMSAA
;
3995 /** GL_KHR_context_flush_control */
3996 GLenum ContextReleaseBehavior
;
3998 struct gl_shader_compiler_options ShaderCompilerOptions
[MESA_SHADER_STAGES
];
4000 /** GL_ARB_tessellation_shader */
4001 GLuint MaxPatchVertices
;
4002 GLuint MaxTessGenLevel
;
4003 GLuint MaxTessPatchComponents
;
4004 GLuint MaxTessControlTotalOutputComponents
;
4005 bool LowerTessLevel
; /**< Lower gl_TessLevel* from float[n] to vecn? */
4006 bool PrimitiveRestartForPatches
;
4007 bool LowerCsDerivedVariables
; /**< Lower gl_GlobalInvocationID and
4008 * gl_LocalInvocationIndex based on
4009 * other builtin variables. */
4011 /** GL_OES_primitive_bounding_box */
4012 bool NoPrimitiveBoundingBoxOutput
;
4014 /** GL_ARB_sparse_buffer */
4015 GLuint SparseBufferPageSize
;
4017 /** Used as an input for sha1 generation in the on-disk shader cache */
4018 unsigned char *dri_config_options_sha1
;
4020 /** When drivers are OK with mapped buffers during draw and other calls. */
4021 bool AllowMappedBuffersDuringExecution
;
4023 /** GL_ARB_get_program_binary */
4024 GLuint NumProgramBinaryFormats
;
4029 * Enable flag for each OpenGL extension. Different device drivers will
4030 * enable different extensions at runtime.
4032 struct gl_extensions
4034 GLboolean dummy
; /* don't remove this! */
4035 GLboolean dummy_true
; /* Set true by _mesa_init_extensions(). */
4036 GLboolean dummy_false
; /* Set false by _mesa_init_extensions(). */
4037 GLboolean ANGLE_texture_compression_dxt
;
4038 GLboolean ARB_ES2_compatibility
;
4039 GLboolean ARB_ES3_compatibility
;
4040 GLboolean ARB_ES3_1_compatibility
;
4041 GLboolean ARB_ES3_2_compatibility
;
4042 GLboolean ARB_arrays_of_arrays
;
4043 GLboolean ARB_base_instance
;
4044 GLboolean ARB_bindless_texture
;
4045 GLboolean ARB_blend_func_extended
;
4046 GLboolean ARB_buffer_storage
;
4047 GLboolean ARB_clear_texture
;
4048 GLboolean ARB_clip_control
;
4049 GLboolean ARB_color_buffer_float
;
4050 GLboolean ARB_compute_shader
;
4051 GLboolean ARB_compute_variable_group_size
;
4052 GLboolean ARB_conditional_render_inverted
;
4053 GLboolean ARB_conservative_depth
;
4054 GLboolean ARB_copy_image
;
4055 GLboolean ARB_cull_distance
;
4056 GLboolean ARB_depth_buffer_float
;
4057 GLboolean ARB_depth_clamp
;
4058 GLboolean ARB_depth_texture
;
4059 GLboolean ARB_derivative_control
;
4060 GLboolean ARB_draw_buffers_blend
;
4061 GLboolean ARB_draw_elements_base_vertex
;
4062 GLboolean ARB_draw_indirect
;
4063 GLboolean ARB_draw_instanced
;
4064 GLboolean ARB_fragment_coord_conventions
;
4065 GLboolean ARB_fragment_layer_viewport
;
4066 GLboolean ARB_fragment_program
;
4067 GLboolean ARB_fragment_program_shadow
;
4068 GLboolean ARB_fragment_shader
;
4069 GLboolean ARB_framebuffer_no_attachments
;
4070 GLboolean ARB_framebuffer_object
;
4071 GLboolean ARB_enhanced_layouts
;
4072 GLboolean ARB_explicit_attrib_location
;
4073 GLboolean ARB_explicit_uniform_location
;
4074 GLboolean ARB_gl_spirv
;
4075 GLboolean ARB_gpu_shader5
;
4076 GLboolean ARB_gpu_shader_fp64
;
4077 GLboolean ARB_gpu_shader_int64
;
4078 GLboolean ARB_half_float_vertex
;
4079 GLboolean ARB_indirect_parameters
;
4080 GLboolean ARB_instanced_arrays
;
4081 GLboolean ARB_internalformat_query
;
4082 GLboolean ARB_internalformat_query2
;
4083 GLboolean ARB_map_buffer_range
;
4084 GLboolean ARB_occlusion_query
;
4085 GLboolean ARB_occlusion_query2
;
4086 GLboolean ARB_pipeline_statistics_query
;
4087 GLboolean ARB_point_sprite
;
4088 GLboolean ARB_polygon_offset_clamp
;
4089 GLboolean ARB_post_depth_coverage
;
4090 GLboolean ARB_query_buffer_object
;
4091 GLboolean ARB_robust_buffer_access_behavior
;
4092 GLboolean ARB_sample_shading
;
4093 GLboolean ARB_seamless_cube_map
;
4094 GLboolean ARB_shader_atomic_counter_ops
;
4095 GLboolean ARB_shader_atomic_counters
;
4096 GLboolean ARB_shader_ballot
;
4097 GLboolean ARB_shader_bit_encoding
;
4098 GLboolean ARB_shader_clock
;
4099 GLboolean ARB_shader_draw_parameters
;
4100 GLboolean ARB_shader_group_vote
;
4101 GLboolean ARB_shader_image_load_store
;
4102 GLboolean ARB_shader_image_size
;
4103 GLboolean ARB_shader_precision
;
4104 GLboolean ARB_shader_stencil_export
;
4105 GLboolean ARB_shader_storage_buffer_object
;
4106 GLboolean ARB_shader_texture_image_samples
;
4107 GLboolean ARB_shader_texture_lod
;
4108 GLboolean ARB_shader_viewport_layer_array
;
4109 GLboolean ARB_shading_language_packing
;
4110 GLboolean ARB_shading_language_420pack
;
4111 GLboolean ARB_shadow
;
4112 GLboolean ARB_sparse_buffer
;
4113 GLboolean ARB_stencil_texturing
;
4115 GLboolean ARB_tessellation_shader
;
4116 GLboolean ARB_texture_border_clamp
;
4117 GLboolean ARB_texture_buffer_object
;
4118 GLboolean ARB_texture_buffer_object_rgb32
;
4119 GLboolean ARB_texture_buffer_range
;
4120 GLboolean ARB_texture_compression_bptc
;
4121 GLboolean ARB_texture_compression_rgtc
;
4122 GLboolean ARB_texture_cube_map
;
4123 GLboolean ARB_texture_cube_map_array
;
4124 GLboolean ARB_texture_env_combine
;
4125 GLboolean ARB_texture_env_crossbar
;
4126 GLboolean ARB_texture_env_dot3
;
4127 GLboolean ARB_texture_filter_anisotropic
;
4128 GLboolean ARB_texture_float
;
4129 GLboolean ARB_texture_gather
;
4130 GLboolean ARB_texture_mirror_clamp_to_edge
;
4131 GLboolean ARB_texture_multisample
;
4132 GLboolean ARB_texture_non_power_of_two
;
4133 GLboolean ARB_texture_stencil8
;
4134 GLboolean ARB_texture_query_levels
;
4135 GLboolean ARB_texture_query_lod
;
4136 GLboolean ARB_texture_rg
;
4137 GLboolean ARB_texture_rgb10_a2ui
;
4138 GLboolean ARB_texture_view
;
4139 GLboolean ARB_timer_query
;
4140 GLboolean ARB_transform_feedback2
;
4141 GLboolean ARB_transform_feedback3
;
4142 GLboolean ARB_transform_feedback_instanced
;
4143 GLboolean ARB_transform_feedback_overflow_query
;
4144 GLboolean ARB_uniform_buffer_object
;
4145 GLboolean ARB_vertex_attrib_64bit
;
4146 GLboolean ARB_vertex_program
;
4147 GLboolean ARB_vertex_shader
;
4148 GLboolean ARB_vertex_type_10f_11f_11f_rev
;
4149 GLboolean ARB_vertex_type_2_10_10_10_rev
;
4150 GLboolean ARB_viewport_array
;
4151 GLboolean EXT_blend_color
;
4152 GLboolean EXT_blend_equation_separate
;
4153 GLboolean EXT_blend_func_separate
;
4154 GLboolean EXT_blend_minmax
;
4155 GLboolean EXT_depth_bounds_test
;
4156 GLboolean EXT_disjoint_timer_query
;
4157 GLboolean EXT_draw_buffers2
;
4158 GLboolean EXT_framebuffer_multisample
;
4159 GLboolean EXT_framebuffer_multisample_blit_scaled
;
4160 GLboolean EXT_framebuffer_sRGB
;
4161 GLboolean EXT_gpu_program_parameters
;
4162 GLboolean EXT_gpu_shader4
;
4163 GLboolean EXT_memory_object
;
4164 GLboolean EXT_memory_object_fd
;
4165 GLboolean EXT_packed_float
;
4166 GLboolean EXT_pixel_buffer_object
;
4167 GLboolean EXT_point_parameters
;
4168 GLboolean EXT_provoking_vertex
;
4169 GLboolean EXT_shader_integer_mix
;
4170 GLboolean EXT_shader_samples_identical
;
4171 GLboolean EXT_stencil_two_side
;
4172 GLboolean EXT_texture_array
;
4173 GLboolean EXT_texture_compression_latc
;
4174 GLboolean EXT_texture_compression_s3tc
;
4175 GLboolean EXT_texture_env_dot3
;
4176 GLboolean EXT_texture_filter_anisotropic
;
4177 GLboolean EXT_texture_integer
;
4178 GLboolean EXT_texture_mirror_clamp
;
4179 GLboolean EXT_texture_shared_exponent
;
4180 GLboolean EXT_texture_snorm
;
4181 GLboolean EXT_texture_sRGB
;
4182 GLboolean EXT_texture_sRGB_decode
;
4183 GLboolean EXT_texture_swizzle
;
4184 GLboolean EXT_texture_type_2_10_10_10_REV
;
4185 GLboolean EXT_transform_feedback
;
4186 GLboolean EXT_timer_query
;
4187 GLboolean EXT_vertex_array_bgra
;
4188 GLboolean EXT_window_rectangles
;
4189 GLboolean OES_copy_image
;
4190 GLboolean OES_primitive_bounding_box
;
4191 GLboolean OES_sample_variables
;
4192 GLboolean OES_standard_derivatives
;
4193 GLboolean OES_texture_buffer
;
4194 GLboolean OES_texture_cube_map_array
;
4195 GLboolean OES_viewport_array
;
4196 /* vendor extensions */
4197 GLboolean AMD_performance_monitor
;
4198 GLboolean AMD_pinned_memory
;
4199 GLboolean AMD_seamless_cubemap_per_texture
;
4200 GLboolean AMD_vertex_shader_layer
;
4201 GLboolean AMD_vertex_shader_viewport_index
;
4202 GLboolean ANDROID_extension_pack_es31a
;
4203 GLboolean APPLE_object_purgeable
;
4204 GLboolean ATI_meminfo
;
4205 GLboolean ATI_texture_compression_3dc
;
4206 GLboolean ATI_texture_mirror_once
;
4207 GLboolean ATI_texture_env_combine3
;
4208 GLboolean ATI_fragment_shader
;
4209 GLboolean ATI_separate_stencil
;
4210 GLboolean GREMEDY_string_marker
;
4211 GLboolean INTEL_conservative_rasterization
;
4212 GLboolean INTEL_performance_query
;
4213 GLboolean KHR_blend_equation_advanced
;
4214 GLboolean KHR_blend_equation_advanced_coherent
;
4215 GLboolean KHR_robustness
;
4216 GLboolean KHR_texture_compression_astc_hdr
;
4217 GLboolean KHR_texture_compression_astc_ldr
;
4218 GLboolean KHR_texture_compression_astc_sliced_3d
;
4219 GLboolean MESA_tile_raster_order
;
4220 GLboolean MESA_pack_invert
;
4221 GLboolean MESA_shader_framebuffer_fetch
;
4222 GLboolean MESA_shader_framebuffer_fetch_non_coherent
;
4223 GLboolean MESA_shader_integer_functions
;
4224 GLboolean MESA_ycbcr_texture
;
4225 GLboolean NV_conditional_render
;
4226 GLboolean NV_fill_rectangle
;
4227 GLboolean NV_fog_distance
;
4228 GLboolean NV_point_sprite
;
4229 GLboolean NV_primitive_restart
;
4230 GLboolean NV_texture_barrier
;
4231 GLboolean NV_texture_env_combine4
;
4232 GLboolean NV_texture_rectangle
;
4233 GLboolean NV_vdpau_interop
;
4234 GLboolean NVX_gpu_memory_info
;
4235 GLboolean TDFX_texture_compression_FXT1
;
4236 GLboolean OES_EGL_image
;
4237 GLboolean OES_draw_texture
;
4238 GLboolean OES_depth_texture_cube_map
;
4239 GLboolean OES_EGL_image_external
;
4240 GLboolean OES_texture_float
;
4241 GLboolean OES_texture_float_linear
;
4242 GLboolean OES_texture_half_float
;
4243 GLboolean OES_texture_half_float_linear
;
4244 GLboolean OES_compressed_ETC1_RGB8_texture
;
4245 GLboolean OES_geometry_shader
;
4246 GLboolean OES_texture_compression_astc
;
4247 GLboolean extension_sentinel
;
4248 /** The extension string */
4249 const GLubyte
*String
;
4250 /** Number of supported extensions */
4253 * The context version which extension helper functions compare against.
4254 * By default, the value is equal to ctx->Version. This changes to ~0
4255 * while meta is in progress.
4259 * Force-enabled, yet unrecognized, extensions.
4260 * See _mesa_one_time_init_extension_overrides()
4262 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4263 const char *unrecognized_extensions
[MAX_UNRECOGNIZED_EXTENSIONS
];
4268 * A stack of matrices (projection, modelview, color, texture, etc).
4270 struct gl_matrix_stack
4272 GLmatrix
*Top
; /**< points into Stack */
4273 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
4274 unsigned StackSize
; /**< Number of elements in Stack */
4275 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
4276 GLuint MaxDepth
; /**< size of Stack[] array */
4277 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4282 * \name Bits for image transfer operations
4283 * \sa __struct gl_contextRec::ImageTransferState.
4286 #define IMAGE_SCALE_BIAS_BIT 0x1
4287 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4288 #define IMAGE_MAP_COLOR_BIT 0x4
4289 #define IMAGE_CLAMP_BIT 0x800
4292 /** Pixel Transfer ops */
4293 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4294 IMAGE_SHIFT_OFFSET_BIT | \
4295 IMAGE_MAP_COLOR_BIT)
4298 * \name Bits to indicate what state has changed.
4301 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4302 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4303 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4304 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4305 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4306 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4307 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4308 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4309 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4310 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4311 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4312 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4313 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4314 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4315 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4316 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4317 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4318 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4319 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4320 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4321 #define _NEW_ARRAY (1u << 20) /**< gl_context::Array */
4322 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4323 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4324 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4325 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4326 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4327 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4328 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4330 #define _NEW_FRAG_CLAMP (1u << 29)
4331 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4332 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4338 * Composite state flags
4341 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4343 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4344 _NEW_TEXTURE_STATE | \
4349 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4359 /* This has to be included here. */
4363 /** Opaque declaration of display list payload data type */
4364 union gl_dlist_node
;
4368 * Provide a location where information about a display list can be
4369 * collected. Could be extended with driverPrivate structures,
4370 * etc. in the future.
4372 struct gl_display_list
4375 GLbitfield Flags
; /**< DLIST_x flags */
4376 GLchar
*Label
; /**< GL_KHR_debug */
4377 /** The dlist commands are in a linked list of nodes */
4378 union gl_dlist_node
*Head
;
4383 * State used during display list compilation and execution.
4385 struct gl_dlist_state
4387 struct gl_display_list
*CurrentList
; /**< List currently being compiled */
4388 union gl_dlist_node
*CurrentBlock
; /**< Pointer to current block of nodes */
4389 GLuint CurrentPos
; /**< Index into current block of nodes */
4390 GLuint CallDepth
; /**< Current recursion calling depth */
4392 GLvertexformat ListVtxfmt
;
4394 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
4395 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
4397 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
4398 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
4401 /* State known to have been set by the currently-compiling display
4402 * list. Used to eliminate some redundant state changes.
4410 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
4411 * to small enums suitable for use as an array index.
4414 enum mesa_debug_source
{
4415 MESA_DEBUG_SOURCE_API
,
4416 MESA_DEBUG_SOURCE_WINDOW_SYSTEM
,
4417 MESA_DEBUG_SOURCE_SHADER_COMPILER
,
4418 MESA_DEBUG_SOURCE_THIRD_PARTY
,
4419 MESA_DEBUG_SOURCE_APPLICATION
,
4420 MESA_DEBUG_SOURCE_OTHER
,
4421 MESA_DEBUG_SOURCE_COUNT
4424 enum mesa_debug_type
{
4425 MESA_DEBUG_TYPE_ERROR
,
4426 MESA_DEBUG_TYPE_DEPRECATED
,
4427 MESA_DEBUG_TYPE_UNDEFINED
,
4428 MESA_DEBUG_TYPE_PORTABILITY
,
4429 MESA_DEBUG_TYPE_PERFORMANCE
,
4430 MESA_DEBUG_TYPE_OTHER
,
4431 MESA_DEBUG_TYPE_MARKER
,
4432 MESA_DEBUG_TYPE_PUSH_GROUP
,
4433 MESA_DEBUG_TYPE_POP_GROUP
,
4434 MESA_DEBUG_TYPE_COUNT
4437 enum mesa_debug_severity
{
4438 MESA_DEBUG_SEVERITY_LOW
,
4439 MESA_DEBUG_SEVERITY_MEDIUM
,
4440 MESA_DEBUG_SEVERITY_HIGH
,
4441 MESA_DEBUG_SEVERITY_NOTIFICATION
,
4442 MESA_DEBUG_SEVERITY_COUNT
4448 * Driver-specific state flags.
4450 * These are or'd with gl_context::NewDriverState to notify a driver about
4451 * a state change. The driver sets the flags at context creation and
4452 * the meaning of the bits set is opaque to core Mesa.
4454 struct gl_driver_flags
4456 /** gl_context::Array::_DrawArrays (vertex array state) */
4459 /** gl_context::TransformFeedback::CurrentObject */
4460 uint64_t NewTransformFeedback
;
4462 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4463 uint64_t NewTransformFeedbackProg
;
4465 /** gl_context::RasterDiscard */
4466 uint64_t NewRasterizerDiscard
;
4468 /** gl_context::TileRasterOrder* */
4469 uint64_t NewTileRasterOrder
;
4472 * gl_context::UniformBufferBindings
4473 * gl_shader_program::UniformBlocks
4475 uint64_t NewUniformBuffer
;
4478 * gl_context::ShaderStorageBufferBindings
4479 * gl_shader_program::ShaderStorageBlocks
4481 uint64_t NewShaderStorageBuffer
;
4483 uint64_t NewTextureBuffer
;
4486 * gl_context::AtomicBufferBindings
4488 uint64_t NewAtomicBuffer
;
4491 * gl_context::ImageUnits
4493 uint64_t NewImageUnits
;
4496 * gl_context::TessCtrlProgram::patch_default_*
4498 uint64_t NewDefaultTessLevels
;
4501 * gl_context::IntelConservativeRasterization
4503 uint64_t NewIntelConservativeRasterization
;
4506 * gl_context::Scissor::WindowRects
4508 uint64_t NewWindowRectangles
;
4510 /** gl_context::Color::sRGBEnabled */
4511 uint64_t NewFramebufferSRGB
;
4513 /** gl_context::Scissor::EnableFlags */
4514 uint64_t NewScissorTest
;
4516 /** gl_context::Scissor::ScissorArray */
4517 uint64_t NewScissorRect
;
4519 /** gl_context::Color::Alpha* */
4520 uint64_t NewAlphaTest
;
4522 /** gl_context::Color::Blend/Dither */
4525 /** gl_context::Color::BlendColor */
4526 uint64_t NewBlendColor
;
4528 /** gl_context::Color::Color/Index */
4529 uint64_t NewColorMask
;
4531 /** gl_context::Depth */
4534 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4535 uint64_t NewLogicOp
;
4537 /** gl_context::Multisample::Enabled */
4538 uint64_t NewMultisampleEnable
;
4540 /** gl_context::Multisample::SampleAlphaTo* */
4541 uint64_t NewSampleAlphaToXEnable
;
4543 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4544 uint64_t NewSampleMask
;
4546 /** gl_context::Multisample::(Min)SampleShading */
4547 uint64_t NewSampleShading
;
4549 /** gl_context::Stencil */
4550 uint64_t NewStencil
;
4552 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4553 uint64_t NewClipControl
;
4555 /** gl_context::Transform::EyeUserPlane */
4556 uint64_t NewClipPlane
;
4558 /** gl_context::Transform::ClipPlanesEnabled */
4559 uint64_t NewClipPlaneEnable
;
4561 /** gl_context::Transform::DepthClamp */
4562 uint64_t NewDepthClamp
;
4564 /** gl_context::Line */
4565 uint64_t NewLineState
;
4567 /** gl_context::Polygon */
4568 uint64_t NewPolygonState
;
4570 /** gl_context::PolygonStipple */
4571 uint64_t NewPolygonStipple
;
4573 /** gl_context::ViewportArray */
4574 uint64_t NewViewport
;
4576 /** Shader constants (uniforms, program parameters, state constants) */
4577 uint64_t NewShaderConstants
[MESA_SHADER_STAGES
];
4580 struct gl_buffer_binding
4582 struct gl_buffer_object
*BufferObject
;
4583 /** Start of uniform block data in the buffer */
4585 /** Size of data allowed to be referenced from the buffer (in bytes) */
4588 * glBindBufferBase() indicates that the Size should be ignored and only
4589 * limited by the current size of the BufferObject.
4591 GLboolean AutomaticSize
;
4595 * ARB_shader_image_load_store image unit.
4597 struct gl_image_unit
4600 * Texture object bound to this unit.
4602 struct gl_texture_object
*TexObj
;
4605 * Level of the texture object bound to this unit.
4610 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4611 * GL_FALSE if only some specific layer of the texture is bound.
4617 * Layer of the texture object bound to this unit as specified by the
4623 * Layer of the texture object bound to this unit, or zero if the
4624 * whole level is bound.
4629 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4630 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4635 * GL internal format that determines the interpretation of the
4636 * image memory when shader image operations are performed through
4642 * Mesa format corresponding to \c Format.
4644 mesa_format _ActualFormat
;
4649 * Shader subroutines storage
4651 struct gl_subroutine_index_binding
4657 struct gl_texture_handle_object
4659 struct gl_texture_object
*texObj
;
4660 struct gl_sampler_object
*sampObj
;
4664 struct gl_image_handle_object
4666 struct gl_image_unit imgObj
;
4670 struct gl_memory_object
4672 GLuint Name
; /**< hash table ID/name */
4673 GLboolean Immutable
; /**< denotes mutability state of parameters */
4674 GLboolean Dedicated
; /**< import memory from a dedicated allocation */
4678 * Mesa rendering context.
4680 * This is the central context data structure for Mesa. Almost all
4681 * OpenGL state is contained in this structure.
4682 * Think of this as a base class from which device drivers will derive
4687 /** State possibly shared with other contexts in the address space */
4688 struct gl_shared_state
*Shared
;
4690 /** \name API function pointer tables */
4695 * The current dispatch table for non-displaylist-saving execution, either
4696 * BeginEnd or OutsideBeginEnd
4698 struct _glapi_table
*Exec
;
4700 * The normal dispatch table for non-displaylist-saving, non-begin/end
4702 struct _glapi_table
*OutsideBeginEnd
;
4703 /** The dispatch table used between glNewList() and glEndList() */
4704 struct _glapi_table
*Save
;
4706 * The dispatch table used between glBegin() and glEnd() (outside of a
4707 * display list). Only valid functions between those two are set, which is
4708 * mostly just the set in a GLvertexformat struct.
4710 struct _glapi_table
*BeginEnd
;
4712 * Dispatch table for when a graphics reset has happened.
4714 struct _glapi_table
*ContextLost
;
4716 * Dispatch table used to marshal API calls from the client program to a
4717 * separate server thread. NULL if API calls are not being marshalled to
4720 struct _glapi_table
*MarshalExec
;
4722 * Dispatch table currently in use for fielding API calls from the client
4723 * program. If API calls are being marshalled to another thread, this ==
4724 * MarshalExec. Otherwise it == CurrentServerDispatch.
4726 struct _glapi_table
*CurrentClientDispatch
;
4729 * Dispatch table currently in use for performing API calls. == Save or
4732 struct _glapi_table
*CurrentServerDispatch
;
4736 struct glthread_state
*GLThread
;
4738 struct gl_config Visual
;
4739 struct gl_framebuffer
*DrawBuffer
; /**< buffer for writing */
4740 struct gl_framebuffer
*ReadBuffer
; /**< buffer for reading */
4741 struct gl_framebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
4742 struct gl_framebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
4745 * Device driver function pointer table
4747 struct dd_function_table Driver
;
4749 /** Core/Driver constants */
4750 struct gl_constants Const
;
4752 /** \name The various 4x4 matrix stacks */
4754 struct gl_matrix_stack ModelviewMatrixStack
;
4755 struct gl_matrix_stack ProjectionMatrixStack
;
4756 struct gl_matrix_stack TextureMatrixStack
[MAX_TEXTURE_UNITS
];
4757 struct gl_matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
4758 struct gl_matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
4761 /** Combined modelview and projection matrix */
4762 GLmatrix _ModelProjectMatrix
;
4764 /** \name Display lists */
4765 struct gl_dlist_state ListState
;
4767 GLboolean ExecuteFlag
; /**< Execute GL commands? */
4768 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
4770 /** Extension information */
4771 struct gl_extensions Extensions
;
4773 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4775 char *VersionString
;
4777 /** \name State attribute stack (for glPush/PopAttrib) */
4779 GLuint AttribStackDepth
;
4780 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
4783 /** \name Renderer attribute groups
4785 * We define a struct for each attribute group to make pushing and popping
4786 * attributes easy. Also it's a good organization.
4789 struct gl_accum_attrib Accum
; /**< Accum buffer attributes */
4790 struct gl_colorbuffer_attrib Color
; /**< Color buffer attributes */
4791 struct gl_current_attrib Current
; /**< Current attributes */
4792 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
4793 struct gl_eval_attrib Eval
; /**< Eval attributes */
4794 struct gl_fog_attrib Fog
; /**< Fog attributes */
4795 struct gl_hint_attrib Hint
; /**< Hint attributes */
4796 struct gl_light_attrib Light
; /**< Light attributes */
4797 struct gl_line_attrib Line
; /**< Line attributes */
4798 struct gl_list_attrib List
; /**< List attributes */
4799 struct gl_multisample_attrib Multisample
;
4800 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
4801 struct gl_point_attrib Point
; /**< Point attributes */
4802 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
4803 GLuint PolygonStipple
[32]; /**< Polygon stipple */
4804 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
4805 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
4806 struct gl_texture_attrib Texture
; /**< Texture attributes */
4807 struct gl_transform_attrib Transform
; /**< Transformation attributes */
4808 struct gl_viewport_attrib ViewportArray
[MAX_VIEWPORTS
]; /**< Viewport attributes */
4811 /** \name Client attribute stack */
4813 GLuint ClientAttribStackDepth
;
4814 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
4817 /** \name Client attribute groups */
4819 struct gl_array_attrib Array
; /**< Vertex arrays */
4820 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
4821 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
4822 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
4825 /** \name Other assorted state (not pushed/popped on attribute stack) */
4827 struct gl_pixelmaps PixelMaps
;
4829 struct gl_evaluators EvalMap
; /**< All evaluators */
4830 struct gl_feedback Feedback
; /**< Feedback */
4831 struct gl_selection Select
; /**< Selection */
4833 struct gl_program_state Program
; /**< general program state */
4834 struct gl_vertex_program_state VertexProgram
;
4835 struct gl_fragment_program_state FragmentProgram
;
4836 struct gl_geometry_program_state GeometryProgram
;
4837 struct gl_compute_program_state ComputeProgram
;
4838 struct gl_tess_ctrl_program_state TessCtrlProgram
;
4839 struct gl_tess_eval_program_state TessEvalProgram
;
4840 struct gl_ati_fragment_shader_state ATIFragmentShader
;
4842 struct gl_pipeline_shader_state Pipeline
; /**< GLSL pipeline shader object state */
4843 struct gl_pipeline_object Shader
; /**< GLSL shader object state */
4846 * Current active shader pipeline state
4848 * Almost all internal users want ::_Shader instead of ::Shader. The
4849 * exceptions are bits of legacy GLSL API that do not know about separate
4852 * If a program is active via \c glUseProgram, this will point to
4855 * If a program pipeline is active via \c glBindProgramPipeline, this will
4856 * point to \c ::Pipeline.Current.
4858 * If neither a program nor a program pipeline is active, this will point to
4859 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
4862 struct gl_pipeline_object
*_Shader
;
4864 struct gl_query_state Query
; /**< occlusion, timer queries */
4866 struct gl_transform_feedback_state TransformFeedback
;
4868 struct gl_perf_monitor_state PerfMonitor
;
4869 struct gl_perf_query_state PerfQuery
;
4871 struct gl_buffer_object
*DrawIndirectBuffer
; /** < GL_ARB_draw_indirect */
4872 struct gl_buffer_object
*ParameterBuffer
; /** < GL_ARB_indirect_parameters */
4873 struct gl_buffer_object
*DispatchIndirectBuffer
; /** < GL_ARB_compute_shader */
4875 struct gl_buffer_object
*CopyReadBuffer
; /**< GL_ARB_copy_buffer */
4876 struct gl_buffer_object
*CopyWriteBuffer
; /**< GL_ARB_copy_buffer */
4878 struct gl_buffer_object
*QueryBuffer
; /**< GL_ARB_query_buffer_object */
4881 * Current GL_ARB_uniform_buffer_object binding referenced by
4882 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
4884 struct gl_buffer_object
*UniformBuffer
;
4887 * Current GL_ARB_shader_storage_buffer_object binding referenced by
4888 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
4890 struct gl_buffer_object
*ShaderStorageBuffer
;
4893 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
4894 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
4895 * associated with uniform blocks by glUniformBlockBinding()'s state in the
4898 struct gl_buffer_binding
4899 UniformBufferBindings
[MAX_COMBINED_UNIFORM_BUFFERS
];
4902 * Array of shader storage buffers for ARB_shader_storage_buffer_object
4903 * and GL 4.3. This is set up using glBindBufferRange() or
4904 * glBindBufferBase(). They are associated with shader storage blocks by
4905 * glShaderStorageBlockBinding()'s state in the shader program.
4907 struct gl_buffer_binding
4908 ShaderStorageBufferBindings
[MAX_COMBINED_SHADER_STORAGE_BUFFERS
];
4911 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
4914 struct gl_buffer_object
*AtomicBuffer
;
4917 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
4920 struct gl_buffer_object
*ExternalVirtualMemoryBuffer
;
4923 * Array of atomic counter buffer binding points.
4925 struct gl_buffer_binding
4926 AtomicBufferBindings
[MAX_COMBINED_ATOMIC_BUFFERS
];
4929 * Array of image units for ARB_shader_image_load_store.
4931 struct gl_image_unit ImageUnits
[MAX_IMAGE_UNITS
];
4933 struct gl_subroutine_index_binding SubroutineIndex
[MESA_SHADER_STAGES
];
4936 struct gl_meta_state
*Meta
; /**< for "meta" operations */
4938 /* GL_EXT_framebuffer_object */
4939 struct gl_renderbuffer
*CurrentRenderbuffer
;
4941 GLenum ErrorValue
; /**< Last error code */
4944 * Recognize and silence repeated error debug messages in buggy apps.
4946 const char *ErrorDebugFmtString
;
4947 GLuint ErrorDebugCount
;
4949 /* GL_ARB_debug_output/GL_KHR_debug */
4950 simple_mtx_t DebugMutex
;
4951 struct gl_debug_state
*Debug
;
4953 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
4954 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
4955 uint64_t NewDriverState
; /**< bitwise-or of flags from DriverFlags */
4957 struct gl_driver_flags DriverFlags
;
4959 GLboolean ViewportInitialized
; /**< has viewport size been initialized? */
4961 GLbitfield varying_vp_inputs
; /**< mask of VERT_BIT_* flags */
4963 /** \name Derived state */
4964 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
4965 GLfloat _EyeZDir
[3];
4966 GLfloat _ModelViewInvScale
; /* may be for model- or eyespace lighting */
4967 GLfloat _ModelViewInvScaleEyespace
; /* always factor defined in spec */
4968 GLboolean _NeedEyeCoords
;
4969 GLboolean _ForceEyeCoords
;
4971 GLuint TextureStateTimestamp
; /**< detect changes to shared state */
4973 struct gl_list_extensions
*ListExt
; /**< driver dlist extensions */
4975 /** \name For debugging/development only */
4977 GLboolean FirstTimeCurrent
;
4981 * False if this context was created without a config. This is needed
4982 * because the initial state of glDrawBuffers depends on this
4984 GLboolean HasConfig
;
4986 GLboolean TextureFormatSupported
[MESA_FORMAT_COUNT
];
4988 GLboolean RasterDiscard
; /**< GL_RASTERIZER_DISCARD */
4989 GLboolean IntelConservativeRasterization
; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
4991 /** Does glVertexAttrib(0) alias glVertex()? */
4992 bool _AttribZeroAliasesVertex
;
4995 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
4996 * renderer's tiles should be excecuted, to meet the requirements of
4997 * GL_MESA_tile_raster_order.
4999 GLboolean TileRasterOrderFixed
;
5000 GLboolean TileRasterOrderIncreasingX
;
5001 GLboolean TileRasterOrderIncreasingY
;
5004 * \name Hooks for module contexts.
5006 * These will eventually live in the driver or elsewhere.
5009 void *swrast_context
;
5010 void *swsetup_context
;
5011 void *swtnl_context
;
5012 struct vbo_context
*vbo_context
;
5013 struct st_context
*st
;
5018 * \name NV_vdpau_interop
5021 const void *vdpDevice
;
5022 const void *vdpGetProcAddress
;
5023 struct set
*vdpSurfaces
;
5027 * Has this context observed a GPU reset in any context in the share group?
5029 * Once this field becomes true, it is never reset to false.
5031 GLboolean ShareGroupReset
;
5034 * \name OES_primitive_bounding_box
5036 * Stores the arguments to glPrimitiveBoundingBox
5038 GLfloat PrimitiveBoundingBox
[8];
5040 struct disk_cache
*Cache
;
5043 * \name GL_ARB_bindless_texture
5046 struct hash_table_u64
*ResidentTextureHandles
;
5047 struct hash_table_u64
*ResidentImageHandles
;
5052 * Information about memory usage. All sizes are in kilobytes.
5054 struct gl_memory_info
5056 unsigned total_device_memory
; /**< size of device memory, e.g. VRAM */
5057 unsigned avail_device_memory
; /**< free device memory at the moment */
5058 unsigned total_staging_memory
; /**< size of staging memory, e.g. GART */
5059 unsigned avail_staging_memory
; /**< free staging memory at the moment */
5060 unsigned device_memory_evicted
; /**< size of memory evicted (monotonic counter) */
5061 unsigned nr_device_memory_evictions
; /**< # of evictions (monotonic counter) */
5065 extern int MESA_VERBOSE
;
5066 extern int MESA_DEBUG_FLAGS
;
5067 # define MESA_FUNCTION __func__
5069 # define MESA_VERBOSE 0
5070 # define MESA_DEBUG_FLAGS 0
5071 # define MESA_FUNCTION "a function"
5075 /** The MESA_VERBOSE var is a bitmask of these flags */
5078 VERBOSE_VARRAY
= 0x0001,
5079 VERBOSE_TEXTURE
= 0x0002,
5080 VERBOSE_MATERIAL
= 0x0004,
5081 VERBOSE_PIPELINE
= 0x0008,
5082 VERBOSE_DRIVER
= 0x0010,
5083 VERBOSE_STATE
= 0x0020,
5084 VERBOSE_API
= 0x0040,
5085 VERBOSE_DISPLAY_LIST
= 0x0100,
5086 VERBOSE_LIGHTING
= 0x0200,
5087 VERBOSE_PRIMS
= 0x0400,
5088 VERBOSE_VERTS
= 0x0800,
5089 VERBOSE_DISASSEM
= 0x1000,
5090 VERBOSE_DRAW
= 0x2000,
5091 VERBOSE_SWAPBUFFERS
= 0x4000
5095 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5098 DEBUG_SILENT
= (1 << 0),
5099 DEBUG_ALWAYS_FLUSH
= (1 << 1),
5100 DEBUG_INCOMPLETE_TEXTURE
= (1 << 2),
5101 DEBUG_INCOMPLETE_FBO
= (1 << 3),
5102 DEBUG_CONTEXT
= (1 << 4)
5109 #endif /* MTYPES_H */