mesa: precompute _mesa_primitive_restart_index during state changes
[mesa.git] / src / mesa / main / mtypes.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
24 */
25
26 /**
27 * \file mtypes.h
28 * Main Mesa data structures.
29 *
30 * Please try to mark derived values with a leading underscore ('_').
31 */
32
33 #ifndef MTYPES_H
34 #define MTYPES_H
35
36
37 #include <stdint.h> /* uint32_t */
38 #include <stdbool.h>
39 #include "c11/threads.h"
40
41 #include "main/glheader.h"
42 #include "main/glthread.h"
43 #include "main/menums.h"
44 #include "main/config.h"
45 #include "glapi/glapi.h"
46 #include "math/m_matrix.h" /* GLmatrix */
47 #include "compiler/shader_enums.h"
48 #include "compiler/shader_info.h"
49 #include "main/formats.h" /* MESA_FORMAT_COUNT */
50 #include "compiler/glsl/list.h"
51 #include "util/simple_mtx.h"
52 #include "util/u_dynarray.h"
53
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
60 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
61
62
63 /**
64 * \name Some forward type declarations
65 */
66 /*@{*/
67 struct _mesa_HashTable;
68 struct gl_attrib_node;
69 struct gl_list_extensions;
70 struct gl_meta_state;
71 struct gl_program_cache;
72 struct gl_texture_object;
73 struct gl_debug_state;
74 struct gl_context;
75 struct st_context;
76 struct gl_uniform_storage;
77 struct prog_instruction;
78 struct gl_program_parameter_list;
79 struct gl_shader_spirv_data;
80 struct set;
81 struct shader_includes;
82 struct vbo_context;
83 /*@}*/
84
85
86 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
87 #define PRIM_MAX GL_PATCHES
88 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
89 #define PRIM_UNKNOWN (PRIM_MAX + 2)
90
91 /**
92 * Determine if the given gl_varying_slot appears in the fragment shader.
93 */
94 static inline GLboolean
95 _mesa_varying_slot_in_fs(gl_varying_slot slot)
96 {
97 switch (slot) {
98 case VARYING_SLOT_PSIZ:
99 case VARYING_SLOT_BFC0:
100 case VARYING_SLOT_BFC1:
101 case VARYING_SLOT_EDGE:
102 case VARYING_SLOT_CLIP_VERTEX:
103 case VARYING_SLOT_LAYER:
104 case VARYING_SLOT_TESS_LEVEL_OUTER:
105 case VARYING_SLOT_TESS_LEVEL_INNER:
106 case VARYING_SLOT_BOUNDING_BOX0:
107 case VARYING_SLOT_BOUNDING_BOX1:
108 return GL_FALSE;
109 default:
110 return GL_TRUE;
111 }
112 }
113
114 /**
115 * Bit flags for all renderbuffers
116 */
117 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
118 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
119 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
120 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
121 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
122 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
123 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
124 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
125 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
126 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
127 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
128 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
129 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
130 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
131 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
132 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
133 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
134 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
135 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
136
137 /**
138 * Mask of all the color buffer bits (but not accum).
139 */
140 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
141 BUFFER_BIT_BACK_LEFT | \
142 BUFFER_BIT_FRONT_RIGHT | \
143 BUFFER_BIT_BACK_RIGHT | \
144 BUFFER_BIT_AUX0 | \
145 BUFFER_BIT_COLOR0 | \
146 BUFFER_BIT_COLOR1 | \
147 BUFFER_BIT_COLOR2 | \
148 BUFFER_BIT_COLOR3 | \
149 BUFFER_BIT_COLOR4 | \
150 BUFFER_BIT_COLOR5 | \
151 BUFFER_BIT_COLOR6 | \
152 BUFFER_BIT_COLOR7)
153
154 /* Mask of bits for depth+stencil buffers */
155 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
156
157 /**
158 * Framebuffer configuration (aka visual / pixelformat)
159 * Note: some of these fields should be boolean, but it appears that
160 * code in drivers/dri/common/util.c requires int-sized fields.
161 */
162 struct gl_config
163 {
164 GLboolean floatMode;
165 GLuint doubleBufferMode;
166 GLuint stereoMode;
167
168 GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
169 GLuint redMask, greenMask, blueMask, alphaMask;
170 GLint redShift, greenShift, blueShift, alphaShift;
171 GLint rgbBits; /* total bits for rgb */
172
173 GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
174 GLint depthBits;
175 GLint stencilBits;
176
177 GLint numAuxBuffers;
178
179 GLint level;
180
181 /* EXT_visual_rating / GLX 1.2 */
182 GLint visualRating;
183
184 /* EXT_visual_info / GLX 1.2 */
185 GLint transparentPixel;
186 /* colors are floats scaled to ints */
187 GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
188 GLint transparentIndex;
189
190 /* ARB_multisample / SGIS_multisample */
191 GLint sampleBuffers;
192 GLuint samples;
193
194 /* SGIX_pbuffer / GLX 1.3 */
195 GLint maxPbufferWidth;
196 GLint maxPbufferHeight;
197 GLint maxPbufferPixels;
198 GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
199 GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
200
201 /* OML_swap_method */
202 GLint swapMethod;
203
204 /* EXT_texture_from_pixmap */
205 GLint bindToTextureRgb;
206 GLint bindToTextureRgba;
207 GLint bindToMipmapTexture;
208 GLint bindToTextureTargets;
209 GLint yInverted;
210
211 /* EXT_framebuffer_sRGB */
212 GLint sRGBCapable;
213
214 /* EGL_KHR_mutable_render_buffer */
215 GLuint mutableRenderBuffer; /* bool */
216 };
217
218
219 /**
220 * \name Bit flags used for updating material values.
221 */
222 /*@{*/
223 #define MAT_ATTRIB_FRONT_AMBIENT 0
224 #define MAT_ATTRIB_BACK_AMBIENT 1
225 #define MAT_ATTRIB_FRONT_DIFFUSE 2
226 #define MAT_ATTRIB_BACK_DIFFUSE 3
227 #define MAT_ATTRIB_FRONT_SPECULAR 4
228 #define MAT_ATTRIB_BACK_SPECULAR 5
229 #define MAT_ATTRIB_FRONT_EMISSION 6
230 #define MAT_ATTRIB_BACK_EMISSION 7
231 #define MAT_ATTRIB_FRONT_SHININESS 8
232 #define MAT_ATTRIB_BACK_SHININESS 9
233 #define MAT_ATTRIB_FRONT_INDEXES 10
234 #define MAT_ATTRIB_BACK_INDEXES 11
235 #define MAT_ATTRIB_MAX 12
236
237 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
238 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
239 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
240 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
241 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
242 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
243
244 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
245 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
246 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
247 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
248 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
249 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
250 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
251 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
252 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
253 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
254 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
255 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
256
257
258 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
259 MAT_BIT_FRONT_AMBIENT | \
260 MAT_BIT_FRONT_DIFFUSE | \
261 MAT_BIT_FRONT_SPECULAR | \
262 MAT_BIT_FRONT_SHININESS | \
263 MAT_BIT_FRONT_INDEXES)
264
265 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
266 MAT_BIT_BACK_AMBIENT | \
267 MAT_BIT_BACK_DIFFUSE | \
268 MAT_BIT_BACK_SPECULAR | \
269 MAT_BIT_BACK_SHININESS | \
270 MAT_BIT_BACK_INDEXES)
271
272 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
273 /*@}*/
274
275
276 /**
277 * Material state.
278 */
279 struct gl_material
280 {
281 GLfloat Attrib[MAT_ATTRIB_MAX][4];
282 };
283
284
285 /**
286 * Light state flags.
287 */
288 /*@{*/
289 #define LIGHT_SPOT 0x1
290 #define LIGHT_LOCAL_VIEWER 0x2
291 #define LIGHT_POSITIONAL 0x4
292 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
293 /*@}*/
294
295
296 /**
297 * Light source state.
298 */
299 struct gl_light
300 {
301 GLfloat Ambient[4]; /**< ambient color */
302 GLfloat Diffuse[4]; /**< diffuse color */
303 GLfloat Specular[4]; /**< specular color */
304 GLfloat EyePosition[4]; /**< position in eye coordinates */
305 GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */
306 GLfloat SpotExponent;
307 GLfloat SpotCutoff; /**< in degrees */
308 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
309 GLfloat ConstantAttenuation;
310 GLfloat LinearAttenuation;
311 GLfloat QuadraticAttenuation;
312 GLboolean Enabled; /**< On/off flag */
313
314 /**
315 * \name Derived fields
316 */
317 /*@{*/
318 GLbitfield _Flags; /**< Mask of LIGHT_x bits defined above */
319
320 GLfloat _Position[4]; /**< position in eye/obj coordinates */
321 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
322 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
323 GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
324 GLfloat _VP_inf_spot_attenuation;
325
326 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
327 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
328 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
329 /*@}*/
330 };
331
332
333 /**
334 * Light model state.
335 */
336 struct gl_lightmodel
337 {
338 GLfloat Ambient[4]; /**< ambient color */
339 GLboolean LocalViewer; /**< Local (or infinite) view point? */
340 GLboolean TwoSide; /**< Two (or one) sided lighting? */
341 GLenum16 ColorControl; /**< either GL_SINGLE_COLOR
342 or GL_SEPARATE_SPECULAR_COLOR */
343 };
344
345
346 /**
347 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
348 */
349 struct gl_accum_attrib
350 {
351 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
352 };
353
354
355 /**
356 * Used for storing clear color, texture border color, etc.
357 * The float values are typically unclamped.
358 */
359 union gl_color_union
360 {
361 GLfloat f[4];
362 GLint i[4];
363 GLuint ui[4];
364 };
365
366
367 /**
368 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
369 */
370 struct gl_colorbuffer_attrib
371 {
372 GLuint ClearIndex; /**< Index for glClear */
373 union gl_color_union ClearColor; /**< Color for glClear, unclamped */
374 GLuint IndexMask; /**< Color index write mask */
375
376 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
377 GLbitfield ColorMask;
378
379 GLenum16 DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
380
381 /**
382 * \name alpha testing
383 */
384 /*@{*/
385 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
386 GLenum16 AlphaFunc; /**< Alpha test function */
387 GLfloat AlphaRefUnclamped;
388 GLclampf AlphaRef; /**< Alpha reference value */
389 /*@}*/
390
391 /**
392 * \name Blending
393 */
394 /*@{*/
395 GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
396
397 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
398 * control, only on the fixed-pointness of the render target.
399 * The query does however depend on fragment color clamping.
400 */
401 GLfloat BlendColorUnclamped[4]; /**< Blending color */
402 GLfloat BlendColor[4]; /**< Blending color */
403
404 struct
405 {
406 GLenum16 SrcRGB; /**< RGB blend source term */
407 GLenum16 DstRGB; /**< RGB blend dest term */
408 GLenum16 SrcA; /**< Alpha blend source term */
409 GLenum16 DstA; /**< Alpha blend dest term */
410 GLenum16 EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
411 GLenum16 EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
412 /**
413 * Set if any blend factor uses SRC1. Computed at the time blend factors
414 * get set.
415 */
416 GLboolean _UsesDualSrc;
417 } Blend[MAX_DRAW_BUFFERS];
418 /** Are the blend func terms currently different for each buffer/target? */
419 GLboolean _BlendFuncPerBuffer;
420 /** Are the blend equations currently different for each buffer/target? */
421 GLboolean _BlendEquationPerBuffer;
422
423 /**
424 * Which advanced blending mode is in use (or BLEND_NONE).
425 *
426 * KHR_blend_equation_advanced only allows advanced blending with a single
427 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
428 * requires all draw buffers to match, so we only need a single value.
429 */
430 enum gl_advanced_blend_mode _AdvancedBlendMode;
431
432 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
433 bool BlendCoherent;
434 /*@}*/
435
436 /**
437 * \name Logic op
438 */
439 /*@{*/
440 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
441 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
442 GLenum16 LogicOp; /**< Logic operator */
443 enum gl_logicop_mode _LogicOp;
444 /*@}*/
445
446 GLboolean DitherFlag; /**< Dither enable flag */
447
448 GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
449 GLenum16 ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
450 GLenum16 ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
451
452 GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */
453 };
454
455
456 /**
457 * Vertex format to describe a vertex element.
458 */
459 struct gl_vertex_format
460 {
461 GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
462 GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
463 enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */
464 GLubyte Size:5; /**< components per element (1,2,3,4) */
465 GLubyte Normalized:1; /**< GL_ARB_vertex_program */
466 GLubyte Integer:1; /**< Integer-valued? */
467 GLubyte Doubles:1; /**< double values are not converted to floats */
468 GLubyte _ElementSize; /**< Size of each element in bytes */
469 };
470
471
472 /**
473 * Current attribute group (GL_CURRENT_BIT).
474 */
475 struct gl_current_attrib
476 {
477 /**
478 * \name Current vertex attributes (color, texcoords, etc).
479 * \note Values are valid only after FLUSH_VERTICES has been called.
480 * \note Index and Edgeflag current values are stored as floats in the
481 * SIX and SEVEN attribute slots.
482 * \note We need double storage for 64-bit vertex attributes
483 */
484 GLfloat Attrib[VERT_ATTRIB_MAX][4*2];
485
486 /**
487 * \name Current raster position attributes (always up to date after a
488 * glRasterPos call).
489 */
490 GLfloat RasterPos[4];
491 GLfloat RasterDistance;
492 GLfloat RasterColor[4];
493 GLfloat RasterSecondaryColor[4];
494 GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
495 GLboolean RasterPosValid;
496 };
497
498
499 /**
500 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
501 */
502 struct gl_depthbuffer_attrib
503 {
504 GLenum16 Func; /**< Function for depth buffer compare */
505 GLclampd Clear; /**< Value to clear depth buffer to */
506 GLboolean Test; /**< Depth buffering enabled flag */
507 GLboolean Mask; /**< Depth buffer writable? */
508 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
509 GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
510 };
511
512
513 /**
514 * Evaluator attribute group (GL_EVAL_BIT).
515 */
516 struct gl_eval_attrib
517 {
518 /**
519 * \name Enable bits
520 */
521 /*@{*/
522 GLboolean Map1Color4;
523 GLboolean Map1Index;
524 GLboolean Map1Normal;
525 GLboolean Map1TextureCoord1;
526 GLboolean Map1TextureCoord2;
527 GLboolean Map1TextureCoord3;
528 GLboolean Map1TextureCoord4;
529 GLboolean Map1Vertex3;
530 GLboolean Map1Vertex4;
531 GLboolean Map2Color4;
532 GLboolean Map2Index;
533 GLboolean Map2Normal;
534 GLboolean Map2TextureCoord1;
535 GLboolean Map2TextureCoord2;
536 GLboolean Map2TextureCoord3;
537 GLboolean Map2TextureCoord4;
538 GLboolean Map2Vertex3;
539 GLboolean Map2Vertex4;
540 GLboolean AutoNormal;
541 /*@}*/
542
543 /**
544 * \name Map Grid endpoints and divisions and calculated du values
545 */
546 /*@{*/
547 GLint MapGrid1un;
548 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
549 GLint MapGrid2un, MapGrid2vn;
550 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
551 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
552 /*@}*/
553 };
554
555
556 /**
557 * Compressed fog mode.
558 */
559 enum gl_fog_mode
560 {
561 FOG_NONE,
562 FOG_LINEAR,
563 FOG_EXP,
564 FOG_EXP2,
565 };
566
567
568 /**
569 * Fog attribute group (GL_FOG_BIT).
570 */
571 struct gl_fog_attrib
572 {
573 GLboolean Enabled; /**< Fog enabled flag */
574 GLboolean ColorSumEnabled;
575 uint8_t _PackedMode; /**< Fog mode as 2 bits */
576 uint8_t _PackedEnabledMode; /**< Masked CompressedMode */
577 GLfloat ColorUnclamped[4]; /**< Fog color */
578 GLfloat Color[4]; /**< Fog color */
579 GLfloat Density; /**< Density >= 0.0 */
580 GLfloat Start; /**< Start distance in eye coords */
581 GLfloat End; /**< End distance in eye coords */
582 GLfloat Index; /**< Fog index */
583 GLenum16 Mode; /**< Fog mode */
584 GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */
585 GLenum16 FogDistanceMode; /**< GL_NV_fog_distance */
586 };
587
588
589 /**
590 * Hint attribute group (GL_HINT_BIT).
591 *
592 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
593 */
594 struct gl_hint_attrib
595 {
596 GLenum16 PerspectiveCorrection;
597 GLenum16 PointSmooth;
598 GLenum16 LineSmooth;
599 GLenum16 PolygonSmooth;
600 GLenum16 Fog;
601 GLenum16 TextureCompression; /**< GL_ARB_texture_compression */
602 GLenum16 GenerateMipmap; /**< GL_SGIS_generate_mipmap */
603 GLenum16 FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
604 GLuint MaxShaderCompilerThreads; /**< GL_ARB_parallel_shader_compile */
605 };
606
607
608 /**
609 * Lighting attribute group (GL_LIGHT_BIT).
610 */
611 struct gl_light_attrib
612 {
613 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
614 struct gl_lightmodel Model; /**< Lighting model */
615
616 /**
617 * Front and back material values.
618 * Note: must call FLUSH_VERTICES() before using.
619 */
620 struct gl_material Material;
621
622 GLboolean Enabled; /**< Lighting enabled flag */
623 GLboolean ColorMaterialEnabled;
624
625 GLenum16 ShadeModel; /**< GL_FLAT or GL_SMOOTH */
626 GLenum16 ProvokingVertex; /**< GL_EXT_provoking_vertex */
627 GLenum16 ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
628 GLenum16 ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
629 GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
630
631
632 GLboolean _ClampVertexColor;
633 GLenum16 ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
634
635 /**
636 * Derived state for optimizations:
637 */
638 /*@{*/
639 GLbitfield _EnabledLights; /**< bitmask containing enabled lights */
640
641 GLboolean _NeedEyeCoords;
642 GLboolean _NeedVertices; /**< Use fast shader? */
643
644 GLfloat _BaseColor[2][3];
645 /*@}*/
646 };
647
648
649 /**
650 * Line attribute group (GL_LINE_BIT).
651 */
652 struct gl_line_attrib
653 {
654 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
655 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
656 GLushort StipplePattern; /**< Stipple pattern */
657 GLint StippleFactor; /**< Stipple repeat factor */
658 GLfloat Width; /**< Line width */
659 };
660
661
662 /**
663 * Display list attribute group (GL_LIST_BIT).
664 */
665 struct gl_list_attrib
666 {
667 GLuint ListBase;
668 };
669
670
671 /**
672 * Multisample attribute group (GL_MULTISAMPLE_BIT).
673 */
674 struct gl_multisample_attrib
675 {
676 GLboolean Enabled;
677 GLboolean SampleAlphaToCoverage;
678 GLboolean SampleAlphaToOne;
679 GLboolean SampleCoverage;
680 GLboolean SampleCoverageInvert;
681 GLboolean SampleShading;
682
683 /* ARB_texture_multisample / GL3.2 additions */
684 GLboolean SampleMask;
685
686 GLfloat SampleCoverageValue; /**< In range [0, 1] */
687 GLfloat MinSampleShadingValue; /**< In range [0, 1] */
688
689 /** The GL spec defines this as an array but >32x MSAA is madness */
690 GLbitfield SampleMaskValue;
691 };
692
693
694 /**
695 * A pixelmap (see glPixelMap)
696 */
697 struct gl_pixelmap
698 {
699 GLint Size;
700 GLfloat Map[MAX_PIXEL_MAP_TABLE];
701 };
702
703
704 /**
705 * Collection of all pixelmaps
706 */
707 struct gl_pixelmaps
708 {
709 struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
710 struct gl_pixelmap GtoG;
711 struct gl_pixelmap BtoB;
712 struct gl_pixelmap AtoA;
713 struct gl_pixelmap ItoR;
714 struct gl_pixelmap ItoG;
715 struct gl_pixelmap ItoB;
716 struct gl_pixelmap ItoA;
717 struct gl_pixelmap ItoI;
718 struct gl_pixelmap StoS;
719 };
720
721
722 /**
723 * Pixel attribute group (GL_PIXEL_MODE_BIT).
724 */
725 struct gl_pixel_attrib
726 {
727 GLenum16 ReadBuffer; /**< source buffer for glRead/CopyPixels() */
728
729 /*--- Begin Pixel Transfer State ---*/
730 /* Fields are in the order in which they're applied... */
731
732 /** Scale & Bias (index shift, offset) */
733 /*@{*/
734 GLfloat RedBias, RedScale;
735 GLfloat GreenBias, GreenScale;
736 GLfloat BlueBias, BlueScale;
737 GLfloat AlphaBias, AlphaScale;
738 GLfloat DepthBias, DepthScale;
739 GLint IndexShift, IndexOffset;
740 /*@}*/
741
742 /* Pixel Maps */
743 /* Note: actual pixel maps are not part of this attrib group */
744 GLboolean MapColorFlag;
745 GLboolean MapStencilFlag;
746
747 /*--- End Pixel Transfer State ---*/
748
749 /** glPixelZoom */
750 GLfloat ZoomX, ZoomY;
751 };
752
753
754 /**
755 * Point attribute group (GL_POINT_BIT).
756 */
757 struct gl_point_attrib
758 {
759 GLfloat Size; /**< User-specified point size */
760 GLfloat Params[3]; /**< GL_EXT_point_parameters */
761 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
762 GLfloat Threshold; /**< GL_EXT_point_parameters */
763 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
764 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
765 GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
766 GLbitfield CoordReplace; /**< GL_ARB_point_sprite*/
767 GLenum16 SpriteRMode; /**< GL_NV_point_sprite (only!) */
768 GLenum16 SpriteOrigin; /**< GL_ARB_point_sprite */
769 };
770
771
772 /**
773 * Polygon attribute group (GL_POLYGON_BIT).
774 */
775 struct gl_polygon_attrib
776 {
777 GLenum16 FrontFace; /**< Either GL_CW or GL_CCW */
778 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
779 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
780 GLboolean CullFlag; /**< Culling on/off flag */
781 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
782 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
783 GLenum16 CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
784 GLfloat OffsetFactor; /**< Polygon offset factor, from user */
785 GLfloat OffsetUnits; /**< Polygon offset units, from user */
786 GLfloat OffsetClamp; /**< Polygon offset clamp, from user */
787 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
788 GLboolean OffsetLine; /**< Offset in GL_LINE mode */
789 GLboolean OffsetFill; /**< Offset in GL_FILL mode */
790 };
791
792
793 /**
794 * Scissor attributes (GL_SCISSOR_BIT).
795 */
796 struct gl_scissor_rect
797 {
798 GLint X, Y; /**< Lower left corner of box */
799 GLsizei Width, Height; /**< Size of box */
800 };
801
802
803 struct gl_scissor_attrib
804 {
805 GLbitfield EnableFlags; /**< Scissor test enabled? */
806 struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
807 GLint NumWindowRects; /**< Count of enabled window rectangles */
808 GLenum16 WindowRectMode; /**< Whether to include or exclude the rects */
809 struct gl_scissor_rect WindowRects[MAX_WINDOW_RECTANGLES];
810 };
811
812
813 /**
814 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
815 *
816 * Three sets of stencil data are tracked so that OpenGL 2.0,
817 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
818 * simultaneously. In each of the stencil state arrays, element 0 corresponds
819 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
820 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
821 * GL_EXT_stencil_two_side GL_BACK state.
822 *
823 * The derived value \c _BackFace is either 1 or 2 depending on whether or
824 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
825 *
826 * The derived value \c _TestTwoSide is set when the front-face and back-face
827 * stencil state are different.
828 */
829 struct gl_stencil_attrib
830 {
831 GLboolean Enabled; /**< Enabled flag */
832 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
833 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */
834 GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
835 GLenum16 Function[3]; /**< Stencil function */
836 GLenum16 FailFunc[3]; /**< Fail function */
837 GLenum16 ZPassFunc[3]; /**< Depth buffer pass function */
838 GLenum16 ZFailFunc[3]; /**< Depth buffer fail function */
839 GLint Ref[3]; /**< Reference value */
840 GLuint ValueMask[3]; /**< Value mask */
841 GLuint WriteMask[3]; /**< Write mask */
842 GLuint Clear; /**< Clear value */
843 };
844
845
846 /**
847 * Bit flags for each type of texture object
848 */
849 /*@{*/
850 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
851 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
852 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
853 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
854 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
855 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
856 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
857 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
858 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
859 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
860 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
861 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
862 /*@}*/
863
864
865 /**
866 * Texture image state. Drivers will typically create a subclass of this
867 * with extra fields for memory buffers, etc.
868 */
869 struct gl_texture_image
870 {
871 GLint InternalFormat; /**< Internal format as given by the user */
872 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
873 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
874 * GL_INTENSITY, GL_DEPTH_COMPONENT or
875 * GL_DEPTH_STENCIL_EXT only. Used for
876 * choosing TexEnv arithmetic.
877 */
878 mesa_format TexFormat; /**< The actual texture memory format */
879
880 GLuint Border; /**< 0 or 1 */
881 GLuint Width; /**< = 2^WidthLog2 + 2*Border */
882 GLuint Height; /**< = 2^HeightLog2 + 2*Border */
883 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
884 GLuint Width2; /**< = Width - 2*Border */
885 GLuint Height2; /**< = Height - 2*Border */
886 GLuint Depth2; /**< = Depth - 2*Border */
887 GLuint WidthLog2; /**< = log2(Width2) */
888 GLuint HeightLog2; /**< = log2(Height2) */
889 GLuint DepthLog2; /**< = log2(Depth2) */
890 GLuint MaxNumLevels; /**< = maximum possible number of mipmap
891 levels, computed from the dimensions */
892
893 struct gl_texture_object *TexObject; /**< Pointer back to parent object */
894 GLuint Level; /**< Which mipmap level am I? */
895 /** Cube map face: index into gl_texture_object::Image[] array */
896 GLuint Face;
897
898 /** GL_ARB_texture_multisample */
899 GLuint NumSamples; /**< Sample count, or 0 for non-multisample */
900 GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */
901 };
902
903
904 /**
905 * Indexes for cube map faces.
906 */
907 typedef enum
908 {
909 FACE_POS_X = 0,
910 FACE_NEG_X = 1,
911 FACE_POS_Y = 2,
912 FACE_NEG_Y = 3,
913 FACE_POS_Z = 4,
914 FACE_NEG_Z = 5,
915 MAX_FACES = 6
916 } gl_face_index;
917
918
919 /**
920 * Sampler object state. These objects are new with GL_ARB_sampler_objects
921 * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
922 */
923 struct gl_sampler_object
924 {
925 simple_mtx_t Mutex;
926 GLuint Name;
927 GLchar *Label; /**< GL_KHR_debug */
928 GLint RefCount;
929
930 GLenum16 WrapS; /**< S-axis texture image wrap mode */
931 GLenum16 WrapT; /**< T-axis texture image wrap mode */
932 GLenum16 WrapR; /**< R-axis texture image wrap mode */
933 GLenum16 MinFilter; /**< minification filter */
934 GLenum16 MagFilter; /**< magnification filter */
935 GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
936 union gl_color_union BorderColor; /**< Interpreted according to texture format */
937 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
938 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
939 GLfloat LodBias; /**< OpenGL 1.4 */
940 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
941 GLenum16 CompareMode; /**< GL_ARB_shadow */
942 GLenum16 CompareFunc; /**< GL_ARB_shadow */
943 GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
944
945 /** GL_ARB_bindless_texture */
946 bool HandleAllocated;
947 struct util_dynarray Handles;
948 };
949
950
951 /**
952 * Texture object state. Contains the array of mipmap images, border color,
953 * wrap modes, filter modes, and shadow/texcompare state.
954 */
955 struct gl_texture_object
956 {
957 simple_mtx_t Mutex; /**< for thread safety */
958 GLint RefCount; /**< reference count */
959 GLuint Name; /**< the user-visible texture object ID */
960 GLenum16 Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
961 GLenum16 DepthMode; /**< GL_ARB_depth_texture */
962 GLchar *Label; /**< GL_KHR_debug */
963
964 struct gl_sampler_object Sampler;
965
966 gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
967 Only valid when Target is valid. */
968 GLfloat Priority; /**< in [0,1] */
969 GLint MaxLevel; /**< max mipmap level (max=1000), OpenGL 1.2 */
970 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
971 GLbyte _MaxLevel; /**< actual max mipmap level (q in the spec) */
972 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - p in spec) */
973 GLint CropRect[4]; /**< GL_OES_draw_texture */
974 GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */
975 GLushort _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
976 GLbyte ImmutableLevels; /**< ES 3.0 / ARB_texture_view */
977 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
978 GLboolean _BaseComplete; /**< Is the base texture level valid? */
979 GLboolean _MipmapComplete; /**< Is the whole mipmap valid? */
980 GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */
981 GLboolean _RenderToTexture; /**< Any rendering to this texture? */
982 GLboolean Purgeable; /**< Is the buffer purgeable under memory
983 pressure? */
984 GLboolean Immutable; /**< GL_ARB_texture_storage */
985 GLboolean _IsFloat; /**< GL_OES_float_texture */
986 GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
987 bool StencilSampling; /**< Should we sample stencil instead of depth? */
988 bool HandleAllocated; /**< GL_ARB_bindless_texture */
989
990 /** GL_OES_EGL_image_external */
991 GLubyte RequiredTextureImageUnits;
992
993 GLubyte MinLevel; /**< GL_ARB_texture_view */
994 GLubyte NumLevels; /**< GL_ARB_texture_view */
995 GLushort MinLayer; /**< GL_ARB_texture_view */
996 GLushort NumLayers; /**< GL_ARB_texture_view */
997
998 /** GL_EXT_memory_object */
999 GLenum16 TextureTiling;
1000
1001 /** GL_ARB_shader_image_load_store */
1002 GLenum16 ImageFormatCompatibilityType;
1003
1004 /** GL_ARB_texture_buffer_object */
1005 GLenum16 BufferObjectFormat;
1006 /** Equivalent Mesa format for BufferObjectFormat. */
1007 mesa_format _BufferObjectFormat;
1008 struct gl_buffer_object *BufferObject;
1009
1010 /** GL_ARB_texture_buffer_range */
1011 GLintptr BufferOffset;
1012 GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
1013
1014 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1015 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1016
1017 /** GL_ARB_bindless_texture */
1018 struct util_dynarray SamplerHandles;
1019 struct util_dynarray ImageHandles;
1020 };
1021
1022
1023 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
1024 #define MAX_COMBINER_TERMS 4
1025
1026
1027 /**
1028 * Texture combine environment state.
1029 */
1030 struct gl_tex_env_combine_state
1031 {
1032 GLenum16 ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1033 GLenum16 ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1034 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
1035 GLenum16 SourceRGB[MAX_COMBINER_TERMS];
1036 GLenum16 SourceA[MAX_COMBINER_TERMS];
1037 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
1038 GLenum16 OperandRGB[MAX_COMBINER_TERMS];
1039 GLenum16 OperandA[MAX_COMBINER_TERMS];
1040 GLubyte ScaleShiftRGB; /**< 0, 1 or 2 */
1041 GLubyte ScaleShiftA; /**< 0, 1 or 2 */
1042 GLubyte _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
1043 GLubyte _NumArgsA; /**< Number of inputs used for the A combiner */
1044 };
1045
1046
1047 /** Compressed TexEnv effective Combine mode */
1048 enum gl_tex_env_mode
1049 {
1050 TEXENV_MODE_REPLACE, /* r = a0 */
1051 TEXENV_MODE_MODULATE, /* r = a0 * a1 */
1052 TEXENV_MODE_ADD, /* r = a0 + a1 */
1053 TEXENV_MODE_ADD_SIGNED, /* r = a0 + a1 - 0.5 */
1054 TEXENV_MODE_INTERPOLATE, /* r = a0 * a2 + a1 * (1 - a2) */
1055 TEXENV_MODE_SUBTRACT, /* r = a0 - a1 */
1056 TEXENV_MODE_DOT3_RGB, /* r = a0 . a1 */
1057 TEXENV_MODE_DOT3_RGB_EXT, /* r = a0 . a1 */
1058 TEXENV_MODE_DOT3_RGBA, /* r = a0 . a1 */
1059 TEXENV_MODE_DOT3_RGBA_EXT, /* r = a0 . a1 */
1060 TEXENV_MODE_MODULATE_ADD_ATI, /* r = a0 * a2 + a1 */
1061 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI, /* r = a0 * a2 + a1 - 0.5 */
1062 TEXENV_MODE_MODULATE_SUBTRACT_ATI, /* r = a0 * a2 - a1 */
1063 TEXENV_MODE_ADD_PRODUCTS_NV, /* r = a0 * a1 + a2 * a3 */
1064 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV, /* r = a0 * a1 + a2 * a3 - 0.5 */
1065 };
1066
1067
1068 /** Compressed TexEnv Combine source */
1069 enum gl_tex_env_source
1070 {
1071 TEXENV_SRC_TEXTURE0,
1072 TEXENV_SRC_TEXTURE1,
1073 TEXENV_SRC_TEXTURE2,
1074 TEXENV_SRC_TEXTURE3,
1075 TEXENV_SRC_TEXTURE4,
1076 TEXENV_SRC_TEXTURE5,
1077 TEXENV_SRC_TEXTURE6,
1078 TEXENV_SRC_TEXTURE7,
1079 TEXENV_SRC_TEXTURE,
1080 TEXENV_SRC_PREVIOUS,
1081 TEXENV_SRC_PRIMARY_COLOR,
1082 TEXENV_SRC_CONSTANT,
1083 TEXENV_SRC_ZERO,
1084 TEXENV_SRC_ONE,
1085 };
1086
1087
1088 /** Compressed TexEnv Combine operand */
1089 enum gl_tex_env_operand
1090 {
1091 TEXENV_OPR_COLOR,
1092 TEXENV_OPR_ONE_MINUS_COLOR,
1093 TEXENV_OPR_ALPHA,
1094 TEXENV_OPR_ONE_MINUS_ALPHA,
1095 };
1096
1097
1098 /** Compressed TexEnv Combine argument */
1099 struct gl_tex_env_argument
1100 {
1101 #ifdef __GNUC__
1102 __extension__ uint8_t Source:4; /**< TEXENV_SRC_x */
1103 __extension__ uint8_t Operand:2; /**< TEXENV_OPR_x */
1104 #else
1105 uint8_t Source; /**< SRC_x */
1106 uint8_t Operand; /**< OPR_x */
1107 #endif
1108 };
1109
1110
1111 /***
1112 * Compressed TexEnv Combine state.
1113 */
1114 struct gl_tex_env_combine_packed
1115 {
1116 uint32_t ModeRGB:4; /**< Effective mode for RGB as 4 bits */
1117 uint32_t ModeA:4; /**< Effective mode for RGB as 4 bits */
1118 uint32_t ScaleShiftRGB:2; /**< 0, 1 or 2 */
1119 uint32_t ScaleShiftA:2; /**< 0, 1 or 2 */
1120 uint32_t NumArgsRGB:3; /**< Number of inputs used for the RGB combiner */
1121 uint32_t NumArgsA:3; /**< Number of inputs used for the A combiner */
1122 /** Source arguments in a packed manner */
1123 struct gl_tex_env_argument ArgsRGB[MAX_COMBINER_TERMS];
1124 struct gl_tex_env_argument ArgsA[MAX_COMBINER_TERMS];
1125 };
1126
1127
1128 /**
1129 * TexGenEnabled flags.
1130 */
1131 /*@{*/
1132 #define S_BIT 1
1133 #define T_BIT 2
1134 #define R_BIT 4
1135 #define Q_BIT 8
1136 #define STR_BITS (S_BIT | T_BIT | R_BIT)
1137 /*@}*/
1138
1139
1140 /**
1141 * Bit flag versions of the corresponding GL_ constants.
1142 */
1143 /*@{*/
1144 #define TEXGEN_SPHERE_MAP 0x1
1145 #define TEXGEN_OBJ_LINEAR 0x2
1146 #define TEXGEN_EYE_LINEAR 0x4
1147 #define TEXGEN_REFLECTION_MAP_NV 0x8
1148 #define TEXGEN_NORMAL_MAP_NV 0x10
1149
1150 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1151 TEXGEN_REFLECTION_MAP_NV | \
1152 TEXGEN_NORMAL_MAP_NV)
1153 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1154 TEXGEN_REFLECTION_MAP_NV | \
1155 TEXGEN_NORMAL_MAP_NV | \
1156 TEXGEN_EYE_LINEAR)
1157 /*@}*/
1158
1159
1160
1161 /** Tex-gen enabled for texture unit? */
1162 #define ENABLE_TEXGEN(unit) (1 << (unit))
1163
1164 /** Non-identity texture matrix for texture unit? */
1165 #define ENABLE_TEXMAT(unit) (1 << (unit))
1166
1167
1168 /**
1169 * Texture coord generation state.
1170 */
1171 struct gl_texgen
1172 {
1173 GLenum16 Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
1174 GLbitfield8 _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
1175 GLfloat ObjectPlane[4];
1176 GLfloat EyePlane[4];
1177 };
1178
1179
1180 /**
1181 * Sampler-related subset of a texture unit, like current texture objects.
1182 */
1183 struct gl_texture_unit
1184 {
1185 GLfloat LodBias; /**< for biasing mipmap levels */
1186
1187 /** Texture targets that have a non-default texture bound */
1188 GLbitfield _BoundTextures;
1189
1190 /** Current sampler object (GL_ARB_sampler_objects) */
1191 struct gl_sampler_object *Sampler;
1192
1193 /** Current texture object pointers */
1194 struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
1195
1196 /** Points to highest priority, complete and enabled texture object */
1197 struct gl_texture_object *_Current;
1198 };
1199
1200
1201 /**
1202 * Fixed-function-related subset of a texture unit, like enable flags,
1203 * texture environment/function/combiners, and texgen state.
1204 */
1205 struct gl_fixedfunc_texture_unit
1206 {
1207 GLbitfield16 Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1208
1209 GLenum16 EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1210 GLclampf EnvColor[4];
1211 GLfloat EnvColorUnclamped[4];
1212
1213 struct gl_texgen GenS;
1214 struct gl_texgen GenT;
1215 struct gl_texgen GenR;
1216 struct gl_texgen GenQ;
1217 GLbitfield8 TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1218 GLbitfield8 _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1219
1220 /**
1221 * \name GL_EXT_texture_env_combine
1222 */
1223 struct gl_tex_env_combine_state Combine;
1224
1225 /**
1226 * Derived state based on \c EnvMode and the \c BaseFormat of the
1227 * currently enabled texture.
1228 */
1229 struct gl_tex_env_combine_state _EnvMode;
1230
1231 /** Current compressed TexEnv & Combine state */
1232 struct gl_tex_env_combine_packed _CurrentCombinePacked;
1233
1234 /**
1235 * Currently enabled combiner state. This will point to either
1236 * \c Combine or \c _EnvMode.
1237 */
1238 struct gl_tex_env_combine_state *_CurrentCombine;
1239 };
1240
1241
1242 /**
1243 * Texture attribute group (GL_TEXTURE_BIT).
1244 */
1245 struct gl_texture_attrib
1246 {
1247 struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
1248
1249 /** GL_ARB_texture_buffer_object */
1250 struct gl_buffer_object *BufferObject;
1251
1252 GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */
1253
1254 /** Texture coord units/sets used for fragment texturing */
1255 GLbitfield8 _EnabledCoordUnits;
1256
1257 /** Texture coord units that have texgen enabled */
1258 GLbitfield8 _TexGenEnabled;
1259
1260 /** Texture coord units that have non-identity matrices */
1261 GLbitfield8 _TexMatEnabled;
1262
1263 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1264 GLbitfield8 _GenFlags;
1265
1266 /** Largest index of a texture unit with _Current != NULL. */
1267 GLshort _MaxEnabledTexImageUnit;
1268
1269 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1270 GLubyte NumCurrentTexUsed;
1271
1272 /** GL_ARB_seamless_cubemap */
1273 GLboolean CubeMapSeamless;
1274
1275 struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
1276 struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS];
1277 };
1278
1279
1280 /**
1281 * Data structure representing a single clip plane (e.g. one of the elements
1282 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1283 */
1284 typedef GLfloat gl_clip_plane[4];
1285
1286
1287 /**
1288 * Transformation attribute group (GL_TRANSFORM_BIT).
1289 */
1290 struct gl_transform_attrib
1291 {
1292 GLenum16 MatrixMode; /**< Matrix mode */
1293 gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */
1294 gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
1295 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
1296 GLboolean Normalize; /**< Normalize all normals? */
1297 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1298 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1299 GLboolean DepthClampNear; /**< GL_AMD_depth_clamp_separate */
1300 GLboolean DepthClampFar; /**< GL_AMD_depth_clamp_separate */
1301 /** GL_ARB_clip_control */
1302 GLenum16 ClipOrigin; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1303 GLenum16 ClipDepthMode;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1304 };
1305
1306
1307 /**
1308 * Viewport attribute group (GL_VIEWPORT_BIT).
1309 */
1310 struct gl_viewport_attrib
1311 {
1312 GLfloat X, Y; /**< position */
1313 GLfloat Width, Height; /**< size */
1314 GLfloat Near, Far; /**< Depth buffer range */
1315 };
1316
1317
1318 /**
1319 * Fields describing a mapped buffer range.
1320 */
1321 struct gl_buffer_mapping
1322 {
1323 GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
1324 GLvoid *Pointer; /**< User-space address of mapping */
1325 GLintptr Offset; /**< Mapped offset */
1326 GLsizeiptr Length; /**< Mapped length */
1327 };
1328
1329
1330 /**
1331 * Usages we've seen for a buffer object.
1332 */
1333 typedef enum
1334 {
1335 USAGE_UNIFORM_BUFFER = 0x1,
1336 USAGE_TEXTURE_BUFFER = 0x2,
1337 USAGE_ATOMIC_COUNTER_BUFFER = 0x4,
1338 USAGE_SHADER_STORAGE_BUFFER = 0x8,
1339 USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10,
1340 USAGE_PIXEL_PACK_BUFFER = 0x20,
1341 USAGE_ARRAY_BUFFER = 0x40,
1342 USAGE_ELEMENT_ARRAY_BUFFER = 0x80,
1343 USAGE_DISABLE_MINMAX_CACHE = 0x100,
1344 } gl_buffer_usage;
1345
1346
1347 /**
1348 * GL_ARB_vertex/pixel_buffer_object buffer object
1349 */
1350 struct gl_buffer_object
1351 {
1352 GLint RefCount;
1353 GLuint Name;
1354 GLchar *Label; /**< GL_KHR_debug */
1355 GLenum16 Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1356 GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
1357 GLsizeiptrARB Size; /**< Size of buffer storage in bytes */
1358 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1359 GLboolean DeletePending; /**< true if buffer object is removed from the hash */
1360 GLboolean Written; /**< Ever written to? (for debugging) */
1361 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1362 GLboolean Immutable; /**< GL_ARB_buffer_storage */
1363 gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
1364
1365 /** Counters used for buffer usage warnings */
1366 GLuint NumSubDataCalls;
1367 GLuint NumMapBufferWriteCalls;
1368
1369 struct gl_buffer_mapping Mappings[MAP_COUNT];
1370
1371 /** Memoization of min/max index computations for static index buffers */
1372 simple_mtx_t MinMaxCacheMutex;
1373 struct hash_table *MinMaxCache;
1374 unsigned MinMaxCacheHitIndices;
1375 unsigned MinMaxCacheMissIndices;
1376 bool MinMaxCacheDirty;
1377
1378 bool HandleAllocated; /**< GL_ARB_bindless_texture */
1379 };
1380
1381
1382 /**
1383 * Client pixel packing/unpacking attributes
1384 */
1385 struct gl_pixelstore_attrib
1386 {
1387 GLint Alignment;
1388 GLint RowLength;
1389 GLint SkipPixels;
1390 GLint SkipRows;
1391 GLint ImageHeight;
1392 GLint SkipImages;
1393 GLboolean SwapBytes;
1394 GLboolean LsbFirst;
1395 GLboolean Invert; /**< GL_MESA_pack_invert */
1396 GLint CompressedBlockWidth; /**< GL_ARB_compressed_texture_pixel_storage */
1397 GLint CompressedBlockHeight;
1398 GLint CompressedBlockDepth;
1399 GLint CompressedBlockSize;
1400 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
1401 };
1402
1403
1404 /**
1405 * Enum for defining the mapping for the position/generic0 attribute.
1406 *
1407 * Do not change the order of the values as these are used as
1408 * array indices.
1409 */
1410 typedef enum
1411 {
1412 ATTRIBUTE_MAP_MODE_IDENTITY, /**< 1:1 mapping */
1413 ATTRIBUTE_MAP_MODE_POSITION, /**< get position and generic0 from position */
1414 ATTRIBUTE_MAP_MODE_GENERIC0, /**< get position and generic0 from generic0 */
1415 ATTRIBUTE_MAP_MODE_MAX /**< for sizing arrays */
1416 } gl_attribute_map_mode;
1417
1418
1419 /**
1420 * Attributes to describe a vertex array.
1421 *
1422 * Contains the size, type, format and normalization flag,
1423 * along with the index of a vertex buffer binding point.
1424 *
1425 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1426 * and is only present for backwards compatibility reasons.
1427 * Rendering always uses VERTEX_BINDING_STRIDE.
1428 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1429 * and VERTEX_BINDING_STRIDE to the same value, while
1430 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1431 */
1432 struct gl_array_attributes
1433 {
1434 /** Points to client array data. Not used when a VBO is bound */
1435 const GLubyte *Ptr;
1436 /** Offset of the first element relative to the binding offset */
1437 GLuint RelativeOffset;
1438 /** Vertex format */
1439 struct gl_vertex_format Format;
1440 /** Stride as specified with gl*Pointer() */
1441 GLshort Stride;
1442 /** Index into gl_vertex_array_object::BufferBinding[] array */
1443 GLubyte BufferBindingIndex;
1444
1445 /**
1446 * Derived effective buffer binding index
1447 *
1448 * Index into the gl_vertex_buffer_binding array of the vao.
1449 * Similar to BufferBindingIndex, but with the mapping of the
1450 * position/generic0 attributes applied and with identical
1451 * gl_vertex_buffer_binding entries collapsed to a single
1452 * entry within the vao.
1453 *
1454 * The value is valid past calling _mesa_update_vao_derived_arrays.
1455 * Note that _mesa_update_vao_derived_arrays is called when binding
1456 * the VAO to Array._DrawVAO.
1457 */
1458 GLubyte _EffBufferBindingIndex;
1459 /**
1460 * Derived effective relative offset.
1461 *
1462 * Relative offset to the effective buffers offset in
1463 * gl_vertex_buffer_binding::_EffOffset.
1464 *
1465 * The value is valid past calling _mesa_update_vao_derived_arrays.
1466 * Note that _mesa_update_vao_derived_arrays is called when binding
1467 * the VAO to Array._DrawVAO.
1468 */
1469 GLushort _EffRelativeOffset;
1470 };
1471
1472
1473 /**
1474 * This describes the buffer object used for a vertex array (or
1475 * multiple vertex arrays). If BufferObj points to the default/null
1476 * buffer object, then the vertex array lives in user memory and not a VBO.
1477 */
1478 struct gl_vertex_buffer_binding
1479 {
1480 GLintptr Offset; /**< User-specified offset */
1481 GLsizei Stride; /**< User-specified stride */
1482 GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
1483 struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
1484 GLbitfield _BoundArrays; /**< Arrays bound to this binding point */
1485
1486 /**
1487 * Derived effective bound arrays.
1488 *
1489 * The effective binding handles enabled arrays past the
1490 * position/generic0 attribute mapping and reduces the refered
1491 * gl_vertex_buffer_binding entries to a unique subset.
1492 *
1493 * The value is valid past calling _mesa_update_vao_derived_arrays.
1494 * Note that _mesa_update_vao_derived_arrays is called when binding
1495 * the VAO to Array._DrawVAO.
1496 */
1497 GLbitfield _EffBoundArrays;
1498 /**
1499 * Derived offset.
1500 *
1501 * The absolute offset to that we can collapse some attributes
1502 * to this unique effective binding.
1503 * For user space array bindings this contains the smallest pointer value
1504 * in the bound and interleaved arrays.
1505 * For VBO bindings this contains an offset that lets the attributes
1506 * _EffRelativeOffset stay positive and in bounds with
1507 * Const.MaxVertexAttribRelativeOffset
1508 *
1509 * The value is valid past calling _mesa_update_vao_derived_arrays.
1510 * Note that _mesa_update_vao_derived_arrays is called when binding
1511 * the VAO to Array._DrawVAO.
1512 */
1513 GLintptr _EffOffset;
1514 };
1515
1516
1517 /**
1518 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1519 * the GL_ARB_vertex_array_object extension.
1520 */
1521 struct gl_vertex_array_object
1522 {
1523 /** Name of the VAO as received from glGenVertexArray. */
1524 GLuint Name;
1525
1526 GLint RefCount;
1527
1528 GLchar *Label; /**< GL_KHR_debug */
1529
1530 /**
1531 * Has this array object been bound?
1532 */
1533 GLboolean EverBound;
1534
1535 /**
1536 * Marked to true if the object is shared between contexts and immutable.
1537 * Then reference counting is done using atomics and thread safe.
1538 * Is used for dlist VAOs.
1539 */
1540 bool SharedAndImmutable;
1541
1542 /** Vertex attribute arrays */
1543 struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX];
1544
1545 /** Vertex buffer bindings */
1546 struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX];
1547
1548 /** Mask indicating which vertex arrays have vertex buffer associated. */
1549 GLbitfield VertexAttribBufferMask;
1550
1551 /** Mask indicating which vertex arrays have a non-zero instance divisor. */
1552 GLbitfield NonZeroDivisorMask;
1553
1554 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1555 GLbitfield Enabled;
1556
1557 /**
1558 * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
1559 *
1560 * The value is valid past calling _mesa_update_vao_derived_arrays.
1561 * Note that _mesa_update_vao_derived_arrays is called when binding
1562 * the VAO to Array._DrawVAO.
1563 */
1564 GLbitfield _EffEnabledVBO;
1565
1566 /** Same as _EffEnabledVBO, but for instance divisors. */
1567 GLbitfield _EffEnabledNonZeroDivisor;
1568
1569 /** Denotes the way the position/generic0 attribute is mapped */
1570 gl_attribute_map_mode _AttributeMapMode;
1571
1572 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1573 GLbitfield NewArrays;
1574
1575 /** The index buffer (also known as the element array buffer in OpenGL). */
1576 struct gl_buffer_object *IndexBufferObj;
1577 };
1578
1579
1580 /**
1581 * Vertex array state
1582 */
1583 struct gl_array_attrib
1584 {
1585 /** Currently bound array object. */
1586 struct gl_vertex_array_object *VAO;
1587
1588 /** The default vertex array object */
1589 struct gl_vertex_array_object *DefaultVAO;
1590
1591 /** The last VAO accessed by a DSA function */
1592 struct gl_vertex_array_object *LastLookedUpVAO;
1593
1594 /** These contents are copied to newly created VAOs. */
1595 struct gl_vertex_array_object DefaultVAOState;
1596
1597 /** Array objects (GL_ARB_vertex_array_object) */
1598 struct _mesa_HashTable *Objects;
1599
1600 GLint ActiveTexture; /**< Client Active Texture */
1601 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1602 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1603
1604 /**
1605 * \name Primitive restart controls
1606 *
1607 * Primitive restart is enabled if either \c PrimitiveRestart or
1608 * \c PrimitiveRestartFixedIndex is set.
1609 */
1610 /*@{*/
1611 GLboolean PrimitiveRestart;
1612 GLboolean PrimitiveRestartFixedIndex;
1613 GLboolean _PrimitiveRestart;
1614 GLuint RestartIndex;
1615 GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */
1616 /*@}*/
1617
1618 /* GL_ARB_vertex_buffer_object */
1619 struct gl_buffer_object *ArrayBufferObj;
1620
1621 /**
1622 * Vertex array object that is used with the currently active draw command.
1623 * The _DrawVAO is either set to the currently bound VAO for array type
1624 * draws or to internal VAO's set up by the vbo module to execute immediate
1625 * mode or display list draws.
1626 */
1627 struct gl_vertex_array_object *_DrawVAO;
1628 /**
1629 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
1630 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
1631 * but may omit those arrays that shall not be referenced by the current
1632 * gl_vertex_program_state::_VPMode. For example the generic attributes are
1633 * maked out form the _DrawVAO's enabled arrays when a fixed function
1634 * array draw is executed.
1635 */
1636 GLbitfield _DrawVAOEnabledAttribs;
1637 /**
1638 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
1639 * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
1640 */
1641 struct gl_vertex_array_object *_EmptyVAO;
1642
1643 /** Legal array datatypes and the API for which they have been computed */
1644 GLbitfield LegalTypesMask;
1645 gl_api LegalTypesMaskAPI;
1646 };
1647
1648
1649 /**
1650 * Feedback buffer state
1651 */
1652 struct gl_feedback
1653 {
1654 GLenum16 Type;
1655 GLbitfield _Mask; /**< FB_* bits */
1656 GLfloat *Buffer;
1657 GLuint BufferSize;
1658 GLuint Count;
1659 };
1660
1661
1662 /**
1663 * Selection buffer state
1664 */
1665 struct gl_selection
1666 {
1667 GLuint *Buffer; /**< selection buffer */
1668 GLuint BufferSize; /**< size of the selection buffer */
1669 GLuint BufferCount; /**< number of values in the selection buffer */
1670 GLuint Hits; /**< number of records in the selection buffer */
1671 GLuint NameStackDepth; /**< name stack depth */
1672 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1673 GLboolean HitFlag; /**< hit flag */
1674 GLfloat HitMinZ; /**< minimum hit depth */
1675 GLfloat HitMaxZ; /**< maximum hit depth */
1676 };
1677
1678
1679 /**
1680 * 1-D Evaluator control points
1681 */
1682 struct gl_1d_map
1683 {
1684 GLuint Order; /**< Number of control points */
1685 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1686 GLfloat *Points; /**< Points to contiguous control points */
1687 };
1688
1689
1690 /**
1691 * 2-D Evaluator control points
1692 */
1693 struct gl_2d_map
1694 {
1695 GLuint Uorder; /**< Number of control points in U dimension */
1696 GLuint Vorder; /**< Number of control points in V dimension */
1697 GLfloat u1, u2, du;
1698 GLfloat v1, v2, dv;
1699 GLfloat *Points; /**< Points to contiguous control points */
1700 };
1701
1702
1703 /**
1704 * All evaluator control point state
1705 */
1706 struct gl_evaluators
1707 {
1708 /**
1709 * \name 1-D maps
1710 */
1711 /*@{*/
1712 struct gl_1d_map Map1Vertex3;
1713 struct gl_1d_map Map1Vertex4;
1714 struct gl_1d_map Map1Index;
1715 struct gl_1d_map Map1Color4;
1716 struct gl_1d_map Map1Normal;
1717 struct gl_1d_map Map1Texture1;
1718 struct gl_1d_map Map1Texture2;
1719 struct gl_1d_map Map1Texture3;
1720 struct gl_1d_map Map1Texture4;
1721 /*@}*/
1722
1723 /**
1724 * \name 2-D maps
1725 */
1726 /*@{*/
1727 struct gl_2d_map Map2Vertex3;
1728 struct gl_2d_map Map2Vertex4;
1729 struct gl_2d_map Map2Index;
1730 struct gl_2d_map Map2Color4;
1731 struct gl_2d_map Map2Normal;
1732 struct gl_2d_map Map2Texture1;
1733 struct gl_2d_map Map2Texture2;
1734 struct gl_2d_map Map2Texture3;
1735 struct gl_2d_map Map2Texture4;
1736 /*@}*/
1737 };
1738
1739
1740 struct gl_transform_feedback_varying_info
1741 {
1742 char *Name;
1743 GLenum16 Type;
1744 GLint BufferIndex;
1745 GLint Size;
1746 GLint Offset;
1747 };
1748
1749
1750 /**
1751 * Per-output info vertex shaders for transform feedback.
1752 */
1753 struct gl_transform_feedback_output
1754 {
1755 uint32_t OutputRegister;
1756 uint32_t OutputBuffer;
1757 uint32_t NumComponents;
1758 uint32_t StreamId;
1759
1760 /** offset (in DWORDs) of this output within the interleaved structure */
1761 uint32_t DstOffset;
1762
1763 /**
1764 * Offset into the output register of the data to output. For example,
1765 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1766 * offset is in the y and z components of the output register.
1767 */
1768 uint32_t ComponentOffset;
1769 };
1770
1771
1772 struct gl_transform_feedback_buffer
1773 {
1774 uint32_t Binding;
1775
1776 uint32_t NumVaryings;
1777
1778 /**
1779 * Total number of components stored in each buffer. This may be used by
1780 * hardware back-ends to determine the correct stride when interleaving
1781 * multiple transform feedback outputs in the same buffer.
1782 */
1783 uint32_t Stride;
1784
1785 /**
1786 * Which transform feedback stream this buffer binding is associated with.
1787 */
1788 uint32_t Stream;
1789 };
1790
1791
1792 /** Post-link transform feedback info. */
1793 struct gl_transform_feedback_info
1794 {
1795 unsigned NumOutputs;
1796
1797 /* Bitmask of active buffer indices. */
1798 unsigned ActiveBuffers;
1799
1800 struct gl_transform_feedback_output *Outputs;
1801
1802 /** Transform feedback varyings used for the linking of this shader program.
1803 *
1804 * Use for glGetTransformFeedbackVarying().
1805 */
1806 struct gl_transform_feedback_varying_info *Varyings;
1807 GLint NumVarying;
1808
1809 struct gl_transform_feedback_buffer Buffers[MAX_FEEDBACK_BUFFERS];
1810 };
1811
1812
1813 /**
1814 * Transform feedback object state
1815 */
1816 struct gl_transform_feedback_object
1817 {
1818 GLuint Name; /**< AKA the object ID */
1819 GLint RefCount;
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
1824 at least once? */
1825 GLboolean EverBound; /**< Has this object been bound? */
1826
1827 /**
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.
1833 *
1834 * Not tracked for desktop GL since it's unnecessary.
1835 */
1836 unsigned GlesRemainingPrims;
1837
1838 /**
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.
1843 */
1844 struct gl_program *program;
1845
1846 /** The feedback buffers */
1847 GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
1848 struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS];
1849
1850 /** Start of feedback data in dest buffer */
1851 GLintptr Offset[MAX_FEEDBACK_BUFFERS];
1852
1853 /**
1854 * Max data to put into dest buffer (in bytes). Computed based on
1855 * RequestedSize and the actual size of the buffer.
1856 */
1857 GLsizeiptr Size[MAX_FEEDBACK_BUFFERS];
1858
1859 /**
1860 * Size that was specified when the buffer was bound. If the buffer was
1861 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1862 * zero.
1863 */
1864 GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS];
1865 };
1866
1867
1868 /**
1869 * Context state for transform feedback.
1870 */
1871 struct gl_transform_feedback_state
1872 {
1873 GLenum16 Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1874
1875 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1876 struct gl_buffer_object *CurrentBuffer;
1877
1878 /** The table of all transform feedback objects */
1879 struct _mesa_HashTable *Objects;
1880
1881 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1882 struct gl_transform_feedback_object *CurrentObject;
1883
1884 /** The default xform-fb object (Name==0) */
1885 struct gl_transform_feedback_object *DefaultObject;
1886 };
1887
1888
1889 /**
1890 * A "performance monitor" as described in AMD_performance_monitor.
1891 */
1892 struct gl_perf_monitor_object
1893 {
1894 GLuint Name;
1895
1896 /** True if the monitor is currently active (Begin called but not End). */
1897 GLboolean Active;
1898
1899 /**
1900 * True if the monitor has ended.
1901 *
1902 * This is distinct from !Active because it may never have began.
1903 */
1904 GLboolean Ended;
1905
1906 /**
1907 * A list of groups with currently active counters.
1908 *
1909 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1910 */
1911 unsigned *ActiveGroups;
1912
1913 /**
1914 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1915 *
1916 * Checking whether counter 'c' in group 'g' is active can be done via:
1917 *
1918 * BITSET_TEST(ActiveCounters[g], c)
1919 */
1920 GLuint **ActiveCounters;
1921 };
1922
1923
1924 union gl_perf_monitor_counter_value
1925 {
1926 float f;
1927 uint64_t u64;
1928 uint32_t u32;
1929 };
1930
1931
1932 struct gl_perf_monitor_counter
1933 {
1934 /** Human readable name for the counter. */
1935 const char *Name;
1936
1937 /**
1938 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1939 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1940 */
1941 GLenum16 Type;
1942
1943 /** Minimum counter value. */
1944 union gl_perf_monitor_counter_value Minimum;
1945
1946 /** Maximum counter value. */
1947 union gl_perf_monitor_counter_value Maximum;
1948 };
1949
1950
1951 struct gl_perf_monitor_group
1952 {
1953 /** Human readable name for the group. */
1954 const char *Name;
1955
1956 /**
1957 * Maximum number of counters in this group which can be active at the
1958 * same time.
1959 */
1960 GLuint MaxActiveCounters;
1961
1962 /** Array of counters within this group. */
1963 const struct gl_perf_monitor_counter *Counters;
1964 GLuint NumCounters;
1965 };
1966
1967
1968 /**
1969 * A query object instance as described in INTEL_performance_query.
1970 *
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
1974 * in a frame.
1975 */
1976 struct gl_perf_query_object
1977 {
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? */
1982 };
1983
1984
1985 /**
1986 * Context state for AMD_performance_monitor.
1987 */
1988 struct gl_perf_monitor_state
1989 {
1990 /** Array of performance monitor groups (indexed by group ID) */
1991 const struct gl_perf_monitor_group *Groups;
1992 GLuint NumGroups;
1993
1994 /** The table of all performance monitors. */
1995 struct _mesa_HashTable *Monitors;
1996 };
1997
1998
1999 /**
2000 * Context state for INTEL_performance_query.
2001 */
2002 struct gl_perf_query_state
2003 {
2004 struct _mesa_HashTable *Objects; /**< The table of all performance query objects */
2005 };
2006
2007
2008 /**
2009 * A bindless sampler object.
2010 */
2011 struct gl_bindless_sampler
2012 {
2013 /** Texture unit (set by glUniform1()). */
2014 GLubyte unit;
2015
2016 /** Whether this bindless sampler is bound to a unit. */
2017 GLboolean bound;
2018
2019 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2020 gl_texture_index target;
2021
2022 /** Pointer to the base of the data. */
2023 GLvoid *data;
2024 };
2025
2026
2027 /**
2028 * A bindless image object.
2029 */
2030 struct gl_bindless_image
2031 {
2032 /** Image unit (set by glUniform1()). */
2033 GLubyte unit;
2034
2035 /** Whether this bindless image is bound to a unit. */
2036 GLboolean bound;
2037
2038 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
2039 * GL_NONE to indicate both read-only and write-only)
2040 */
2041 GLenum16 access;
2042
2043 /** Pointer to the base of the data. */
2044 GLvoid *data;
2045 };
2046
2047
2048 /**
2049 * Current vertex processing mode: fixed function vs. shader.
2050 * In reality, fixed function is probably implemented by a shader but that's
2051 * not what we care about here.
2052 */
2053 typedef enum
2054 {
2055 VP_MODE_FF, /**< legacy / fixed function */
2056 VP_MODE_SHADER, /**< ARB vertex program or GLSL vertex shader */
2057 VP_MODE_MAX /**< for sizing arrays */
2058 } gl_vertex_processing_mode;
2059
2060
2061 /**
2062 * Base class for any kind of program object
2063 */
2064 struct gl_program
2065 {
2066 /** FIXME: This must be first until we split shader_info from nir_shader */
2067 struct shader_info info;
2068
2069 GLuint Id;
2070 GLint RefCount;
2071 GLubyte *String; /**< Null-terminated program text */
2072
2073 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2074 GLenum16 Target;
2075 GLenum16 Format; /**< String encoding format */
2076
2077 GLboolean _Used; /**< Ever used for drawing? Used for debugging */
2078
2079 struct nir_shader *nir;
2080
2081 /* Saved and restored with metadata. Freed with ralloc. */
2082 void *driver_cache_blob;
2083 size_t driver_cache_blob_size;
2084
2085 bool is_arb_asm; /** Is this an ARB assembly-style program */
2086
2087 /** Is this program written to on disk shader cache */
2088 bool program_written_to_cache;
2089
2090 /** A bitfield indicating which vertex shader inputs consume two slots
2091 *
2092 * This is used for mapping from single-slot input locations in the GL API
2093 * to dual-slot double input locations in the shader. This field is set
2094 * once as part of linking and never updated again to ensure the mapping
2095 * remains consistent.
2096 *
2097 * Note: There may be dual-slot variables in the original shader source
2098 * which do not appear in this bitfield due to having been eliminated by
2099 * the compiler prior to DualSlotInputs being calculated. There may also
2100 * be bits set in this bitfield which are set but which the shader never
2101 * reads due to compiler optimizations eliminating such variables after
2102 * DualSlotInputs is calculated.
2103 */
2104 GLbitfield64 DualSlotInputs;
2105 /** Subset of OutputsWritten outputs written with non-zero index. */
2106 GLbitfield64 SecondaryOutputsWritten;
2107 /** TEXTURE_x_BIT bitmask */
2108 GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
2109 /** Bitfield of which samplers are used */
2110 GLbitfield SamplersUsed;
2111 /** Texture units used for shadow sampling. */
2112 GLbitfield ShadowSamplers;
2113 /** Texture units used for samplerExternalOES */
2114 GLbitfield ExternalSamplersUsed;
2115
2116 /** Named parameters, constants, etc. from program text */
2117 struct gl_program_parameter_list *Parameters;
2118
2119 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2120 GLubyte SamplerUnits[MAX_SAMPLERS];
2121
2122 /* FIXME: We should be able to make this struct a union. However some
2123 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2124 * these fields, we should fix this.
2125 */
2126 struct {
2127 /** Fields used by GLSL programs */
2128 struct {
2129 /** Data shared by gl_program and gl_shader_program */
2130 struct gl_shader_program_data *data;
2131
2132 struct gl_active_atomic_buffer **AtomicBuffers;
2133
2134 /** Post-link transform feedback info. */
2135 struct gl_transform_feedback_info *LinkedTransformFeedback;
2136
2137 /**
2138 * Number of types for subroutine uniforms.
2139 */
2140 GLuint NumSubroutineUniformTypes;
2141
2142 /**
2143 * Subroutine uniform remap table
2144 * based on the program level uniform remap table.
2145 */
2146 GLuint NumSubroutineUniforms; /* non-sparse total */
2147 GLuint NumSubroutineUniformRemapTable;
2148 struct gl_uniform_storage **SubroutineUniformRemapTable;
2149
2150 /**
2151 * Num of subroutine functions for this stage and storage for them.
2152 */
2153 GLuint NumSubroutineFunctions;
2154 GLuint MaxSubroutineFunctionIndex;
2155 struct gl_subroutine_function *SubroutineFunctions;
2156
2157 /**
2158 * Map from image uniform index to image unit (set by glUniform1i())
2159 *
2160 * An image uniform index is associated with each image uniform by
2161 * the linker. The image index associated with each uniform is
2162 * stored in the \c gl_uniform_storage::image field.
2163 */
2164 GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
2165
2166 /**
2167 * Access qualifier specified in the shader for each image uniform
2168 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY, \c
2169 * GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
2170 * write-only.
2171 *
2172 * It may be different, though only more strict than the value of
2173 * \c gl_image_unit::Access for the corresponding image unit.
2174 */
2175 GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
2176
2177 struct gl_uniform_block **UniformBlocks;
2178 struct gl_uniform_block **ShaderStorageBlocks;
2179
2180 /**
2181 * Bitmask of shader storage blocks not declared as read-only.
2182 */
2183 unsigned ShaderStorageBlocksWriteAccess;
2184
2185 /** Which texture target is being sampled
2186 * (TEXTURE_1D/2D/3D/etc_INDEX)
2187 */
2188 GLubyte SamplerTargets[MAX_SAMPLERS];
2189
2190 /**
2191 * Number of samplers declared with the bindless_sampler layout
2192 * qualifier as specified by ARB_bindless_texture.
2193 */
2194 GLuint NumBindlessSamplers;
2195 GLboolean HasBoundBindlessSampler;
2196 struct gl_bindless_sampler *BindlessSamplers;
2197
2198 /**
2199 * Number of images declared with the bindless_image layout qualifier
2200 * as specified by ARB_bindless_texture.
2201 */
2202 GLuint NumBindlessImages;
2203 GLboolean HasBoundBindlessImage;
2204 struct gl_bindless_image *BindlessImages;
2205
2206 union {
2207 struct {
2208 /**
2209 * A bitmask of gl_advanced_blend_mode values
2210 */
2211 GLbitfield BlendSupport;
2212 } fs;
2213 };
2214 } sh;
2215
2216 /** ARB assembly-style program fields */
2217 struct {
2218 struct prog_instruction *Instructions;
2219
2220 /**
2221 * Local parameters used by the program.
2222 *
2223 * It's dynamically allocated because it is rarely used (just
2224 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2225 * once it's allocated.
2226 */
2227 GLfloat (*LocalParams)[4];
2228
2229 /** Bitmask of which register files are read/written with indirect
2230 * addressing. Mask of (1 << PROGRAM_x) bits.
2231 */
2232 GLbitfield IndirectRegisterFiles;
2233
2234 /** Logical counts */
2235 /*@{*/
2236 GLuint NumInstructions;
2237 GLuint NumTemporaries;
2238 GLuint NumParameters;
2239 GLuint NumAttributes;
2240 GLuint NumAddressRegs;
2241 GLuint NumAluInstructions;
2242 GLuint NumTexInstructions;
2243 GLuint NumTexIndirections;
2244 /*@}*/
2245 /** Native, actual h/w counts */
2246 /*@{*/
2247 GLuint NumNativeInstructions;
2248 GLuint NumNativeTemporaries;
2249 GLuint NumNativeParameters;
2250 GLuint NumNativeAttributes;
2251 GLuint NumNativeAddressRegs;
2252 GLuint NumNativeAluInstructions;
2253 GLuint NumNativeTexInstructions;
2254 GLuint NumNativeTexIndirections;
2255 /*@}*/
2256
2257 /** Used by ARB assembly-style programs. Can only be true for vertex
2258 * programs.
2259 */
2260 GLboolean IsPositionInvariant;
2261 } arb;
2262 };
2263 };
2264
2265
2266 /**
2267 * State common to vertex and fragment programs.
2268 */
2269 struct gl_program_state
2270 {
2271 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2272 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2273 };
2274
2275
2276 /**
2277 * Context state for vertex programs.
2278 */
2279 struct gl_vertex_program_state
2280 {
2281 GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2282 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2283 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2284 /** Should fixed-function T&L be implemented with a vertex prog? */
2285 GLboolean _MaintainTnlProgram;
2286
2287 struct gl_program *Current; /**< User-bound vertex program */
2288
2289 /** Currently enabled and valid vertex program (including internal
2290 * programs, user-defined vertex programs and GLSL vertex shaders).
2291 * This is the program we must use when rendering.
2292 */
2293 struct gl_program *_Current;
2294
2295 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2296
2297 /** Program to emulate fixed-function T&L (see above) */
2298 struct gl_program *_TnlProgram;
2299
2300 /** Cache of fixed-function programs */
2301 struct gl_program_cache *Cache;
2302
2303 GLboolean _Overriden;
2304
2305 /**
2306 * If we have a vertex program, a TNL program or no program at all.
2307 * Note that this value should be kept up to date all the time,
2308 * nevertheless its correctness is asserted in _mesa_update_state.
2309 * The reason is to avoid calling _mesa_update_state twice we need
2310 * this value on draw *before* actually calling _mesa_update_state.
2311 * Also it should need to get recomputed only on changes to the
2312 * vertex program which are heavyweight already.
2313 */
2314 gl_vertex_processing_mode _VPMode;
2315 };
2316
2317 /**
2318 * Context state for tessellation control programs.
2319 */
2320 struct gl_tess_ctrl_program_state
2321 {
2322 /** Currently bound and valid shader. */
2323 struct gl_program *_Current;
2324
2325 GLint patch_vertices;
2326 GLfloat patch_default_outer_level[4];
2327 GLfloat patch_default_inner_level[2];
2328 };
2329
2330 /**
2331 * Context state for tessellation evaluation programs.
2332 */
2333 struct gl_tess_eval_program_state
2334 {
2335 /** Currently bound and valid shader. */
2336 struct gl_program *_Current;
2337 };
2338
2339 /**
2340 * Context state for geometry programs.
2341 */
2342 struct gl_geometry_program_state
2343 {
2344 /**
2345 * Currently enabled and valid program (including internal programs
2346 * and compiled shader programs).
2347 */
2348 struct gl_program *_Current;
2349 };
2350
2351 /**
2352 * Context state for fragment programs.
2353 */
2354 struct gl_fragment_program_state
2355 {
2356 GLboolean Enabled; /**< User-set fragment program enable flag */
2357 /** Should fixed-function texturing be implemented with a fragment prog? */
2358 GLboolean _MaintainTexEnvProgram;
2359
2360 struct gl_program *Current; /**< User-bound fragment program */
2361
2362 /**
2363 * Currently enabled and valid fragment program (including internal
2364 * programs, user-defined fragment programs and GLSL fragment shaders).
2365 * This is the program we must use when rendering.
2366 */
2367 struct gl_program *_Current;
2368
2369 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2370
2371 /** Program to emulate fixed-function texture env/combine (see above) */
2372 struct gl_program *_TexEnvProgram;
2373
2374 /** Cache of fixed-function programs */
2375 struct gl_program_cache *Cache;
2376 };
2377
2378
2379 /**
2380 * Context state for compute programs.
2381 */
2382 struct gl_compute_program_state
2383 {
2384 /** Currently enabled and valid program (including internal programs
2385 * and compiled shader programs).
2386 */
2387 struct gl_program *_Current;
2388 };
2389
2390
2391 /**
2392 * ATI_fragment_shader runtime state
2393 */
2394
2395 struct atifs_instruction;
2396 struct atifs_setupinst;
2397
2398 /**
2399 * ATI fragment shader
2400 */
2401 struct ati_fragment_shader
2402 {
2403 GLuint Id;
2404 GLint RefCount;
2405 struct atifs_instruction *Instructions[2];
2406 struct atifs_setupinst *SetupInst[2];
2407 GLfloat Constants[8][4];
2408 GLbitfield LocalConstDef; /**< Indicates which constants have been set */
2409 GLubyte numArithInstr[2];
2410 GLubyte regsAssigned[2];
2411 GLubyte NumPasses; /**< 1 or 2 */
2412 /**
2413 * Current compile stage: 0 setup pass1, 1 arith pass1,
2414 * 2 setup pass2, 3 arith pass2.
2415 */
2416 GLubyte cur_pass;
2417 GLubyte last_optype;
2418 GLboolean interpinp1;
2419 GLboolean isValid;
2420 /**
2421 * Array of 2 bit values for each tex unit to remember whether
2422 * STR or STQ swizzle was used
2423 */
2424 GLuint swizzlerq;
2425 struct gl_program *Program;
2426 };
2427
2428 /**
2429 * Context state for GL_ATI_fragment_shader
2430 */
2431 struct gl_ati_fragment_shader_state
2432 {
2433 GLboolean Enabled;
2434 GLboolean Compiling;
2435 GLfloat GlobalConstants[8][4];
2436 struct ati_fragment_shader *Current;
2437 };
2438
2439 /**
2440 * Shader subroutine function definition
2441 */
2442 struct gl_subroutine_function
2443 {
2444 char *name;
2445 int index;
2446 int num_compat_types;
2447 const struct glsl_type **types;
2448 };
2449
2450 /**
2451 * Shader information needed by both gl_shader and gl_linked shader.
2452 */
2453 struct gl_shader_info
2454 {
2455 /**
2456 * Tessellation Control shader state from layout qualifiers.
2457 */
2458 struct {
2459 /**
2460 * 0 - vertices not declared in shader, or
2461 * 1 .. GL_MAX_PATCH_VERTICES
2462 */
2463 GLint VerticesOut;
2464 } TessCtrl;
2465
2466 /**
2467 * Tessellation Evaluation shader state from layout qualifiers.
2468 */
2469 struct {
2470 /**
2471 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2472 * in this shader.
2473 */
2474 GLenum16 PrimitiveMode;
2475
2476 enum gl_tess_spacing Spacing;
2477
2478 /**
2479 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2480 */
2481 GLenum16 VertexOrder;
2482 /**
2483 * 1, 0, or -1 if it's not set in this shader.
2484 */
2485 int PointMode;
2486 } TessEval;
2487
2488 /**
2489 * Geometry shader state from GLSL 1.50 layout qualifiers.
2490 */
2491 struct {
2492 GLint VerticesOut;
2493 /**
2494 * 0 - Invocations count not declared in shader, or
2495 * 1 .. Const.MaxGeometryShaderInvocations
2496 */
2497 GLint Invocations;
2498 /**
2499 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2500 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2501 * shader.
2502 */
2503 GLenum16 InputType;
2504 /**
2505 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2506 * it's not set in this shader.
2507 */
2508 GLenum16 OutputType;
2509 } Geom;
2510
2511 /**
2512 * Compute shader state from ARB_compute_shader and
2513 * ARB_compute_variable_group_size layout qualifiers.
2514 */
2515 struct {
2516 /**
2517 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2518 * it's not set in this shader.
2519 */
2520 unsigned LocalSize[3];
2521
2522 /**
2523 * Whether a variable work group size has been specified as defined by
2524 * ARB_compute_variable_group_size.
2525 */
2526 bool LocalSizeVariable;
2527
2528 /*
2529 * Arrangement of invocations used to calculate derivatives in a compute
2530 * shader. From NV_compute_shader_derivatives.
2531 */
2532 enum gl_derivative_group DerivativeGroup;
2533 } Comp;
2534 };
2535
2536 /**
2537 * A linked GLSL shader object.
2538 */
2539 struct gl_linked_shader
2540 {
2541 gl_shader_stage Stage;
2542
2543 #ifdef DEBUG
2544 unsigned SourceChecksum;
2545 #endif
2546
2547 struct gl_program *Program; /**< Post-compile assembly code */
2548
2549 /**
2550 * \name Sampler tracking
2551 *
2552 * \note Each of these fields is only set post-linking.
2553 */
2554 /*@{*/
2555 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
2556 /*@}*/
2557
2558 /**
2559 * Number of default uniform block components used by this shader.
2560 *
2561 * This field is only set post-linking.
2562 */
2563 unsigned num_uniform_components;
2564
2565 /**
2566 * Number of combined uniform components used by this shader.
2567 *
2568 * This field is only set post-linking. It is the sum of the uniform block
2569 * sizes divided by sizeof(float), and num_uniform_compoennts.
2570 */
2571 unsigned num_combined_uniform_components;
2572
2573 struct exec_list *ir;
2574 struct exec_list *packed_varyings;
2575 struct exec_list *fragdata_arrays;
2576 struct glsl_symbol_table *symbols;
2577
2578 /**
2579 * ARB_gl_spirv related data.
2580 *
2581 * This is actually a reference to the gl_shader::spirv_data, which
2582 * stores information that is also needed during linking.
2583 */
2584 struct gl_shader_spirv_data *spirv_data;
2585 };
2586
2587
2588 /**
2589 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2590 * was skipped due to the shader matching one that's been seen before by
2591 * the on-disk cache.
2592 */
2593 enum gl_compile_status
2594 {
2595 COMPILE_FAILURE = 0,
2596 COMPILE_SUCCESS,
2597 COMPILE_SKIPPED
2598 };
2599
2600 /**
2601 * A GLSL shader object.
2602 */
2603 struct gl_shader
2604 {
2605 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2606 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2607 * Must be the first field.
2608 */
2609 GLenum16 Type;
2610 gl_shader_stage Stage;
2611 GLuint Name; /**< AKA the handle */
2612 GLint RefCount; /**< Reference count */
2613 GLchar *Label; /**< GL_KHR_debug */
2614 unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
2615 GLboolean DeletePending;
2616 bool IsES; /**< True if this shader uses GLSL ES */
2617
2618 enum gl_compile_status CompileStatus;
2619
2620 #ifdef DEBUG
2621 unsigned SourceChecksum; /**< for debug/logging purposes */
2622 #endif
2623 const GLchar *Source; /**< Source code string */
2624
2625 const GLchar *FallbackSource; /**< Fallback string used by on-disk cache*/
2626
2627 GLchar *InfoLog;
2628
2629 unsigned Version; /**< GLSL version used for linking */
2630
2631 /**
2632 * A bitmask of gl_advanced_blend_mode values
2633 */
2634 GLbitfield BlendSupport;
2635
2636 struct exec_list *ir;
2637 struct glsl_symbol_table *symbols;
2638
2639 /**
2640 * Whether early fragment tests are enabled as defined by
2641 * ARB_shader_image_load_store.
2642 */
2643 bool EarlyFragmentTests;
2644
2645 bool ARB_fragment_coord_conventions_enable;
2646
2647 bool redeclares_gl_fragcoord;
2648 bool uses_gl_fragcoord;
2649
2650 bool PostDepthCoverage;
2651 bool PixelInterlockOrdered;
2652 bool PixelInterlockUnordered;
2653 bool SampleInterlockOrdered;
2654 bool SampleInterlockUnordered;
2655 bool InnerCoverage;
2656
2657 /**
2658 * Fragment shader state from GLSL 1.50 layout qualifiers.
2659 */
2660 bool origin_upper_left;
2661 bool pixel_center_integer;
2662
2663 /**
2664 * Whether bindless_sampler/bindless_image, and respectively
2665 * bound_sampler/bound_image are declared at global scope as defined by
2666 * ARB_bindless_texture.
2667 */
2668 bool bindless_sampler;
2669 bool bindless_image;
2670 bool bound_sampler;
2671 bool bound_image;
2672
2673 /** Global xfb_stride out qualifier if any */
2674 GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
2675
2676 struct gl_shader_info info;
2677
2678 /* ARB_gl_spirv related data */
2679 struct gl_shader_spirv_data *spirv_data;
2680 };
2681
2682
2683 struct gl_uniform_buffer_variable
2684 {
2685 char *Name;
2686
2687 /**
2688 * Name of the uniform as seen by glGetUniformIndices.
2689 *
2690 * glGetUniformIndices requires that the block instance index \b not be
2691 * present in the name of queried uniforms.
2692 *
2693 * \note
2694 * \c gl_uniform_buffer_variable::IndexName and
2695 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2696 */
2697 char *IndexName;
2698
2699 const struct glsl_type *Type;
2700 unsigned int Offset;
2701 GLboolean RowMajor;
2702 };
2703
2704
2705 struct gl_uniform_block
2706 {
2707 /** Declared name of the uniform block */
2708 char *Name;
2709
2710 /** Array of supplemental information about UBO ir_variables. */
2711 struct gl_uniform_buffer_variable *Uniforms;
2712 GLuint NumUniforms;
2713
2714 /**
2715 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2716 * with glBindBufferBase to bind a buffer object to this uniform block.
2717 */
2718 GLuint Binding;
2719
2720 /**
2721 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2722 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2723 */
2724 GLuint UniformBufferSize;
2725
2726 /** Stages that reference this block */
2727 uint8_t stageref;
2728
2729 /**
2730 * Linearized array index for uniform block instance arrays
2731 *
2732 * Given a uniform block instance array declared with size
2733 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2734 * have the linearized array index
2735 *
2736 * m-1 m
2737 * i_m + ∑ i_j * ∏ s_k
2738 * j=0 k=j+1
2739 *
2740 * For a uniform block instance that is not an array, this is always 0.
2741 */
2742 uint8_t linearized_array_index;
2743
2744 /**
2745 * Layout specified in the shader
2746 *
2747 * This isn't accessible through the API, but it is used while
2748 * cross-validating uniform blocks.
2749 */
2750 enum glsl_interface_packing _Packing;
2751 GLboolean _RowMajor;
2752 };
2753
2754 /**
2755 * Structure that represents a reference to an atomic buffer from some
2756 * shader program.
2757 */
2758 struct gl_active_atomic_buffer
2759 {
2760 /** Uniform indices of the atomic counters declared within it. */
2761 GLuint *Uniforms;
2762 GLuint NumUniforms;
2763
2764 /** Binding point index associated with it. */
2765 GLuint Binding;
2766
2767 /** Minimum reasonable size it is expected to have. */
2768 GLuint MinimumSize;
2769
2770 /** Shader stages making use of it. */
2771 GLboolean StageReferences[MESA_SHADER_STAGES];
2772 };
2773
2774 /**
2775 * Data container for shader queries. This holds only the minimal
2776 * amount of required information for resource queries to work.
2777 */
2778 struct gl_shader_variable
2779 {
2780 /**
2781 * Declared type of the variable
2782 */
2783 const struct glsl_type *type;
2784
2785 /**
2786 * If the variable is in an interface block, this is the type of the block.
2787 */
2788 const struct glsl_type *interface_type;
2789
2790 /**
2791 * For variables inside structs (possibly recursively), this is the
2792 * outermost struct type.
2793 */
2794 const struct glsl_type *outermost_struct_type;
2795
2796 /**
2797 * Declared name of the variable
2798 */
2799 char *name;
2800
2801 /**
2802 * Storage location of the base of this variable
2803 *
2804 * The precise meaning of this field depends on the nature of the variable.
2805 *
2806 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2807 * - Vertex shader output: one of the values from \c gl_varying_slot.
2808 * - Geometry shader input: one of the values from \c gl_varying_slot.
2809 * - Geometry shader output: one of the values from \c gl_varying_slot.
2810 * - Fragment shader input: one of the values from \c gl_varying_slot.
2811 * - Fragment shader output: one of the values from \c gl_frag_result.
2812 * - Uniforms: Per-stage uniform slot number for default uniform block.
2813 * - Uniforms: Index within the uniform block definition for UBO members.
2814 * - Non-UBO Uniforms: explicit location until linking then reused to
2815 * store uniform slot number.
2816 * - Other: This field is not currently used.
2817 *
2818 * If the variable is a uniform, shader input, or shader output, and the
2819 * slot has not been assigned, the value will be -1.
2820 */
2821 int location;
2822
2823 /**
2824 * Specifies the first component the variable is stored in as per
2825 * ARB_enhanced_layouts.
2826 */
2827 unsigned component:2;
2828
2829 /**
2830 * Output index for dual source blending.
2831 *
2832 * \note
2833 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2834 * source blending.
2835 */
2836 unsigned index:1;
2837
2838 /**
2839 * Specifies whether a shader input/output is per-patch in tessellation
2840 * shader stages.
2841 */
2842 unsigned patch:1;
2843
2844 /**
2845 * Storage class of the variable.
2846 *
2847 * \sa (n)ir_variable_mode
2848 */
2849 unsigned mode:4;
2850
2851 /**
2852 * Interpolation mode for shader inputs / outputs
2853 *
2854 * \sa glsl_interp_mode
2855 */
2856 unsigned interpolation:2;
2857
2858 /**
2859 * Was the location explicitly set in the shader?
2860 *
2861 * If the location is explicitly set in the shader, it \b cannot be changed
2862 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2863 * no effect).
2864 */
2865 unsigned explicit_location:1;
2866
2867 /**
2868 * Precision qualifier.
2869 */
2870 unsigned precision:2;
2871 };
2872
2873 /**
2874 * Active resource in a gl_shader_program
2875 */
2876 struct gl_program_resource
2877 {
2878 GLenum16 Type; /** Program interface type. */
2879 const void *Data; /** Pointer to resource associated data structure. */
2880 uint8_t StageReferences; /** Bitmask of shader stage references. */
2881 };
2882
2883 /**
2884 * Link status enum. LINKING_SKIPPED is used to indicate linking
2885 * was skipped due to the shader being loaded from the on-disk cache.
2886 */
2887 enum gl_link_status
2888 {
2889 LINKING_FAILURE = 0,
2890 LINKING_SUCCESS,
2891 LINKING_SKIPPED
2892 };
2893
2894 /**
2895 * A data structure to be shared by gl_shader_program and gl_program.
2896 */
2897 struct gl_shader_program_data
2898 {
2899 GLint RefCount; /**< Reference count */
2900
2901 /** SHA1 hash of linked shader program */
2902 unsigned char sha1[20];
2903
2904 unsigned NumUniformStorage;
2905 unsigned NumHiddenUniforms;
2906 struct gl_uniform_storage *UniformStorage;
2907
2908 unsigned NumUniformBlocks;
2909 unsigned NumShaderStorageBlocks;
2910
2911 struct gl_uniform_block *UniformBlocks;
2912 struct gl_uniform_block *ShaderStorageBlocks;
2913
2914 struct gl_active_atomic_buffer *AtomicBuffers;
2915 unsigned NumAtomicBuffers;
2916
2917 /* Shader cache variables used during restore */
2918 unsigned NumUniformDataSlots;
2919 union gl_constant_value *UniformDataSlots;
2920
2921 /* Used to hold initial uniform values for program binary restores.
2922 *
2923 * From the ARB_get_program_binary spec:
2924 *
2925 * "A successful call to ProgramBinary will reset all uniform
2926 * variables to their initial values. The initial value is either
2927 * the value of the variable's initializer as specified in the
2928 * original shader source, or 0 if no initializer was present.
2929 */
2930 union gl_constant_value *UniformDataDefaults;
2931
2932 /** Hash for quick search by name. */
2933 struct hash_table_u64 *ProgramResourceHash;
2934
2935 GLboolean Validated;
2936
2937 /** List of all active resources after linking. */
2938 struct gl_program_resource *ProgramResourceList;
2939 unsigned NumProgramResourceList;
2940
2941 enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
2942 GLchar *InfoLog;
2943
2944 unsigned Version; /**< GLSL version used for linking */
2945
2946 /* Mask of stages this program was linked against */
2947 unsigned linked_stages;
2948
2949 /* Whether the shaders of this program are loaded from SPIR-V binaries
2950 * (all have the SPIR_V_BINARY_ARB state). This was introduced by the
2951 * ARB_gl_spirv extension.
2952 */
2953 bool spirv;
2954 };
2955
2956 /**
2957 * A GLSL program object.
2958 * Basically a linked collection of vertex and fragment shaders.
2959 */
2960 struct gl_shader_program
2961 {
2962 GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */
2963 GLuint Name; /**< aka handle or ID */
2964 GLchar *Label; /**< GL_KHR_debug */
2965 GLint RefCount; /**< Reference count */
2966 GLboolean DeletePending;
2967
2968 /**
2969 * Is the application intending to glGetProgramBinary this program?
2970 *
2971 * BinaryRetrievableHint is the currently active hint that gets set
2972 * during initialization and after linking and BinaryRetrievableHintPending
2973 * is the hint set by the user to be active when program is linked next time.
2974 */
2975 GLboolean BinaryRetrievableHint;
2976 GLboolean BinaryRetrievableHintPending;
2977
2978 /**
2979 * Indicates whether program can be bound for individual pipeline stages
2980 * using UseProgramStages after it is next linked.
2981 */
2982 GLboolean SeparateShader;
2983
2984 GLuint NumShaders; /**< number of attached shaders */
2985 struct gl_shader **Shaders; /**< List of attached the shaders */
2986
2987 /**
2988 * User-defined attribute bindings
2989 *
2990 * These are set via \c glBindAttribLocation and are used to direct the
2991 * GLSL linker. These are \b not the values used in the compiled shader,
2992 * and they are \b not the values returned by \c glGetAttribLocation.
2993 */
2994 struct string_to_uint_map *AttributeBindings;
2995
2996 /**
2997 * User-defined fragment data bindings
2998 *
2999 * These are set via \c glBindFragDataLocation and are used to direct the
3000 * GLSL linker. These are \b not the values used in the compiled shader,
3001 * and they are \b not the values returned by \c glGetFragDataLocation.
3002 */
3003 struct string_to_uint_map *FragDataBindings;
3004 struct string_to_uint_map *FragDataIndexBindings;
3005
3006 /**
3007 * Transform feedback varyings last specified by
3008 * glTransformFeedbackVaryings().
3009 *
3010 * For the current set of transform feedback varyings used for transform
3011 * feedback output, see LinkedTransformFeedback.
3012 */
3013 struct {
3014 GLenum16 BufferMode;
3015 /** Global xfb_stride out qualifier if any */
3016 GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
3017 GLuint NumVarying;
3018 GLchar **VaryingNames; /**< Array [NumVarying] of char * */
3019 } TransformFeedback;
3020
3021 struct gl_program *last_vert_prog;
3022
3023 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3024 enum gl_frag_depth_layout FragDepthLayout;
3025
3026 /**
3027 * Geometry shader state - copied into gl_program by
3028 * _mesa_copy_linked_program_data().
3029 */
3030 struct {
3031 GLint VerticesIn;
3032
3033 bool UsesEndPrimitive;
3034 bool UsesStreams;
3035 } Geom;
3036
3037 /**
3038 * Compute shader state - copied into gl_program by
3039 * _mesa_copy_linked_program_data().
3040 */
3041 struct {
3042 /**
3043 * Size of shared variables accessed by the compute shader.
3044 */
3045 unsigned SharedSize;
3046 } Comp;
3047
3048 /** Data shared by gl_program and gl_shader_program */
3049 struct gl_shader_program_data *data;
3050
3051 /**
3052 * Mapping from GL uniform locations returned by \c glUniformLocation to
3053 * UniformStorage entries. Arrays will have multiple contiguous slots
3054 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3055 */
3056 unsigned NumUniformRemapTable;
3057 struct gl_uniform_storage **UniformRemapTable;
3058
3059 /**
3060 * Sometimes there are empty slots left over in UniformRemapTable after we
3061 * allocate slots to explicit locations. This list stores the blocks of
3062 * continuous empty slots inside UniformRemapTable.
3063 */
3064 struct exec_list EmptyUniformLocations;
3065
3066 /**
3067 * Total number of explicit uniform location including inactive uniforms.
3068 */
3069 unsigned NumExplicitUniformLocations;
3070
3071 /**
3072 * Map of active uniform names to locations
3073 *
3074 * Maps any active uniform that is not an array element to a location.
3075 * Each active uniform, including individual structure members will appear
3076 * in this map. This roughly corresponds to the set of names that would be
3077 * enumerated by \c glGetActiveUniform.
3078 */
3079 struct string_to_uint_map *UniformHash;
3080
3081 GLboolean SamplersValidated; /**< Samplers validated against texture units? */
3082
3083 bool IsES; /**< True if this program uses GLSL ES */
3084
3085 /**
3086 * Per-stage shaders resulting from the first stage of linking.
3087 *
3088 * Set of linked shaders for this program. The array is accessed using the
3089 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3090 * \c NULL.
3091 */
3092 struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
3093
3094 /**
3095 * True if any of the fragment shaders attached to this program use:
3096 * #extension ARB_fragment_coord_conventions: enable
3097 */
3098 GLboolean ARB_fragment_coord_conventions_enable;
3099 };
3100
3101
3102 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3103 #define GLSL_LOG 0x2 /**< Write shaders to files */
3104 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3105 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3106 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3107 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3108 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3109 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3110 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3111 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3112
3113
3114 /**
3115 * Context state for GLSL vertex/fragment shaders.
3116 * Extended to support pipeline object
3117 */
3118 struct gl_pipeline_object
3119 {
3120 /** Name of the pipeline object as received from glGenProgramPipelines.
3121 * It would be 0 for shaders without separate shader objects.
3122 */
3123 GLuint Name;
3124
3125 GLint RefCount;
3126
3127 GLchar *Label; /**< GL_KHR_debug */
3128
3129 /**
3130 * Programs used for rendering
3131 *
3132 * There is a separate program set for each shader stage.
3133 */
3134 struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
3135
3136 struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
3137
3138 /**
3139 * Program used by glUniform calls.
3140 *
3141 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3142 */
3143 struct gl_shader_program *ActiveProgram;
3144
3145 GLbitfield Flags; /**< Mask of GLSL_x flags */
3146 GLboolean EverBound; /**< Has the pipeline object been created */
3147 GLboolean Validated; /**< Pipeline Validation status */
3148
3149 GLchar *InfoLog;
3150 };
3151
3152 /**
3153 * Context state for GLSL pipeline shaders.
3154 */
3155 struct gl_pipeline_shader_state
3156 {
3157 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3158 struct gl_pipeline_object *Current;
3159
3160 /** Default Object to ensure that _Shader is never NULL */
3161 struct gl_pipeline_object *Default;
3162
3163 /** Pipeline objects */
3164 struct _mesa_HashTable *Objects;
3165 };
3166
3167 /**
3168 * Compiler options for a single GLSL shaders type
3169 */
3170 struct gl_shader_compiler_options
3171 {
3172 /** Driver-selectable options: */
3173 GLboolean EmitNoLoops;
3174 GLboolean EmitNoCont; /**< Emit CONT opcode? */
3175 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
3176 GLboolean EmitNoPow; /**< Emit POW opcodes? */
3177 GLboolean EmitNoSat; /**< Emit SAT opcodes? */
3178 GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
3179 * gl_CullDistance together from
3180 * float[8] to vec4[2]
3181 **/
3182 GLbitfield LowerBuiltinVariablesXfb; /**< Which builtin variables should
3183 * be lowered for transform feedback
3184 **/
3185
3186 /**
3187 * If we can lower the precision of variables based on precision
3188 * qualifiers
3189 */
3190 GLboolean LowerPrecision;
3191
3192 /**
3193 * \name Forms of indirect addressing the driver cannot do.
3194 */
3195 /*@{*/
3196 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
3197 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
3198 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
3199 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
3200 GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
3201 /*@}*/
3202
3203 GLuint MaxIfDepth; /**< Maximum nested IF blocks */
3204 GLuint MaxUnrollIterations;
3205
3206 /**
3207 * Optimize code for array of structures backends.
3208 *
3209 * This is a proxy for:
3210 * - preferring DP4 instructions (rather than MUL/MAD) for
3211 * matrix * vector operations, such as position transformation.
3212 */
3213 GLboolean OptimizeForAOS;
3214
3215 /** Lower UBO and SSBO access to intrinsics. */
3216 GLboolean LowerBufferInterfaceBlocks;
3217
3218 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3219 GLboolean ClampBlockIndicesToArrayBounds;
3220
3221 /** (driconf) Force gl_Position to be considered invariant */
3222 GLboolean PositionAlwaysInvariant;
3223
3224 const struct nir_shader_compiler_options *NirOptions;
3225 };
3226
3227
3228 /**
3229 * Occlusion/timer query object.
3230 */
3231 struct gl_query_object
3232 {
3233 GLenum16 Target; /**< The query target, when active */
3234 GLuint Id; /**< hash table ID/name */
3235 GLchar *Label; /**< GL_KHR_debug */
3236 GLuint64EXT Result; /**< the counter */
3237 GLboolean Active; /**< inside Begin/EndQuery */
3238 GLboolean Ready; /**< result is ready? */
3239 GLboolean EverBound;/**< has query object ever been bound */
3240 GLuint Stream; /**< The stream */
3241 };
3242
3243
3244 /**
3245 * Context state for query objects.
3246 */
3247 struct gl_query_state
3248 {
3249 struct _mesa_HashTable *QueryObjects;
3250 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
3251 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
3252
3253 /** GL_NV_conditional_render */
3254 struct gl_query_object *CondRenderQuery;
3255
3256 /** GL_EXT_transform_feedback */
3257 struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
3258 struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
3259
3260 /** GL_ARB_transform_feedback_overflow_query */
3261 struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS];
3262 struct gl_query_object *TransformFeedbackOverflowAny;
3263
3264 /** GL_ARB_timer_query */
3265 struct gl_query_object *TimeElapsed;
3266
3267 /** GL_ARB_pipeline_statistics_query */
3268 struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
3269
3270 GLenum16 CondRenderMode;
3271 };
3272
3273
3274 /** Sync object state */
3275 struct gl_sync_object
3276 {
3277 GLuint Name; /**< Fence name */
3278 GLint RefCount; /**< Reference count */
3279 GLchar *Label; /**< GL_KHR_debug */
3280 GLboolean DeletePending; /**< Object was deleted while there were still
3281 * live references (e.g., sync not yet finished)
3282 */
3283 GLenum16 SyncCondition;
3284 GLbitfield Flags; /**< Flags passed to glFenceSync */
3285 GLuint StatusFlag:1; /**< Has the sync object been signaled? */
3286 };
3287
3288
3289 /**
3290 * State which can be shared by multiple contexts:
3291 */
3292 struct gl_shared_state
3293 {
3294 simple_mtx_t Mutex; /**< for thread safety */
3295 GLint RefCount; /**< Reference count */
3296 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
3297 struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */
3298 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
3299
3300 /** Default texture objects (shared by all texture units) */
3301 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
3302
3303 /** Fallback texture used when a bound texture is incomplete */
3304 struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
3305
3306 /**
3307 * \name Thread safety and statechange notification for texture
3308 * objects.
3309 *
3310 * \todo Improve the granularity of locking.
3311 */
3312 /*@{*/
3313 mtx_t TexMutex; /**< texobj thread safety */
3314 GLuint TextureStateStamp; /**< state notification for shared tex */
3315 /*@}*/
3316
3317 /**
3318 * \name Vertex/geometry/fragment programs
3319 */
3320 /*@{*/
3321 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
3322 struct gl_program *DefaultVertexProgram;
3323 struct gl_program *DefaultFragmentProgram;
3324 /*@}*/
3325
3326 /* GL_ATI_fragment_shader */
3327 struct _mesa_HashTable *ATIShaders;
3328 struct ati_fragment_shader *DefaultFragmentShader;
3329
3330 struct _mesa_HashTable *BufferObjects;
3331
3332 /** Table of both gl_shader and gl_shader_program objects */
3333 struct _mesa_HashTable *ShaderObjects;
3334
3335 /* GL_EXT_framebuffer_object */
3336 struct _mesa_HashTable *RenderBuffers;
3337 struct _mesa_HashTable *FrameBuffers;
3338
3339 /* GL_ARB_sync */
3340 struct set *SyncObjects;
3341
3342 /** GL_ARB_sampler_objects */
3343 struct _mesa_HashTable *SamplerObjects;
3344
3345 /* GL_ARB_bindless_texture */
3346 struct hash_table_u64 *TextureHandles;
3347 struct hash_table_u64 *ImageHandles;
3348 mtx_t HandlesMutex; /**< For texture/image handles safety */
3349
3350 /* GL_ARB_shading_language_include */
3351 struct shader_includes *ShaderIncludes;
3352 /* glCompileShaderInclude expects ShaderIncludes not to change while it is
3353 * in progress.
3354 */
3355 mtx_t ShaderIncludeMutex;
3356
3357 /**
3358 * Some context in this share group was affected by a GPU reset
3359 *
3360 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3361 * been affected by a GPU reset must also return
3362 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3363 *
3364 * Once this field becomes true, it is never reset to false.
3365 */
3366 bool ShareGroupReset;
3367
3368 /** EXT_external_objects */
3369 struct _mesa_HashTable *MemoryObjects;
3370
3371 /** EXT_semaphore */
3372 struct _mesa_HashTable *SemaphoreObjects;
3373
3374 /**
3375 * Some context in this share group was affected by a disjoint
3376 * operation. This operation can be anything that has effects on
3377 * values of timer queries in such manner that they become invalid for
3378 * performance metrics. As example gpu reset, counter overflow or gpu
3379 * frequency changes.
3380 */
3381 bool DisjointOperation;
3382 };
3383
3384
3385
3386 /**
3387 * Renderbuffers represent drawing surfaces such as color, depth and/or
3388 * stencil. A framebuffer object has a set of renderbuffers.
3389 * Drivers will typically derive subclasses of this type.
3390 */
3391 struct gl_renderbuffer
3392 {
3393 simple_mtx_t Mutex; /**< for thread safety */
3394 GLuint ClassID; /**< Useful for drivers */
3395 GLuint Name;
3396 GLchar *Label; /**< GL_KHR_debug */
3397 GLint RefCount;
3398 GLuint Width, Height;
3399 GLuint Depth;
3400 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
3401 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
3402 /**
3403 * True for renderbuffers that wrap textures, giving the driver a chance to
3404 * flush render caches through the FinishRenderTexture hook.
3405 *
3406 * Drivers may also set this on renderbuffers other than those generated by
3407 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3408 * called without a rb->TexImage.
3409 */
3410 GLboolean NeedsFinishRenderTexture;
3411 GLubyte NumSamples; /**< zero means not multisampled */
3412 GLubyte NumStorageSamples; /**< for AMD_framebuffer_multisample_advanced */
3413 GLenum16 InternalFormat; /**< The user-specified format */
3414 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3415 GL_STENCIL_INDEX. */
3416 mesa_format Format; /**< The actual renderbuffer memory format */
3417 /**
3418 * Pointer to the texture image if this renderbuffer wraps a texture,
3419 * otherwise NULL.
3420 *
3421 * Note that the reference on the gl_texture_object containing this
3422 * TexImage is held by the gl_renderbuffer_attachment.
3423 */
3424 struct gl_texture_image *TexImage;
3425
3426 /** Delete this renderbuffer */
3427 void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
3428
3429 /** Allocate new storage for this renderbuffer */
3430 GLboolean (*AllocStorage)(struct gl_context *ctx,
3431 struct gl_renderbuffer *rb,
3432 GLenum internalFormat,
3433 GLuint width, GLuint height);
3434 };
3435
3436
3437 /**
3438 * A renderbuffer attachment points to either a texture object (and specifies
3439 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3440 */
3441 struct gl_renderbuffer_attachment
3442 {
3443 GLenum16 Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3444 GLboolean Complete;
3445
3446 /**
3447 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3448 * application supplied renderbuffer object.
3449 */
3450 struct gl_renderbuffer *Renderbuffer;
3451
3452 /**
3453 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3454 * supplied texture object.
3455 */
3456 struct gl_texture_object *Texture;
3457 GLuint TextureLevel; /**< Attached mipmap level. */
3458 GLsizei NumSamples; /**< from FramebufferTexture2DMultisampleEXT */
3459 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
3460 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
3461 * and 2D array textures */
3462 GLboolean Layered;
3463 };
3464
3465
3466 /**
3467 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3468 * In C++ terms, think of this as a base class from which device drivers
3469 * will make derived classes.
3470 */
3471 struct gl_framebuffer
3472 {
3473 simple_mtx_t Mutex; /**< for thread safety */
3474 /**
3475 * If zero, this is a window system framebuffer. If non-zero, this
3476 * is a FBO framebuffer; note that for some devices (i.e. those with
3477 * a natural pixel coordinate system for FBOs that differs from the
3478 * OpenGL/Mesa coordinate system), this means that the viewport,
3479 * polygon face orientation, and polygon stipple will have to be inverted.
3480 */
3481 GLuint Name;
3482 GLint RefCount;
3483
3484 GLchar *Label; /**< GL_KHR_debug */
3485
3486 GLboolean DeletePending;
3487
3488 /**
3489 * The framebuffer's visual. Immutable if this is a window system buffer.
3490 * Computed from attachments if user-made FBO.
3491 */
3492 struct gl_config Visual;
3493
3494 /**
3495 * Size of frame buffer in pixels. If there are no attachments, then both
3496 * of these are 0.
3497 */
3498 GLuint Width, Height;
3499
3500 /**
3501 * In the case that the framebuffer has no attachment (i.e.
3502 * GL_ARB_framebuffer_no_attachments) then the geometry of
3503 * the framebuffer is specified by the default values.
3504 */
3505 struct {
3506 GLuint Width, Height, Layers, NumSamples;
3507 GLboolean FixedSampleLocations;
3508 /* Derived from NumSamples by the driver so that it can choose a valid
3509 * value for the hardware.
3510 */
3511 GLuint _NumSamples;
3512 } DefaultGeometry;
3513
3514 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3515 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3516 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3517 */
3518 /*@{*/
3519 GLint _Xmin, _Xmax;
3520 GLint _Ymin, _Ymax;
3521 /*@}*/
3522
3523 /** \name Derived Z buffer stuff */
3524 /*@{*/
3525 GLuint _DepthMax; /**< Max depth buffer value */
3526 GLfloat _DepthMaxF; /**< Float max depth buffer value */
3527 GLfloat _MRD; /**< minimum resolvable difference in Z values */
3528 /*@}*/
3529
3530 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3531 GLenum16 _Status;
3532
3533 /** Whether one of Attachment has Type != GL_NONE
3534 * NOTE: the values for Width and Height are set to 0 in case of having
3535 * no attachments, a backend driver supporting the extension
3536 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3537 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3538 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3539 * _Ymax do NOT take into account _HasAttachments being false). To get the
3540 * geometry of the framebuffer, the helper functions
3541 * _mesa_geometric_width(),
3542 * _mesa_geometric_height(),
3543 * _mesa_geometric_samples() and
3544 * _mesa_geometric_layers()
3545 * are available that check _HasAttachments.
3546 */
3547 bool _HasAttachments;
3548
3549 GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
3550 GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */
3551 GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */
3552
3553 /* ARB_color_buffer_float */
3554 GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
3555 GLboolean _HasSNormOrFloatColorBuffer;
3556
3557 /**
3558 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3559 * is not layered. For cube maps and cube map arrays, each cube face
3560 * counts as a layer. As the case for Width, Height a backend driver
3561 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3562 * in the case that _HasAttachments is false
3563 */
3564 GLuint MaxNumLayers;
3565
3566 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3567 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
3568
3569 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3570 * attribute group and GL_PIXEL attribute group, respectively.
3571 */
3572 GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS];
3573 GLenum16 ColorReadBuffer;
3574
3575 /* GL_ARB_sample_locations */
3576 GLfloat *SampleLocationTable; /**< If NULL, no table has been specified */
3577 GLboolean ProgrammableSampleLocations;
3578 GLboolean SampleLocationPixelGrid;
3579
3580 /** Computed from ColorDraw/ReadBuffer above */
3581 GLuint _NumColorDrawBuffers;
3582 gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
3583 gl_buffer_index _ColorReadBufferIndex;
3584 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
3585 struct gl_renderbuffer *_ColorReadBuffer;
3586
3587 /* GL_MESA_framebuffer_flip_y */
3588 bool FlipY;
3589
3590 /** Delete this framebuffer */
3591 void (*Delete)(struct gl_framebuffer *fb);
3592 };
3593
3594
3595 /**
3596 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3597 */
3598 struct gl_precision
3599 {
3600 GLushort RangeMin; /**< min value exponent */
3601 GLushort RangeMax; /**< max value exponent */
3602 GLushort Precision; /**< number of mantissa bits */
3603 };
3604
3605
3606 /**
3607 * Limits for vertex, geometry and fragment programs/shaders.
3608 */
3609 struct gl_program_constants
3610 {
3611 /* logical limits */
3612 GLuint MaxInstructions;
3613 GLuint MaxAluInstructions;
3614 GLuint MaxTexInstructions;
3615 GLuint MaxTexIndirections;
3616 GLuint MaxAttribs;
3617 GLuint MaxTemps;
3618 GLuint MaxAddressRegs;
3619 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3620 GLuint MaxParameters;
3621 GLuint MaxLocalParams;
3622 GLuint MaxEnvParams;
3623 /* native/hardware limits */
3624 GLuint MaxNativeInstructions;
3625 GLuint MaxNativeAluInstructions;
3626 GLuint MaxNativeTexInstructions;
3627 GLuint MaxNativeTexIndirections;
3628 GLuint MaxNativeAttribs;
3629 GLuint MaxNativeTemps;
3630 GLuint MaxNativeAddressRegs;
3631 GLuint MaxNativeParameters;
3632 /* For shaders */
3633 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
3634
3635 /**
3636 * \name Per-stage input / output limits
3637 *
3638 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3639 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3640 * ES). This is stored as \c gl_constants::MaxVarying.
3641 *
3642 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3643 * variables. Each stage as a certain number of outputs that it can feed
3644 * to the next stage and a certain number inputs that it can consume from
3645 * the previous stage.
3646 *
3647 * Vertex shader inputs do not participate this in this accounting.
3648 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3649 *
3650 * Fragment shader outputs do not participate this in this accounting.
3651 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3652 */
3653 /*@{*/
3654 GLuint MaxInputComponents;
3655 GLuint MaxOutputComponents;
3656 /*@}*/
3657
3658 /* ES 2.0 and GL_ARB_ES2_compatibility */
3659 struct gl_precision LowFloat, MediumFloat, HighFloat;
3660 struct gl_precision LowInt, MediumInt, HighInt;
3661 /* GL_ARB_uniform_buffer_object */
3662 GLuint MaxUniformBlocks;
3663 uint64_t MaxCombinedUniformComponents;
3664 GLuint MaxTextureImageUnits;
3665
3666 /* GL_ARB_shader_atomic_counters */
3667 GLuint MaxAtomicBuffers;
3668 GLuint MaxAtomicCounters;
3669
3670 /* GL_ARB_shader_image_load_store */
3671 GLuint MaxImageUniforms;
3672
3673 /* GL_ARB_shader_storage_buffer_object */
3674 GLuint MaxShaderStorageBlocks;
3675 };
3676
3677 /**
3678 * Constants which may be overridden by device driver during context creation
3679 * but are never changed after that.
3680 */
3681 struct gl_constants
3682 {
3683 GLuint MaxTextureMbytes; /**< Max memory per image, in MB */
3684 GLuint MaxTextureSize; /**< Max 1D/2D texture size, in pixels*/
3685 GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
3686 GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
3687 GLuint MaxArrayTextureLayers; /**< Max layers in array textures */
3688 GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */
3689 GLuint MaxTextureCoordUnits;
3690 GLuint MaxCombinedTextureImageUnits;
3691 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3692 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
3693 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
3694 GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
3695
3696 GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
3697
3698 GLuint MaxArrayLockSize;
3699
3700 GLint SubPixelBits;
3701
3702 GLfloat MinPointSize, MaxPointSize; /**< aliased */
3703 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
3704 GLfloat PointSizeGranularity;
3705 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
3706 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
3707 GLfloat LineWidthGranularity;
3708
3709 GLuint MaxClipPlanes;
3710 GLuint MaxLights;
3711 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
3712 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
3713
3714 GLuint MaxViewportWidth, MaxViewportHeight;
3715 GLuint MaxViewports; /**< GL_ARB_viewport_array */
3716 GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
3717 struct {
3718 GLfloat Min;
3719 GLfloat Max;
3720 } ViewportBounds; /**< GL_ARB_viewport_array */
3721 GLuint MaxWindowRectangles; /**< GL_EXT_window_rectangles */
3722
3723 struct gl_program_constants Program[MESA_SHADER_STAGES];
3724 GLuint MaxProgramMatrices;
3725 GLuint MaxProgramMatrixStackDepth;
3726
3727 struct {
3728 GLuint SamplesPassed;
3729 GLuint TimeElapsed;
3730 GLuint Timestamp;
3731 GLuint PrimitivesGenerated;
3732 GLuint PrimitivesWritten;
3733 GLuint VerticesSubmitted;
3734 GLuint PrimitivesSubmitted;
3735 GLuint VsInvocations;
3736 GLuint TessPatches;
3737 GLuint TessInvocations;
3738 GLuint GsInvocations;
3739 GLuint GsPrimitives;
3740 GLuint FsInvocations;
3741 GLuint ComputeInvocations;
3742 GLuint ClInPrimitives;
3743 GLuint ClOutPrimitives;
3744 } QueryCounterBits;
3745
3746 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
3747
3748 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
3749 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
3750 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
3751
3752 /**
3753 * GL_ARB_framebuffer_no_attachments
3754 */
3755 GLuint MaxFramebufferWidth;
3756 GLuint MaxFramebufferHeight;
3757 GLuint MaxFramebufferLayers;
3758 GLuint MaxFramebufferSamples;
3759
3760 /** Number of varying vectors between any two shader stages. */
3761 GLuint MaxVarying;
3762
3763 /** @{
3764 * GL_ARB_uniform_buffer_object
3765 */
3766 GLuint MaxCombinedUniformBlocks;
3767 GLuint MaxUniformBufferBindings;
3768 GLuint MaxUniformBlockSize;
3769 GLuint UniformBufferOffsetAlignment;
3770 /** @} */
3771
3772 /** @{
3773 * GL_ARB_shader_storage_buffer_object
3774 */
3775 GLuint MaxCombinedShaderStorageBlocks;
3776 GLuint MaxShaderStorageBufferBindings;
3777 GLuint MaxShaderStorageBlockSize;
3778 GLuint ShaderStorageBufferOffsetAlignment;
3779 /** @} */
3780
3781 /**
3782 * GL_ARB_explicit_uniform_location
3783 */
3784 GLuint MaxUserAssignableUniformLocations;
3785
3786 /** geometry shader */
3787 GLuint MaxGeometryOutputVertices;
3788 GLuint MaxGeometryTotalOutputComponents;
3789 GLuint MaxGeometryShaderInvocations;
3790
3791 GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3792 GLuint GLSLVersionCompat; /**< Desktop compat GLSL version supported */
3793
3794 /**
3795 * Changes default GLSL extension behavior from "error" to "warn". It's out
3796 * of spec, but it can make some apps work that otherwise wouldn't.
3797 */
3798 GLboolean ForceGLSLExtensionsWarn;
3799
3800 /**
3801 * If non-zero, forces GLSL shaders to behave as if they began
3802 * with "#version ForceGLSLVersion".
3803 */
3804 GLuint ForceGLSLVersion;
3805
3806 /**
3807 * Allow GLSL #extension directives in the middle of shaders.
3808 */
3809 GLboolean AllowGLSLExtensionDirectiveMidShader;
3810
3811 /**
3812 * Allow builtins as part of constant expressions. This was not allowed
3813 * until GLSL 1.20 this allows it everywhere.
3814 */
3815 GLboolean AllowGLSLBuiltinConstantExpression;
3816
3817 /**
3818 * Allow some relaxation of GLSL ES shader restrictions. This encompasses
3819 * a number of relaxations to the ES shader rules.
3820 */
3821 GLboolean AllowGLSLRelaxedES;
3822
3823 /**
3824 * Allow GLSL built-in variables to be redeclared verbatim
3825 */
3826 GLboolean AllowGLSLBuiltinVariableRedeclaration;
3827
3828 /**
3829 * Allow GLSL interpolation qualifier mismatch across shader stages.
3830 */
3831 GLboolean AllowGLSLCrossStageInterpolationMismatch;
3832
3833 /**
3834 * Allow creating a higher compat profile (version 3.1+) for apps that
3835 * request it. Be careful when adding that driconf option because some
3836 * features are unimplemented and might not work correctly.
3837 */
3838 GLboolean AllowHigherCompatVersion;
3839
3840 /**
3841 * Allow layout qualifiers on function parameters.
3842 */
3843 GLboolean AllowLayoutQualifiersOnFunctionParameters;
3844
3845 /**
3846 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3847 * D3D9 when apps rely on this behaviour.
3848 */
3849 GLboolean ForceGLSLAbsSqrt;
3850
3851 /**
3852 * Force uninitialized variables to default to zero.
3853 */
3854 GLboolean GLSLZeroInit;
3855
3856 /**
3857 * Does the driver support real 32-bit integers? (Otherwise, integers are
3858 * simulated via floats.)
3859 */
3860 GLboolean NativeIntegers;
3861
3862 /**
3863 * Does VertexID count from zero or from base vertex?
3864 *
3865 * \note
3866 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3867 * ignored and need not be set.
3868 */
3869 bool VertexID_is_zero_based;
3870
3871 /**
3872 * If the driver supports real 32-bit integers, what integer value should be
3873 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3874 */
3875 GLuint UniformBooleanTrue;
3876
3877 /**
3878 * Maximum amount of time, measured in nanseconds, that the server can wait.
3879 */
3880 GLuint64 MaxServerWaitTimeout;
3881
3882 /** GL_EXT_provoking_vertex */
3883 GLboolean QuadsFollowProvokingVertexConvention;
3884
3885 /** GL_ARB_viewport_array */
3886 GLenum16 LayerAndVPIndexProvokingVertex;
3887
3888 /** OpenGL version 3.0 */
3889 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3890
3891 /** OpenGL version 3.2 */
3892 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
3893
3894 /** OpenGL version 4.4 */
3895 GLuint MaxVertexAttribStride;
3896
3897 /** GL_EXT_transform_feedback */
3898 GLuint MaxTransformFeedbackBuffers;
3899 GLuint MaxTransformFeedbackSeparateComponents;
3900 GLuint MaxTransformFeedbackInterleavedComponents;
3901 GLuint MaxVertexStreams;
3902
3903 /** GL_EXT_gpu_shader4 */
3904 GLint MinProgramTexelOffset, MaxProgramTexelOffset;
3905
3906 /** GL_ARB_texture_gather */
3907 GLuint MinProgramTextureGatherOffset;
3908 GLuint MaxProgramTextureGatherOffset;
3909 GLuint MaxProgramTextureGatherComponents;
3910
3911 /* GL_ARB_robustness */
3912 GLenum16 ResetStrategy;
3913
3914 /* GL_KHR_robustness */
3915 GLboolean RobustAccess;
3916
3917 /* GL_ARB_blend_func_extended */
3918 GLuint MaxDualSourceDrawBuffers;
3919
3920 /**
3921 * Whether the implementation strips out and ignores texture borders.
3922 *
3923 * Many GPU hardware implementations don't support rendering with texture
3924 * borders and mipmapped textures. (Note: not static border color, but the
3925 * old 1-pixel border around each edge). Implementations then have to do
3926 * slow fallbacks to be correct, or just ignore the border and be fast but
3927 * wrong. Setting the flag strips the border off of TexImage calls,
3928 * providing "fast but wrong" at significantly reduced driver complexity.
3929 *
3930 * Texture borders are deprecated in GL 3.0.
3931 **/
3932 GLboolean StripTextureBorder;
3933
3934 /**
3935 * For drivers which can do a better job at eliminating unused uniforms
3936 * than the GLSL compiler.
3937 *
3938 * XXX Remove these as soon as a better solution is available.
3939 */
3940 GLboolean GLSLSkipStrictMaxUniformLimitCheck;
3941
3942 /**
3943 * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
3944 * are system values.
3945 **/
3946 bool GLSLFragCoordIsSysVal;
3947 bool GLSLPointCoordIsSysVal;
3948 bool GLSLFrontFacingIsSysVal;
3949
3950 /**
3951 * Run the minimum amount of GLSL optimizations to be able to link
3952 * shaders optimally (eliminate dead varyings and uniforms) and just do
3953 * all the necessary lowering.
3954 */
3955 bool GLSLOptimizeConservatively;
3956
3957 /**
3958 * Whether to call lower_const_arrays_to_uniforms() during linking.
3959 */
3960 bool GLSLLowerConstArrays;
3961
3962 /**
3963 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3964 * (otherwise, they're system values).
3965 */
3966 bool GLSLTessLevelsAsInputs;
3967
3968 /**
3969 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3970 * than passing the transform feedback object to the drawing function.
3971 */
3972 GLboolean AlwaysUseGetTransformFeedbackVertexCount;
3973
3974 /** GL_ARB_map_buffer_alignment */
3975 GLuint MinMapBufferAlignment;
3976
3977 /**
3978 * Disable varying packing. This is out of spec, but potentially useful
3979 * for older platforms that supports a limited number of texture
3980 * indirections--on these platforms, unpacking the varyings in the fragment
3981 * shader increases the number of texture indirections by 1, which might
3982 * make some shaders not executable at all.
3983 *
3984 * Drivers that support transform feedback must set this value to GL_FALSE.
3985 */
3986 GLboolean DisableVaryingPacking;
3987
3988 /**
3989 * Disable varying packing if used for transform feedback. This is needed
3990 * for some drivers (e.g. Panfrost) where transform feedback requires
3991 * unpacked varyings.
3992 *
3993 * This variable is mutually exlusive with DisableVaryingPacking.
3994 */
3995 GLboolean DisableTransformFeedbackPacking;
3996
3997 /**
3998 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3999 * layout is set as shared (the default) or packed. However most Mesa drivers
4000 * just use STD140 for these layouts. This flag allows drivers to use STD430
4001 * for packed and shared layouts which allows arrays to be packed more
4002 * tightly.
4003 */
4004 bool UseSTD430AsDefaultPacking;
4005
4006 /**
4007 * Should meaningful names be generated for compiler temporary variables?
4008 *
4009 * Generally, it is not useful to have the compiler generate "meaningful"
4010 * names for temporary variables that it creates. This can, however, be a
4011 * useful debugging aid. In Mesa debug builds or release builds when
4012 * MESA_GLSL is set at run-time, meaningful names will be generated.
4013 * Drivers can also force names to be generated by setting this field.
4014 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
4015 * vertex shader assembly) is set at run-time.
4016 */
4017 bool GenerateTemporaryNames;
4018
4019 /*
4020 * Maximum value supported for an index in DrawElements and friends.
4021 *
4022 * This must be at least (1ull<<24)-1. The default value is
4023 * (1ull<<32)-1.
4024 *
4025 * \since ES 3.0 or GL_ARB_ES3_compatibility
4026 * \sa _mesa_init_constants
4027 */
4028 GLuint64 MaxElementIndex;
4029
4030 /**
4031 * Disable interpretation of line continuations (lines ending with a
4032 * backslash character ('\') in GLSL source.
4033 */
4034 GLboolean DisableGLSLLineContinuations;
4035
4036 /** GL_ARB_texture_multisample */
4037 GLint MaxColorTextureSamples;
4038 GLint MaxDepthTextureSamples;
4039 GLint MaxIntegerSamples;
4040
4041 /** GL_AMD_framebuffer_multisample_advanced */
4042 GLint MaxColorFramebufferSamples;
4043 GLint MaxColorFramebufferStorageSamples;
4044 GLint MaxDepthStencilFramebufferSamples;
4045
4046 /* An array of supported MSAA modes allowing different sample
4047 * counts per attachment type.
4048 */
4049 struct {
4050 GLint NumColorSamples;
4051 GLint NumColorStorageSamples;
4052 GLint NumDepthStencilSamples;
4053 } SupportedMultisampleModes[40];
4054 GLint NumSupportedMultisampleModes;
4055
4056 /**
4057 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
4058 * samples are laid out in a rectangular grid roughly corresponding to
4059 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
4060 * are used to map indices of rectangular grid to sample numbers within
4061 * a pixel. This mapping of indices to sample numbers must be initialized
4062 * by the driver for the target hardware. For example, if we have the 8X
4063 * MSAA sample number layout (sample positions) for XYZ hardware:
4064 *
4065 * sample indices layout sample number layout
4066 * --------- ---------
4067 * | 0 | 1 | | a | b |
4068 * --------- ---------
4069 * | 2 | 3 | | c | d |
4070 * --------- ---------
4071 * | 4 | 5 | | e | f |
4072 * --------- ---------
4073 * | 6 | 7 | | g | h |
4074 * --------- ---------
4075 *
4076 * Where a,b,c,d,e,f,g,h are integers between [0-7].
4077 *
4078 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
4079 * below:
4080 * SampleMap8x = {a, b, c, d, e, f, g, h};
4081 *
4082 * Follow the logic for sample counts 2-8.
4083 *
4084 * For 16x the sample indices layout as a 4x4 grid as follows:
4085 *
4086 * -----------------
4087 * | 0 | 1 | 2 | 3 |
4088 * -----------------
4089 * | 4 | 5 | 6 | 7 |
4090 * -----------------
4091 * | 8 | 9 |10 |11 |
4092 * -----------------
4093 * |12 |13 |14 |15 |
4094 * -----------------
4095 */
4096 uint8_t SampleMap2x[2];
4097 uint8_t SampleMap4x[4];
4098 uint8_t SampleMap8x[8];
4099 uint8_t SampleMap16x[16];
4100
4101 /** GL_ARB_shader_atomic_counters */
4102 GLuint MaxAtomicBufferBindings;
4103 GLuint MaxAtomicBufferSize;
4104 GLuint MaxCombinedAtomicBuffers;
4105 GLuint MaxCombinedAtomicCounters;
4106
4107 /** GL_ARB_vertex_attrib_binding */
4108 GLint MaxVertexAttribRelativeOffset;
4109 GLint MaxVertexAttribBindings;
4110
4111 /* GL_ARB_shader_image_load_store */
4112 GLuint MaxImageUnits;
4113 GLuint MaxCombinedShaderOutputResources;
4114 GLuint MaxImageSamples;
4115 GLuint MaxCombinedImageUniforms;
4116
4117 /** GL_ARB_compute_shader */
4118 GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
4119 GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
4120 GLuint MaxComputeWorkGroupInvocations;
4121 GLuint MaxComputeSharedMemorySize;
4122
4123 /** GL_ARB_compute_variable_group_size */
4124 GLuint MaxComputeVariableGroupSize[3]; /* Array of x, y, z dimensions */
4125 GLuint MaxComputeVariableGroupInvocations;
4126
4127 /** GL_ARB_gpu_shader5 */
4128 GLfloat MinFragmentInterpolationOffset;
4129 GLfloat MaxFragmentInterpolationOffset;
4130
4131 GLboolean FakeSWMSAA;
4132
4133 /** GL_KHR_context_flush_control */
4134 GLenum16 ContextReleaseBehavior;
4135
4136 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
4137
4138 /** GL_ARB_tessellation_shader */
4139 GLuint MaxPatchVertices;
4140 GLuint MaxTessGenLevel;
4141 GLuint MaxTessPatchComponents;
4142 GLuint MaxTessControlTotalOutputComponents;
4143 bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
4144 bool PrimitiveRestartForPatches;
4145 bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
4146 * gl_LocalInvocationIndex based on
4147 * other builtin variables. */
4148
4149 /** GL_OES_primitive_bounding_box */
4150 bool NoPrimitiveBoundingBoxOutput;
4151
4152 /** GL_ARB_sparse_buffer */
4153 GLuint SparseBufferPageSize;
4154
4155 /** Used as an input for sha1 generation in the on-disk shader cache */
4156 unsigned char *dri_config_options_sha1;
4157
4158 /** When drivers are OK with mapped buffers during draw and other calls. */
4159 bool AllowMappedBuffersDuringExecution;
4160
4161 /** GL_ARB_get_program_binary */
4162 GLuint NumProgramBinaryFormats;
4163
4164 /** GL_NV_conservative_raster */
4165 GLuint MaxSubpixelPrecisionBiasBits;
4166
4167 /** GL_NV_conservative_raster_dilate */
4168 GLfloat ConservativeRasterDilateRange[2];
4169 GLfloat ConservativeRasterDilateGranularity;
4170
4171 /** Is the drivers uniform storage packed or padded to 16 bytes. */
4172 bool PackedDriverUniformStorage;
4173
4174 /** Does the driver make use of the NIR based GLSL linker */
4175 bool UseNIRGLSLLinker;
4176
4177 /** Wether or not glBitmap uses red textures rather than alpha */
4178 bool BitmapUsesRed;
4179
4180 /** Whether the vertex buffer offset is a signed 32-bit integer. */
4181 bool VertexBufferOffsetIsInt32;
4182
4183 /** Whether the driver can handle MultiDrawElements with non-VBO indices. */
4184 bool MultiDrawWithUserIndices;
4185
4186 /** Whether out-of-order draw (Begin/End) optimizations are allowed. */
4187 bool AllowDrawOutOfOrder;
4188
4189 /** GL_ARB_gl_spirv */
4190 struct spirv_supported_capabilities SpirVCapabilities;
4191
4192 /** GL_ARB_spirv_extensions */
4193 struct spirv_supported_extensions *SpirVExtensions;
4194
4195 char *VendorOverride;
4196
4197 /** Buffer size used to upload vertices from glBegin/glEnd. */
4198 unsigned glBeginEndBufferSize;
4199 };
4200
4201
4202 /**
4203 * Enable flag for each OpenGL extension. Different device drivers will
4204 * enable different extensions at runtime.
4205 */
4206 struct gl_extensions
4207 {
4208 GLboolean dummy; /* don't remove this! */
4209 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
4210 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
4211 GLboolean ANGLE_texture_compression_dxt;
4212 GLboolean ARB_ES2_compatibility;
4213 GLboolean ARB_ES3_compatibility;
4214 GLboolean ARB_ES3_1_compatibility;
4215 GLboolean ARB_ES3_2_compatibility;
4216 GLboolean ARB_arrays_of_arrays;
4217 GLboolean ARB_base_instance;
4218 GLboolean ARB_bindless_texture;
4219 GLboolean ARB_blend_func_extended;
4220 GLboolean ARB_buffer_storage;
4221 GLboolean ARB_clear_texture;
4222 GLboolean ARB_clip_control;
4223 GLboolean ARB_color_buffer_float;
4224 GLboolean ARB_compatibility;
4225 GLboolean ARB_compute_shader;
4226 GLboolean ARB_compute_variable_group_size;
4227 GLboolean ARB_conditional_render_inverted;
4228 GLboolean ARB_conservative_depth;
4229 GLboolean ARB_copy_image;
4230 GLboolean ARB_cull_distance;
4231 GLboolean ARB_depth_buffer_float;
4232 GLboolean ARB_depth_clamp;
4233 GLboolean ARB_depth_texture;
4234 GLboolean ARB_derivative_control;
4235 GLboolean ARB_draw_buffers_blend;
4236 GLboolean ARB_draw_elements_base_vertex;
4237 GLboolean ARB_draw_indirect;
4238 GLboolean ARB_draw_instanced;
4239 GLboolean ARB_fragment_coord_conventions;
4240 GLboolean ARB_fragment_layer_viewport;
4241 GLboolean ARB_fragment_program;
4242 GLboolean ARB_fragment_program_shadow;
4243 GLboolean ARB_fragment_shader;
4244 GLboolean ARB_framebuffer_no_attachments;
4245 GLboolean ARB_framebuffer_object;
4246 GLboolean ARB_fragment_shader_interlock;
4247 GLboolean ARB_enhanced_layouts;
4248 GLboolean ARB_explicit_attrib_location;
4249 GLboolean ARB_explicit_uniform_location;
4250 GLboolean ARB_gl_spirv;
4251 GLboolean ARB_gpu_shader5;
4252 GLboolean ARB_gpu_shader_fp64;
4253 GLboolean ARB_gpu_shader_int64;
4254 GLboolean ARB_half_float_vertex;
4255 GLboolean ARB_indirect_parameters;
4256 GLboolean ARB_instanced_arrays;
4257 GLboolean ARB_internalformat_query;
4258 GLboolean ARB_internalformat_query2;
4259 GLboolean ARB_map_buffer_range;
4260 GLboolean ARB_occlusion_query;
4261 GLboolean ARB_occlusion_query2;
4262 GLboolean ARB_pipeline_statistics_query;
4263 GLboolean ARB_point_sprite;
4264 GLboolean ARB_polygon_offset_clamp;
4265 GLboolean ARB_post_depth_coverage;
4266 GLboolean ARB_query_buffer_object;
4267 GLboolean ARB_robust_buffer_access_behavior;
4268 GLboolean ARB_sample_locations;
4269 GLboolean ARB_sample_shading;
4270 GLboolean ARB_seamless_cube_map;
4271 GLboolean ARB_shader_atomic_counter_ops;
4272 GLboolean ARB_shader_atomic_counters;
4273 GLboolean ARB_shader_ballot;
4274 GLboolean ARB_shader_bit_encoding;
4275 GLboolean ARB_shader_clock;
4276 GLboolean ARB_shader_draw_parameters;
4277 GLboolean ARB_shader_group_vote;
4278 GLboolean ARB_shader_image_load_store;
4279 GLboolean ARB_shader_image_size;
4280 GLboolean ARB_shader_precision;
4281 GLboolean ARB_shader_stencil_export;
4282 GLboolean ARB_shader_storage_buffer_object;
4283 GLboolean ARB_shader_texture_image_samples;
4284 GLboolean ARB_shader_texture_lod;
4285 GLboolean ARB_shader_viewport_layer_array;
4286 GLboolean ARB_shading_language_packing;
4287 GLboolean ARB_shading_language_420pack;
4288 GLboolean ARB_shadow;
4289 GLboolean ARB_sparse_buffer;
4290 GLboolean ARB_stencil_texturing;
4291 GLboolean ARB_spirv_extensions;
4292 GLboolean ARB_sync;
4293 GLboolean ARB_tessellation_shader;
4294 GLboolean ARB_texture_border_clamp;
4295 GLboolean ARB_texture_buffer_object;
4296 GLboolean ARB_texture_buffer_object_rgb32;
4297 GLboolean ARB_texture_buffer_range;
4298 GLboolean ARB_texture_compression_bptc;
4299 GLboolean ARB_texture_compression_rgtc;
4300 GLboolean ARB_texture_cube_map;
4301 GLboolean ARB_texture_cube_map_array;
4302 GLboolean ARB_texture_env_combine;
4303 GLboolean ARB_texture_env_crossbar;
4304 GLboolean ARB_texture_env_dot3;
4305 GLboolean ARB_texture_filter_anisotropic;
4306 GLboolean ARB_texture_float;
4307 GLboolean ARB_texture_gather;
4308 GLboolean ARB_texture_mirror_clamp_to_edge;
4309 GLboolean ARB_texture_multisample;
4310 GLboolean ARB_texture_non_power_of_two;
4311 GLboolean ARB_texture_stencil8;
4312 GLboolean ARB_texture_query_levels;
4313 GLboolean ARB_texture_query_lod;
4314 GLboolean ARB_texture_rg;
4315 GLboolean ARB_texture_rgb10_a2ui;
4316 GLboolean ARB_texture_view;
4317 GLboolean ARB_timer_query;
4318 GLboolean ARB_transform_feedback2;
4319 GLboolean ARB_transform_feedback3;
4320 GLboolean ARB_transform_feedback_instanced;
4321 GLboolean ARB_transform_feedback_overflow_query;
4322 GLboolean ARB_uniform_buffer_object;
4323 GLboolean ARB_vertex_attrib_64bit;
4324 GLboolean ARB_vertex_program;
4325 GLboolean ARB_vertex_shader;
4326 GLboolean ARB_vertex_type_10f_11f_11f_rev;
4327 GLboolean ARB_vertex_type_2_10_10_10_rev;
4328 GLboolean ARB_viewport_array;
4329 GLboolean EXT_blend_color;
4330 GLboolean EXT_blend_equation_separate;
4331 GLboolean EXT_blend_func_separate;
4332 GLboolean EXT_blend_minmax;
4333 GLboolean EXT_demote_to_helper_invocation;
4334 GLboolean EXT_depth_bounds_test;
4335 GLboolean EXT_disjoint_timer_query;
4336 GLboolean EXT_draw_buffers2;
4337 GLboolean EXT_EGL_image_storage;
4338 GLboolean EXT_float_blend;
4339 GLboolean EXT_framebuffer_multisample;
4340 GLboolean EXT_framebuffer_multisample_blit_scaled;
4341 GLboolean EXT_framebuffer_sRGB;
4342 GLboolean EXT_gpu_program_parameters;
4343 GLboolean EXT_gpu_shader4;
4344 GLboolean EXT_memory_object;
4345 GLboolean EXT_memory_object_fd;
4346 GLboolean EXT_multisampled_render_to_texture;
4347 GLboolean EXT_packed_float;
4348 GLboolean EXT_pixel_buffer_object;
4349 GLboolean EXT_point_parameters;
4350 GLboolean EXT_provoking_vertex;
4351 GLboolean EXT_render_snorm;
4352 GLboolean EXT_semaphore;
4353 GLboolean EXT_semaphore_fd;
4354 GLboolean EXT_shader_image_load_formatted;
4355 GLboolean EXT_shader_image_load_store;
4356 GLboolean EXT_shader_integer_mix;
4357 GLboolean EXT_shader_samples_identical;
4358 GLboolean EXT_sRGB;
4359 GLboolean EXT_stencil_two_side;
4360 GLboolean EXT_texture_array;
4361 GLboolean EXT_texture_buffer_object;
4362 GLboolean EXT_texture_compression_latc;
4363 GLboolean EXT_texture_compression_s3tc;
4364 GLboolean EXT_texture_compression_s3tc_srgb;
4365 GLboolean EXT_texture_env_dot3;
4366 GLboolean EXT_texture_filter_anisotropic;
4367 GLboolean EXT_texture_integer;
4368 GLboolean EXT_texture_mirror_clamp;
4369 GLboolean EXT_texture_norm16;
4370 GLboolean EXT_texture_shadow_lod;
4371 GLboolean EXT_texture_shared_exponent;
4372 GLboolean EXT_texture_snorm;
4373 GLboolean EXT_texture_sRGB;
4374 GLboolean EXT_texture_sRGB_R8;
4375 GLboolean EXT_texture_sRGB_decode;
4376 GLboolean EXT_texture_swizzle;
4377 GLboolean EXT_texture_type_2_10_10_10_REV;
4378 GLboolean EXT_transform_feedback;
4379 GLboolean EXT_timer_query;
4380 GLboolean EXT_vertex_array_bgra;
4381 GLboolean EXT_window_rectangles;
4382 GLboolean OES_copy_image;
4383 GLboolean OES_primitive_bounding_box;
4384 GLboolean OES_sample_variables;
4385 GLboolean OES_standard_derivatives;
4386 GLboolean OES_texture_buffer;
4387 GLboolean OES_texture_cube_map_array;
4388 GLboolean OES_texture_view;
4389 GLboolean OES_viewport_array;
4390 /* vendor extensions */
4391 GLboolean AMD_compressed_ATC_texture;
4392 GLboolean AMD_framebuffer_multisample_advanced;
4393 GLboolean AMD_depth_clamp_separate;
4394 GLboolean AMD_performance_monitor;
4395 GLboolean AMD_pinned_memory;
4396 GLboolean AMD_seamless_cubemap_per_texture;
4397 GLboolean AMD_vertex_shader_layer;
4398 GLboolean AMD_vertex_shader_viewport_index;
4399 GLboolean ANDROID_extension_pack_es31a;
4400 GLboolean APPLE_object_purgeable;
4401 GLboolean ATI_meminfo;
4402 GLboolean ATI_texture_compression_3dc;
4403 GLboolean ATI_texture_mirror_once;
4404 GLboolean ATI_texture_env_combine3;
4405 GLboolean ATI_fragment_shader;
4406 GLboolean GREMEDY_string_marker;
4407 GLboolean INTEL_blackhole_render;
4408 GLboolean INTEL_conservative_rasterization;
4409 GLboolean INTEL_performance_query;
4410 GLboolean INTEL_shader_atomic_float_minmax;
4411 GLboolean INTEL_shader_integer_functions2;
4412 GLboolean KHR_blend_equation_advanced;
4413 GLboolean KHR_blend_equation_advanced_coherent;
4414 GLboolean KHR_robustness;
4415 GLboolean KHR_texture_compression_astc_hdr;
4416 GLboolean KHR_texture_compression_astc_ldr;
4417 GLboolean KHR_texture_compression_astc_sliced_3d;
4418 GLboolean MESA_framebuffer_flip_y;
4419 GLboolean MESA_tile_raster_order;
4420 GLboolean MESA_pack_invert;
4421 GLboolean EXT_shader_framebuffer_fetch;
4422 GLboolean EXT_shader_framebuffer_fetch_non_coherent;
4423 GLboolean MESA_shader_integer_functions;
4424 GLboolean MESA_ycbcr_texture;
4425 GLboolean NV_compute_shader_derivatives;
4426 GLboolean NV_conditional_render;
4427 GLboolean NV_copy_image;
4428 GLboolean NV_fill_rectangle;
4429 GLboolean NV_fog_distance;
4430 GLboolean NV_point_sprite;
4431 GLboolean NV_primitive_restart;
4432 GLboolean NV_shader_atomic_float;
4433 GLboolean NV_texture_barrier;
4434 GLboolean NV_texture_env_combine4;
4435 GLboolean NV_texture_rectangle;
4436 GLboolean NV_vdpau_interop;
4437 GLboolean NV_conservative_raster;
4438 GLboolean NV_conservative_raster_dilate;
4439 GLboolean NV_conservative_raster_pre_snap_triangles;
4440 GLboolean NV_conservative_raster_pre_snap;
4441 GLboolean NVX_gpu_memory_info;
4442 GLboolean TDFX_texture_compression_FXT1;
4443 GLboolean OES_EGL_image;
4444 GLboolean OES_draw_texture;
4445 GLboolean OES_depth_texture_cube_map;
4446 GLboolean OES_EGL_image_external;
4447 GLboolean OES_texture_float;
4448 GLboolean OES_texture_float_linear;
4449 GLboolean OES_texture_half_float;
4450 GLboolean OES_texture_half_float_linear;
4451 GLboolean OES_compressed_ETC1_RGB8_texture;
4452 GLboolean OES_geometry_shader;
4453 GLboolean OES_texture_compression_astc;
4454 GLboolean extension_sentinel;
4455 /** The extension string */
4456 const GLubyte *String;
4457 /** Number of supported extensions */
4458 GLuint Count;
4459 /**
4460 * The context version which extension helper functions compare against.
4461 * By default, the value is equal to ctx->Version. This changes to ~0
4462 * while meta is in progress.
4463 */
4464 GLubyte Version;
4465 /**
4466 * Force-enabled, yet unrecognized, extensions.
4467 * See _mesa_one_time_init_extension_overrides()
4468 */
4469 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4470 const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
4471 };
4472
4473
4474 /**
4475 * A stack of matrices (projection, modelview, color, texture, etc).
4476 */
4477 struct gl_matrix_stack
4478 {
4479 GLmatrix *Top; /**< points into Stack */
4480 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
4481 unsigned StackSize; /**< Number of elements in Stack */
4482 GLuint Depth; /**< 0 <= Depth < MaxDepth */
4483 GLuint MaxDepth; /**< size of Stack[] array */
4484 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4485 };
4486
4487
4488 /**
4489 * \name Bits for image transfer operations
4490 * \sa __struct gl_contextRec::ImageTransferState.
4491 */
4492 /*@{*/
4493 #define IMAGE_SCALE_BIAS_BIT 0x1
4494 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4495 #define IMAGE_MAP_COLOR_BIT 0x4
4496 #define IMAGE_CLAMP_BIT 0x800
4497
4498
4499 /** Pixel Transfer ops */
4500 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4501 IMAGE_SHIFT_OFFSET_BIT | \
4502 IMAGE_MAP_COLOR_BIT)
4503
4504
4505 /**
4506 * \name Bits to indicate what state has changed.
4507 */
4508 /*@{*/
4509 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4510 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4511 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4512 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4513 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4514 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4515 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4516 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4517 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4518 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4519 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4520 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4521 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4522 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4523 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4524 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4525 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4526 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4527 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4528 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4529 /* gap */
4530 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4531 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4532 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4533 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4534 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4535 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4536 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4537 /* gap */
4538 #define _NEW_FRAG_CLAMP (1u << 29)
4539 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4540 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4541 #define _NEW_ALL ~0
4542 /*@}*/
4543
4544
4545 /**
4546 * Composite state flags
4547 */
4548 /*@{*/
4549 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4550
4551 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4552 _NEW_TEXTURE_STATE | \
4553 _NEW_POINT | \
4554 _NEW_PROGRAM | \
4555 _NEW_MODELVIEW)
4556
4557 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4558 _NEW_FOG | \
4559 _NEW_PROGRAM)
4560
4561
4562 /*@}*/
4563
4564
4565
4566
4567 /* This has to be included here. */
4568 #include "dd.h"
4569
4570
4571 /** Opaque declaration of display list payload data type */
4572 union gl_dlist_node;
4573
4574
4575 /**
4576 * Per-display list information.
4577 */
4578 struct gl_display_list
4579 {
4580 GLuint Name;
4581 GLbitfield Flags; /**< DLIST_x flags */
4582 GLchar *Label; /**< GL_KHR_debug */
4583 /** The dlist commands are in a linked list of nodes */
4584 union gl_dlist_node *Head;
4585 };
4586
4587
4588 /**
4589 * State used during display list compilation and execution.
4590 */
4591 struct gl_dlist_state
4592 {
4593 struct gl_display_list *CurrentList; /**< List currently being compiled */
4594 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
4595 GLuint CurrentPos; /**< Index into current block of nodes */
4596 GLuint CallDepth; /**< Current recursion calling depth */
4597
4598 GLvertexformat ListVtxfmt;
4599
4600 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
4601 uint32_t CurrentAttrib[VERT_ATTRIB_MAX][8];
4602
4603 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
4604 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
4605
4606 struct {
4607 /* State known to have been set by the currently-compiling display
4608 * list. Used to eliminate some redundant state changes.
4609 */
4610 GLenum16 ShadeModel;
4611 } Current;
4612 };
4613
4614 /**
4615 * Driver-specific state flags.
4616 *
4617 * These are or'd with gl_context::NewDriverState to notify a driver about
4618 * a state change. The driver sets the flags at context creation and
4619 * the meaning of the bits set is opaque to core Mesa.
4620 */
4621 struct gl_driver_flags
4622 {
4623 /** gl_context::Array::_DrawArrays (vertex array state) */
4624 uint64_t NewArray;
4625
4626 /** gl_context::TransformFeedback::CurrentObject */
4627 uint64_t NewTransformFeedback;
4628
4629 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4630 uint64_t NewTransformFeedbackProg;
4631
4632 /** gl_context::RasterDiscard */
4633 uint64_t NewRasterizerDiscard;
4634
4635 /** gl_context::TileRasterOrder* */
4636 uint64_t NewTileRasterOrder;
4637
4638 /**
4639 * gl_context::UniformBufferBindings
4640 * gl_shader_program::UniformBlocks
4641 */
4642 uint64_t NewUniformBuffer;
4643
4644 /**
4645 * gl_context::ShaderStorageBufferBindings
4646 * gl_shader_program::ShaderStorageBlocks
4647 */
4648 uint64_t NewShaderStorageBuffer;
4649
4650 uint64_t NewTextureBuffer;
4651
4652 /**
4653 * gl_context::AtomicBufferBindings
4654 */
4655 uint64_t NewAtomicBuffer;
4656
4657 /**
4658 * gl_context::ImageUnits
4659 */
4660 uint64_t NewImageUnits;
4661
4662 /**
4663 * gl_context::TessCtrlProgram::patch_default_*
4664 */
4665 uint64_t NewDefaultTessLevels;
4666
4667 /**
4668 * gl_context::IntelConservativeRasterization
4669 */
4670 uint64_t NewIntelConservativeRasterization;
4671
4672 /**
4673 * gl_context::NvConservativeRasterization
4674 */
4675 uint64_t NewNvConservativeRasterization;
4676
4677 /**
4678 * gl_context::ConservativeRasterMode/ConservativeRasterDilate
4679 * gl_context::SubpixelPrecisionBias
4680 */
4681 uint64_t NewNvConservativeRasterizationParams;
4682
4683 /**
4684 * gl_context::Scissor::WindowRects
4685 */
4686 uint64_t NewWindowRectangles;
4687
4688 /** gl_context::Color::sRGBEnabled */
4689 uint64_t NewFramebufferSRGB;
4690
4691 /** gl_context::Scissor::EnableFlags */
4692 uint64_t NewScissorTest;
4693
4694 /** gl_context::Scissor::ScissorArray */
4695 uint64_t NewScissorRect;
4696
4697 /** gl_context::Color::Alpha* */
4698 uint64_t NewAlphaTest;
4699
4700 /** gl_context::Color::Blend/Dither */
4701 uint64_t NewBlend;
4702
4703 /** gl_context::Color::BlendColor */
4704 uint64_t NewBlendColor;
4705
4706 /** gl_context::Color::Color/Index */
4707 uint64_t NewColorMask;
4708
4709 /** gl_context::Depth */
4710 uint64_t NewDepth;
4711
4712 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4713 uint64_t NewLogicOp;
4714
4715 /** gl_context::Multisample::Enabled */
4716 uint64_t NewMultisampleEnable;
4717
4718 /** gl_context::Multisample::SampleAlphaTo* */
4719 uint64_t NewSampleAlphaToXEnable;
4720
4721 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4722 uint64_t NewSampleMask;
4723
4724 /** gl_context::Multisample::(Min)SampleShading */
4725 uint64_t NewSampleShading;
4726
4727 /** gl_context::Stencil */
4728 uint64_t NewStencil;
4729
4730 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4731 uint64_t NewClipControl;
4732
4733 /** gl_context::Transform::EyeUserPlane */
4734 uint64_t NewClipPlane;
4735
4736 /** gl_context::Transform::ClipPlanesEnabled */
4737 uint64_t NewClipPlaneEnable;
4738
4739 /** gl_context::Transform::DepthClamp */
4740 uint64_t NewDepthClamp;
4741
4742 /** gl_context::Line */
4743 uint64_t NewLineState;
4744
4745 /** gl_context::Polygon */
4746 uint64_t NewPolygonState;
4747
4748 /** gl_context::PolygonStipple */
4749 uint64_t NewPolygonStipple;
4750
4751 /** gl_context::ViewportArray */
4752 uint64_t NewViewport;
4753
4754 /** Shader constants (uniforms, program parameters, state constants) */
4755 uint64_t NewShaderConstants[MESA_SHADER_STAGES];
4756
4757 /** Programmable sample location state for gl_context::DrawBuffer */
4758 uint64_t NewSampleLocations;
4759 };
4760
4761 struct gl_buffer_binding
4762 {
4763 struct gl_buffer_object *BufferObject;
4764 /** Start of uniform block data in the buffer */
4765 GLintptr Offset;
4766 /** Size of data allowed to be referenced from the buffer (in bytes) */
4767 GLsizeiptr Size;
4768 /**
4769 * glBindBufferBase() indicates that the Size should be ignored and only
4770 * limited by the current size of the BufferObject.
4771 */
4772 GLboolean AutomaticSize;
4773 };
4774
4775 /**
4776 * ARB_shader_image_load_store image unit.
4777 */
4778 struct gl_image_unit
4779 {
4780 /**
4781 * Texture object bound to this unit.
4782 */
4783 struct gl_texture_object *TexObj;
4784
4785 /**
4786 * Level of the texture object bound to this unit.
4787 */
4788 GLubyte Level;
4789
4790 /**
4791 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4792 * GL_FALSE if only some specific layer of the texture is bound.
4793 * \sa Layer
4794 */
4795 GLboolean Layered;
4796
4797 /**
4798 * Layer of the texture object bound to this unit as specified by the
4799 * application.
4800 */
4801 GLushort Layer;
4802
4803 /**
4804 * Layer of the texture object bound to this unit, or zero if
4805 * Layered == false.
4806 */
4807 GLushort _Layer;
4808
4809 /**
4810 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4811 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4812 */
4813 GLenum16 Access;
4814
4815 /**
4816 * GL internal format that determines the interpretation of the
4817 * image memory when shader image operations are performed through
4818 * this unit.
4819 */
4820 GLenum16 Format;
4821
4822 /**
4823 * Mesa format corresponding to \c Format.
4824 */
4825 mesa_format _ActualFormat:16;
4826 };
4827
4828 /**
4829 * Shader subroutines storage
4830 */
4831 struct gl_subroutine_index_binding
4832 {
4833 GLuint NumIndex;
4834 GLuint *IndexPtr;
4835 };
4836
4837 struct gl_texture_handle_object
4838 {
4839 struct gl_texture_object *texObj;
4840 struct gl_sampler_object *sampObj;
4841 GLuint64 handle;
4842 };
4843
4844 struct gl_image_handle_object
4845 {
4846 struct gl_image_unit imgObj;
4847 GLuint64 handle;
4848 };
4849
4850 struct gl_memory_object
4851 {
4852 GLuint Name; /**< hash table ID/name */
4853 GLboolean Immutable; /**< denotes mutability state of parameters */
4854 GLboolean Dedicated; /**< import memory from a dedicated allocation */
4855 };
4856
4857 struct gl_semaphore_object
4858 {
4859 GLuint Name; /**< hash table ID/name */
4860 };
4861
4862 /**
4863 * Mesa rendering context.
4864 *
4865 * This is the central context data structure for Mesa. Almost all
4866 * OpenGL state is contained in this structure.
4867 * Think of this as a base class from which device drivers will derive
4868 * sub classes.
4869 */
4870 struct gl_context
4871 {
4872 /** State possibly shared with other contexts in the address space */
4873 struct gl_shared_state *Shared;
4874
4875 /** \name API function pointer tables */
4876 /*@{*/
4877 gl_api API;
4878
4879 /**
4880 * The current dispatch table for non-displaylist-saving execution, either
4881 * BeginEnd or OutsideBeginEnd
4882 */
4883 struct _glapi_table *Exec;
4884 /**
4885 * The normal dispatch table for non-displaylist-saving, non-begin/end
4886 */
4887 struct _glapi_table *OutsideBeginEnd;
4888 /** The dispatch table used between glNewList() and glEndList() */
4889 struct _glapi_table *Save;
4890 /**
4891 * The dispatch table used between glBegin() and glEnd() (outside of a
4892 * display list). Only valid functions between those two are set, which is
4893 * mostly just the set in a GLvertexformat struct.
4894 */
4895 struct _glapi_table *BeginEnd;
4896 /**
4897 * Dispatch table for when a graphics reset has happened.
4898 */
4899 struct _glapi_table *ContextLost;
4900 /**
4901 * Dispatch table used to marshal API calls from the client program to a
4902 * separate server thread. NULL if API calls are not being marshalled to
4903 * another thread.
4904 */
4905 struct _glapi_table *MarshalExec;
4906 /**
4907 * Dispatch table currently in use for fielding API calls from the client
4908 * program. If API calls are being marshalled to another thread, this ==
4909 * MarshalExec. Otherwise it == CurrentServerDispatch.
4910 */
4911 struct _glapi_table *CurrentClientDispatch;
4912
4913 /**
4914 * Dispatch table currently in use for performing API calls. == Save or
4915 * Exec.
4916 */
4917 struct _glapi_table *CurrentServerDispatch;
4918
4919 /*@}*/
4920
4921 struct glthread_state GLThread;
4922
4923 struct gl_config Visual;
4924 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
4925 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
4926 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
4927 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
4928
4929 /**
4930 * Device driver function pointer table
4931 */
4932 struct dd_function_table Driver;
4933
4934 /** Core/Driver constants */
4935 struct gl_constants Const;
4936
4937 /** \name The various 4x4 matrix stacks */
4938 /*@{*/
4939 struct gl_matrix_stack ModelviewMatrixStack;
4940 struct gl_matrix_stack ProjectionMatrixStack;
4941 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
4942 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
4943 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
4944 /*@}*/
4945
4946 /** Combined modelview and projection matrix */
4947 GLmatrix _ModelProjectMatrix;
4948
4949 /** \name Display lists */
4950 struct gl_dlist_state ListState;
4951
4952 GLboolean ExecuteFlag; /**< Execute GL commands? */
4953 GLboolean CompileFlag; /**< Compile GL commands into display list? */
4954
4955 /** Extension information */
4956 struct gl_extensions Extensions;
4957
4958 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4959 GLuint Version;
4960 char *VersionString;
4961
4962 /** \name State attribute stack (for glPush/PopAttrib) */
4963 /*@{*/
4964 GLuint AttribStackDepth;
4965 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
4966 /*@}*/
4967
4968 /** \name Renderer attribute groups
4969 *
4970 * We define a struct for each attribute group to make pushing and popping
4971 * attributes easy. Also it's a good organization.
4972 */
4973 /*@{*/
4974 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
4975 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
4976 struct gl_current_attrib Current; /**< Current attributes */
4977 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
4978 struct gl_eval_attrib Eval; /**< Eval attributes */
4979 struct gl_fog_attrib Fog; /**< Fog attributes */
4980 struct gl_hint_attrib Hint; /**< Hint attributes */
4981 struct gl_light_attrib Light; /**< Light attributes */
4982 struct gl_line_attrib Line; /**< Line attributes */
4983 struct gl_list_attrib List; /**< List attributes */
4984 struct gl_multisample_attrib Multisample;
4985 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
4986 struct gl_point_attrib Point; /**< Point attributes */
4987 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
4988 GLuint PolygonStipple[32]; /**< Polygon stipple */
4989 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
4990 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
4991 struct gl_texture_attrib Texture; /**< Texture attributes */
4992 struct gl_transform_attrib Transform; /**< Transformation attributes */
4993 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
4994 GLuint SubpixelPrecisionBias[2]; /**< Viewport attributes */
4995 /*@}*/
4996
4997 /** \name Client attribute stack */
4998 /*@{*/
4999 GLuint ClientAttribStackDepth;
5000 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
5001 /*@}*/
5002
5003 /** \name Client attribute groups */
5004 /*@{*/
5005 struct gl_array_attrib Array; /**< Vertex arrays */
5006 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
5007 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
5008 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
5009 /*@}*/
5010
5011 /** \name Other assorted state (not pushed/popped on attribute stack) */
5012 /*@{*/
5013 struct gl_pixelmaps PixelMaps;
5014
5015 struct gl_evaluators EvalMap; /**< All evaluators */
5016 struct gl_feedback Feedback; /**< Feedback */
5017 struct gl_selection Select; /**< Selection */
5018
5019 struct gl_program_state Program; /**< general program state */
5020 struct gl_vertex_program_state VertexProgram;
5021 struct gl_fragment_program_state FragmentProgram;
5022 struct gl_geometry_program_state GeometryProgram;
5023 struct gl_compute_program_state ComputeProgram;
5024 struct gl_tess_ctrl_program_state TessCtrlProgram;
5025 struct gl_tess_eval_program_state TessEvalProgram;
5026 struct gl_ati_fragment_shader_state ATIFragmentShader;
5027
5028 struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
5029 struct gl_pipeline_object Shader; /**< GLSL shader object state */
5030
5031 /**
5032 * Current active shader pipeline state
5033 *
5034 * Almost all internal users want ::_Shader instead of ::Shader. The
5035 * exceptions are bits of legacy GLSL API that do not know about separate
5036 * shader objects.
5037 *
5038 * If a program is active via \c glUseProgram, this will point to
5039 * \c ::Shader.
5040 *
5041 * If a program pipeline is active via \c glBindProgramPipeline, this will
5042 * point to \c ::Pipeline.Current.
5043 *
5044 * If neither a program nor a program pipeline is active, this will point to
5045 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
5046 * \c NULL.
5047 */
5048 struct gl_pipeline_object *_Shader;
5049
5050 /**
5051 * NIR containing the functions that implement software fp64 support.
5052 */
5053 struct nir_shader *SoftFP64;
5054
5055 struct gl_query_state Query; /**< occlusion, timer queries */
5056
5057 struct gl_transform_feedback_state TransformFeedback;
5058
5059 struct gl_perf_monitor_state PerfMonitor;
5060 struct gl_perf_query_state PerfQuery;
5061
5062 struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
5063 struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */
5064 struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */
5065
5066 struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
5067 struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
5068
5069 struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
5070
5071 /**
5072 * Current GL_ARB_uniform_buffer_object binding referenced by
5073 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
5074 */
5075 struct gl_buffer_object *UniformBuffer;
5076
5077 /**
5078 * Current GL_ARB_shader_storage_buffer_object binding referenced by
5079 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
5080 */
5081 struct gl_buffer_object *ShaderStorageBuffer;
5082
5083 /**
5084 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
5085 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
5086 * associated with uniform blocks by glUniformBlockBinding()'s state in the
5087 * shader program.
5088 */
5089 struct gl_buffer_binding
5090 UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
5091
5092 /**
5093 * Array of shader storage buffers for ARB_shader_storage_buffer_object
5094 * and GL 4.3. This is set up using glBindBufferRange() or
5095 * glBindBufferBase(). They are associated with shader storage blocks by
5096 * glShaderStorageBlockBinding()'s state in the shader program.
5097 */
5098 struct gl_buffer_binding
5099 ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
5100
5101 /**
5102 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
5103 * target.
5104 */
5105 struct gl_buffer_object *AtomicBuffer;
5106
5107 /**
5108 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
5109 * target.
5110 */
5111 struct gl_buffer_object *ExternalVirtualMemoryBuffer;
5112
5113 /**
5114 * Array of atomic counter buffer binding points.
5115 */
5116 struct gl_buffer_binding
5117 AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
5118
5119 /**
5120 * Array of image units for ARB_shader_image_load_store.
5121 */
5122 struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
5123
5124 struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES];
5125 /*@}*/
5126
5127 struct gl_meta_state *Meta; /**< for "meta" operations */
5128
5129 /* GL_EXT_framebuffer_object */
5130 struct gl_renderbuffer *CurrentRenderbuffer;
5131
5132 GLenum16 ErrorValue; /**< Last error code */
5133
5134 /**
5135 * Recognize and silence repeated error debug messages in buggy apps.
5136 */
5137 const char *ErrorDebugFmtString;
5138 GLuint ErrorDebugCount;
5139
5140 /* GL_ARB_debug_output/GL_KHR_debug */
5141 simple_mtx_t DebugMutex;
5142 struct gl_debug_state *Debug;
5143
5144 GLenum16 RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5145 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
5146 uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */
5147
5148 struct gl_driver_flags DriverFlags;
5149
5150 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
5151 GLboolean _AllowDrawOutOfOrder;
5152
5153 GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
5154
5155 /** \name Derived state */
5156 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
5157 GLfloat _EyeZDir[3];
5158 GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
5159 GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
5160 GLboolean _NeedEyeCoords;
5161 GLboolean _ForceEyeCoords;
5162
5163 GLuint TextureStateTimestamp; /**< detect changes to shared state */
5164
5165 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
5166
5167 /** \name For debugging/development only */
5168 /*@{*/
5169 GLboolean FirstTimeCurrent;
5170 /*@}*/
5171
5172 /**
5173 * False if this context was created without a config. This is needed
5174 * because the initial state of glDrawBuffers depends on this
5175 */
5176 GLboolean HasConfig;
5177
5178 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
5179
5180 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
5181 GLboolean IntelConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */
5182 GLboolean ConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_NV */
5183 GLfloat ConservativeRasterDilate;
5184 GLenum16 ConservativeRasterMode;
5185
5186 GLboolean IntelBlackholeRender; /**< GL_INTEL_blackhole_render */
5187
5188 /** Does glVertexAttrib(0) alias glVertex()? */
5189 bool _AttribZeroAliasesVertex;
5190
5191 /**
5192 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5193 * renderer's tiles should be excecuted, to meet the requirements of
5194 * GL_MESA_tile_raster_order.
5195 */
5196 GLboolean TileRasterOrderFixed;
5197 GLboolean TileRasterOrderIncreasingX;
5198 GLboolean TileRasterOrderIncreasingY;
5199
5200 /**
5201 * \name Hooks for module contexts.
5202 *
5203 * These will eventually live in the driver or elsewhere.
5204 */
5205 /*@{*/
5206 void *swrast_context;
5207 void *swsetup_context;
5208 void *swtnl_context;
5209 struct vbo_context *vbo_context;
5210 struct st_context *st;
5211 /*@}*/
5212
5213 /**
5214 * \name NV_vdpau_interop
5215 */
5216 /*@{*/
5217 const void *vdpDevice;
5218 const void *vdpGetProcAddress;
5219 struct set *vdpSurfaces;
5220 /*@}*/
5221
5222 /**
5223 * Has this context observed a GPU reset in any context in the share group?
5224 *
5225 * Once this field becomes true, it is never reset to false.
5226 */
5227 GLboolean ShareGroupReset;
5228
5229 /**
5230 * \name OES_primitive_bounding_box
5231 *
5232 * Stores the arguments to glPrimitiveBoundingBox
5233 */
5234 GLfloat PrimitiveBoundingBox[8];
5235
5236 struct disk_cache *Cache;
5237
5238 /**
5239 * \name GL_ARB_bindless_texture
5240 */
5241 /*@{*/
5242 struct hash_table_u64 *ResidentTextureHandles;
5243 struct hash_table_u64 *ResidentImageHandles;
5244 /*@}*/
5245
5246 bool shader_builtin_ref;
5247 };
5248
5249 /**
5250 * Information about memory usage. All sizes are in kilobytes.
5251 */
5252 struct gl_memory_info
5253 {
5254 unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
5255 unsigned avail_device_memory; /**< free device memory at the moment */
5256 unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
5257 unsigned avail_staging_memory; /**< free staging memory at the moment */
5258 unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
5259 unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
5260 };
5261
5262 #ifndef NDEBUG
5263 extern int MESA_VERBOSE;
5264 extern int MESA_DEBUG_FLAGS;
5265 #else
5266 # define MESA_VERBOSE 0
5267 # define MESA_DEBUG_FLAGS 0
5268 #endif
5269
5270
5271 /** The MESA_VERBOSE var is a bitmask of these flags */
5272 enum _verbose
5273 {
5274 VERBOSE_VARRAY = 0x0001,
5275 VERBOSE_TEXTURE = 0x0002,
5276 VERBOSE_MATERIAL = 0x0004,
5277 VERBOSE_PIPELINE = 0x0008,
5278 VERBOSE_DRIVER = 0x0010,
5279 VERBOSE_STATE = 0x0020,
5280 VERBOSE_API = 0x0040,
5281 VERBOSE_DISPLAY_LIST = 0x0100,
5282 VERBOSE_LIGHTING = 0x0200,
5283 VERBOSE_PRIMS = 0x0400,
5284 VERBOSE_VERTS = 0x0800,
5285 VERBOSE_DISASSEM = 0x1000,
5286 VERBOSE_DRAW = 0x2000,
5287 VERBOSE_SWAPBUFFERS = 0x4000
5288 };
5289
5290
5291 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5292 enum _debug
5293 {
5294 DEBUG_SILENT = (1 << 0),
5295 DEBUG_ALWAYS_FLUSH = (1 << 1),
5296 DEBUG_INCOMPLETE_TEXTURE = (1 << 2),
5297 DEBUG_INCOMPLETE_FBO = (1 << 3),
5298 DEBUG_CONTEXT = (1 << 4)
5299 };
5300
5301 #ifdef __cplusplus
5302 }
5303 #endif
5304
5305 #endif /* MTYPES_H */