egl: Fixes transparency with EGL and X11.
[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/menums.h"
43 #include "main/config.h"
44 #include "glapi/glapi.h"
45 #include "math/m_matrix.h" /* GLmatrix */
46 #include "compiler/shader_enums.h"
47 #include "compiler/shader_info.h"
48 #include "main/formats.h" /* MESA_FORMAT_COUNT */
49 #include "compiler/glsl/list.h"
50 #include "util/simple_mtx.h"
51 #include "util/u_dynarray.h"
52
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
59 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
60
61
62 /**
63 * \name Some forward type declarations
64 */
65 /*@{*/
66 struct _mesa_HashTable;
67 struct gl_attrib_node;
68 struct gl_list_extensions;
69 struct gl_meta_state;
70 struct gl_program_cache;
71 struct gl_texture_object;
72 struct gl_debug_state;
73 struct gl_context;
74 struct st_context;
75 struct gl_uniform_storage;
76 struct prog_instruction;
77 struct gl_program_parameter_list;
78 struct gl_shader_spirv_data;
79 struct set;
80 struct vbo_context;
81 /*@}*/
82
83
84 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
85 #define PRIM_MAX GL_PATCHES
86 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
87 #define PRIM_UNKNOWN (PRIM_MAX + 2)
88
89 /**
90 * Determine if the given gl_varying_slot appears in the fragment shader.
91 */
92 static inline GLboolean
93 _mesa_varying_slot_in_fs(gl_varying_slot slot)
94 {
95 switch (slot) {
96 case VARYING_SLOT_PSIZ:
97 case VARYING_SLOT_BFC0:
98 case VARYING_SLOT_BFC1:
99 case VARYING_SLOT_EDGE:
100 case VARYING_SLOT_CLIP_VERTEX:
101 case VARYING_SLOT_LAYER:
102 case VARYING_SLOT_TESS_LEVEL_OUTER:
103 case VARYING_SLOT_TESS_LEVEL_INNER:
104 case VARYING_SLOT_BOUNDING_BOX0:
105 case VARYING_SLOT_BOUNDING_BOX1:
106 return GL_FALSE;
107 default:
108 return GL_TRUE;
109 }
110 }
111
112 /**
113 * Bit flags for all renderbuffers
114 */
115 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
116 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
117 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
118 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
119 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
120 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
121 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
122 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
123 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
124 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
125 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
126 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
127 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
128 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
129 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
130 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
131 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
132 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
133 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
134
135 /**
136 * Mask of all the color buffer bits (but not accum).
137 */
138 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
139 BUFFER_BIT_BACK_LEFT | \
140 BUFFER_BIT_FRONT_RIGHT | \
141 BUFFER_BIT_BACK_RIGHT | \
142 BUFFER_BIT_AUX0 | \
143 BUFFER_BIT_COLOR0 | \
144 BUFFER_BIT_COLOR1 | \
145 BUFFER_BIT_COLOR2 | \
146 BUFFER_BIT_COLOR3 | \
147 BUFFER_BIT_COLOR4 | \
148 BUFFER_BIT_COLOR5 | \
149 BUFFER_BIT_COLOR6 | \
150 BUFFER_BIT_COLOR7)
151
152 /* Mask of bits for depth+stencil buffers */
153 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
154
155 /**
156 * Framebuffer configuration (aka visual / pixelformat)
157 * Note: some of these fields should be boolean, but it appears that
158 * code in drivers/dri/common/util.c requires int-sized fields.
159 */
160 struct gl_config
161 {
162 GLboolean floatMode;
163 GLuint doubleBufferMode;
164 GLuint stereoMode;
165
166 GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
167 GLuint redMask, greenMask, blueMask, alphaMask;
168 GLint redShift, greenShift, blueShift, alphaShift;
169 GLint rgbBits; /* total bits for rgb */
170
171 GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
172 GLint depthBits;
173 GLint stencilBits;
174
175 GLint numAuxBuffers;
176
177 GLint level;
178
179 /* EXT_visual_rating / GLX 1.2 */
180 GLint visualRating;
181
182 /* EXT_visual_info / GLX 1.2 */
183 GLint transparentPixel;
184 /* colors are floats scaled to ints */
185 GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
186 GLint transparentIndex;
187
188 /* ARB_multisample / SGIS_multisample */
189 GLint sampleBuffers;
190 GLuint samples;
191
192 /* SGIX_pbuffer / GLX 1.3 */
193 GLint maxPbufferWidth;
194 GLint maxPbufferHeight;
195 GLint maxPbufferPixels;
196 GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
197 GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
198
199 /* OML_swap_method */
200 GLint swapMethod;
201
202 /* EXT_texture_from_pixmap */
203 GLint bindToTextureRgb;
204 GLint bindToTextureRgba;
205 GLint bindToMipmapTexture;
206 GLint bindToTextureTargets;
207 GLint yInverted;
208
209 /* EXT_framebuffer_sRGB */
210 GLint sRGBCapable;
211
212 /* EGL_KHR_mutable_render_buffer */
213 GLuint mutableRenderBuffer; /* bool */
214
215 /* EGL_MESA_config_select_group */
216 GLint configSelectGroup;
217 };
218
219
220 /**
221 * \name Bit flags used for updating material values.
222 */
223 /*@{*/
224 #define MAT_ATTRIB_FRONT_AMBIENT 0
225 #define MAT_ATTRIB_BACK_AMBIENT 1
226 #define MAT_ATTRIB_FRONT_DIFFUSE 2
227 #define MAT_ATTRIB_BACK_DIFFUSE 3
228 #define MAT_ATTRIB_FRONT_SPECULAR 4
229 #define MAT_ATTRIB_BACK_SPECULAR 5
230 #define MAT_ATTRIB_FRONT_EMISSION 6
231 #define MAT_ATTRIB_BACK_EMISSION 7
232 #define MAT_ATTRIB_FRONT_SHININESS 8
233 #define MAT_ATTRIB_BACK_SHININESS 9
234 #define MAT_ATTRIB_FRONT_INDEXES 10
235 #define MAT_ATTRIB_BACK_INDEXES 11
236 #define MAT_ATTRIB_MAX 12
237
238 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
239 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
240 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
241 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
242 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
243 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
244
245 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
246 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
247 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
248 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
249 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
250 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
251 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
252 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
253 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
254 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
255 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
256 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
257
258
259 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
260 MAT_BIT_FRONT_AMBIENT | \
261 MAT_BIT_FRONT_DIFFUSE | \
262 MAT_BIT_FRONT_SPECULAR | \
263 MAT_BIT_FRONT_SHININESS | \
264 MAT_BIT_FRONT_INDEXES)
265
266 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
267 MAT_BIT_BACK_AMBIENT | \
268 MAT_BIT_BACK_DIFFUSE | \
269 MAT_BIT_BACK_SPECULAR | \
270 MAT_BIT_BACK_SHININESS | \
271 MAT_BIT_BACK_INDEXES)
272
273 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
274 /*@}*/
275
276
277 /**
278 * Material state.
279 */
280 struct gl_material
281 {
282 GLfloat Attrib[MAT_ATTRIB_MAX][4];
283 };
284
285
286 /**
287 * Light state flags.
288 */
289 /*@{*/
290 #define LIGHT_SPOT 0x1
291 #define LIGHT_LOCAL_VIEWER 0x2
292 #define LIGHT_POSITIONAL 0x4
293 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
294 /*@}*/
295
296
297 /**
298 * Light source state.
299 */
300 struct gl_light
301 {
302 GLfloat Ambient[4]; /**< ambient color */
303 GLfloat Diffuse[4]; /**< diffuse color */
304 GLfloat Specular[4]; /**< specular color */
305 GLfloat EyePosition[4]; /**< position in eye coordinates */
306 GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */
307 GLfloat SpotExponent;
308 GLfloat SpotCutoff; /**< in degrees */
309 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
310 GLfloat ConstantAttenuation;
311 GLfloat LinearAttenuation;
312 GLfloat QuadraticAttenuation;
313 GLboolean Enabled; /**< On/off flag */
314
315 /**
316 * \name Derived fields
317 */
318 /*@{*/
319 GLbitfield _Flags; /**< Mask of LIGHT_x bits defined above */
320
321 GLfloat _Position[4]; /**< position in eye/obj coordinates */
322 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
323 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
324 GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
325 GLfloat _VP_inf_spot_attenuation;
326
327 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
328 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
329 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
330 /*@}*/
331 };
332
333
334 /**
335 * Light model state.
336 */
337 struct gl_lightmodel
338 {
339 GLfloat Ambient[4]; /**< ambient color */
340 GLboolean LocalViewer; /**< Local (or infinite) view point? */
341 GLboolean TwoSide; /**< Two (or one) sided lighting? */
342 GLenum16 ColorControl; /**< either GL_SINGLE_COLOR
343 or GL_SEPARATE_SPECULAR_COLOR */
344 };
345
346
347 /**
348 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
349 */
350 struct gl_accum_attrib
351 {
352 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
353 };
354
355
356 /**
357 * Used for storing clear color, texture border color, etc.
358 * The float values are typically unclamped.
359 */
360 union gl_color_union
361 {
362 GLfloat f[4];
363 GLint i[4];
364 GLuint ui[4];
365 };
366
367
368 /**
369 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
370 */
371 struct gl_colorbuffer_attrib
372 {
373 GLuint ClearIndex; /**< Index for glClear */
374 union gl_color_union ClearColor; /**< Color for glClear, unclamped */
375 GLuint IndexMask; /**< Color index write mask */
376
377 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
378 GLbitfield ColorMask;
379
380 GLenum16 DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
381
382 /**
383 * \name alpha testing
384 */
385 /*@{*/
386 GLboolean AlphaEnabled; /**< Alpha test enabled flag */
387 GLenum16 AlphaFunc; /**< Alpha test function */
388 GLfloat AlphaRefUnclamped;
389 GLclampf AlphaRef; /**< Alpha reference value */
390 /*@}*/
391
392 /**
393 * \name Blending
394 */
395 /*@{*/
396 GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
397
398 /* NOTE: this does _not_ depend on fragment clamping or any other clamping
399 * control, only on the fixed-pointness of the render target.
400 * The query does however depend on fragment color clamping.
401 */
402 GLfloat BlendColorUnclamped[4]; /**< Blending color */
403 GLfloat BlendColor[4]; /**< Blending color */
404
405 struct
406 {
407 GLenum16 SrcRGB; /**< RGB blend source term */
408 GLenum16 DstRGB; /**< RGB blend dest term */
409 GLenum16 SrcA; /**< Alpha blend source term */
410 GLenum16 DstA; /**< Alpha blend dest term */
411 GLenum16 EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
412 GLenum16 EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
413 /**
414 * Set if any blend factor uses SRC1. Computed at the time blend factors
415 * get set.
416 */
417 GLboolean _UsesDualSrc;
418 } Blend[MAX_DRAW_BUFFERS];
419 /** Are the blend func terms currently different for each buffer/target? */
420 GLboolean _BlendFuncPerBuffer;
421 /** Are the blend equations currently different for each buffer/target? */
422 GLboolean _BlendEquationPerBuffer;
423
424 /**
425 * Which advanced blending mode is in use (or BLEND_NONE).
426 *
427 * KHR_blend_equation_advanced only allows advanced blending with a single
428 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
429 * requires all draw buffers to match, so we only need a single value.
430 */
431 enum gl_advanced_blend_mode _AdvancedBlendMode;
432
433 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
434 bool BlendCoherent;
435 /*@}*/
436
437 /**
438 * \name Logic op
439 */
440 /*@{*/
441 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
442 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
443 GLenum16 LogicOp; /**< Logic operator */
444 enum gl_logicop_mode _LogicOp;
445 /*@}*/
446
447 GLboolean DitherFlag; /**< Dither enable flag */
448
449 GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
450 GLenum16 ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
451 GLenum16 ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
452
453 GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */
454 };
455
456
457 /**
458 * Vertex format to describe a vertex element.
459 */
460 struct gl_vertex_format
461 {
462 GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
463 GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
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 of VERT_BIT_* values indicating which arrays are enabled */
1552 GLbitfield Enabled;
1553
1554 /**
1555 * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
1556 *
1557 * The value is valid past calling _mesa_update_vao_derived_arrays.
1558 * Note that _mesa_update_vao_derived_arrays is called when binding
1559 * the VAO to Array._DrawVAO.
1560 */
1561 GLbitfield _EffEnabledVBO;
1562
1563 /** Denotes the way the position/generic0 attribute is mapped */
1564 gl_attribute_map_mode _AttributeMapMode;
1565
1566 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1567 GLbitfield NewArrays;
1568
1569 /** The index buffer (also known as the element array buffer in OpenGL). */
1570 struct gl_buffer_object *IndexBufferObj;
1571 };
1572
1573
1574 /**
1575 * Vertex array state
1576 */
1577 struct gl_array_attrib
1578 {
1579 /** Currently bound array object. */
1580 struct gl_vertex_array_object *VAO;
1581
1582 /** The default vertex array object */
1583 struct gl_vertex_array_object *DefaultVAO;
1584
1585 /** The last VAO accessed by a DSA function */
1586 struct gl_vertex_array_object *LastLookedUpVAO;
1587
1588 /** Array objects (GL_ARB_vertex_array_object) */
1589 struct _mesa_HashTable *Objects;
1590
1591 GLint ActiveTexture; /**< Client Active Texture */
1592 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1593 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1594
1595 /**
1596 * \name Primitive restart controls
1597 *
1598 * Primitive restart is enabled if either \c PrimitiveRestart or
1599 * \c PrimitiveRestartFixedIndex is set.
1600 */
1601 /*@{*/
1602 GLboolean PrimitiveRestart;
1603 GLboolean PrimitiveRestartFixedIndex;
1604 GLboolean _PrimitiveRestart;
1605 GLuint RestartIndex;
1606 /*@}*/
1607
1608 /* GL_ARB_vertex_buffer_object */
1609 struct gl_buffer_object *ArrayBufferObj;
1610
1611 /**
1612 * Vertex array object that is used with the currently active draw command.
1613 * The _DrawVAO is either set to the currently bound VAO for array type
1614 * draws or to internal VAO's set up by the vbo module to execute immediate
1615 * mode or display list draws.
1616 */
1617 struct gl_vertex_array_object *_DrawVAO;
1618 /**
1619 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
1620 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
1621 * but may omit those arrays that shall not be referenced by the current
1622 * gl_vertex_program_state::_VPMode. For example the generic attributes are
1623 * maked out form the _DrawVAO's enabled arrays when a fixed function
1624 * array draw is executed.
1625 */
1626 GLbitfield _DrawVAOEnabledAttribs;
1627 /**
1628 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
1629 * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
1630 */
1631 struct gl_vertex_array_object *_EmptyVAO;
1632
1633 /** Legal array datatypes and the API for which they have been computed */
1634 GLbitfield LegalTypesMask;
1635 gl_api LegalTypesMaskAPI;
1636 };
1637
1638
1639 /**
1640 * Feedback buffer state
1641 */
1642 struct gl_feedback
1643 {
1644 GLenum16 Type;
1645 GLbitfield _Mask; /**< FB_* bits */
1646 GLfloat *Buffer;
1647 GLuint BufferSize;
1648 GLuint Count;
1649 };
1650
1651
1652 /**
1653 * Selection buffer state
1654 */
1655 struct gl_selection
1656 {
1657 GLuint *Buffer; /**< selection buffer */
1658 GLuint BufferSize; /**< size of the selection buffer */
1659 GLuint BufferCount; /**< number of values in the selection buffer */
1660 GLuint Hits; /**< number of records in the selection buffer */
1661 GLuint NameStackDepth; /**< name stack depth */
1662 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1663 GLboolean HitFlag; /**< hit flag */
1664 GLfloat HitMinZ; /**< minimum hit depth */
1665 GLfloat HitMaxZ; /**< maximum hit depth */
1666 };
1667
1668
1669 /**
1670 * 1-D Evaluator control points
1671 */
1672 struct gl_1d_map
1673 {
1674 GLuint Order; /**< Number of control points */
1675 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1676 GLfloat *Points; /**< Points to contiguous control points */
1677 };
1678
1679
1680 /**
1681 * 2-D Evaluator control points
1682 */
1683 struct gl_2d_map
1684 {
1685 GLuint Uorder; /**< Number of control points in U dimension */
1686 GLuint Vorder; /**< Number of control points in V dimension */
1687 GLfloat u1, u2, du;
1688 GLfloat v1, v2, dv;
1689 GLfloat *Points; /**< Points to contiguous control points */
1690 };
1691
1692
1693 /**
1694 * All evaluator control point state
1695 */
1696 struct gl_evaluators
1697 {
1698 /**
1699 * \name 1-D maps
1700 */
1701 /*@{*/
1702 struct gl_1d_map Map1Vertex3;
1703 struct gl_1d_map Map1Vertex4;
1704 struct gl_1d_map Map1Index;
1705 struct gl_1d_map Map1Color4;
1706 struct gl_1d_map Map1Normal;
1707 struct gl_1d_map Map1Texture1;
1708 struct gl_1d_map Map1Texture2;
1709 struct gl_1d_map Map1Texture3;
1710 struct gl_1d_map Map1Texture4;
1711 /*@}*/
1712
1713 /**
1714 * \name 2-D maps
1715 */
1716 /*@{*/
1717 struct gl_2d_map Map2Vertex3;
1718 struct gl_2d_map Map2Vertex4;
1719 struct gl_2d_map Map2Index;
1720 struct gl_2d_map Map2Color4;
1721 struct gl_2d_map Map2Normal;
1722 struct gl_2d_map Map2Texture1;
1723 struct gl_2d_map Map2Texture2;
1724 struct gl_2d_map Map2Texture3;
1725 struct gl_2d_map Map2Texture4;
1726 /*@}*/
1727 };
1728
1729
1730 struct gl_transform_feedback_varying_info
1731 {
1732 char *Name;
1733 GLenum16 Type;
1734 GLint BufferIndex;
1735 GLint Size;
1736 GLint Offset;
1737 };
1738
1739
1740 /**
1741 * Per-output info vertex shaders for transform feedback.
1742 */
1743 struct gl_transform_feedback_output
1744 {
1745 uint32_t OutputRegister;
1746 uint32_t OutputBuffer;
1747 uint32_t NumComponents;
1748 uint32_t StreamId;
1749
1750 /** offset (in DWORDs) of this output within the interleaved structure */
1751 uint32_t DstOffset;
1752
1753 /**
1754 * Offset into the output register of the data to output. For example,
1755 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1756 * offset is in the y and z components of the output register.
1757 */
1758 uint32_t ComponentOffset;
1759 };
1760
1761
1762 struct gl_transform_feedback_buffer
1763 {
1764 uint32_t Binding;
1765
1766 uint32_t NumVaryings;
1767
1768 /**
1769 * Total number of components stored in each buffer. This may be used by
1770 * hardware back-ends to determine the correct stride when interleaving
1771 * multiple transform feedback outputs in the same buffer.
1772 */
1773 uint32_t Stride;
1774
1775 /**
1776 * Which transform feedback stream this buffer binding is associated with.
1777 */
1778 uint32_t Stream;
1779 };
1780
1781
1782 /** Post-link transform feedback info. */
1783 struct gl_transform_feedback_info
1784 {
1785 unsigned NumOutputs;
1786
1787 /* Bitmask of active buffer indices. */
1788 unsigned ActiveBuffers;
1789
1790 struct gl_transform_feedback_output *Outputs;
1791
1792 /** Transform feedback varyings used for the linking of this shader program.
1793 *
1794 * Use for glGetTransformFeedbackVarying().
1795 */
1796 struct gl_transform_feedback_varying_info *Varyings;
1797 GLint NumVarying;
1798
1799 struct gl_transform_feedback_buffer Buffers[MAX_FEEDBACK_BUFFERS];
1800 };
1801
1802
1803 /**
1804 * Transform feedback object state
1805 */
1806 struct gl_transform_feedback_object
1807 {
1808 GLuint Name; /**< AKA the object ID */
1809 GLint RefCount;
1810 GLchar *Label; /**< GL_KHR_debug */
1811 GLboolean Active; /**< Is transform feedback enabled? */
1812 GLboolean Paused; /**< Is transform feedback paused? */
1813 GLboolean EndedAnytime; /**< Has EndTransformFeedback been called
1814 at least once? */
1815 GLboolean EverBound; /**< Has this object been bound? */
1816
1817 /**
1818 * GLES: if Active is true, remaining number of primitives which can be
1819 * rendered without overflow. This is necessary to track because GLES
1820 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1821 * glDrawArraysInstanced would overflow transform feedback buffers.
1822 * Undefined if Active is false.
1823 *
1824 * Not tracked for desktop GL since it's unnecessary.
1825 */
1826 unsigned GlesRemainingPrims;
1827
1828 /**
1829 * The program active when BeginTransformFeedback() was called.
1830 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1831 * where stage is the pipeline stage that is the source of data for
1832 * transform feedback.
1833 */
1834 struct gl_program *program;
1835
1836 /** The feedback buffers */
1837 GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
1838 struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS];
1839
1840 /** Start of feedback data in dest buffer */
1841 GLintptr Offset[MAX_FEEDBACK_BUFFERS];
1842
1843 /**
1844 * Max data to put into dest buffer (in bytes). Computed based on
1845 * RequestedSize and the actual size of the buffer.
1846 */
1847 GLsizeiptr Size[MAX_FEEDBACK_BUFFERS];
1848
1849 /**
1850 * Size that was specified when the buffer was bound. If the buffer was
1851 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1852 * zero.
1853 */
1854 GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS];
1855 };
1856
1857
1858 /**
1859 * Context state for transform feedback.
1860 */
1861 struct gl_transform_feedback_state
1862 {
1863 GLenum16 Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1864
1865 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1866 struct gl_buffer_object *CurrentBuffer;
1867
1868 /** The table of all transform feedback objects */
1869 struct _mesa_HashTable *Objects;
1870
1871 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1872 struct gl_transform_feedback_object *CurrentObject;
1873
1874 /** The default xform-fb object (Name==0) */
1875 struct gl_transform_feedback_object *DefaultObject;
1876 };
1877
1878
1879 /**
1880 * A "performance monitor" as described in AMD_performance_monitor.
1881 */
1882 struct gl_perf_monitor_object
1883 {
1884 GLuint Name;
1885
1886 /** True if the monitor is currently active (Begin called but not End). */
1887 GLboolean Active;
1888
1889 /**
1890 * True if the monitor has ended.
1891 *
1892 * This is distinct from !Active because it may never have began.
1893 */
1894 GLboolean Ended;
1895
1896 /**
1897 * A list of groups with currently active counters.
1898 *
1899 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1900 */
1901 unsigned *ActiveGroups;
1902
1903 /**
1904 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1905 *
1906 * Checking whether counter 'c' in group 'g' is active can be done via:
1907 *
1908 * BITSET_TEST(ActiveCounters[g], c)
1909 */
1910 GLuint **ActiveCounters;
1911 };
1912
1913
1914 union gl_perf_monitor_counter_value
1915 {
1916 float f;
1917 uint64_t u64;
1918 uint32_t u32;
1919 };
1920
1921
1922 struct gl_perf_monitor_counter
1923 {
1924 /** Human readable name for the counter. */
1925 const char *Name;
1926
1927 /**
1928 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1929 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1930 */
1931 GLenum16 Type;
1932
1933 /** Minimum counter value. */
1934 union gl_perf_monitor_counter_value Minimum;
1935
1936 /** Maximum counter value. */
1937 union gl_perf_monitor_counter_value Maximum;
1938 };
1939
1940
1941 struct gl_perf_monitor_group
1942 {
1943 /** Human readable name for the group. */
1944 const char *Name;
1945
1946 /**
1947 * Maximum number of counters in this group which can be active at the
1948 * same time.
1949 */
1950 GLuint MaxActiveCounters;
1951
1952 /** Array of counters within this group. */
1953 const struct gl_perf_monitor_counter *Counters;
1954 GLuint NumCounters;
1955 };
1956
1957
1958 /**
1959 * A query object instance as described in INTEL_performance_query.
1960 *
1961 * NB: We want to keep this and the corresponding backend structure
1962 * relatively lean considering that applications may expect to
1963 * allocate enough objects to be able to query around all draw calls
1964 * in a frame.
1965 */
1966 struct gl_perf_query_object
1967 {
1968 GLuint Id; /**< hash table ID/name */
1969 unsigned Used:1; /**< has been used for 1 or more queries */
1970 unsigned Active:1; /**< inside Begin/EndPerfQuery */
1971 unsigned Ready:1; /**< result is ready? */
1972 };
1973
1974
1975 /**
1976 * Context state for AMD_performance_monitor.
1977 */
1978 struct gl_perf_monitor_state
1979 {
1980 /** Array of performance monitor groups (indexed by group ID) */
1981 const struct gl_perf_monitor_group *Groups;
1982 GLuint NumGroups;
1983
1984 /** The table of all performance monitors. */
1985 struct _mesa_HashTable *Monitors;
1986 };
1987
1988
1989 /**
1990 * Context state for INTEL_performance_query.
1991 */
1992 struct gl_perf_query_state
1993 {
1994 struct _mesa_HashTable *Objects; /**< The table of all performance query objects */
1995 };
1996
1997
1998 /**
1999 * A bindless sampler object.
2000 */
2001 struct gl_bindless_sampler
2002 {
2003 /** Texture unit (set by glUniform1()). */
2004 GLubyte unit;
2005
2006 /** Whether this bindless sampler is bound to a unit. */
2007 GLboolean bound;
2008
2009 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2010 gl_texture_index target;
2011
2012 /** Pointer to the base of the data. */
2013 GLvoid *data;
2014 };
2015
2016
2017 /**
2018 * A bindless image object.
2019 */
2020 struct gl_bindless_image
2021 {
2022 /** Image unit (set by glUniform1()). */
2023 GLubyte unit;
2024
2025 /** Whether this bindless image is bound to a unit. */
2026 GLboolean bound;
2027
2028 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
2029 * GL_NONE to indicate both read-only and write-only)
2030 */
2031 GLenum16 access;
2032
2033 /** Pointer to the base of the data. */
2034 GLvoid *data;
2035 };
2036
2037
2038 /**
2039 * Current vertex processing mode: fixed function vs. shader.
2040 * In reality, fixed function is probably implemented by a shader but that's
2041 * not what we care about here.
2042 */
2043 typedef enum
2044 {
2045 VP_MODE_FF, /**< legacy / fixed function */
2046 VP_MODE_SHADER, /**< ARB vertex program or GLSL vertex shader */
2047 VP_MODE_MAX /**< for sizing arrays */
2048 } gl_vertex_processing_mode;
2049
2050
2051 /**
2052 * Base class for any kind of program object
2053 */
2054 struct gl_program
2055 {
2056 /** FIXME: This must be first until we split shader_info from nir_shader */
2057 struct shader_info info;
2058
2059 GLuint Id;
2060 GLint RefCount;
2061 GLubyte *String; /**< Null-terminated program text */
2062
2063 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2064 GLenum16 Target;
2065 GLenum16 Format; /**< String encoding format */
2066
2067 GLboolean _Used; /**< Ever used for drawing? Used for debugging */
2068
2069 struct nir_shader *nir;
2070
2071 /* Saved and restored with metadata. Freed with ralloc. */
2072 void *driver_cache_blob;
2073 size_t driver_cache_blob_size;
2074
2075 bool is_arb_asm; /** Is this an ARB assembly-style program */
2076
2077 /** Is this program written to on disk shader cache */
2078 bool program_written_to_cache;
2079
2080 /** A bitfield indicating which vertex shader inputs consume two slots
2081 *
2082 * This is used for mapping from single-slot input locations in the GL API
2083 * to dual-slot double input locations in the shader. This field is set
2084 * once as part of linking and never updated again to ensure the mapping
2085 * remains consistent.
2086 *
2087 * Note: There may be dual-slot variables in the original shader source
2088 * which do not appear in this bitfield due to having been eliminated by
2089 * the compiler prior to DualSlotInputs being calculated. There may also
2090 * be bits set in this bitfield which are set but which the shader never
2091 * reads due to compiler optimizations eliminating such variables after
2092 * DualSlotInputs is calculated.
2093 */
2094 GLbitfield64 DualSlotInputs;
2095 /** Subset of OutputsWritten outputs written with non-zero index. */
2096 GLbitfield64 SecondaryOutputsWritten;
2097 /** TEXTURE_x_BIT bitmask */
2098 GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
2099 /** Bitfield of which samplers are used */
2100 GLbitfield SamplersUsed;
2101 /** Texture units used for shadow sampling. */
2102 GLbitfield ShadowSamplers;
2103 /** Texture units used for samplerExternalOES */
2104 GLbitfield ExternalSamplersUsed;
2105
2106 /** Named parameters, constants, etc. from program text */
2107 struct gl_program_parameter_list *Parameters;
2108
2109 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2110 GLubyte SamplerUnits[MAX_SAMPLERS];
2111
2112 /* FIXME: We should be able to make this struct a union. However some
2113 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2114 * these fields, we should fix this.
2115 */
2116 struct {
2117 /** Fields used by GLSL programs */
2118 struct {
2119 /** Data shared by gl_program and gl_shader_program */
2120 struct gl_shader_program_data *data;
2121
2122 struct gl_active_atomic_buffer **AtomicBuffers;
2123
2124 /** Post-link transform feedback info. */
2125 struct gl_transform_feedback_info *LinkedTransformFeedback;
2126
2127 /**
2128 * Number of types for subroutine uniforms.
2129 */
2130 GLuint NumSubroutineUniformTypes;
2131
2132 /**
2133 * Subroutine uniform remap table
2134 * based on the program level uniform remap table.
2135 */
2136 GLuint NumSubroutineUniforms; /* non-sparse total */
2137 GLuint NumSubroutineUniformRemapTable;
2138 struct gl_uniform_storage **SubroutineUniformRemapTable;
2139
2140 /**
2141 * Num of subroutine functions for this stage and storage for them.
2142 */
2143 GLuint NumSubroutineFunctions;
2144 GLuint MaxSubroutineFunctionIndex;
2145 struct gl_subroutine_function *SubroutineFunctions;
2146
2147 /**
2148 * Map from image uniform index to image unit (set by glUniform1i())
2149 *
2150 * An image uniform index is associated with each image uniform by
2151 * the linker. The image index associated with each uniform is
2152 * stored in the \c gl_uniform_storage::image field.
2153 */
2154 GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
2155
2156 /**
2157 * Access qualifier specified in the shader for each image uniform
2158 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY, \c
2159 * GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
2160 * write-only.
2161 *
2162 * It may be different, though only more strict than the value of
2163 * \c gl_image_unit::Access for the corresponding image unit.
2164 */
2165 GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
2166
2167 struct gl_uniform_block **UniformBlocks;
2168 struct gl_uniform_block **ShaderStorageBlocks;
2169
2170 /**
2171 * Bitmask of shader storage blocks not declared as read-only.
2172 */
2173 unsigned ShaderStorageBlocksWriteAccess;
2174
2175 /** Which texture target is being sampled
2176 * (TEXTURE_1D/2D/3D/etc_INDEX)
2177 */
2178 GLubyte SamplerTargets[MAX_SAMPLERS];
2179
2180 /**
2181 * Number of samplers declared with the bindless_sampler layout
2182 * qualifier as specified by ARB_bindless_texture.
2183 */
2184 GLuint NumBindlessSamplers;
2185 GLboolean HasBoundBindlessSampler;
2186 struct gl_bindless_sampler *BindlessSamplers;
2187
2188 /**
2189 * Number of images declared with the bindless_image layout qualifier
2190 * as specified by ARB_bindless_texture.
2191 */
2192 GLuint NumBindlessImages;
2193 GLboolean HasBoundBindlessImage;
2194 struct gl_bindless_image *BindlessImages;
2195
2196 union {
2197 struct {
2198 /**
2199 * A bitmask of gl_advanced_blend_mode values
2200 */
2201 GLbitfield BlendSupport;
2202 } fs;
2203 };
2204 } sh;
2205
2206 /** ARB assembly-style program fields */
2207 struct {
2208 struct prog_instruction *Instructions;
2209
2210 /**
2211 * Local parameters used by the program.
2212 *
2213 * It's dynamically allocated because it is rarely used (just
2214 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2215 * once it's allocated.
2216 */
2217 GLfloat (*LocalParams)[4];
2218
2219 /** Bitmask of which register files are read/written with indirect
2220 * addressing. Mask of (1 << PROGRAM_x) bits.
2221 */
2222 GLbitfield IndirectRegisterFiles;
2223
2224 /** Logical counts */
2225 /*@{*/
2226 GLuint NumInstructions;
2227 GLuint NumTemporaries;
2228 GLuint NumParameters;
2229 GLuint NumAttributes;
2230 GLuint NumAddressRegs;
2231 GLuint NumAluInstructions;
2232 GLuint NumTexInstructions;
2233 GLuint NumTexIndirections;
2234 /*@}*/
2235 /** Native, actual h/w counts */
2236 /*@{*/
2237 GLuint NumNativeInstructions;
2238 GLuint NumNativeTemporaries;
2239 GLuint NumNativeParameters;
2240 GLuint NumNativeAttributes;
2241 GLuint NumNativeAddressRegs;
2242 GLuint NumNativeAluInstructions;
2243 GLuint NumNativeTexInstructions;
2244 GLuint NumNativeTexIndirections;
2245 /*@}*/
2246
2247 /** Used by ARB assembly-style programs. Can only be true for vertex
2248 * programs.
2249 */
2250 GLboolean IsPositionInvariant;
2251 } arb;
2252 };
2253 };
2254
2255
2256 /**
2257 * State common to vertex and fragment programs.
2258 */
2259 struct gl_program_state
2260 {
2261 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2262 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2263 };
2264
2265
2266 /**
2267 * Context state for vertex programs.
2268 */
2269 struct gl_vertex_program_state
2270 {
2271 GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2272 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2273 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2274 /** Should fixed-function T&L be implemented with a vertex prog? */
2275 GLboolean _MaintainTnlProgram;
2276
2277 struct gl_program *Current; /**< User-bound vertex program */
2278
2279 /** Currently enabled and valid vertex program (including internal
2280 * programs, user-defined vertex programs and GLSL vertex shaders).
2281 * This is the program we must use when rendering.
2282 */
2283 struct gl_program *_Current;
2284
2285 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2286
2287 /** Program to emulate fixed-function T&L (see above) */
2288 struct gl_program *_TnlProgram;
2289
2290 /** Cache of fixed-function programs */
2291 struct gl_program_cache *Cache;
2292
2293 GLboolean _Overriden;
2294
2295 /**
2296 * If we have a vertex program, a TNL program or no program at all.
2297 * Note that this value should be kept up to date all the time,
2298 * nevertheless its correctness is asserted in _mesa_update_state.
2299 * The reason is to avoid calling _mesa_update_state twice we need
2300 * this value on draw *before* actually calling _mesa_update_state.
2301 * Also it should need to get recomputed only on changes to the
2302 * vertex program which are heavyweight already.
2303 */
2304 gl_vertex_processing_mode _VPMode;
2305 };
2306
2307 /**
2308 * Context state for tessellation control programs.
2309 */
2310 struct gl_tess_ctrl_program_state
2311 {
2312 /** Currently bound and valid shader. */
2313 struct gl_program *_Current;
2314
2315 GLint patch_vertices;
2316 GLfloat patch_default_outer_level[4];
2317 GLfloat patch_default_inner_level[2];
2318 };
2319
2320 /**
2321 * Context state for tessellation evaluation programs.
2322 */
2323 struct gl_tess_eval_program_state
2324 {
2325 /** Currently bound and valid shader. */
2326 struct gl_program *_Current;
2327 };
2328
2329 /**
2330 * Context state for geometry programs.
2331 */
2332 struct gl_geometry_program_state
2333 {
2334 /**
2335 * Currently enabled and valid program (including internal programs
2336 * and compiled shader programs).
2337 */
2338 struct gl_program *_Current;
2339 };
2340
2341 /**
2342 * Context state for fragment programs.
2343 */
2344 struct gl_fragment_program_state
2345 {
2346 GLboolean Enabled; /**< User-set fragment program enable flag */
2347 /** Should fixed-function texturing be implemented with a fragment prog? */
2348 GLboolean _MaintainTexEnvProgram;
2349
2350 struct gl_program *Current; /**< User-bound fragment program */
2351
2352 /**
2353 * Currently enabled and valid fragment program (including internal
2354 * programs, user-defined fragment programs and GLSL fragment shaders).
2355 * This is the program we must use when rendering.
2356 */
2357 struct gl_program *_Current;
2358
2359 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2360
2361 /** Program to emulate fixed-function texture env/combine (see above) */
2362 struct gl_program *_TexEnvProgram;
2363
2364 /** Cache of fixed-function programs */
2365 struct gl_program_cache *Cache;
2366 };
2367
2368
2369 /**
2370 * Context state for compute programs.
2371 */
2372 struct gl_compute_program_state
2373 {
2374 /** Currently enabled and valid program (including internal programs
2375 * and compiled shader programs).
2376 */
2377 struct gl_program *_Current;
2378 };
2379
2380
2381 /**
2382 * ATI_fragment_shader runtime state
2383 */
2384
2385 struct atifs_instruction;
2386 struct atifs_setupinst;
2387
2388 /**
2389 * ATI fragment shader
2390 */
2391 struct ati_fragment_shader
2392 {
2393 GLuint Id;
2394 GLint RefCount;
2395 struct atifs_instruction *Instructions[2];
2396 struct atifs_setupinst *SetupInst[2];
2397 GLfloat Constants[8][4];
2398 GLbitfield LocalConstDef; /**< Indicates which constants have been set */
2399 GLubyte numArithInstr[2];
2400 GLubyte regsAssigned[2];
2401 GLubyte NumPasses; /**< 1 or 2 */
2402 /**
2403 * Current compile stage: 0 setup pass1, 1 arith pass1,
2404 * 2 setup pass2, 3 arith pass2.
2405 */
2406 GLubyte cur_pass;
2407 GLubyte last_optype;
2408 GLboolean interpinp1;
2409 GLboolean isValid;
2410 /**
2411 * Array of 2 bit values for each tex unit to remember whether
2412 * STR or STQ swizzle was used
2413 */
2414 GLuint swizzlerq;
2415 struct gl_program *Program;
2416 };
2417
2418 /**
2419 * Context state for GL_ATI_fragment_shader
2420 */
2421 struct gl_ati_fragment_shader_state
2422 {
2423 GLboolean Enabled;
2424 GLboolean Compiling;
2425 GLfloat GlobalConstants[8][4];
2426 struct ati_fragment_shader *Current;
2427 };
2428
2429 /**
2430 * Shader subroutine function definition
2431 */
2432 struct gl_subroutine_function
2433 {
2434 char *name;
2435 int index;
2436 int num_compat_types;
2437 const struct glsl_type **types;
2438 };
2439
2440 /**
2441 * Shader information needed by both gl_shader and gl_linked shader.
2442 */
2443 struct gl_shader_info
2444 {
2445 /**
2446 * Tessellation Control shader state from layout qualifiers.
2447 */
2448 struct {
2449 /**
2450 * 0 - vertices not declared in shader, or
2451 * 1 .. GL_MAX_PATCH_VERTICES
2452 */
2453 GLint VerticesOut;
2454 } TessCtrl;
2455
2456 /**
2457 * Tessellation Evaluation shader state from layout qualifiers.
2458 */
2459 struct {
2460 /**
2461 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2462 * in this shader.
2463 */
2464 GLenum16 PrimitiveMode;
2465
2466 enum gl_tess_spacing Spacing;
2467
2468 /**
2469 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2470 */
2471 GLenum16 VertexOrder;
2472 /**
2473 * 1, 0, or -1 if it's not set in this shader.
2474 */
2475 int PointMode;
2476 } TessEval;
2477
2478 /**
2479 * Geometry shader state from GLSL 1.50 layout qualifiers.
2480 */
2481 struct {
2482 GLint VerticesOut;
2483 /**
2484 * 0 - Invocations count not declared in shader, or
2485 * 1 .. Const.MaxGeometryShaderInvocations
2486 */
2487 GLint Invocations;
2488 /**
2489 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2490 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2491 * shader.
2492 */
2493 GLenum16 InputType;
2494 /**
2495 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2496 * it's not set in this shader.
2497 */
2498 GLenum16 OutputType;
2499 } Geom;
2500
2501 /**
2502 * Compute shader state from ARB_compute_shader and
2503 * ARB_compute_variable_group_size layout qualifiers.
2504 */
2505 struct {
2506 /**
2507 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2508 * it's not set in this shader.
2509 */
2510 unsigned LocalSize[3];
2511
2512 /**
2513 * Whether a variable work group size has been specified as defined by
2514 * ARB_compute_variable_group_size.
2515 */
2516 bool LocalSizeVariable;
2517
2518 /*
2519 * Arrangement of invocations used to calculate derivatives in a compute
2520 * shader. From NV_compute_shader_derivatives.
2521 */
2522 enum gl_derivative_group DerivativeGroup;
2523 } Comp;
2524 };
2525
2526 /**
2527 * A linked GLSL shader object.
2528 */
2529 struct gl_linked_shader
2530 {
2531 gl_shader_stage Stage;
2532
2533 #ifdef DEBUG
2534 unsigned SourceChecksum;
2535 #endif
2536
2537 struct gl_program *Program; /**< Post-compile assembly code */
2538
2539 /**
2540 * \name Sampler tracking
2541 *
2542 * \note Each of these fields is only set post-linking.
2543 */
2544 /*@{*/
2545 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
2546 /*@}*/
2547
2548 /**
2549 * Number of default uniform block components used by this shader.
2550 *
2551 * This field is only set post-linking.
2552 */
2553 unsigned num_uniform_components;
2554
2555 /**
2556 * Number of combined uniform components used by this shader.
2557 *
2558 * This field is only set post-linking. It is the sum of the uniform block
2559 * sizes divided by sizeof(float), and num_uniform_compoennts.
2560 */
2561 unsigned num_combined_uniform_components;
2562
2563 struct exec_list *ir;
2564 struct exec_list *packed_varyings;
2565 struct exec_list *fragdata_arrays;
2566 struct glsl_symbol_table *symbols;
2567
2568 /**
2569 * ARB_gl_spirv related data.
2570 *
2571 * This is actually a reference to the gl_shader::spirv_data, which
2572 * stores information that is also needed during linking.
2573 */
2574 struct gl_shader_spirv_data *spirv_data;
2575 };
2576
2577
2578 /**
2579 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2580 * was skipped due to the shader matching one that's been seen before by
2581 * the on-disk cache.
2582 */
2583 enum gl_compile_status
2584 {
2585 COMPILE_FAILURE = 0,
2586 COMPILE_SUCCESS,
2587 COMPILE_SKIPPED
2588 };
2589
2590 /**
2591 * A GLSL shader object.
2592 */
2593 struct gl_shader
2594 {
2595 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2596 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2597 * Must be the first field.
2598 */
2599 GLenum16 Type;
2600 gl_shader_stage Stage;
2601 GLuint Name; /**< AKA the handle */
2602 GLint RefCount; /**< Reference count */
2603 GLchar *Label; /**< GL_KHR_debug */
2604 unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
2605 GLboolean DeletePending;
2606 bool IsES; /**< True if this shader uses GLSL ES */
2607
2608 enum gl_compile_status CompileStatus;
2609
2610 #ifdef DEBUG
2611 unsigned SourceChecksum; /**< for debug/logging purposes */
2612 #endif
2613 const GLchar *Source; /**< Source code string */
2614
2615 const GLchar *FallbackSource; /**< Fallback string used by on-disk cache*/
2616
2617 GLchar *InfoLog;
2618
2619 unsigned Version; /**< GLSL version used for linking */
2620
2621 /**
2622 * A bitmask of gl_advanced_blend_mode values
2623 */
2624 GLbitfield BlendSupport;
2625
2626 struct exec_list *ir;
2627 struct glsl_symbol_table *symbols;
2628
2629 /**
2630 * Whether early fragment tests are enabled as defined by
2631 * ARB_shader_image_load_store.
2632 */
2633 bool EarlyFragmentTests;
2634
2635 bool ARB_fragment_coord_conventions_enable;
2636
2637 bool redeclares_gl_fragcoord;
2638 bool uses_gl_fragcoord;
2639
2640 bool PostDepthCoverage;
2641 bool PixelInterlockOrdered;
2642 bool PixelInterlockUnordered;
2643 bool SampleInterlockOrdered;
2644 bool SampleInterlockUnordered;
2645 bool InnerCoverage;
2646
2647 /**
2648 * Fragment shader state from GLSL 1.50 layout qualifiers.
2649 */
2650 bool origin_upper_left;
2651 bool pixel_center_integer;
2652
2653 /**
2654 * Whether bindless_sampler/bindless_image, and respectively
2655 * bound_sampler/bound_image are declared at global scope as defined by
2656 * ARB_bindless_texture.
2657 */
2658 bool bindless_sampler;
2659 bool bindless_image;
2660 bool bound_sampler;
2661 bool bound_image;
2662
2663 /** Global xfb_stride out qualifier if any */
2664 GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
2665
2666 struct gl_shader_info info;
2667
2668 /* ARB_gl_spirv related data */
2669 struct gl_shader_spirv_data *spirv_data;
2670 };
2671
2672
2673 struct gl_uniform_buffer_variable
2674 {
2675 char *Name;
2676
2677 /**
2678 * Name of the uniform as seen by glGetUniformIndices.
2679 *
2680 * glGetUniformIndices requires that the block instance index \b not be
2681 * present in the name of queried uniforms.
2682 *
2683 * \note
2684 * \c gl_uniform_buffer_variable::IndexName and
2685 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2686 */
2687 char *IndexName;
2688
2689 const struct glsl_type *Type;
2690 unsigned int Offset;
2691 GLboolean RowMajor;
2692 };
2693
2694
2695 struct gl_uniform_block
2696 {
2697 /** Declared name of the uniform block */
2698 char *Name;
2699
2700 /** Array of supplemental information about UBO ir_variables. */
2701 struct gl_uniform_buffer_variable *Uniforms;
2702 GLuint NumUniforms;
2703
2704 /**
2705 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2706 * with glBindBufferBase to bind a buffer object to this uniform block.
2707 */
2708 GLuint Binding;
2709
2710 /**
2711 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2712 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2713 */
2714 GLuint UniformBufferSize;
2715
2716 /** Stages that reference this block */
2717 uint8_t stageref;
2718
2719 /**
2720 * Linearized array index for uniform block instance arrays
2721 *
2722 * Given a uniform block instance array declared with size
2723 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2724 * have the linearized array index
2725 *
2726 * m-1 m
2727 * i_m + ∑ i_j * ∏ s_k
2728 * j=0 k=j+1
2729 *
2730 * For a uniform block instance that is not an array, this is always 0.
2731 */
2732 uint8_t linearized_array_index;
2733
2734 /**
2735 * Layout specified in the shader
2736 *
2737 * This isn't accessible through the API, but it is used while
2738 * cross-validating uniform blocks.
2739 */
2740 enum glsl_interface_packing _Packing;
2741 GLboolean _RowMajor;
2742 };
2743
2744 /**
2745 * Structure that represents a reference to an atomic buffer from some
2746 * shader program.
2747 */
2748 struct gl_active_atomic_buffer
2749 {
2750 /** Uniform indices of the atomic counters declared within it. */
2751 GLuint *Uniforms;
2752 GLuint NumUniforms;
2753
2754 /** Binding point index associated with it. */
2755 GLuint Binding;
2756
2757 /** Minimum reasonable size it is expected to have. */
2758 GLuint MinimumSize;
2759
2760 /** Shader stages making use of it. */
2761 GLboolean StageReferences[MESA_SHADER_STAGES];
2762 };
2763
2764 /**
2765 * Data container for shader queries. This holds only the minimal
2766 * amount of required information for resource queries to work.
2767 */
2768 struct gl_shader_variable
2769 {
2770 /**
2771 * Declared type of the variable
2772 */
2773 const struct glsl_type *type;
2774
2775 /**
2776 * If the variable is in an interface block, this is the type of the block.
2777 */
2778 const struct glsl_type *interface_type;
2779
2780 /**
2781 * For variables inside structs (possibly recursively), this is the
2782 * outermost struct type.
2783 */
2784 const struct glsl_type *outermost_struct_type;
2785
2786 /**
2787 * Declared name of the variable
2788 */
2789 char *name;
2790
2791 /**
2792 * Storage location of the base of this variable
2793 *
2794 * The precise meaning of this field depends on the nature of the variable.
2795 *
2796 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2797 * - Vertex shader output: one of the values from \c gl_varying_slot.
2798 * - Geometry shader input: one of the values from \c gl_varying_slot.
2799 * - Geometry shader output: one of the values from \c gl_varying_slot.
2800 * - Fragment shader input: one of the values from \c gl_varying_slot.
2801 * - Fragment shader output: one of the values from \c gl_frag_result.
2802 * - Uniforms: Per-stage uniform slot number for default uniform block.
2803 * - Uniforms: Index within the uniform block definition for UBO members.
2804 * - Non-UBO Uniforms: explicit location until linking then reused to
2805 * store uniform slot number.
2806 * - Other: This field is not currently used.
2807 *
2808 * If the variable is a uniform, shader input, or shader output, and the
2809 * slot has not been assigned, the value will be -1.
2810 */
2811 int location;
2812
2813 /**
2814 * Specifies the first component the variable is stored in as per
2815 * ARB_enhanced_layouts.
2816 */
2817 unsigned component:2;
2818
2819 /**
2820 * Output index for dual source blending.
2821 *
2822 * \note
2823 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2824 * source blending.
2825 */
2826 unsigned index:1;
2827
2828 /**
2829 * Specifies whether a shader input/output is per-patch in tessellation
2830 * shader stages.
2831 */
2832 unsigned patch:1;
2833
2834 /**
2835 * Storage class of the variable.
2836 *
2837 * \sa (n)ir_variable_mode
2838 */
2839 unsigned mode:4;
2840
2841 /**
2842 * Interpolation mode for shader inputs / outputs
2843 *
2844 * \sa glsl_interp_mode
2845 */
2846 unsigned interpolation:2;
2847
2848 /**
2849 * Was the location explicitly set in the shader?
2850 *
2851 * If the location is explicitly set in the shader, it \b cannot be changed
2852 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2853 * no effect).
2854 */
2855 unsigned explicit_location:1;
2856
2857 /**
2858 * Precision qualifier.
2859 */
2860 unsigned precision:2;
2861 };
2862
2863 /**
2864 * Active resource in a gl_shader_program
2865 */
2866 struct gl_program_resource
2867 {
2868 GLenum16 Type; /** Program interface type. */
2869 const void *Data; /** Pointer to resource associated data structure. */
2870 uint8_t StageReferences; /** Bitmask of shader stage references. */
2871 };
2872
2873 /**
2874 * Link status enum. LINKING_SKIPPED is used to indicate linking
2875 * was skipped due to the shader being loaded from the on-disk cache.
2876 */
2877 enum gl_link_status
2878 {
2879 LINKING_FAILURE = 0,
2880 LINKING_SUCCESS,
2881 LINKING_SKIPPED
2882 };
2883
2884 /**
2885 * A data structure to be shared by gl_shader_program and gl_program.
2886 */
2887 struct gl_shader_program_data
2888 {
2889 GLint RefCount; /**< Reference count */
2890
2891 /** SHA1 hash of linked shader program */
2892 unsigned char sha1[20];
2893
2894 unsigned NumUniformStorage;
2895 unsigned NumHiddenUniforms;
2896 struct gl_uniform_storage *UniformStorage;
2897
2898 unsigned NumUniformBlocks;
2899 unsigned NumShaderStorageBlocks;
2900
2901 struct gl_uniform_block *UniformBlocks;
2902 struct gl_uniform_block *ShaderStorageBlocks;
2903
2904 struct gl_active_atomic_buffer *AtomicBuffers;
2905 unsigned NumAtomicBuffers;
2906
2907 /* Shader cache variables used during restore */
2908 unsigned NumUniformDataSlots;
2909 union gl_constant_value *UniformDataSlots;
2910
2911 /* Used to hold initial uniform values for program binary restores.
2912 *
2913 * From the ARB_get_program_binary spec:
2914 *
2915 * "A successful call to ProgramBinary will reset all uniform
2916 * variables to their initial values. The initial value is either
2917 * the value of the variable's initializer as specified in the
2918 * original shader source, or 0 if no initializer was present.
2919 */
2920 union gl_constant_value *UniformDataDefaults;
2921
2922 GLboolean Validated;
2923
2924 /** List of all active resources after linking. */
2925 struct gl_program_resource *ProgramResourceList;
2926 unsigned NumProgramResourceList;
2927
2928 enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
2929 GLchar *InfoLog;
2930
2931 unsigned Version; /**< GLSL version used for linking */
2932
2933 /* Mask of stages this program was linked against */
2934 unsigned linked_stages;
2935
2936 /* Whether the shaders of this program are loaded from SPIR-V binaries
2937 * (all have the SPIR_V_BINARY_ARB state). This was introduced by the
2938 * ARB_gl_spirv extension.
2939 */
2940 bool spirv;
2941 };
2942
2943 /**
2944 * A GLSL program object.
2945 * Basically a linked collection of vertex and fragment shaders.
2946 */
2947 struct gl_shader_program
2948 {
2949 GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */
2950 GLuint Name; /**< aka handle or ID */
2951 GLchar *Label; /**< GL_KHR_debug */
2952 GLint RefCount; /**< Reference count */
2953 GLboolean DeletePending;
2954
2955 /**
2956 * Is the application intending to glGetProgramBinary this program?
2957 *
2958 * BinaryRetrievableHint is the currently active hint that gets set
2959 * during initialization and after linking and BinaryRetrievableHintPending
2960 * is the hint set by the user to be active when program is linked next time.
2961 */
2962 GLboolean BinaryRetrievableHint;
2963 GLboolean BinaryRetrievableHintPending;
2964
2965 /**
2966 * Indicates whether program can be bound for individual pipeline stages
2967 * using UseProgramStages after it is next linked.
2968 */
2969 GLboolean SeparateShader;
2970
2971 GLuint NumShaders; /**< number of attached shaders */
2972 struct gl_shader **Shaders; /**< List of attached the shaders */
2973
2974 /**
2975 * User-defined attribute bindings
2976 *
2977 * These are set via \c glBindAttribLocation and are used to direct the
2978 * GLSL linker. These are \b not the values used in the compiled shader,
2979 * and they are \b not the values returned by \c glGetAttribLocation.
2980 */
2981 struct string_to_uint_map *AttributeBindings;
2982
2983 /**
2984 * User-defined fragment data bindings
2985 *
2986 * These are set via \c glBindFragDataLocation and are used to direct the
2987 * GLSL linker. These are \b not the values used in the compiled shader,
2988 * and they are \b not the values returned by \c glGetFragDataLocation.
2989 */
2990 struct string_to_uint_map *FragDataBindings;
2991 struct string_to_uint_map *FragDataIndexBindings;
2992
2993 /**
2994 * Transform feedback varyings last specified by
2995 * glTransformFeedbackVaryings().
2996 *
2997 * For the current set of transform feedback varyings used for transform
2998 * feedback output, see LinkedTransformFeedback.
2999 */
3000 struct {
3001 GLenum16 BufferMode;
3002 /** Global xfb_stride out qualifier if any */
3003 GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
3004 GLuint NumVarying;
3005 GLchar **VaryingNames; /**< Array [NumVarying] of char * */
3006 } TransformFeedback;
3007
3008 struct gl_program *last_vert_prog;
3009
3010 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3011 enum gl_frag_depth_layout FragDepthLayout;
3012
3013 /**
3014 * Geometry shader state - copied into gl_program by
3015 * _mesa_copy_linked_program_data().
3016 */
3017 struct {
3018 GLint VerticesIn;
3019
3020 bool UsesEndPrimitive;
3021 bool UsesStreams;
3022 } Geom;
3023
3024 /**
3025 * Compute shader state - copied into gl_program by
3026 * _mesa_copy_linked_program_data().
3027 */
3028 struct {
3029 /**
3030 * Size of shared variables accessed by the compute shader.
3031 */
3032 unsigned SharedSize;
3033 } Comp;
3034
3035 /** Data shared by gl_program and gl_shader_program */
3036 struct gl_shader_program_data *data;
3037
3038 /**
3039 * Mapping from GL uniform locations returned by \c glUniformLocation to
3040 * UniformStorage entries. Arrays will have multiple contiguous slots
3041 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3042 */
3043 unsigned NumUniformRemapTable;
3044 struct gl_uniform_storage **UniformRemapTable;
3045
3046 /**
3047 * Sometimes there are empty slots left over in UniformRemapTable after we
3048 * allocate slots to explicit locations. This list stores the blocks of
3049 * continuous empty slots inside UniformRemapTable.
3050 */
3051 struct exec_list EmptyUniformLocations;
3052
3053 /**
3054 * Total number of explicit uniform location including inactive uniforms.
3055 */
3056 unsigned NumExplicitUniformLocations;
3057
3058 /**
3059 * Map of active uniform names to locations
3060 *
3061 * Maps any active uniform that is not an array element to a location.
3062 * Each active uniform, including individual structure members will appear
3063 * in this map. This roughly corresponds to the set of names that would be
3064 * enumerated by \c glGetActiveUniform.
3065 */
3066 struct string_to_uint_map *UniformHash;
3067
3068 GLboolean SamplersValidated; /**< Samplers validated against texture units? */
3069
3070 bool IsES; /**< True if this program uses GLSL ES */
3071
3072 /**
3073 * Per-stage shaders resulting from the first stage of linking.
3074 *
3075 * Set of linked shaders for this program. The array is accessed using the
3076 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3077 * \c NULL.
3078 */
3079 struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
3080
3081 /**
3082 * True if any of the fragment shaders attached to this program use:
3083 * #extension ARB_fragment_coord_conventions: enable
3084 */
3085 GLboolean ARB_fragment_coord_conventions_enable;
3086 };
3087
3088
3089 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3090 #define GLSL_LOG 0x2 /**< Write shaders to files */
3091 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3092 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3093 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3094 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3095 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3096 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3097 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3098 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3099
3100
3101 /**
3102 * Context state for GLSL vertex/fragment shaders.
3103 * Extended to support pipeline object
3104 */
3105 struct gl_pipeline_object
3106 {
3107 /** Name of the pipeline object as received from glGenProgramPipelines.
3108 * It would be 0 for shaders without separate shader objects.
3109 */
3110 GLuint Name;
3111
3112 GLint RefCount;
3113
3114 GLchar *Label; /**< GL_KHR_debug */
3115
3116 /**
3117 * Programs used for rendering
3118 *
3119 * There is a separate program set for each shader stage.
3120 */
3121 struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
3122
3123 struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
3124
3125 /**
3126 * Program used by glUniform calls.
3127 *
3128 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3129 */
3130 struct gl_shader_program *ActiveProgram;
3131
3132 GLbitfield Flags; /**< Mask of GLSL_x flags */
3133 GLboolean EverBound; /**< Has the pipeline object been created */
3134 GLboolean Validated; /**< Pipeline Validation status */
3135
3136 GLchar *InfoLog;
3137 };
3138
3139 /**
3140 * Context state for GLSL pipeline shaders.
3141 */
3142 struct gl_pipeline_shader_state
3143 {
3144 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3145 struct gl_pipeline_object *Current;
3146
3147 /** Default Object to ensure that _Shader is never NULL */
3148 struct gl_pipeline_object *Default;
3149
3150 /** Pipeline objects */
3151 struct _mesa_HashTable *Objects;
3152 };
3153
3154 /**
3155 * Compiler options for a single GLSL shaders type
3156 */
3157 struct gl_shader_compiler_options
3158 {
3159 /** Driver-selectable options: */
3160 GLboolean EmitNoLoops;
3161 GLboolean EmitNoCont; /**< Emit CONT opcode? */
3162 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
3163 GLboolean EmitNoPow; /**< Emit POW opcodes? */
3164 GLboolean EmitNoSat; /**< Emit SAT opcodes? */
3165 GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
3166 * gl_CullDistance together from
3167 * float[8] to vec4[2]
3168 **/
3169
3170 /**
3171 * \name Forms of indirect addressing the driver cannot do.
3172 */
3173 /*@{*/
3174 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
3175 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
3176 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
3177 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
3178 GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
3179 /*@}*/
3180
3181 GLuint MaxIfDepth; /**< Maximum nested IF blocks */
3182 GLuint MaxUnrollIterations;
3183
3184 /**
3185 * Optimize code for array of structures backends.
3186 *
3187 * This is a proxy for:
3188 * - preferring DP4 instructions (rather than MUL/MAD) for
3189 * matrix * vector operations, such as position transformation.
3190 */
3191 GLboolean OptimizeForAOS;
3192
3193 /** Lower UBO and SSBO access to intrinsics. */
3194 GLboolean LowerBufferInterfaceBlocks;
3195
3196 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3197 GLboolean ClampBlockIndicesToArrayBounds;
3198
3199 const struct nir_shader_compiler_options *NirOptions;
3200 };
3201
3202
3203 /**
3204 * Occlusion/timer query object.
3205 */
3206 struct gl_query_object
3207 {
3208 GLenum16 Target; /**< The query target, when active */
3209 GLuint Id; /**< hash table ID/name */
3210 GLchar *Label; /**< GL_KHR_debug */
3211 GLuint64EXT Result; /**< the counter */
3212 GLboolean Active; /**< inside Begin/EndQuery */
3213 GLboolean Ready; /**< result is ready? */
3214 GLboolean EverBound;/**< has query object ever been bound */
3215 GLuint Stream; /**< The stream */
3216 };
3217
3218
3219 /**
3220 * Context state for query objects.
3221 */
3222 struct gl_query_state
3223 {
3224 struct _mesa_HashTable *QueryObjects;
3225 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
3226 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
3227
3228 /** GL_NV_conditional_render */
3229 struct gl_query_object *CondRenderQuery;
3230
3231 /** GL_EXT_transform_feedback */
3232 struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
3233 struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
3234
3235 /** GL_ARB_transform_feedback_overflow_query */
3236 struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS];
3237 struct gl_query_object *TransformFeedbackOverflowAny;
3238
3239 /** GL_ARB_timer_query */
3240 struct gl_query_object *TimeElapsed;
3241
3242 /** GL_ARB_pipeline_statistics_query */
3243 struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
3244
3245 GLenum16 CondRenderMode;
3246 };
3247
3248
3249 /** Sync object state */
3250 struct gl_sync_object
3251 {
3252 GLuint Name; /**< Fence name */
3253 GLint RefCount; /**< Reference count */
3254 GLchar *Label; /**< GL_KHR_debug */
3255 GLboolean DeletePending; /**< Object was deleted while there were still
3256 * live references (e.g., sync not yet finished)
3257 */
3258 GLenum16 SyncCondition;
3259 GLbitfield Flags; /**< Flags passed to glFenceSync */
3260 GLuint StatusFlag:1; /**< Has the sync object been signaled? */
3261 };
3262
3263
3264 /**
3265 * State which can be shared by multiple contexts:
3266 */
3267 struct gl_shared_state
3268 {
3269 simple_mtx_t Mutex; /**< for thread safety */
3270 GLint RefCount; /**< Reference count */
3271 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
3272 struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */
3273 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
3274
3275 /** Default texture objects (shared by all texture units) */
3276 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
3277
3278 /** Fallback texture used when a bound texture is incomplete */
3279 struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
3280
3281 /**
3282 * \name Thread safety and statechange notification for texture
3283 * objects.
3284 *
3285 * \todo Improve the granularity of locking.
3286 */
3287 /*@{*/
3288 mtx_t TexMutex; /**< texobj thread safety */
3289 GLuint TextureStateStamp; /**< state notification for shared tex */
3290 /*@}*/
3291
3292 /** Default buffer object for vertex arrays that aren't in VBOs */
3293 struct gl_buffer_object *NullBufferObj;
3294
3295 /**
3296 * \name Vertex/geometry/fragment programs
3297 */
3298 /*@{*/
3299 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
3300 struct gl_program *DefaultVertexProgram;
3301 struct gl_program *DefaultFragmentProgram;
3302 /*@}*/
3303
3304 /* GL_ATI_fragment_shader */
3305 struct _mesa_HashTable *ATIShaders;
3306 struct ati_fragment_shader *DefaultFragmentShader;
3307
3308 struct _mesa_HashTable *BufferObjects;
3309
3310 /** Table of both gl_shader and gl_shader_program objects */
3311 struct _mesa_HashTable *ShaderObjects;
3312
3313 /* GL_EXT_framebuffer_object */
3314 struct _mesa_HashTable *RenderBuffers;
3315 struct _mesa_HashTable *FrameBuffers;
3316
3317 /* GL_ARB_sync */
3318 struct set *SyncObjects;
3319
3320 /** GL_ARB_sampler_objects */
3321 struct _mesa_HashTable *SamplerObjects;
3322
3323 /* GL_ARB_bindless_texture */
3324 struct hash_table_u64 *TextureHandles;
3325 struct hash_table_u64 *ImageHandles;
3326 mtx_t HandlesMutex; /**< For texture/image handles safety */
3327
3328 /**
3329 * Some context in this share group was affected by a GPU reset
3330 *
3331 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3332 * been affected by a GPU reset must also return
3333 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3334 *
3335 * Once this field becomes true, it is never reset to false.
3336 */
3337 bool ShareGroupReset;
3338
3339 /** EXT_external_objects */
3340 struct _mesa_HashTable *MemoryObjects;
3341
3342 /** EXT_semaphore */
3343 struct _mesa_HashTable *SemaphoreObjects;
3344
3345 /**
3346 * Some context in this share group was affected by a disjoint
3347 * operation. This operation can be anything that has effects on
3348 * values of timer queries in such manner that they become invalid for
3349 * performance metrics. As example gpu reset, counter overflow or gpu
3350 * frequency changes.
3351 */
3352 bool DisjointOperation;
3353 };
3354
3355
3356
3357 /**
3358 * Renderbuffers represent drawing surfaces such as color, depth and/or
3359 * stencil. A framebuffer object has a set of renderbuffers.
3360 * Drivers will typically derive subclasses of this type.
3361 */
3362 struct gl_renderbuffer
3363 {
3364 simple_mtx_t Mutex; /**< for thread safety */
3365 GLuint ClassID; /**< Useful for drivers */
3366 GLuint Name;
3367 GLchar *Label; /**< GL_KHR_debug */
3368 GLint RefCount;
3369 GLuint Width, Height;
3370 GLuint Depth;
3371 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
3372 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
3373 /**
3374 * True for renderbuffers that wrap textures, giving the driver a chance to
3375 * flush render caches through the FinishRenderTexture hook.
3376 *
3377 * Drivers may also set this on renderbuffers other than those generated by
3378 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3379 * called without a rb->TexImage.
3380 */
3381 GLboolean NeedsFinishRenderTexture;
3382 GLubyte NumSamples; /**< zero means not multisampled */
3383 GLubyte NumStorageSamples; /**< for AMD_framebuffer_multisample_advanced */
3384 GLenum16 InternalFormat; /**< The user-specified format */
3385 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3386 GL_STENCIL_INDEX. */
3387 mesa_format Format; /**< The actual renderbuffer memory format */
3388 /**
3389 * Pointer to the texture image if this renderbuffer wraps a texture,
3390 * otherwise NULL.
3391 *
3392 * Note that the reference on the gl_texture_object containing this
3393 * TexImage is held by the gl_renderbuffer_attachment.
3394 */
3395 struct gl_texture_image *TexImage;
3396
3397 /** Delete this renderbuffer */
3398 void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
3399
3400 /** Allocate new storage for this renderbuffer */
3401 GLboolean (*AllocStorage)(struct gl_context *ctx,
3402 struct gl_renderbuffer *rb,
3403 GLenum internalFormat,
3404 GLuint width, GLuint height);
3405 };
3406
3407
3408 /**
3409 * A renderbuffer attachment points to either a texture object (and specifies
3410 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3411 */
3412 struct gl_renderbuffer_attachment
3413 {
3414 GLenum16 Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3415 GLboolean Complete;
3416
3417 /**
3418 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3419 * application supplied renderbuffer object.
3420 */
3421 struct gl_renderbuffer *Renderbuffer;
3422
3423 /**
3424 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3425 * supplied texture object.
3426 */
3427 struct gl_texture_object *Texture;
3428 GLuint TextureLevel; /**< Attached mipmap level. */
3429 GLsizei NumSamples; /**< from FramebufferTexture2DMultisampleEXT */
3430 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
3431 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
3432 * and 2D array textures */
3433 GLboolean Layered;
3434 };
3435
3436
3437 /**
3438 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3439 * In C++ terms, think of this as a base class from which device drivers
3440 * will make derived classes.
3441 */
3442 struct gl_framebuffer
3443 {
3444 simple_mtx_t Mutex; /**< for thread safety */
3445 /**
3446 * If zero, this is a window system framebuffer. If non-zero, this
3447 * is a FBO framebuffer; note that for some devices (i.e. those with
3448 * a natural pixel coordinate system for FBOs that differs from the
3449 * OpenGL/Mesa coordinate system), this means that the viewport,
3450 * polygon face orientation, and polygon stipple will have to be inverted.
3451 */
3452 GLuint Name;
3453 GLint RefCount;
3454
3455 GLchar *Label; /**< GL_KHR_debug */
3456
3457 GLboolean DeletePending;
3458
3459 /**
3460 * The framebuffer's visual. Immutable if this is a window system buffer.
3461 * Computed from attachments if user-made FBO.
3462 */
3463 struct gl_config Visual;
3464
3465 /**
3466 * Size of frame buffer in pixels. If there are no attachments, then both
3467 * of these are 0.
3468 */
3469 GLuint Width, Height;
3470
3471 /**
3472 * In the case that the framebuffer has no attachment (i.e.
3473 * GL_ARB_framebuffer_no_attachments) then the geometry of
3474 * the framebuffer is specified by the default values.
3475 */
3476 struct {
3477 GLuint Width, Height, Layers, NumSamples;
3478 GLboolean FixedSampleLocations;
3479 /* Derived from NumSamples by the driver so that it can choose a valid
3480 * value for the hardware.
3481 */
3482 GLuint _NumSamples;
3483 } DefaultGeometry;
3484
3485 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3486 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3487 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3488 */
3489 /*@{*/
3490 GLint _Xmin, _Xmax;
3491 GLint _Ymin, _Ymax;
3492 /*@}*/
3493
3494 /** \name Derived Z buffer stuff */
3495 /*@{*/
3496 GLuint _DepthMax; /**< Max depth buffer value */
3497 GLfloat _DepthMaxF; /**< Float max depth buffer value */
3498 GLfloat _MRD; /**< minimum resolvable difference in Z values */
3499 /*@}*/
3500
3501 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3502 GLenum16 _Status;
3503
3504 /** Whether one of Attachment has Type != GL_NONE
3505 * NOTE: the values for Width and Height are set to 0 in case of having
3506 * no attachments, a backend driver supporting the extension
3507 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3508 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3509 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3510 * _Ymax do NOT take into account _HasAttachments being false). To get the
3511 * geometry of the framebuffer, the helper functions
3512 * _mesa_geometric_width(),
3513 * _mesa_geometric_height(),
3514 * _mesa_geometric_samples() and
3515 * _mesa_geometric_layers()
3516 * are available that check _HasAttachments.
3517 */
3518 bool _HasAttachments;
3519
3520 GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
3521 GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */
3522 GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */
3523
3524 /* ARB_color_buffer_float */
3525 GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
3526 GLboolean _HasSNormOrFloatColorBuffer;
3527
3528 /**
3529 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3530 * is not layered. For cube maps and cube map arrays, each cube face
3531 * counts as a layer. As the case for Width, Height a backend driver
3532 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3533 * in the case that _HasAttachments is false
3534 */
3535 GLuint MaxNumLayers;
3536
3537 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3538 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
3539
3540 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3541 * attribute group and GL_PIXEL attribute group, respectively.
3542 */
3543 GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS];
3544 GLenum16 ColorReadBuffer;
3545
3546 /* GL_ARB_sample_locations */
3547 GLfloat *SampleLocationTable; /**< If NULL, no table has been specified */
3548 GLboolean ProgrammableSampleLocations;
3549 GLboolean SampleLocationPixelGrid;
3550
3551 /** Computed from ColorDraw/ReadBuffer above */
3552 GLuint _NumColorDrawBuffers;
3553 gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
3554 gl_buffer_index _ColorReadBufferIndex;
3555 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
3556 struct gl_renderbuffer *_ColorReadBuffer;
3557
3558 /* GL_MESA_framebuffer_flip_y */
3559 bool FlipY;
3560
3561 /** Delete this framebuffer */
3562 void (*Delete)(struct gl_framebuffer *fb);
3563 };
3564
3565
3566 /**
3567 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3568 */
3569 struct gl_precision
3570 {
3571 GLushort RangeMin; /**< min value exponent */
3572 GLushort RangeMax; /**< max value exponent */
3573 GLushort Precision; /**< number of mantissa bits */
3574 };
3575
3576
3577 /**
3578 * Limits for vertex, geometry and fragment programs/shaders.
3579 */
3580 struct gl_program_constants
3581 {
3582 /* logical limits */
3583 GLuint MaxInstructions;
3584 GLuint MaxAluInstructions;
3585 GLuint MaxTexInstructions;
3586 GLuint MaxTexIndirections;
3587 GLuint MaxAttribs;
3588 GLuint MaxTemps;
3589 GLuint MaxAddressRegs;
3590 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3591 GLuint MaxParameters;
3592 GLuint MaxLocalParams;
3593 GLuint MaxEnvParams;
3594 /* native/hardware limits */
3595 GLuint MaxNativeInstructions;
3596 GLuint MaxNativeAluInstructions;
3597 GLuint MaxNativeTexInstructions;
3598 GLuint MaxNativeTexIndirections;
3599 GLuint MaxNativeAttribs;
3600 GLuint MaxNativeTemps;
3601 GLuint MaxNativeAddressRegs;
3602 GLuint MaxNativeParameters;
3603 /* For shaders */
3604 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
3605
3606 /**
3607 * \name Per-stage input / output limits
3608 *
3609 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3610 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3611 * ES). This is stored as \c gl_constants::MaxVarying.
3612 *
3613 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3614 * variables. Each stage as a certain number of outputs that it can feed
3615 * to the next stage and a certain number inputs that it can consume from
3616 * the previous stage.
3617 *
3618 * Vertex shader inputs do not participate this in this accounting.
3619 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3620 *
3621 * Fragment shader outputs do not participate this in this accounting.
3622 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3623 */
3624 /*@{*/
3625 GLuint MaxInputComponents;
3626 GLuint MaxOutputComponents;
3627 /*@}*/
3628
3629 /* ES 2.0 and GL_ARB_ES2_compatibility */
3630 struct gl_precision LowFloat, MediumFloat, HighFloat;
3631 struct gl_precision LowInt, MediumInt, HighInt;
3632 /* GL_ARB_uniform_buffer_object */
3633 GLuint MaxUniformBlocks;
3634 uint64_t MaxCombinedUniformComponents;
3635 GLuint MaxTextureImageUnits;
3636
3637 /* GL_ARB_shader_atomic_counters */
3638 GLuint MaxAtomicBuffers;
3639 GLuint MaxAtomicCounters;
3640
3641 /* GL_ARB_shader_image_load_store */
3642 GLuint MaxImageUniforms;
3643
3644 /* GL_ARB_shader_storage_buffer_object */
3645 GLuint MaxShaderStorageBlocks;
3646 };
3647
3648 /**
3649 * Constants which may be overridden by device driver during context creation
3650 * but are never changed after that.
3651 */
3652 struct gl_constants
3653 {
3654 GLuint MaxTextureMbytes; /**< Max memory per image, in MB */
3655 GLuint MaxTextureSize; /**< Max 1D/2D texture size, in pixels*/
3656 GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
3657 GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
3658 GLuint MaxArrayTextureLayers; /**< Max layers in array textures */
3659 GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */
3660 GLuint MaxTextureCoordUnits;
3661 GLuint MaxCombinedTextureImageUnits;
3662 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3663 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
3664 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
3665 GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
3666
3667 GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
3668
3669 GLuint MaxArrayLockSize;
3670
3671 GLint SubPixelBits;
3672
3673 GLfloat MinPointSize, MaxPointSize; /**< aliased */
3674 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
3675 GLfloat PointSizeGranularity;
3676 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
3677 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
3678 GLfloat LineWidthGranularity;
3679
3680 GLuint MaxClipPlanes;
3681 GLuint MaxLights;
3682 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
3683 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
3684
3685 GLuint MaxViewportWidth, MaxViewportHeight;
3686 GLuint MaxViewports; /**< GL_ARB_viewport_array */
3687 GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
3688 struct {
3689 GLfloat Min;
3690 GLfloat Max;
3691 } ViewportBounds; /**< GL_ARB_viewport_array */
3692 GLuint MaxWindowRectangles; /**< GL_EXT_window_rectangles */
3693
3694 struct gl_program_constants Program[MESA_SHADER_STAGES];
3695 GLuint MaxProgramMatrices;
3696 GLuint MaxProgramMatrixStackDepth;
3697
3698 struct {
3699 GLuint SamplesPassed;
3700 GLuint TimeElapsed;
3701 GLuint Timestamp;
3702 GLuint PrimitivesGenerated;
3703 GLuint PrimitivesWritten;
3704 GLuint VerticesSubmitted;
3705 GLuint PrimitivesSubmitted;
3706 GLuint VsInvocations;
3707 GLuint TessPatches;
3708 GLuint TessInvocations;
3709 GLuint GsInvocations;
3710 GLuint GsPrimitives;
3711 GLuint FsInvocations;
3712 GLuint ComputeInvocations;
3713 GLuint ClInPrimitives;
3714 GLuint ClOutPrimitives;
3715 } QueryCounterBits;
3716
3717 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
3718
3719 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
3720 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
3721 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
3722
3723 /**
3724 * GL_ARB_framebuffer_no_attachments
3725 */
3726 GLuint MaxFramebufferWidth;
3727 GLuint MaxFramebufferHeight;
3728 GLuint MaxFramebufferLayers;
3729 GLuint MaxFramebufferSamples;
3730
3731 /** Number of varying vectors between any two shader stages. */
3732 GLuint MaxVarying;
3733
3734 /** @{
3735 * GL_ARB_uniform_buffer_object
3736 */
3737 GLuint MaxCombinedUniformBlocks;
3738 GLuint MaxUniformBufferBindings;
3739 GLuint MaxUniformBlockSize;
3740 GLuint UniformBufferOffsetAlignment;
3741 /** @} */
3742
3743 /** @{
3744 * GL_ARB_shader_storage_buffer_object
3745 */
3746 GLuint MaxCombinedShaderStorageBlocks;
3747 GLuint MaxShaderStorageBufferBindings;
3748 GLuint MaxShaderStorageBlockSize;
3749 GLuint ShaderStorageBufferOffsetAlignment;
3750 /** @} */
3751
3752 /**
3753 * GL_ARB_explicit_uniform_location
3754 */
3755 GLuint MaxUserAssignableUniformLocations;
3756
3757 /** geometry shader */
3758 GLuint MaxGeometryOutputVertices;
3759 GLuint MaxGeometryTotalOutputComponents;
3760 GLuint MaxGeometryShaderInvocations;
3761
3762 GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3763 GLuint GLSLVersionCompat; /**< Desktop compat GLSL version supported */
3764
3765 /**
3766 * Changes default GLSL extension behavior from "error" to "warn". It's out
3767 * of spec, but it can make some apps work that otherwise wouldn't.
3768 */
3769 GLboolean ForceGLSLExtensionsWarn;
3770
3771 /**
3772 * If non-zero, forces GLSL shaders to behave as if they began
3773 * with "#version ForceGLSLVersion".
3774 */
3775 GLuint ForceGLSLVersion;
3776
3777 /**
3778 * Allow GLSL #extension directives in the middle of shaders.
3779 */
3780 GLboolean AllowGLSLExtensionDirectiveMidShader;
3781
3782 /**
3783 * Allow builtins as part of constant expressions. This was not allowed
3784 * until GLSL 1.20 this allows it everywhere.
3785 */
3786 GLboolean AllowGLSLBuiltinConstantExpression;
3787
3788 /**
3789 * Allow some relaxation of GLSL ES shader restrictions. This encompasses
3790 * a number of relaxations to the ES shader rules.
3791 */
3792 GLboolean AllowGLSLRelaxedES;
3793
3794 /**
3795 * Allow GLSL built-in variables to be redeclared verbatim
3796 */
3797 GLboolean AllowGLSLBuiltinVariableRedeclaration;
3798
3799 /**
3800 * Allow GLSL interpolation qualifier mismatch across shader stages.
3801 */
3802 GLboolean AllowGLSLCrossStageInterpolationMismatch;
3803
3804 /**
3805 * Allow creating a higher compat profile (version 3.1+) for apps that
3806 * request it. Be careful when adding that driconf option because some
3807 * features are unimplemented and might not work correctly.
3808 */
3809 GLboolean AllowHigherCompatVersion;
3810
3811 /**
3812 * Allow layout qualifiers on function parameters.
3813 */
3814 GLboolean AllowLayoutQualifiersOnFunctionParameters;
3815
3816 /**
3817 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3818 * D3D9 when apps rely on this behaviour.
3819 */
3820 GLboolean ForceGLSLAbsSqrt;
3821
3822 /**
3823 * Force uninitialized variables to default to zero.
3824 */
3825 GLboolean GLSLZeroInit;
3826
3827 /**
3828 * Does the driver support real 32-bit integers? (Otherwise, integers are
3829 * simulated via floats.)
3830 */
3831 GLboolean NativeIntegers;
3832
3833 /**
3834 * Does VertexID count from zero or from base vertex?
3835 *
3836 * \note
3837 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3838 * ignored and need not be set.
3839 */
3840 bool VertexID_is_zero_based;
3841
3842 /**
3843 * If the driver supports real 32-bit integers, what integer value should be
3844 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3845 */
3846 GLuint UniformBooleanTrue;
3847
3848 /**
3849 * Maximum amount of time, measured in nanseconds, that the server can wait.
3850 */
3851 GLuint64 MaxServerWaitTimeout;
3852
3853 /** GL_EXT_provoking_vertex */
3854 GLboolean QuadsFollowProvokingVertexConvention;
3855
3856 /** GL_ARB_viewport_array */
3857 GLenum16 LayerAndVPIndexProvokingVertex;
3858
3859 /** OpenGL version 3.0 */
3860 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3861
3862 /** OpenGL version 3.2 */
3863 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
3864
3865 /** OpenGL version 4.4 */
3866 GLuint MaxVertexAttribStride;
3867
3868 /** GL_EXT_transform_feedback */
3869 GLuint MaxTransformFeedbackBuffers;
3870 GLuint MaxTransformFeedbackSeparateComponents;
3871 GLuint MaxTransformFeedbackInterleavedComponents;
3872 GLuint MaxVertexStreams;
3873
3874 /** GL_EXT_gpu_shader4 */
3875 GLint MinProgramTexelOffset, MaxProgramTexelOffset;
3876
3877 /** GL_ARB_texture_gather */
3878 GLuint MinProgramTextureGatherOffset;
3879 GLuint MaxProgramTextureGatherOffset;
3880 GLuint MaxProgramTextureGatherComponents;
3881
3882 /* GL_ARB_robustness */
3883 GLenum16 ResetStrategy;
3884
3885 /* GL_KHR_robustness */
3886 GLboolean RobustAccess;
3887
3888 /* GL_ARB_blend_func_extended */
3889 GLuint MaxDualSourceDrawBuffers;
3890
3891 /**
3892 * Whether the implementation strips out and ignores texture borders.
3893 *
3894 * Many GPU hardware implementations don't support rendering with texture
3895 * borders and mipmapped textures. (Note: not static border color, but the
3896 * old 1-pixel border around each edge). Implementations then have to do
3897 * slow fallbacks to be correct, or just ignore the border and be fast but
3898 * wrong. Setting the flag strips the border off of TexImage calls,
3899 * providing "fast but wrong" at significantly reduced driver complexity.
3900 *
3901 * Texture borders are deprecated in GL 3.0.
3902 **/
3903 GLboolean StripTextureBorder;
3904
3905 /**
3906 * For drivers which can do a better job at eliminating unused uniforms
3907 * than the GLSL compiler.
3908 *
3909 * XXX Remove these as soon as a better solution is available.
3910 */
3911 GLboolean GLSLSkipStrictMaxUniformLimitCheck;
3912
3913 /**
3914 * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
3915 * are system values.
3916 **/
3917 bool GLSLFragCoordIsSysVal;
3918 bool GLSLPointCoordIsSysVal;
3919 bool GLSLFrontFacingIsSysVal;
3920
3921 /**
3922 * Run the minimum amount of GLSL optimizations to be able to link
3923 * shaders optimally (eliminate dead varyings and uniforms) and just do
3924 * all the necessary lowering.
3925 */
3926 bool GLSLOptimizeConservatively;
3927
3928 /**
3929 * Whether to call lower_const_arrays_to_uniforms() during linking.
3930 */
3931 bool GLSLLowerConstArrays;
3932
3933 /**
3934 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3935 * (otherwise, they're system values).
3936 */
3937 bool GLSLTessLevelsAsInputs;
3938
3939 /**
3940 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3941 * than passing the transform feedback object to the drawing function.
3942 */
3943 GLboolean AlwaysUseGetTransformFeedbackVertexCount;
3944
3945 /** GL_ARB_map_buffer_alignment */
3946 GLuint MinMapBufferAlignment;
3947
3948 /**
3949 * Disable varying packing. This is out of spec, but potentially useful
3950 * for older platforms that supports a limited number of texture
3951 * indirections--on these platforms, unpacking the varyings in the fragment
3952 * shader increases the number of texture indirections by 1, which might
3953 * make some shaders not executable at all.
3954 *
3955 * Drivers that support transform feedback must set this value to GL_FALSE.
3956 */
3957 GLboolean DisableVaryingPacking;
3958
3959 /**
3960 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3961 * layout is set as shared (the default) or packed. However most Mesa drivers
3962 * just use STD140 for these layouts. This flag allows drivers to use STD430
3963 * for packed and shared layouts which allows arrays to be packed more
3964 * tightly.
3965 */
3966 bool UseSTD430AsDefaultPacking;
3967
3968 /**
3969 * Should meaningful names be generated for compiler temporary variables?
3970 *
3971 * Generally, it is not useful to have the compiler generate "meaningful"
3972 * names for temporary variables that it creates. This can, however, be a
3973 * useful debugging aid. In Mesa debug builds or release builds when
3974 * MESA_GLSL is set at run-time, meaningful names will be generated.
3975 * Drivers can also force names to be generated by setting this field.
3976 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
3977 * vertex shader assembly) is set at run-time.
3978 */
3979 bool GenerateTemporaryNames;
3980
3981 /*
3982 * Maximum value supported for an index in DrawElements and friends.
3983 *
3984 * This must be at least (1ull<<24)-1. The default value is
3985 * (1ull<<32)-1.
3986 *
3987 * \since ES 3.0 or GL_ARB_ES3_compatibility
3988 * \sa _mesa_init_constants
3989 */
3990 GLuint64 MaxElementIndex;
3991
3992 /**
3993 * Disable interpretation of line continuations (lines ending with a
3994 * backslash character ('\') in GLSL source.
3995 */
3996 GLboolean DisableGLSLLineContinuations;
3997
3998 /** GL_ARB_texture_multisample */
3999 GLint MaxColorTextureSamples;
4000 GLint MaxDepthTextureSamples;
4001 GLint MaxIntegerSamples;
4002
4003 /** GL_AMD_framebuffer_multisample_advanced */
4004 GLint MaxColorFramebufferSamples;
4005 GLint MaxColorFramebufferStorageSamples;
4006 GLint MaxDepthStencilFramebufferSamples;
4007
4008 /* An array of supported MSAA modes allowing different sample
4009 * counts per attachment type.
4010 */
4011 struct {
4012 GLint NumColorSamples;
4013 GLint NumColorStorageSamples;
4014 GLint NumDepthStencilSamples;
4015 } SupportedMultisampleModes[40];
4016 GLint NumSupportedMultisampleModes;
4017
4018 /**
4019 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
4020 * samples are laid out in a rectangular grid roughly corresponding to
4021 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
4022 * are used to map indices of rectangular grid to sample numbers within
4023 * a pixel. This mapping of indices to sample numbers must be initialized
4024 * by the driver for the target hardware. For example, if we have the 8X
4025 * MSAA sample number layout (sample positions) for XYZ hardware:
4026 *
4027 * sample indices layout sample number layout
4028 * --------- ---------
4029 * | 0 | 1 | | a | b |
4030 * --------- ---------
4031 * | 2 | 3 | | c | d |
4032 * --------- ---------
4033 * | 4 | 5 | | e | f |
4034 * --------- ---------
4035 * | 6 | 7 | | g | h |
4036 * --------- ---------
4037 *
4038 * Where a,b,c,d,e,f,g,h are integers between [0-7].
4039 *
4040 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
4041 * below:
4042 * SampleMap8x = {a, b, c, d, e, f, g, h};
4043 *
4044 * Follow the logic for sample counts 2-8.
4045 *
4046 * For 16x the sample indices layout as a 4x4 grid as follows:
4047 *
4048 * -----------------
4049 * | 0 | 1 | 2 | 3 |
4050 * -----------------
4051 * | 4 | 5 | 6 | 7 |
4052 * -----------------
4053 * | 8 | 9 |10 |11 |
4054 * -----------------
4055 * |12 |13 |14 |15 |
4056 * -----------------
4057 */
4058 uint8_t SampleMap2x[2];
4059 uint8_t SampleMap4x[4];
4060 uint8_t SampleMap8x[8];
4061 uint8_t SampleMap16x[16];
4062
4063 /** GL_ARB_shader_atomic_counters */
4064 GLuint MaxAtomicBufferBindings;
4065 GLuint MaxAtomicBufferSize;
4066 GLuint MaxCombinedAtomicBuffers;
4067 GLuint MaxCombinedAtomicCounters;
4068
4069 /** GL_ARB_vertex_attrib_binding */
4070 GLint MaxVertexAttribRelativeOffset;
4071 GLint MaxVertexAttribBindings;
4072
4073 /* GL_ARB_shader_image_load_store */
4074 GLuint MaxImageUnits;
4075 GLuint MaxCombinedShaderOutputResources;
4076 GLuint MaxImageSamples;
4077 GLuint MaxCombinedImageUniforms;
4078
4079 /** GL_ARB_compute_shader */
4080 GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
4081 GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
4082 GLuint MaxComputeWorkGroupInvocations;
4083 GLuint MaxComputeSharedMemorySize;
4084
4085 /** GL_ARB_compute_variable_group_size */
4086 GLuint MaxComputeVariableGroupSize[3]; /* Array of x, y, z dimensions */
4087 GLuint MaxComputeVariableGroupInvocations;
4088
4089 /** GL_ARB_gpu_shader5 */
4090 GLfloat MinFragmentInterpolationOffset;
4091 GLfloat MaxFragmentInterpolationOffset;
4092
4093 GLboolean FakeSWMSAA;
4094
4095 /** GL_KHR_context_flush_control */
4096 GLenum16 ContextReleaseBehavior;
4097
4098 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
4099
4100 /** GL_ARB_tessellation_shader */
4101 GLuint MaxPatchVertices;
4102 GLuint MaxTessGenLevel;
4103 GLuint MaxTessPatchComponents;
4104 GLuint MaxTessControlTotalOutputComponents;
4105 bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
4106 bool PrimitiveRestartForPatches;
4107 bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
4108 * gl_LocalInvocationIndex based on
4109 * other builtin variables. */
4110
4111 /** GL_OES_primitive_bounding_box */
4112 bool NoPrimitiveBoundingBoxOutput;
4113
4114 /** GL_ARB_sparse_buffer */
4115 GLuint SparseBufferPageSize;
4116
4117 /** Used as an input for sha1 generation in the on-disk shader cache */
4118 unsigned char *dri_config_options_sha1;
4119
4120 /** When drivers are OK with mapped buffers during draw and other calls. */
4121 bool AllowMappedBuffersDuringExecution;
4122
4123 /** GL_ARB_get_program_binary */
4124 GLuint NumProgramBinaryFormats;
4125
4126 /** GL_NV_conservative_raster */
4127 GLuint MaxSubpixelPrecisionBiasBits;
4128
4129 /** GL_NV_conservative_raster_dilate */
4130 GLfloat ConservativeRasterDilateRange[2];
4131 GLfloat ConservativeRasterDilateGranularity;
4132
4133 /** Is the drivers uniform storage packed or padded to 16 bytes. */
4134 bool PackedDriverUniformStorage;
4135
4136 /** Wether or not glBitmap uses red textures rather than alpha */
4137 bool BitmapUsesRed;
4138
4139 /** GL_ARB_gl_spirv */
4140 struct spirv_supported_capabilities SpirVCapabilities;
4141
4142 /** GL_ARB_spirv_extensions */
4143 struct spirv_supported_extensions *SpirVExtensions;
4144
4145 char *VendorOverride;
4146 };
4147
4148
4149 /**
4150 * Enable flag for each OpenGL extension. Different device drivers will
4151 * enable different extensions at runtime.
4152 */
4153 struct gl_extensions
4154 {
4155 GLboolean dummy; /* don't remove this! */
4156 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
4157 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
4158 GLboolean ANGLE_texture_compression_dxt;
4159 GLboolean ARB_ES2_compatibility;
4160 GLboolean ARB_ES3_compatibility;
4161 GLboolean ARB_ES3_1_compatibility;
4162 GLboolean ARB_ES3_2_compatibility;
4163 GLboolean ARB_arrays_of_arrays;
4164 GLboolean ARB_base_instance;
4165 GLboolean ARB_bindless_texture;
4166 GLboolean ARB_blend_func_extended;
4167 GLboolean ARB_buffer_storage;
4168 GLboolean ARB_clear_texture;
4169 GLboolean ARB_clip_control;
4170 GLboolean ARB_color_buffer_float;
4171 GLboolean ARB_compatibility;
4172 GLboolean ARB_compute_shader;
4173 GLboolean ARB_compute_variable_group_size;
4174 GLboolean ARB_conditional_render_inverted;
4175 GLboolean ARB_conservative_depth;
4176 GLboolean ARB_copy_image;
4177 GLboolean ARB_cull_distance;
4178 GLboolean ARB_depth_buffer_float;
4179 GLboolean ARB_depth_clamp;
4180 GLboolean ARB_depth_texture;
4181 GLboolean ARB_derivative_control;
4182 GLboolean ARB_draw_buffers_blend;
4183 GLboolean ARB_draw_elements_base_vertex;
4184 GLboolean ARB_draw_indirect;
4185 GLboolean ARB_draw_instanced;
4186 GLboolean ARB_fragment_coord_conventions;
4187 GLboolean ARB_fragment_layer_viewport;
4188 GLboolean ARB_fragment_program;
4189 GLboolean ARB_fragment_program_shadow;
4190 GLboolean ARB_fragment_shader;
4191 GLboolean ARB_framebuffer_no_attachments;
4192 GLboolean ARB_framebuffer_object;
4193 GLboolean ARB_fragment_shader_interlock;
4194 GLboolean ARB_enhanced_layouts;
4195 GLboolean ARB_explicit_attrib_location;
4196 GLboolean ARB_explicit_uniform_location;
4197 GLboolean ARB_gl_spirv;
4198 GLboolean ARB_gpu_shader5;
4199 GLboolean ARB_gpu_shader_fp64;
4200 GLboolean ARB_gpu_shader_int64;
4201 GLboolean ARB_half_float_vertex;
4202 GLboolean ARB_indirect_parameters;
4203 GLboolean ARB_instanced_arrays;
4204 GLboolean ARB_internalformat_query;
4205 GLboolean ARB_internalformat_query2;
4206 GLboolean ARB_map_buffer_range;
4207 GLboolean ARB_occlusion_query;
4208 GLboolean ARB_occlusion_query2;
4209 GLboolean ARB_pipeline_statistics_query;
4210 GLboolean ARB_point_sprite;
4211 GLboolean ARB_polygon_offset_clamp;
4212 GLboolean ARB_post_depth_coverage;
4213 GLboolean ARB_query_buffer_object;
4214 GLboolean ARB_robust_buffer_access_behavior;
4215 GLboolean ARB_sample_locations;
4216 GLboolean ARB_sample_shading;
4217 GLboolean ARB_seamless_cube_map;
4218 GLboolean ARB_shader_atomic_counter_ops;
4219 GLboolean ARB_shader_atomic_counters;
4220 GLboolean ARB_shader_ballot;
4221 GLboolean ARB_shader_bit_encoding;
4222 GLboolean ARB_shader_clock;
4223 GLboolean ARB_shader_draw_parameters;
4224 GLboolean ARB_shader_group_vote;
4225 GLboolean ARB_shader_image_load_store;
4226 GLboolean ARB_shader_image_size;
4227 GLboolean ARB_shader_precision;
4228 GLboolean ARB_shader_stencil_export;
4229 GLboolean ARB_shader_storage_buffer_object;
4230 GLboolean ARB_shader_texture_image_samples;
4231 GLboolean ARB_shader_texture_lod;
4232 GLboolean ARB_shader_viewport_layer_array;
4233 GLboolean ARB_shading_language_packing;
4234 GLboolean ARB_shading_language_420pack;
4235 GLboolean ARB_shadow;
4236 GLboolean ARB_sparse_buffer;
4237 GLboolean ARB_stencil_texturing;
4238 GLboolean ARB_spirv_extensions;
4239 GLboolean ARB_sync;
4240 GLboolean ARB_tessellation_shader;
4241 GLboolean ARB_texture_border_clamp;
4242 GLboolean ARB_texture_buffer_object;
4243 GLboolean ARB_texture_buffer_object_rgb32;
4244 GLboolean ARB_texture_buffer_range;
4245 GLboolean ARB_texture_compression_bptc;
4246 GLboolean ARB_texture_compression_rgtc;
4247 GLboolean ARB_texture_cube_map;
4248 GLboolean ARB_texture_cube_map_array;
4249 GLboolean ARB_texture_env_combine;
4250 GLboolean ARB_texture_env_crossbar;
4251 GLboolean ARB_texture_env_dot3;
4252 GLboolean ARB_texture_filter_anisotropic;
4253 GLboolean ARB_texture_float;
4254 GLboolean ARB_texture_gather;
4255 GLboolean ARB_texture_mirror_clamp_to_edge;
4256 GLboolean ARB_texture_multisample;
4257 GLboolean ARB_texture_non_power_of_two;
4258 GLboolean ARB_texture_stencil8;
4259 GLboolean ARB_texture_query_levels;
4260 GLboolean ARB_texture_query_lod;
4261 GLboolean ARB_texture_rg;
4262 GLboolean ARB_texture_rgb10_a2ui;
4263 GLboolean ARB_texture_view;
4264 GLboolean ARB_timer_query;
4265 GLboolean ARB_transform_feedback2;
4266 GLboolean ARB_transform_feedback3;
4267 GLboolean ARB_transform_feedback_instanced;
4268 GLboolean ARB_transform_feedback_overflow_query;
4269 GLboolean ARB_uniform_buffer_object;
4270 GLboolean ARB_vertex_attrib_64bit;
4271 GLboolean ARB_vertex_program;
4272 GLboolean ARB_vertex_shader;
4273 GLboolean ARB_vertex_type_10f_11f_11f_rev;
4274 GLboolean ARB_vertex_type_2_10_10_10_rev;
4275 GLboolean ARB_viewport_array;
4276 GLboolean EXT_blend_color;
4277 GLboolean EXT_blend_equation_separate;
4278 GLboolean EXT_blend_func_separate;
4279 GLboolean EXT_blend_minmax;
4280 GLboolean EXT_demote_to_helper_invocation;
4281 GLboolean EXT_depth_bounds_test;
4282 GLboolean EXT_disjoint_timer_query;
4283 GLboolean EXT_draw_buffers2;
4284 GLboolean EXT_float_blend;
4285 GLboolean EXT_framebuffer_multisample;
4286 GLboolean EXT_framebuffer_multisample_blit_scaled;
4287 GLboolean EXT_framebuffer_sRGB;
4288 GLboolean EXT_gpu_program_parameters;
4289 GLboolean EXT_gpu_shader4;
4290 GLboolean EXT_memory_object;
4291 GLboolean EXT_memory_object_fd;
4292 GLboolean EXT_multisampled_render_to_texture;
4293 GLboolean EXT_packed_float;
4294 GLboolean EXT_pixel_buffer_object;
4295 GLboolean EXT_point_parameters;
4296 GLboolean EXT_provoking_vertex;
4297 GLboolean EXT_render_snorm;
4298 GLboolean EXT_semaphore;
4299 GLboolean EXT_semaphore_fd;
4300 GLboolean EXT_shader_image_load_formatted;
4301 GLboolean EXT_shader_image_load_store;
4302 GLboolean EXT_shader_integer_mix;
4303 GLboolean EXT_shader_samples_identical;
4304 GLboolean EXT_sRGB;
4305 GLboolean EXT_stencil_two_side;
4306 GLboolean EXT_texture_array;
4307 GLboolean EXT_texture_buffer_object;
4308 GLboolean EXT_texture_compression_latc;
4309 GLboolean EXT_texture_compression_s3tc;
4310 GLboolean EXT_texture_compression_s3tc_srgb;
4311 GLboolean EXT_texture_env_dot3;
4312 GLboolean EXT_texture_filter_anisotropic;
4313 GLboolean EXT_texture_integer;
4314 GLboolean EXT_texture_mirror_clamp;
4315 GLboolean EXT_texture_shadow_lod;
4316 GLboolean EXT_texture_shared_exponent;
4317 GLboolean EXT_texture_snorm;
4318 GLboolean EXT_texture_sRGB;
4319 GLboolean EXT_texture_sRGB_R8;
4320 GLboolean EXT_texture_sRGB_decode;
4321 GLboolean EXT_texture_swizzle;
4322 GLboolean EXT_texture_type_2_10_10_10_REV;
4323 GLboolean EXT_transform_feedback;
4324 GLboolean EXT_timer_query;
4325 GLboolean EXT_vertex_array_bgra;
4326 GLboolean EXT_window_rectangles;
4327 GLboolean OES_copy_image;
4328 GLboolean OES_primitive_bounding_box;
4329 GLboolean OES_sample_variables;
4330 GLboolean OES_standard_derivatives;
4331 GLboolean OES_texture_buffer;
4332 GLboolean OES_texture_cube_map_array;
4333 GLboolean OES_texture_view;
4334 GLboolean OES_viewport_array;
4335 /* vendor extensions */
4336 GLboolean AMD_compressed_ATC_texture;
4337 GLboolean AMD_framebuffer_multisample_advanced;
4338 GLboolean AMD_depth_clamp_separate;
4339 GLboolean AMD_performance_monitor;
4340 GLboolean AMD_pinned_memory;
4341 GLboolean AMD_seamless_cubemap_per_texture;
4342 GLboolean AMD_vertex_shader_layer;
4343 GLboolean AMD_vertex_shader_viewport_index;
4344 GLboolean ANDROID_extension_pack_es31a;
4345 GLboolean APPLE_object_purgeable;
4346 GLboolean ATI_meminfo;
4347 GLboolean ATI_texture_compression_3dc;
4348 GLboolean ATI_texture_mirror_once;
4349 GLboolean ATI_texture_env_combine3;
4350 GLboolean ATI_fragment_shader;
4351 GLboolean GREMEDY_string_marker;
4352 GLboolean INTEL_conservative_rasterization;
4353 GLboolean INTEL_performance_query;
4354 GLboolean INTEL_shader_atomic_float_minmax;
4355 GLboolean KHR_blend_equation_advanced;
4356 GLboolean KHR_blend_equation_advanced_coherent;
4357 GLboolean KHR_robustness;
4358 GLboolean KHR_texture_compression_astc_hdr;
4359 GLboolean KHR_texture_compression_astc_ldr;
4360 GLboolean KHR_texture_compression_astc_sliced_3d;
4361 GLboolean MESA_framebuffer_flip_y;
4362 GLboolean MESA_tile_raster_order;
4363 GLboolean MESA_pack_invert;
4364 GLboolean EXT_shader_framebuffer_fetch;
4365 GLboolean EXT_shader_framebuffer_fetch_non_coherent;
4366 GLboolean MESA_shader_integer_functions;
4367 GLboolean MESA_ycbcr_texture;
4368 GLboolean NV_compute_shader_derivatives;
4369 GLboolean NV_conditional_render;
4370 GLboolean NV_fill_rectangle;
4371 GLboolean NV_fog_distance;
4372 GLboolean NV_point_sprite;
4373 GLboolean NV_primitive_restart;
4374 GLboolean NV_shader_atomic_float;
4375 GLboolean NV_texture_barrier;
4376 GLboolean NV_texture_env_combine4;
4377 GLboolean NV_texture_rectangle;
4378 GLboolean NV_vdpau_interop;
4379 GLboolean NV_conservative_raster;
4380 GLboolean NV_conservative_raster_dilate;
4381 GLboolean NV_conservative_raster_pre_snap_triangles;
4382 GLboolean NV_conservative_raster_pre_snap;
4383 GLboolean NVX_gpu_memory_info;
4384 GLboolean TDFX_texture_compression_FXT1;
4385 GLboolean OES_EGL_image;
4386 GLboolean OES_draw_texture;
4387 GLboolean OES_depth_texture_cube_map;
4388 GLboolean OES_EGL_image_external;
4389 GLboolean OES_texture_float;
4390 GLboolean OES_texture_float_linear;
4391 GLboolean OES_texture_half_float;
4392 GLboolean OES_texture_half_float_linear;
4393 GLboolean OES_compressed_ETC1_RGB8_texture;
4394 GLboolean OES_geometry_shader;
4395 GLboolean OES_texture_compression_astc;
4396 GLboolean extension_sentinel;
4397 /** The extension string */
4398 const GLubyte *String;
4399 /** Number of supported extensions */
4400 GLuint Count;
4401 /**
4402 * The context version which extension helper functions compare against.
4403 * By default, the value is equal to ctx->Version. This changes to ~0
4404 * while meta is in progress.
4405 */
4406 GLubyte Version;
4407 /**
4408 * Force-enabled, yet unrecognized, extensions.
4409 * See _mesa_one_time_init_extension_overrides()
4410 */
4411 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4412 const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
4413 };
4414
4415
4416 /**
4417 * A stack of matrices (projection, modelview, color, texture, etc).
4418 */
4419 struct gl_matrix_stack
4420 {
4421 GLmatrix *Top; /**< points into Stack */
4422 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
4423 unsigned StackSize; /**< Number of elements in Stack */
4424 GLuint Depth; /**< 0 <= Depth < MaxDepth */
4425 GLuint MaxDepth; /**< size of Stack[] array */
4426 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4427 };
4428
4429
4430 /**
4431 * \name Bits for image transfer operations
4432 * \sa __struct gl_contextRec::ImageTransferState.
4433 */
4434 /*@{*/
4435 #define IMAGE_SCALE_BIAS_BIT 0x1
4436 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4437 #define IMAGE_MAP_COLOR_BIT 0x4
4438 #define IMAGE_CLAMP_BIT 0x800
4439
4440
4441 /** Pixel Transfer ops */
4442 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4443 IMAGE_SHIFT_OFFSET_BIT | \
4444 IMAGE_MAP_COLOR_BIT)
4445
4446
4447 /**
4448 * \name Bits to indicate what state has changed.
4449 */
4450 /*@{*/
4451 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4452 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4453 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4454 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4455 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4456 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4457 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4458 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4459 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4460 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4461 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4462 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4463 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4464 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4465 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4466 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4467 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4468 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4469 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4470 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4471 /* gap */
4472 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4473 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4474 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4475 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4476 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4477 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4478 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4479 /* gap */
4480 #define _NEW_FRAG_CLAMP (1u << 29)
4481 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4482 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4483 #define _NEW_ALL ~0
4484 /*@}*/
4485
4486
4487 /**
4488 * Composite state flags
4489 */
4490 /*@{*/
4491 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4492
4493 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4494 _NEW_TEXTURE_STATE | \
4495 _NEW_POINT | \
4496 _NEW_PROGRAM | \
4497 _NEW_MODELVIEW)
4498
4499 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4500 _NEW_FOG | \
4501 _NEW_PROGRAM)
4502
4503
4504 /*@}*/
4505
4506
4507
4508
4509 /* This has to be included here. */
4510 #include "dd.h"
4511
4512
4513 /** Opaque declaration of display list payload data type */
4514 union gl_dlist_node;
4515
4516
4517 /**
4518 * Per-display list information.
4519 */
4520 struct gl_display_list
4521 {
4522 GLuint Name;
4523 GLbitfield Flags; /**< DLIST_x flags */
4524 GLchar *Label; /**< GL_KHR_debug */
4525 /** The dlist commands are in a linked list of nodes */
4526 union gl_dlist_node *Head;
4527 };
4528
4529
4530 /**
4531 * State used during display list compilation and execution.
4532 */
4533 struct gl_dlist_state
4534 {
4535 struct gl_display_list *CurrentList; /**< List currently being compiled */
4536 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
4537 GLuint CurrentPos; /**< Index into current block of nodes */
4538 GLuint CallDepth; /**< Current recursion calling depth */
4539
4540 GLvertexformat ListVtxfmt;
4541
4542 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
4543 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][8];
4544
4545 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
4546 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
4547
4548 struct {
4549 /* State known to have been set by the currently-compiling display
4550 * list. Used to eliminate some redundant state changes.
4551 */
4552 GLenum16 ShadeModel;
4553 } Current;
4554 };
4555
4556 /**
4557 * Driver-specific state flags.
4558 *
4559 * These are or'd with gl_context::NewDriverState to notify a driver about
4560 * a state change. The driver sets the flags at context creation and
4561 * the meaning of the bits set is opaque to core Mesa.
4562 */
4563 struct gl_driver_flags
4564 {
4565 /** gl_context::Array::_DrawArrays (vertex array state) */
4566 uint64_t NewArray;
4567
4568 /** gl_context::TransformFeedback::CurrentObject */
4569 uint64_t NewTransformFeedback;
4570
4571 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4572 uint64_t NewTransformFeedbackProg;
4573
4574 /** gl_context::RasterDiscard */
4575 uint64_t NewRasterizerDiscard;
4576
4577 /** gl_context::TileRasterOrder* */
4578 uint64_t NewTileRasterOrder;
4579
4580 /**
4581 * gl_context::UniformBufferBindings
4582 * gl_shader_program::UniformBlocks
4583 */
4584 uint64_t NewUniformBuffer;
4585
4586 /**
4587 * gl_context::ShaderStorageBufferBindings
4588 * gl_shader_program::ShaderStorageBlocks
4589 */
4590 uint64_t NewShaderStorageBuffer;
4591
4592 uint64_t NewTextureBuffer;
4593
4594 /**
4595 * gl_context::AtomicBufferBindings
4596 */
4597 uint64_t NewAtomicBuffer;
4598
4599 /**
4600 * gl_context::ImageUnits
4601 */
4602 uint64_t NewImageUnits;
4603
4604 /**
4605 * gl_context::TessCtrlProgram::patch_default_*
4606 */
4607 uint64_t NewDefaultTessLevels;
4608
4609 /**
4610 * gl_context::IntelConservativeRasterization
4611 */
4612 uint64_t NewIntelConservativeRasterization;
4613
4614 /**
4615 * gl_context::NvConservativeRasterization
4616 */
4617 uint64_t NewNvConservativeRasterization;
4618
4619 /**
4620 * gl_context::ConservativeRasterMode/ConservativeRasterDilate
4621 * gl_context::SubpixelPrecisionBias
4622 */
4623 uint64_t NewNvConservativeRasterizationParams;
4624
4625 /**
4626 * gl_context::Scissor::WindowRects
4627 */
4628 uint64_t NewWindowRectangles;
4629
4630 /** gl_context::Color::sRGBEnabled */
4631 uint64_t NewFramebufferSRGB;
4632
4633 /** gl_context::Scissor::EnableFlags */
4634 uint64_t NewScissorTest;
4635
4636 /** gl_context::Scissor::ScissorArray */
4637 uint64_t NewScissorRect;
4638
4639 /** gl_context::Color::Alpha* */
4640 uint64_t NewAlphaTest;
4641
4642 /** gl_context::Color::Blend/Dither */
4643 uint64_t NewBlend;
4644
4645 /** gl_context::Color::BlendColor */
4646 uint64_t NewBlendColor;
4647
4648 /** gl_context::Color::Color/Index */
4649 uint64_t NewColorMask;
4650
4651 /** gl_context::Depth */
4652 uint64_t NewDepth;
4653
4654 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4655 uint64_t NewLogicOp;
4656
4657 /** gl_context::Multisample::Enabled */
4658 uint64_t NewMultisampleEnable;
4659
4660 /** gl_context::Multisample::SampleAlphaTo* */
4661 uint64_t NewSampleAlphaToXEnable;
4662
4663 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4664 uint64_t NewSampleMask;
4665
4666 /** gl_context::Multisample::(Min)SampleShading */
4667 uint64_t NewSampleShading;
4668
4669 /** gl_context::Stencil */
4670 uint64_t NewStencil;
4671
4672 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4673 uint64_t NewClipControl;
4674
4675 /** gl_context::Transform::EyeUserPlane */
4676 uint64_t NewClipPlane;
4677
4678 /** gl_context::Transform::ClipPlanesEnabled */
4679 uint64_t NewClipPlaneEnable;
4680
4681 /** gl_context::Transform::DepthClamp */
4682 uint64_t NewDepthClamp;
4683
4684 /** gl_context::Line */
4685 uint64_t NewLineState;
4686
4687 /** gl_context::Polygon */
4688 uint64_t NewPolygonState;
4689
4690 /** gl_context::PolygonStipple */
4691 uint64_t NewPolygonStipple;
4692
4693 /** gl_context::ViewportArray */
4694 uint64_t NewViewport;
4695
4696 /** Shader constants (uniforms, program parameters, state constants) */
4697 uint64_t NewShaderConstants[MESA_SHADER_STAGES];
4698
4699 /** Programmable sample location state for gl_context::DrawBuffer */
4700 uint64_t NewSampleLocations;
4701 };
4702
4703 struct gl_buffer_binding
4704 {
4705 struct gl_buffer_object *BufferObject;
4706 /** Start of uniform block data in the buffer */
4707 GLintptr Offset;
4708 /** Size of data allowed to be referenced from the buffer (in bytes) */
4709 GLsizeiptr Size;
4710 /**
4711 * glBindBufferBase() indicates that the Size should be ignored and only
4712 * limited by the current size of the BufferObject.
4713 */
4714 GLboolean AutomaticSize;
4715 };
4716
4717 /**
4718 * ARB_shader_image_load_store image unit.
4719 */
4720 struct gl_image_unit
4721 {
4722 /**
4723 * Texture object bound to this unit.
4724 */
4725 struct gl_texture_object *TexObj;
4726
4727 /**
4728 * Level of the texture object bound to this unit.
4729 */
4730 GLubyte Level;
4731
4732 /**
4733 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4734 * GL_FALSE if only some specific layer of the texture is bound.
4735 * \sa Layer
4736 */
4737 GLboolean Layered;
4738
4739 /**
4740 * Layer of the texture object bound to this unit as specified by the
4741 * application.
4742 */
4743 GLushort Layer;
4744
4745 /**
4746 * Layer of the texture object bound to this unit, or zero if
4747 * Layered == false.
4748 */
4749 GLushort _Layer;
4750
4751 /**
4752 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4753 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4754 */
4755 GLenum16 Access;
4756
4757 /**
4758 * GL internal format that determines the interpretation of the
4759 * image memory when shader image operations are performed through
4760 * this unit.
4761 */
4762 GLenum16 Format;
4763
4764 /**
4765 * Mesa format corresponding to \c Format.
4766 */
4767 mesa_format _ActualFormat:16;
4768 };
4769
4770 /**
4771 * Shader subroutines storage
4772 */
4773 struct gl_subroutine_index_binding
4774 {
4775 GLuint NumIndex;
4776 GLuint *IndexPtr;
4777 };
4778
4779 struct gl_texture_handle_object
4780 {
4781 struct gl_texture_object *texObj;
4782 struct gl_sampler_object *sampObj;
4783 GLuint64 handle;
4784 };
4785
4786 struct gl_image_handle_object
4787 {
4788 struct gl_image_unit imgObj;
4789 GLuint64 handle;
4790 };
4791
4792 struct gl_memory_object
4793 {
4794 GLuint Name; /**< hash table ID/name */
4795 GLboolean Immutable; /**< denotes mutability state of parameters */
4796 GLboolean Dedicated; /**< import memory from a dedicated allocation */
4797 };
4798
4799 struct gl_semaphore_object
4800 {
4801 GLuint Name; /**< hash table ID/name */
4802 };
4803
4804 /**
4805 * Mesa rendering context.
4806 *
4807 * This is the central context data structure for Mesa. Almost all
4808 * OpenGL state is contained in this structure.
4809 * Think of this as a base class from which device drivers will derive
4810 * sub classes.
4811 */
4812 struct gl_context
4813 {
4814 /** State possibly shared with other contexts in the address space */
4815 struct gl_shared_state *Shared;
4816
4817 /** \name API function pointer tables */
4818 /*@{*/
4819 gl_api API;
4820
4821 /**
4822 * The current dispatch table for non-displaylist-saving execution, either
4823 * BeginEnd or OutsideBeginEnd
4824 */
4825 struct _glapi_table *Exec;
4826 /**
4827 * The normal dispatch table for non-displaylist-saving, non-begin/end
4828 */
4829 struct _glapi_table *OutsideBeginEnd;
4830 /** The dispatch table used between glNewList() and glEndList() */
4831 struct _glapi_table *Save;
4832 /**
4833 * The dispatch table used between glBegin() and glEnd() (outside of a
4834 * display list). Only valid functions between those two are set, which is
4835 * mostly just the set in a GLvertexformat struct.
4836 */
4837 struct _glapi_table *BeginEnd;
4838 /**
4839 * Dispatch table for when a graphics reset has happened.
4840 */
4841 struct _glapi_table *ContextLost;
4842 /**
4843 * Dispatch table used to marshal API calls from the client program to a
4844 * separate server thread. NULL if API calls are not being marshalled to
4845 * another thread.
4846 */
4847 struct _glapi_table *MarshalExec;
4848 /**
4849 * Dispatch table currently in use for fielding API calls from the client
4850 * program. If API calls are being marshalled to another thread, this ==
4851 * MarshalExec. Otherwise it == CurrentServerDispatch.
4852 */
4853 struct _glapi_table *CurrentClientDispatch;
4854
4855 /**
4856 * Dispatch table currently in use for performing API calls. == Save or
4857 * Exec.
4858 */
4859 struct _glapi_table *CurrentServerDispatch;
4860
4861 /*@}*/
4862
4863 struct glthread_state *GLThread;
4864
4865 struct gl_config Visual;
4866 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
4867 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
4868 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
4869 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
4870
4871 /**
4872 * Device driver function pointer table
4873 */
4874 struct dd_function_table Driver;
4875
4876 /** Core/Driver constants */
4877 struct gl_constants Const;
4878
4879 /** \name The various 4x4 matrix stacks */
4880 /*@{*/
4881 struct gl_matrix_stack ModelviewMatrixStack;
4882 struct gl_matrix_stack ProjectionMatrixStack;
4883 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
4884 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
4885 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
4886 /*@}*/
4887
4888 /** Combined modelview and projection matrix */
4889 GLmatrix _ModelProjectMatrix;
4890
4891 /** \name Display lists */
4892 struct gl_dlist_state ListState;
4893
4894 GLboolean ExecuteFlag; /**< Execute GL commands? */
4895 GLboolean CompileFlag; /**< Compile GL commands into display list? */
4896
4897 /** Extension information */
4898 struct gl_extensions Extensions;
4899
4900 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4901 GLuint Version;
4902 char *VersionString;
4903
4904 /** \name State attribute stack (for glPush/PopAttrib) */
4905 /*@{*/
4906 GLuint AttribStackDepth;
4907 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
4908 /*@}*/
4909
4910 /** \name Renderer attribute groups
4911 *
4912 * We define a struct for each attribute group to make pushing and popping
4913 * attributes easy. Also it's a good organization.
4914 */
4915 /*@{*/
4916 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
4917 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
4918 struct gl_current_attrib Current; /**< Current attributes */
4919 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
4920 struct gl_eval_attrib Eval; /**< Eval attributes */
4921 struct gl_fog_attrib Fog; /**< Fog attributes */
4922 struct gl_hint_attrib Hint; /**< Hint attributes */
4923 struct gl_light_attrib Light; /**< Light attributes */
4924 struct gl_line_attrib Line; /**< Line attributes */
4925 struct gl_list_attrib List; /**< List attributes */
4926 struct gl_multisample_attrib Multisample;
4927 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
4928 struct gl_point_attrib Point; /**< Point attributes */
4929 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
4930 GLuint PolygonStipple[32]; /**< Polygon stipple */
4931 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
4932 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
4933 struct gl_texture_attrib Texture; /**< Texture attributes */
4934 struct gl_transform_attrib Transform; /**< Transformation attributes */
4935 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
4936 GLuint SubpixelPrecisionBias[2]; /**< Viewport attributes */
4937 /*@}*/
4938
4939 /** \name Client attribute stack */
4940 /*@{*/
4941 GLuint ClientAttribStackDepth;
4942 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
4943 /*@}*/
4944
4945 /** \name Client attribute groups */
4946 /*@{*/
4947 struct gl_array_attrib Array; /**< Vertex arrays */
4948 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
4949 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
4950 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
4951 /*@}*/
4952
4953 /** \name Other assorted state (not pushed/popped on attribute stack) */
4954 /*@{*/
4955 struct gl_pixelmaps PixelMaps;
4956
4957 struct gl_evaluators EvalMap; /**< All evaluators */
4958 struct gl_feedback Feedback; /**< Feedback */
4959 struct gl_selection Select; /**< Selection */
4960
4961 struct gl_program_state Program; /**< general program state */
4962 struct gl_vertex_program_state VertexProgram;
4963 struct gl_fragment_program_state FragmentProgram;
4964 struct gl_geometry_program_state GeometryProgram;
4965 struct gl_compute_program_state ComputeProgram;
4966 struct gl_tess_ctrl_program_state TessCtrlProgram;
4967 struct gl_tess_eval_program_state TessEvalProgram;
4968 struct gl_ati_fragment_shader_state ATIFragmentShader;
4969
4970 struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
4971 struct gl_pipeline_object Shader; /**< GLSL shader object state */
4972
4973 /**
4974 * Current active shader pipeline state
4975 *
4976 * Almost all internal users want ::_Shader instead of ::Shader. The
4977 * exceptions are bits of legacy GLSL API that do not know about separate
4978 * shader objects.
4979 *
4980 * If a program is active via \c glUseProgram, this will point to
4981 * \c ::Shader.
4982 *
4983 * If a program pipeline is active via \c glBindProgramPipeline, this will
4984 * point to \c ::Pipeline.Current.
4985 *
4986 * If neither a program nor a program pipeline is active, this will point to
4987 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
4988 * \c NULL.
4989 */
4990 struct gl_pipeline_object *_Shader;
4991
4992 /**
4993 * NIR containing the functions that implement software fp64 support.
4994 */
4995 struct nir_shader *SoftFP64;
4996
4997 struct gl_query_state Query; /**< occlusion, timer queries */
4998
4999 struct gl_transform_feedback_state TransformFeedback;
5000
5001 struct gl_perf_monitor_state PerfMonitor;
5002 struct gl_perf_query_state PerfQuery;
5003
5004 struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
5005 struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */
5006 struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */
5007
5008 struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
5009 struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
5010
5011 struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
5012
5013 /**
5014 * Current GL_ARB_uniform_buffer_object binding referenced by
5015 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
5016 */
5017 struct gl_buffer_object *UniformBuffer;
5018
5019 /**
5020 * Current GL_ARB_shader_storage_buffer_object binding referenced by
5021 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
5022 */
5023 struct gl_buffer_object *ShaderStorageBuffer;
5024
5025 /**
5026 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
5027 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
5028 * associated with uniform blocks by glUniformBlockBinding()'s state in the
5029 * shader program.
5030 */
5031 struct gl_buffer_binding
5032 UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
5033
5034 /**
5035 * Array of shader storage buffers for ARB_shader_storage_buffer_object
5036 * and GL 4.3. This is set up using glBindBufferRange() or
5037 * glBindBufferBase(). They are associated with shader storage blocks by
5038 * glShaderStorageBlockBinding()'s state in the shader program.
5039 */
5040 struct gl_buffer_binding
5041 ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
5042
5043 /**
5044 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
5045 * target.
5046 */
5047 struct gl_buffer_object *AtomicBuffer;
5048
5049 /**
5050 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
5051 * target.
5052 */
5053 struct gl_buffer_object *ExternalVirtualMemoryBuffer;
5054
5055 /**
5056 * Array of atomic counter buffer binding points.
5057 */
5058 struct gl_buffer_binding
5059 AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
5060
5061 /**
5062 * Array of image units for ARB_shader_image_load_store.
5063 */
5064 struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
5065
5066 struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES];
5067 /*@}*/
5068
5069 struct gl_meta_state *Meta; /**< for "meta" operations */
5070
5071 /* GL_EXT_framebuffer_object */
5072 struct gl_renderbuffer *CurrentRenderbuffer;
5073
5074 GLenum16 ErrorValue; /**< Last error code */
5075
5076 /**
5077 * Recognize and silence repeated error debug messages in buggy apps.
5078 */
5079 const char *ErrorDebugFmtString;
5080 GLuint ErrorDebugCount;
5081
5082 /* GL_ARB_debug_output/GL_KHR_debug */
5083 simple_mtx_t DebugMutex;
5084 struct gl_debug_state *Debug;
5085
5086 GLenum16 RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5087 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
5088 uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */
5089
5090 struct gl_driver_flags DriverFlags;
5091
5092 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
5093
5094 GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
5095
5096 /** \name Derived state */
5097 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
5098 GLfloat _EyeZDir[3];
5099 GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
5100 GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
5101 GLboolean _NeedEyeCoords;
5102 GLboolean _ForceEyeCoords;
5103
5104 GLuint TextureStateTimestamp; /**< detect changes to shared state */
5105
5106 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
5107
5108 /** \name For debugging/development only */
5109 /*@{*/
5110 GLboolean FirstTimeCurrent;
5111 /*@}*/
5112
5113 /**
5114 * False if this context was created without a config. This is needed
5115 * because the initial state of glDrawBuffers depends on this
5116 */
5117 GLboolean HasConfig;
5118
5119 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
5120
5121 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
5122 GLboolean IntelConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */
5123 GLboolean ConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_NV */
5124 GLfloat ConservativeRasterDilate;
5125 GLenum16 ConservativeRasterMode;
5126
5127 /** Does glVertexAttrib(0) alias glVertex()? */
5128 bool _AttribZeroAliasesVertex;
5129
5130 /**
5131 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5132 * renderer's tiles should be excecuted, to meet the requirements of
5133 * GL_MESA_tile_raster_order.
5134 */
5135 GLboolean TileRasterOrderFixed;
5136 GLboolean TileRasterOrderIncreasingX;
5137 GLboolean TileRasterOrderIncreasingY;
5138
5139 /**
5140 * \name Hooks for module contexts.
5141 *
5142 * These will eventually live in the driver or elsewhere.
5143 */
5144 /*@{*/
5145 void *swrast_context;
5146 void *swsetup_context;
5147 void *swtnl_context;
5148 struct vbo_context *vbo_context;
5149 struct st_context *st;
5150 /*@}*/
5151
5152 /**
5153 * \name NV_vdpau_interop
5154 */
5155 /*@{*/
5156 const void *vdpDevice;
5157 const void *vdpGetProcAddress;
5158 struct set *vdpSurfaces;
5159 /*@}*/
5160
5161 /**
5162 * Has this context observed a GPU reset in any context in the share group?
5163 *
5164 * Once this field becomes true, it is never reset to false.
5165 */
5166 GLboolean ShareGroupReset;
5167
5168 /**
5169 * \name OES_primitive_bounding_box
5170 *
5171 * Stores the arguments to glPrimitiveBoundingBox
5172 */
5173 GLfloat PrimitiveBoundingBox[8];
5174
5175 struct disk_cache *Cache;
5176
5177 /**
5178 * \name GL_ARB_bindless_texture
5179 */
5180 /*@{*/
5181 struct hash_table_u64 *ResidentTextureHandles;
5182 struct hash_table_u64 *ResidentImageHandles;
5183 /*@}*/
5184
5185 bool shader_builtin_ref;
5186 };
5187
5188 /**
5189 * Information about memory usage. All sizes are in kilobytes.
5190 */
5191 struct gl_memory_info
5192 {
5193 unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
5194 unsigned avail_device_memory; /**< free device memory at the moment */
5195 unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
5196 unsigned avail_staging_memory; /**< free staging memory at the moment */
5197 unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
5198 unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
5199 };
5200
5201 #ifndef NDEBUG
5202 extern int MESA_VERBOSE;
5203 extern int MESA_DEBUG_FLAGS;
5204 #else
5205 # define MESA_VERBOSE 0
5206 # define MESA_DEBUG_FLAGS 0
5207 #endif
5208
5209
5210 /** The MESA_VERBOSE var is a bitmask of these flags */
5211 enum _verbose
5212 {
5213 VERBOSE_VARRAY = 0x0001,
5214 VERBOSE_TEXTURE = 0x0002,
5215 VERBOSE_MATERIAL = 0x0004,
5216 VERBOSE_PIPELINE = 0x0008,
5217 VERBOSE_DRIVER = 0x0010,
5218 VERBOSE_STATE = 0x0020,
5219 VERBOSE_API = 0x0040,
5220 VERBOSE_DISPLAY_LIST = 0x0100,
5221 VERBOSE_LIGHTING = 0x0200,
5222 VERBOSE_PRIMS = 0x0400,
5223 VERBOSE_VERTS = 0x0800,
5224 VERBOSE_DISASSEM = 0x1000,
5225 VERBOSE_DRAW = 0x2000,
5226 VERBOSE_SWAPBUFFERS = 0x4000
5227 };
5228
5229
5230 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5231 enum _debug
5232 {
5233 DEBUG_SILENT = (1 << 0),
5234 DEBUG_ALWAYS_FLUSH = (1 << 1),
5235 DEBUG_INCOMPLETE_TEXTURE = (1 << 2),
5236 DEBUG_INCOMPLETE_FBO = (1 << 3),
5237 DEBUG_CONTEXT = (1 << 4)
5238 };
5239
5240 #ifdef __cplusplus
5241 }
5242 #endif
5243
5244 #endif /* MTYPES_H */