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