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