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