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