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