mesa: rename gl_vertex_array_object::_VertexAttrib -> _VertexArray
[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 GLenum _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 GLint RefCount;
1025 GLchar *Label; /**< GL_KHR_debug */
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 union gl_color_union BorderColor; /**< Interpreted according to texture format */
1033 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
1034 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
1035 GLfloat LodBias; /**< OpenGL 1.4 */
1036 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
1037 GLenum16 CompareMode; /**< GL_ARB_shadow */
1038 GLenum16 CompareFunc; /**< GL_ARB_shadow */
1039 GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
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 GLchar *Label; /**< GL_KHR_debug */
1058 GLenum16 Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1059 gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
1060 Only valid when Target is valid. */
1061
1062 struct gl_sampler_object Sampler;
1063
1064 GLenum16 DepthMode; /**< GL_ARB_depth_texture */
1065
1066 GLfloat Priority; /**< in [0,1] */
1067 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
1068 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
1069 GLint ImmutableLevels; /**< ES 3.0 / ARB_texture_view */
1070 GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
1071 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - p in spec) */
1072 GLint CropRect[4]; /**< GL_OES_draw_texture */
1073 GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */
1074 GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
1075 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
1076 GLboolean _BaseComplete; /**< Is the base texture level valid? */
1077 GLboolean _MipmapComplete; /**< Is the whole mipmap valid? */
1078 GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */
1079 GLboolean _RenderToTexture; /**< Any rendering to this texture? */
1080 GLboolean Purgeable; /**< Is the buffer purgeable under memory
1081 pressure? */
1082 GLboolean Immutable; /**< GL_ARB_texture_storage */
1083 GLboolean _IsFloat; /**< GL_OES_float_texture */
1084 GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
1085 bool StencilSampling; /**< Should we sample stencil instead of depth? */
1086 bool HandleAllocated; /**< GL_ARB_bindless_texture */
1087
1088 GLuint MinLevel; /**< GL_ARB_texture_view */
1089 GLuint MinLayer; /**< GL_ARB_texture_view */
1090 GLuint NumLevels; /**< GL_ARB_texture_view */
1091 GLuint NumLayers; /**< GL_ARB_texture_view */
1092
1093 /** GL_EXT_memory_object */
1094 GLenum16 TextureTiling;
1095
1096 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1097 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
1098
1099 /** GL_ARB_texture_buffer_object */
1100 struct gl_buffer_object *BufferObject;
1101 GLenum16 BufferObjectFormat;
1102 /** Equivalent Mesa format for BufferObjectFormat. */
1103 mesa_format _BufferObjectFormat;
1104 /** GL_ARB_texture_buffer_range */
1105 GLintptr BufferOffset;
1106 GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
1107
1108 /** GL_OES_EGL_image_external */
1109 GLint RequiredTextureImageUnits;
1110
1111 /** GL_ARB_shader_image_load_store */
1112 GLenum16 ImageFormatCompatibilityType;
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 GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
1138 GLuint ScaleShiftA; /**< 0, 1 or 2 */
1139 GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
1140 GLuint _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 GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
1272 GLfloat ObjectPlane[4];
1273 GLfloat EyePlane[4];
1274 };
1275
1276
1277 /**
1278 * Texture unit state. Contains enable flags, texture environment/function/
1279 * combiners, texgen state, and pointers to current texture objects.
1280 */
1281 struct gl_texture_unit
1282 {
1283 GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
1284
1285 GLenum16 EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1286 GLclampf EnvColor[4];
1287 GLfloat EnvColorUnclamped[4];
1288
1289 struct gl_texgen GenS;
1290 struct gl_texgen GenT;
1291 struct gl_texgen GenR;
1292 struct gl_texgen GenQ;
1293 GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
1294 GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
1295
1296 GLfloat LodBias; /**< for biasing mipmap levels */
1297
1298 /** Texture targets that have a non-default texture bound */
1299 GLbitfield _BoundTextures;
1300
1301 /** Current sampler object (GL_ARB_sampler_objects) */
1302 struct gl_sampler_object *Sampler;
1303
1304 /**
1305 * \name GL_EXT_texture_env_combine
1306 */
1307 struct gl_tex_env_combine_state Combine;
1308
1309 /**
1310 * Derived state based on \c EnvMode and the \c BaseFormat of the
1311 * currently enabled texture.
1312 */
1313 struct gl_tex_env_combine_state _EnvMode;
1314
1315 /**
1316 * Currently enabled combiner state. This will point to either
1317 * \c Combine or \c _EnvMode.
1318 */
1319 struct gl_tex_env_combine_state *_CurrentCombine;
1320
1321 /** Current texture object pointers */
1322 struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
1323
1324 /** Points to highest priority, complete and enabled texture object */
1325 struct gl_texture_object *_Current;
1326
1327 /** Current compressed TexEnv & Combine state */
1328 struct gl_tex_env_combine_packed _CurrentCombinePacked;
1329 };
1330
1331
1332 /**
1333 * Texture attribute group (GL_TEXTURE_BIT).
1334 */
1335 struct gl_texture_attrib
1336 {
1337 GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */
1338
1339 /** GL_ARB_seamless_cubemap */
1340 GLboolean CubeMapSeamless;
1341
1342 struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
1343
1344 /** GL_ARB_texture_buffer_object */
1345 struct gl_buffer_object *BufferObject;
1346
1347 /** Texture coord units/sets used for fragment texturing */
1348 GLbitfield _EnabledCoordUnits;
1349
1350 /** Texture coord units that have texgen enabled */
1351 GLbitfield _TexGenEnabled;
1352
1353 /** Texture coord units that have non-identity matrices */
1354 GLbitfield _TexMatEnabled;
1355
1356 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
1357 GLbitfield _GenFlags;
1358
1359 /** Largest index of a texture unit with _Current != NULL. */
1360 GLint _MaxEnabledTexImageUnit;
1361
1362 /** Largest index + 1 of texture units that have had any CurrentTex set. */
1363 GLint NumCurrentTexUsed;
1364
1365 struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
1366 };
1367
1368
1369 /**
1370 * Data structure representing a single clip plane (e.g. one of the elements
1371 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
1372 */
1373 typedef GLfloat gl_clip_plane[4];
1374
1375
1376 /**
1377 * Transformation attribute group (GL_TRANSFORM_BIT).
1378 */
1379 struct gl_transform_attrib
1380 {
1381 GLenum16 MatrixMode; /**< Matrix mode */
1382 gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */
1383 gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
1384 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
1385 GLboolean Normalize; /**< Normalize all normals? */
1386 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
1387 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
1388 GLboolean DepthClamp; /**< GL_ARB_depth_clamp */
1389 /** GL_ARB_clip_control */
1390 GLenum16 ClipOrigin; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
1391 GLenum16 ClipDepthMode;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
1392 };
1393
1394
1395 /**
1396 * Viewport attribute group (GL_VIEWPORT_BIT).
1397 */
1398 struct gl_viewport_attrib
1399 {
1400 GLfloat X, Y; /**< position */
1401 GLfloat Width, Height; /**< size */
1402 GLdouble Near, Far; /**< Depth buffer range */
1403 };
1404
1405
1406 typedef enum
1407 {
1408 MAP_USER,
1409 MAP_INTERNAL,
1410 MAP_COUNT
1411 } gl_map_buffer_index;
1412
1413
1414 /**
1415 * Fields describing a mapped buffer range.
1416 */
1417 struct gl_buffer_mapping
1418 {
1419 GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
1420 GLvoid *Pointer; /**< User-space address of mapping */
1421 GLintptr Offset; /**< Mapped offset */
1422 GLsizeiptr Length; /**< Mapped length */
1423 };
1424
1425
1426 /**
1427 * Usages we've seen for a buffer object.
1428 */
1429 typedef enum
1430 {
1431 USAGE_UNIFORM_BUFFER = 0x1,
1432 USAGE_TEXTURE_BUFFER = 0x2,
1433 USAGE_ATOMIC_COUNTER_BUFFER = 0x4,
1434 USAGE_SHADER_STORAGE_BUFFER = 0x8,
1435 USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10,
1436 USAGE_PIXEL_PACK_BUFFER = 0x20,
1437 USAGE_DISABLE_MINMAX_CACHE = 0x40,
1438 } gl_buffer_usage;
1439
1440
1441 /**
1442 * GL_ARB_vertex/pixel_buffer_object buffer object
1443 */
1444 struct gl_buffer_object
1445 {
1446 GLint RefCount;
1447 GLuint Name;
1448 GLchar *Label; /**< GL_KHR_debug */
1449 GLenum16 Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
1450 GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
1451 GLsizeiptrARB Size; /**< Size of buffer storage in bytes */
1452 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
1453 GLboolean DeletePending; /**< true if buffer object is removed from the hash */
1454 GLboolean Written; /**< Ever written to? (for debugging) */
1455 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
1456 GLboolean Immutable; /**< GL_ARB_buffer_storage */
1457 gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
1458
1459 /** Counters used for buffer usage warnings */
1460 GLuint NumSubDataCalls;
1461 GLuint NumMapBufferWriteCalls;
1462
1463 struct gl_buffer_mapping Mappings[MAP_COUNT];
1464
1465 /** Memoization of min/max index computations for static index buffers */
1466 simple_mtx_t MinMaxCacheMutex;
1467 struct hash_table *MinMaxCache;
1468 unsigned MinMaxCacheHitIndices;
1469 unsigned MinMaxCacheMissIndices;
1470 bool MinMaxCacheDirty;
1471
1472 bool HandleAllocated; /**< GL_ARB_bindless_texture */
1473 };
1474
1475
1476 /**
1477 * Client pixel packing/unpacking attributes
1478 */
1479 struct gl_pixelstore_attrib
1480 {
1481 GLint Alignment;
1482 GLint RowLength;
1483 GLint SkipPixels;
1484 GLint SkipRows;
1485 GLint ImageHeight;
1486 GLint SkipImages;
1487 GLboolean SwapBytes;
1488 GLboolean LsbFirst;
1489 GLboolean Invert; /**< GL_MESA_pack_invert */
1490 GLint CompressedBlockWidth; /**< GL_ARB_compressed_texture_pixel_storage */
1491 GLint CompressedBlockHeight;
1492 GLint CompressedBlockDepth;
1493 GLint CompressedBlockSize;
1494 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
1495 };
1496
1497
1498 /**
1499 * Vertex array information which is derived from gl_array_attributes
1500 * and gl_vertex_buffer_binding information. Used by the VBO module and
1501 * device drivers.
1502 */
1503 struct gl_vertex_array
1504 {
1505 /** if NULL, vertex data are in user memory */
1506 struct gl_buffer_object *BufferObj;
1507 /** Pointer into user memory, or offset into the BufferObj */
1508 const GLubyte *Ptr;
1509 GLsizei StrideB; /**< actual stride in bytes */
1510 GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
1511 GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
1512 GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
1513 unsigned Size:4; /**< components per element (1,2,3,4) */
1514 unsigned _ElementSize:8; /**< in bytes, up to 4*sizeof(GLdouble) */
1515 unsigned Normalized:1; /**< GL_ARB_vertex_program */
1516 unsigned Integer:1; /**< Integer-valued? */
1517 unsigned Doubles:1; /**< doubles not converted to floats */
1518 };
1519
1520
1521 /**
1522 * Enum for defining the mapping for the position/generic0 attribute.
1523 *
1524 * Do not change the order of the values as these are used as
1525 * array indices.
1526 */
1527 typedef enum
1528 {
1529 ATTRIBUTE_MAP_MODE_IDENTITY, /**< 1:1 mapping */
1530 ATTRIBUTE_MAP_MODE_POSITION, /**< get position and generic0 from position */
1531 ATTRIBUTE_MAP_MODE_GENERIC0, /**< get position and generic0 from generic0 */
1532 ATTRIBUTE_MAP_MODE_MAX /**< for sizing arrays */
1533 } gl_attribute_map_mode;
1534
1535
1536 /**
1537 * Attributes to describe a vertex array.
1538 *
1539 * Contains the size, type, format and normalization flag,
1540 * along with the index of a vertex buffer binding point.
1541 *
1542 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
1543 * and is only present for backwards compatibility reasons.
1544 * Rendering always uses VERTEX_BINDING_STRIDE.
1545 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
1546 * and VERTEX_BINDING_STRIDE to the same value, while
1547 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
1548 */
1549 struct gl_array_attributes
1550 {
1551 /** Points to client array data. Not used when a VBO is bound */
1552 const GLubyte *Ptr;
1553 /** Offset of the first element relative to the binding offset */
1554 GLuint RelativeOffset;
1555 GLshort Stride; /**< Stride as specified with gl*Pointer() */
1556 GLenum16 Type; /**< Datatype: GL_FLOAT, GL_INT, etc */
1557 GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
1558 GLboolean Enabled; /**< Whether the array is enabled */
1559 GLubyte Size; /**< Components per element (1,2,3,4) */
1560 unsigned Normalized:1; /**< Fixed-point values are normalized when converted to floats */
1561 unsigned Integer:1; /**< Fixed-point values are not converted to floats */
1562 unsigned Doubles:1; /**< double precision values are not converted to floats */
1563 unsigned _ElementSize:8; /**< Size of each element in bytes */
1564 /** Index into gl_vertex_array_object::BufferBinding[] array */
1565 unsigned BufferBindingIndex:6;
1566 };
1567
1568
1569 /**
1570 * This describes the buffer object used for a vertex array (or
1571 * multiple vertex arrays). If BufferObj points to the default/null
1572 * buffer object, then the vertex array lives in user memory and not a VBO.
1573 */
1574 struct gl_vertex_buffer_binding
1575 {
1576 GLintptr Offset; /**< User-specified offset */
1577 GLsizei Stride; /**< User-specified stride */
1578 GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
1579 struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
1580 GLbitfield _BoundArrays; /**< Arrays bound to this binding point */
1581 };
1582
1583
1584 /**
1585 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
1586 * the GL_ARB_vertex_array_object extension.
1587 */
1588 struct gl_vertex_array_object
1589 {
1590 /** Name of the VAO as received from glGenVertexArray. */
1591 GLuint Name;
1592
1593 GLint RefCount;
1594
1595 GLchar *Label; /**< GL_KHR_debug */
1596
1597 /**
1598 * Has this array object been bound?
1599 */
1600 GLboolean EverBound;
1601
1602 /**
1603 * Derived vertex attribute arrays
1604 *
1605 * This is a legacy data structure created from gl_array_attributes and
1606 * gl_vertex_buffer_binding, only used by the VBO module at this time.
1607 */
1608 struct gl_vertex_array _VertexArray[VERT_ATTRIB_MAX];
1609
1610 /** Vertex attribute arrays */
1611 struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX];
1612
1613 /** Vertex buffer bindings */
1614 struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX];
1615
1616 /** Mask indicating which vertex arrays have vertex buffer associated. */
1617 GLbitfield VertexAttribBufferMask;
1618
1619 /** Mask of VERT_BIT_* values indicating which arrays are enabled */
1620 GLbitfield _Enabled;
1621
1622 /** Denotes the way the position/generic0 attribute is mapped */
1623 gl_attribute_map_mode _AttributeMapMode;
1624
1625 /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
1626 GLbitfield NewArrays;
1627
1628 /** The index buffer (also known as the element array buffer in OpenGL). */
1629 struct gl_buffer_object *IndexBufferObj;
1630 };
1631
1632
1633 /**
1634 * Enum for the OpenGL APIs we know about and may support.
1635 *
1636 * NOTE: This must match the api_enum table in
1637 * src/mesa/main/get_hash_generator.py
1638 */
1639 typedef enum
1640 {
1641 API_OPENGL_COMPAT, /* legacy / compatibility contexts */
1642 API_OPENGLES,
1643 API_OPENGLES2,
1644 API_OPENGL_CORE,
1645 API_OPENGL_LAST = API_OPENGL_CORE
1646 } gl_api;
1647
1648
1649 /**
1650 * Vertex array state
1651 */
1652 struct gl_array_attrib
1653 {
1654 /** Currently bound array object. */
1655 struct gl_vertex_array_object *VAO;
1656
1657 /** The default vertex array object */
1658 struct gl_vertex_array_object *DefaultVAO;
1659
1660 /** The last VAO accessed by a DSA function */
1661 struct gl_vertex_array_object *LastLookedUpVAO;
1662
1663 /** Array objects (GL_ARB_vertex_array_object) */
1664 struct _mesa_HashTable *Objects;
1665
1666 GLint ActiveTexture; /**< Client Active Texture */
1667 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
1668 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
1669
1670 /**
1671 * \name Primitive restart controls
1672 *
1673 * Primitive restart is enabled if either \c PrimitiveRestart or
1674 * \c PrimitiveRestartFixedIndex is set.
1675 */
1676 /*@{*/
1677 GLboolean PrimitiveRestart;
1678 GLboolean PrimitiveRestartFixedIndex;
1679 GLboolean _PrimitiveRestart;
1680 GLuint RestartIndex;
1681 /*@}*/
1682
1683 /* GL_ARB_vertex_buffer_object */
1684 struct gl_buffer_object *ArrayBufferObj;
1685
1686 /**
1687 * Vertex arrays as consumed by a driver.
1688 * The array pointer is set up only by the VBO module.
1689 */
1690 const struct gl_vertex_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
1691
1692 /** Legal array datatypes and the API for which they have been computed */
1693 GLbitfield LegalTypesMask;
1694 gl_api LegalTypesMaskAPI;
1695 };
1696
1697
1698 /**
1699 * Feedback buffer state
1700 */
1701 struct gl_feedback
1702 {
1703 GLenum16 Type;
1704 GLbitfield _Mask; /**< FB_* bits */
1705 GLfloat *Buffer;
1706 GLuint BufferSize;
1707 GLuint Count;
1708 };
1709
1710
1711 /**
1712 * Selection buffer state
1713 */
1714 struct gl_selection
1715 {
1716 GLuint *Buffer; /**< selection buffer */
1717 GLuint BufferSize; /**< size of the selection buffer */
1718 GLuint BufferCount; /**< number of values in the selection buffer */
1719 GLuint Hits; /**< number of records in the selection buffer */
1720 GLuint NameStackDepth; /**< name stack depth */
1721 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
1722 GLboolean HitFlag; /**< hit flag */
1723 GLfloat HitMinZ; /**< minimum hit depth */
1724 GLfloat HitMaxZ; /**< maximum hit depth */
1725 };
1726
1727
1728 /**
1729 * 1-D Evaluator control points
1730 */
1731 struct gl_1d_map
1732 {
1733 GLuint Order; /**< Number of control points */
1734 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
1735 GLfloat *Points; /**< Points to contiguous control points */
1736 };
1737
1738
1739 /**
1740 * 2-D Evaluator control points
1741 */
1742 struct gl_2d_map
1743 {
1744 GLuint Uorder; /**< Number of control points in U dimension */
1745 GLuint Vorder; /**< Number of control points in V dimension */
1746 GLfloat u1, u2, du;
1747 GLfloat v1, v2, dv;
1748 GLfloat *Points; /**< Points to contiguous control points */
1749 };
1750
1751
1752 /**
1753 * All evaluator control point state
1754 */
1755 struct gl_evaluators
1756 {
1757 /**
1758 * \name 1-D maps
1759 */
1760 /*@{*/
1761 struct gl_1d_map Map1Vertex3;
1762 struct gl_1d_map Map1Vertex4;
1763 struct gl_1d_map Map1Index;
1764 struct gl_1d_map Map1Color4;
1765 struct gl_1d_map Map1Normal;
1766 struct gl_1d_map Map1Texture1;
1767 struct gl_1d_map Map1Texture2;
1768 struct gl_1d_map Map1Texture3;
1769 struct gl_1d_map Map1Texture4;
1770 /*@}*/
1771
1772 /**
1773 * \name 2-D maps
1774 */
1775 /*@{*/
1776 struct gl_2d_map Map2Vertex3;
1777 struct gl_2d_map Map2Vertex4;
1778 struct gl_2d_map Map2Index;
1779 struct gl_2d_map Map2Color4;
1780 struct gl_2d_map Map2Normal;
1781 struct gl_2d_map Map2Texture1;
1782 struct gl_2d_map Map2Texture2;
1783 struct gl_2d_map Map2Texture3;
1784 struct gl_2d_map Map2Texture4;
1785 /*@}*/
1786 };
1787
1788
1789 struct gl_transform_feedback_varying_info
1790 {
1791 char *Name;
1792 GLenum16 Type;
1793 GLint BufferIndex;
1794 GLint Size;
1795 GLint Offset;
1796 };
1797
1798
1799 /**
1800 * Per-output info vertex shaders for transform feedback.
1801 */
1802 struct gl_transform_feedback_output
1803 {
1804 uint32_t OutputRegister;
1805 uint32_t OutputBuffer;
1806 uint32_t NumComponents;
1807 uint32_t StreamId;
1808
1809 /** offset (in DWORDs) of this output within the interleaved structure */
1810 uint32_t DstOffset;
1811
1812 /**
1813 * Offset into the output register of the data to output. For example,
1814 * if NumComponents is 2 and ComponentOffset is 1, then the data to
1815 * offset is in the y and z components of the output register.
1816 */
1817 uint32_t ComponentOffset;
1818 };
1819
1820
1821 struct gl_transform_feedback_buffer
1822 {
1823 uint32_t Binding;
1824
1825 uint32_t NumVaryings;
1826
1827 /**
1828 * Total number of components stored in each buffer. This may be used by
1829 * hardware back-ends to determine the correct stride when interleaving
1830 * multiple transform feedback outputs in the same buffer.
1831 */
1832 uint32_t Stride;
1833
1834 /**
1835 * Which transform feedback stream this buffer binding is associated with.
1836 */
1837 uint32_t Stream;
1838 };
1839
1840
1841 /** Post-link transform feedback info. */
1842 struct gl_transform_feedback_info
1843 {
1844 /* Was xfb enabled via the api or in shader layout qualifiers */
1845 bool api_enabled;
1846
1847 unsigned NumOutputs;
1848
1849 /* Bitmask of active buffer indices. */
1850 unsigned ActiveBuffers;
1851
1852 struct gl_transform_feedback_output *Outputs;
1853
1854 /** Transform feedback varyings used for the linking of this shader program.
1855 *
1856 * Use for glGetTransformFeedbackVarying().
1857 */
1858 struct gl_transform_feedback_varying_info *Varyings;
1859 GLint NumVarying;
1860
1861 struct gl_transform_feedback_buffer Buffers[MAX_FEEDBACK_BUFFERS];
1862 };
1863
1864
1865 /**
1866 * Transform feedback object state
1867 */
1868 struct gl_transform_feedback_object
1869 {
1870 GLuint Name; /**< AKA the object ID */
1871 GLint RefCount;
1872 GLchar *Label; /**< GL_KHR_debug */
1873 GLboolean Active; /**< Is transform feedback enabled? */
1874 GLboolean Paused; /**< Is transform feedback paused? */
1875 GLboolean EndedAnytime; /**< Has EndTransformFeedback been called
1876 at least once? */
1877 GLboolean EverBound; /**< Has this object been bound? */
1878
1879 /**
1880 * GLES: if Active is true, remaining number of primitives which can be
1881 * rendered without overflow. This is necessary to track because GLES
1882 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
1883 * glDrawArraysInstanced would overflow transform feedback buffers.
1884 * Undefined if Active is false.
1885 *
1886 * Not tracked for desktop GL since it's unnecessary.
1887 */
1888 unsigned GlesRemainingPrims;
1889
1890 /**
1891 * The program active when BeginTransformFeedback() was called.
1892 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
1893 * where stage is the pipeline stage that is the source of data for
1894 * transform feedback.
1895 */
1896 struct gl_program *program;
1897
1898 /** The feedback buffers */
1899 GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
1900 struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS];
1901
1902 /** Start of feedback data in dest buffer */
1903 GLintptr Offset[MAX_FEEDBACK_BUFFERS];
1904
1905 /**
1906 * Max data to put into dest buffer (in bytes). Computed based on
1907 * RequestedSize and the actual size of the buffer.
1908 */
1909 GLsizeiptr Size[MAX_FEEDBACK_BUFFERS];
1910
1911 /**
1912 * Size that was specified when the buffer was bound. If the buffer was
1913 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
1914 * zero.
1915 */
1916 GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS];
1917 };
1918
1919
1920 /**
1921 * Context state for transform feedback.
1922 */
1923 struct gl_transform_feedback_state
1924 {
1925 GLenum16 Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
1926
1927 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
1928 struct gl_buffer_object *CurrentBuffer;
1929
1930 /** The table of all transform feedback objects */
1931 struct _mesa_HashTable *Objects;
1932
1933 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
1934 struct gl_transform_feedback_object *CurrentObject;
1935
1936 /** The default xform-fb object (Name==0) */
1937 struct gl_transform_feedback_object *DefaultObject;
1938 };
1939
1940
1941 /**
1942 * A "performance monitor" as described in AMD_performance_monitor.
1943 */
1944 struct gl_perf_monitor_object
1945 {
1946 GLuint Name;
1947
1948 /** True if the monitor is currently active (Begin called but not End). */
1949 GLboolean Active;
1950
1951 /**
1952 * True if the monitor has ended.
1953 *
1954 * This is distinct from !Active because it may never have began.
1955 */
1956 GLboolean Ended;
1957
1958 /**
1959 * A list of groups with currently active counters.
1960 *
1961 * ActiveGroups[g] == n if there are n counters active from group 'g'.
1962 */
1963 unsigned *ActiveGroups;
1964
1965 /**
1966 * An array of bitsets, subscripted by group ID, then indexed by counter ID.
1967 *
1968 * Checking whether counter 'c' in group 'g' is active can be done via:
1969 *
1970 * BITSET_TEST(ActiveCounters[g], c)
1971 */
1972 GLuint **ActiveCounters;
1973 };
1974
1975
1976 union gl_perf_monitor_counter_value
1977 {
1978 float f;
1979 uint64_t u64;
1980 uint32_t u32;
1981 };
1982
1983
1984 struct gl_perf_monitor_counter
1985 {
1986 /** Human readable name for the counter. */
1987 const char *Name;
1988
1989 /**
1990 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT,
1991 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
1992 */
1993 GLenum16 Type;
1994
1995 /** Minimum counter value. */
1996 union gl_perf_monitor_counter_value Minimum;
1997
1998 /** Maximum counter value. */
1999 union gl_perf_monitor_counter_value Maximum;
2000 };
2001
2002
2003 struct gl_perf_monitor_group
2004 {
2005 /** Human readable name for the group. */
2006 const char *Name;
2007
2008 /**
2009 * Maximum number of counters in this group which can be active at the
2010 * same time.
2011 */
2012 GLuint MaxActiveCounters;
2013
2014 /** Array of counters within this group. */
2015 const struct gl_perf_monitor_counter *Counters;
2016 GLuint NumCounters;
2017 };
2018
2019
2020 /**
2021 * A query object instance as described in INTEL_performance_query.
2022 *
2023 * NB: We want to keep this and the corresponding backend structure
2024 * relatively lean considering that applications may expect to
2025 * allocate enough objects to be able to query around all draw calls
2026 * in a frame.
2027 */
2028 struct gl_perf_query_object
2029 {
2030 GLuint Id; /**< hash table ID/name */
2031 unsigned Used:1; /**< has been used for 1 or more queries */
2032 unsigned Active:1; /**< inside Begin/EndPerfQuery */
2033 unsigned Ready:1; /**< result is ready? */
2034 };
2035
2036
2037 /**
2038 * Context state for AMD_performance_monitor.
2039 */
2040 struct gl_perf_monitor_state
2041 {
2042 /** Array of performance monitor groups (indexed by group ID) */
2043 const struct gl_perf_monitor_group *Groups;
2044 GLuint NumGroups;
2045
2046 /** The table of all performance monitors. */
2047 struct _mesa_HashTable *Monitors;
2048 };
2049
2050
2051 /**
2052 * Context state for INTEL_performance_query.
2053 */
2054 struct gl_perf_query_state
2055 {
2056 struct _mesa_HashTable *Objects; /**< The table of all performance query objects */
2057 };
2058
2059
2060 /**
2061 * A bindless sampler object.
2062 */
2063 struct gl_bindless_sampler
2064 {
2065 /** Texture unit (set by glUniform1()). */
2066 GLubyte unit;
2067
2068 /** Whether this bindless sampler is bound to a unit. */
2069 GLboolean bound;
2070
2071 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
2072 gl_texture_index target;
2073
2074 /** Pointer to the base of the data. */
2075 GLvoid *data;
2076 };
2077
2078
2079 /**
2080 * A bindless image object.
2081 */
2082 struct gl_bindless_image
2083 {
2084 /** Image unit (set by glUniform1()). */
2085 GLubyte unit;
2086
2087 /** Whether this bindless image is bound to a unit. */
2088 GLboolean bound;
2089
2090 /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
2091 GLenum16 access;
2092
2093 /** Pointer to the base of the data. */
2094 GLvoid *data;
2095 };
2096
2097
2098 /**
2099 * Names of the various vertex/fragment program register files, etc.
2100 *
2101 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
2102 * All values should fit in a 4-bit field.
2103 *
2104 * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be
2105 * considered to be "uniform" variables since they can only be set outside
2106 * glBegin/End. They're also all stored in the same Parameters array.
2107 */
2108 typedef enum
2109 {
2110 PROGRAM_TEMPORARY, /**< machine->Temporary[] */
2111 PROGRAM_ARRAY, /**< Arrays & Matrixes */
2112 PROGRAM_INPUT, /**< machine->Inputs[] */
2113 PROGRAM_OUTPUT, /**< machine->Outputs[] */
2114 PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */
2115 PROGRAM_CONSTANT, /**< gl_program->Parameters[] */
2116 PROGRAM_UNIFORM, /**< gl_program->Parameters[] */
2117 PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */
2118 PROGRAM_ADDRESS, /**< machine->AddressReg */
2119 PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */
2120 PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */
2121 PROGRAM_UNDEFINED, /**< Invalid/TBD value */
2122 PROGRAM_IMMEDIATE, /**< Immediate value, used by TGSI */
2123 PROGRAM_BUFFER, /**< for shader buffers, compile-time only */
2124 PROGRAM_MEMORY, /**< for shared, global and local memory */
2125 PROGRAM_IMAGE, /**< for shader images, compile-time only */
2126 PROGRAM_HW_ATOMIC, /**< for hw atomic counters, compile-time only */
2127 PROGRAM_FILE_MAX
2128 } gl_register_file;
2129
2130
2131 /**
2132 * Base class for any kind of program object
2133 */
2134 struct gl_program
2135 {
2136 /** FIXME: This must be first until we split shader_info from nir_shader */
2137 struct shader_info info;
2138
2139 GLuint Id;
2140 GLint RefCount;
2141 GLubyte *String; /**< Null-terminated program text */
2142
2143 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
2144 GLenum16 Target;
2145 GLenum16 Format; /**< String encoding format */
2146
2147 GLboolean _Used; /**< Ever used for drawing? Used for debugging */
2148
2149 struct nir_shader *nir;
2150
2151 /* Saved and restored with metadata. Freed with ralloc. */
2152 void *driver_cache_blob;
2153 size_t driver_cache_blob_size;
2154
2155 bool is_arb_asm; /** Is this an ARB assembly-style program */
2156
2157 /** Is this program written to on disk shader cache */
2158 bool program_written_to_cache;
2159
2160 /** Subset of OutputsWritten outputs written with non-zero index. */
2161 GLbitfield64 SecondaryOutputsWritten;
2162 /** TEXTURE_x_BIT bitmask */
2163 GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
2164 /** Bitfield of which samplers are used */
2165 GLbitfield SamplersUsed;
2166 /** Texture units used for shadow sampling. */
2167 GLbitfield ShadowSamplers;
2168 /** Texture units used for samplerExternalOES */
2169 GLbitfield ExternalSamplersUsed;
2170
2171 /* Fragement shader only fields */
2172 GLboolean OriginUpperLeft;
2173 GLboolean PixelCenterInteger;
2174
2175 /** Named parameters, constants, etc. from program text */
2176 struct gl_program_parameter_list *Parameters;
2177
2178 /** Map from sampler unit to texture unit (set by glUniform1i()) */
2179 GLubyte SamplerUnits[MAX_SAMPLERS];
2180
2181 /* FIXME: We should be able to make this struct a union. However some
2182 * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
2183 * these fields, we should fix this.
2184 */
2185 struct {
2186 /** Fields used by GLSL programs */
2187 struct {
2188 /** Data shared by gl_program and gl_shader_program */
2189 struct gl_shader_program_data *data;
2190
2191 struct gl_active_atomic_buffer **AtomicBuffers;
2192
2193 /** Post-link transform feedback info. */
2194 struct gl_transform_feedback_info *LinkedTransformFeedback;
2195
2196 /**
2197 * Number of types for subroutine uniforms.
2198 */
2199 GLuint NumSubroutineUniformTypes;
2200
2201 /**
2202 * Subroutine uniform remap table
2203 * based on the program level uniform remap table.
2204 */
2205 GLuint NumSubroutineUniforms; /* non-sparse total */
2206 GLuint NumSubroutineUniformRemapTable;
2207 struct gl_uniform_storage **SubroutineUniformRemapTable;
2208
2209 /**
2210 * Num of subroutine functions for this stage and storage for them.
2211 */
2212 GLuint NumSubroutineFunctions;
2213 GLuint MaxSubroutineFunctionIndex;
2214 struct gl_subroutine_function *SubroutineFunctions;
2215
2216 /**
2217 * Map from image uniform index to image unit (set by glUniform1i())
2218 *
2219 * An image uniform index is associated with each image uniform by
2220 * the linker. The image index associated with each uniform is
2221 * stored in the \c gl_uniform_storage::image field.
2222 */
2223 GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
2224
2225 /**
2226 * Access qualifier specified in the shader for each image uniform
2227 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
2228 * GL_READ_WRITE.
2229 *
2230 * It may be different, though only more strict than the value of
2231 * \c gl_image_unit::Access for the corresponding image unit.
2232 */
2233 GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
2234
2235 struct gl_uniform_block **UniformBlocks;
2236 struct gl_uniform_block **ShaderStorageBlocks;
2237
2238 /** Which texture target is being sampled
2239 * (TEXTURE_1D/2D/3D/etc_INDEX)
2240 */
2241 gl_texture_index SamplerTargets[MAX_SAMPLERS];
2242
2243 /**
2244 * Number of samplers declared with the bindless_sampler layout
2245 * qualifier as specified by ARB_bindless_texture.
2246 */
2247 GLuint NumBindlessSamplers;
2248 GLboolean HasBoundBindlessSampler;
2249 struct gl_bindless_sampler *BindlessSamplers;
2250
2251 /**
2252 * Number of images declared with the bindless_image layout qualifier
2253 * as specified by ARB_bindless_texture.
2254 */
2255 GLuint NumBindlessImages;
2256 GLboolean HasBoundBindlessImage;
2257 struct gl_bindless_image *BindlessImages;
2258
2259 union {
2260 struct {
2261 /**
2262 * A bitmask of gl_advanced_blend_mode values
2263 */
2264 GLbitfield BlendSupport;
2265 } fs;
2266 };
2267 } sh;
2268
2269 /** ARB assembly-style program fields */
2270 struct {
2271 struct prog_instruction *Instructions;
2272
2273 /**
2274 * Local parameters used by the program.
2275 *
2276 * It's dynamically allocated because it is rarely used (just
2277 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
2278 * once it's allocated.
2279 */
2280 GLfloat (*LocalParams)[4];
2281
2282 /** Bitmask of which register files are read/written with indirect
2283 * addressing. Mask of (1 << PROGRAM_x) bits.
2284 */
2285 GLbitfield IndirectRegisterFiles;
2286
2287 /** Logical counts */
2288 /*@{*/
2289 GLuint NumInstructions;
2290 GLuint NumTemporaries;
2291 GLuint NumParameters;
2292 GLuint NumAttributes;
2293 GLuint NumAddressRegs;
2294 GLuint NumAluInstructions;
2295 GLuint NumTexInstructions;
2296 GLuint NumTexIndirections;
2297 /*@}*/
2298 /** Native, actual h/w counts */
2299 /*@{*/
2300 GLuint NumNativeInstructions;
2301 GLuint NumNativeTemporaries;
2302 GLuint NumNativeParameters;
2303 GLuint NumNativeAttributes;
2304 GLuint NumNativeAddressRegs;
2305 GLuint NumNativeAluInstructions;
2306 GLuint NumNativeTexInstructions;
2307 GLuint NumNativeTexIndirections;
2308 /*@}*/
2309
2310 /** Used by ARB assembly-style programs. Can only be true for vertex
2311 * programs.
2312 */
2313 GLboolean IsPositionInvariant;
2314 } arb;
2315 };
2316 };
2317
2318
2319 /**
2320 * State common to vertex and fragment programs.
2321 */
2322 struct gl_program_state
2323 {
2324 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
2325 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
2326 };
2327
2328
2329 /**
2330 * Context state for vertex programs.
2331 */
2332 struct gl_vertex_program_state
2333 {
2334 GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
2335 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
2336 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
2337 /** Should fixed-function T&L be implemented with a vertex prog? */
2338 GLboolean _MaintainTnlProgram;
2339
2340 struct gl_program *Current; /**< User-bound vertex program */
2341
2342 /** Currently enabled and valid vertex program (including internal
2343 * programs, user-defined vertex programs and GLSL vertex shaders).
2344 * This is the program we must use when rendering.
2345 */
2346 struct gl_program *_Current;
2347
2348 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2349
2350 /** Program to emulate fixed-function T&L (see above) */
2351 struct gl_program *_TnlProgram;
2352
2353 /** Cache of fixed-function programs */
2354 struct gl_program_cache *Cache;
2355
2356 GLboolean _Overriden;
2357 };
2358
2359 /**
2360 * Context state for tessellation control programs.
2361 */
2362 struct gl_tess_ctrl_program_state
2363 {
2364 /** Currently bound and valid shader. */
2365 struct gl_program *_Current;
2366
2367 GLint patch_vertices;
2368 GLfloat patch_default_outer_level[4];
2369 GLfloat patch_default_inner_level[2];
2370 };
2371
2372 /**
2373 * Context state for tessellation evaluation programs.
2374 */
2375 struct gl_tess_eval_program_state
2376 {
2377 /** Currently bound and valid shader. */
2378 struct gl_program *_Current;
2379 };
2380
2381 /**
2382 * Context state for geometry programs.
2383 */
2384 struct gl_geometry_program_state
2385 {
2386 /**
2387 * Currently enabled and valid program (including internal programs
2388 * and compiled shader programs).
2389 */
2390 struct gl_program *_Current;
2391 };
2392
2393 /**
2394 * Context state for fragment programs.
2395 */
2396 struct gl_fragment_program_state
2397 {
2398 GLboolean Enabled; /**< User-set fragment program enable flag */
2399 /** Should fixed-function texturing be implemented with a fragment prog? */
2400 GLboolean _MaintainTexEnvProgram;
2401
2402 struct gl_program *Current; /**< User-bound fragment program */
2403
2404 /**
2405 * Currently enabled and valid fragment program (including internal
2406 * programs, user-defined fragment programs and GLSL fragment shaders).
2407 * This is the program we must use when rendering.
2408 */
2409 struct gl_program *_Current;
2410
2411 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
2412
2413 /** Program to emulate fixed-function texture env/combine (see above) */
2414 struct gl_program *_TexEnvProgram;
2415
2416 /** Cache of fixed-function programs */
2417 struct gl_program_cache *Cache;
2418 };
2419
2420
2421 /**
2422 * Context state for compute programs.
2423 */
2424 struct gl_compute_program_state
2425 {
2426 /** Currently enabled and valid program (including internal programs
2427 * and compiled shader programs).
2428 */
2429 struct gl_program *_Current;
2430 };
2431
2432
2433 /**
2434 * ATI_fragment_shader runtime state
2435 */
2436
2437 struct atifs_instruction;
2438 struct atifs_setupinst;
2439
2440 /**
2441 * ATI fragment shader
2442 */
2443 struct ati_fragment_shader
2444 {
2445 GLuint Id;
2446 GLint RefCount;
2447 struct atifs_instruction *Instructions[2];
2448 struct atifs_setupinst *SetupInst[2];
2449 GLfloat Constants[8][4];
2450 GLbitfield LocalConstDef; /**< Indicates which constants have been set */
2451 GLubyte numArithInstr[2];
2452 GLubyte regsAssigned[2];
2453 GLubyte NumPasses; /**< 1 or 2 */
2454 /**
2455 * Current compile stage: 0 setup pass1, 1 arith pass1,
2456 * 2 setup pass2, 3 arith pass2.
2457 */
2458 GLubyte cur_pass;
2459 GLubyte last_optype;
2460 GLboolean interpinp1;
2461 GLboolean isValid;
2462 /**
2463 * Array of 2 bit values for each tex unit to remember whether
2464 * STR or STQ swizzle was used
2465 */
2466 GLuint swizzlerq;
2467 struct gl_program *Program;
2468 };
2469
2470 /**
2471 * Context state for GL_ATI_fragment_shader
2472 */
2473 struct gl_ati_fragment_shader_state
2474 {
2475 GLboolean Enabled;
2476 GLboolean Compiling;
2477 GLfloat GlobalConstants[8][4];
2478 struct ati_fragment_shader *Current;
2479 };
2480
2481 /**
2482 * Shader subroutine function definition
2483 */
2484 struct gl_subroutine_function
2485 {
2486 char *name;
2487 int index;
2488 int num_compat_types;
2489 const struct glsl_type **types;
2490 };
2491
2492 /**
2493 * Shader information needed by both gl_shader and gl_linked shader.
2494 */
2495 struct gl_shader_info
2496 {
2497 /**
2498 * Tessellation Control shader state from layout qualifiers.
2499 */
2500 struct {
2501 /**
2502 * 0 - vertices not declared in shader, or
2503 * 1 .. GL_MAX_PATCH_VERTICES
2504 */
2505 GLint VerticesOut;
2506 } TessCtrl;
2507
2508 /**
2509 * Tessellation Evaluation shader state from layout qualifiers.
2510 */
2511 struct {
2512 /**
2513 * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
2514 * in this shader.
2515 */
2516 GLenum16 PrimitiveMode;
2517
2518 enum gl_tess_spacing Spacing;
2519
2520 /**
2521 * GL_CW, GL_CCW, or 0 if it's not set in this shader.
2522 */
2523 GLenum16 VertexOrder;
2524 /**
2525 * 1, 0, or -1 if it's not set in this shader.
2526 */
2527 int PointMode;
2528 } TessEval;
2529
2530 /**
2531 * Geometry shader state from GLSL 1.50 layout qualifiers.
2532 */
2533 struct {
2534 GLint VerticesOut;
2535 /**
2536 * 0 - Invocations count not declared in shader, or
2537 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
2538 */
2539 GLint Invocations;
2540 /**
2541 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
2542 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
2543 * shader.
2544 */
2545 GLenum16 InputType;
2546 /**
2547 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
2548 * it's not set in this shader.
2549 */
2550 GLenum16 OutputType;
2551 } Geom;
2552
2553 /**
2554 * Compute shader state from ARB_compute_shader and
2555 * ARB_compute_variable_group_size layout qualifiers.
2556 */
2557 struct {
2558 /**
2559 * Size specified using local_size_{x,y,z}, or all 0's to indicate that
2560 * it's not set in this shader.
2561 */
2562 unsigned LocalSize[3];
2563
2564 /**
2565 * Whether a variable work group size has been specified as defined by
2566 * ARB_compute_variable_group_size.
2567 */
2568 bool LocalSizeVariable;
2569 } Comp;
2570 };
2571
2572 /**
2573 * A linked GLSL shader object.
2574 */
2575 struct gl_linked_shader
2576 {
2577 gl_shader_stage Stage;
2578
2579 #ifdef DEBUG
2580 unsigned SourceChecksum;
2581 #endif
2582
2583 struct gl_program *Program; /**< Post-compile assembly code */
2584
2585 /**
2586 * \name Sampler tracking
2587 *
2588 * \note Each of these fields is only set post-linking.
2589 */
2590 /*@{*/
2591 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
2592 /*@}*/
2593
2594 /**
2595 * Number of default uniform block components used by this shader.
2596 *
2597 * This field is only set post-linking.
2598 */
2599 unsigned num_uniform_components;
2600
2601 /**
2602 * Number of combined uniform components used by this shader.
2603 *
2604 * This field is only set post-linking. It is the sum of the uniform block
2605 * sizes divided by sizeof(float), and num_uniform_compoennts.
2606 */
2607 unsigned num_combined_uniform_components;
2608
2609 struct exec_list *ir;
2610 struct exec_list *packed_varyings;
2611 struct exec_list *fragdata_arrays;
2612 struct glsl_symbol_table *symbols;
2613 };
2614
2615
2616 /**
2617 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
2618 * was skipped due to the shader matching one that's been seen before by
2619 * the on-disk cache.
2620 */
2621 enum gl_compile_status
2622 {
2623 COMPILE_FAILURE = 0,
2624 COMPILE_SUCCESS,
2625 COMPILE_SKIPPED,
2626 COMPILED_NO_OPTS
2627 };
2628
2629 /**
2630 * A GLSL shader object.
2631 */
2632 struct gl_shader
2633 {
2634 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
2635 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
2636 * Must be the first field.
2637 */
2638 GLenum16 Type;
2639 gl_shader_stage Stage;
2640 GLuint Name; /**< AKA the handle */
2641 GLint RefCount; /**< Reference count */
2642 GLchar *Label; /**< GL_KHR_debug */
2643 unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
2644 GLboolean DeletePending;
2645 bool IsES; /**< True if this shader uses GLSL ES */
2646
2647 enum gl_compile_status CompileStatus;
2648
2649 #ifdef DEBUG
2650 unsigned SourceChecksum; /**< for debug/logging purposes */
2651 #endif
2652 const GLchar *Source; /**< Source code string */
2653
2654 const GLchar *FallbackSource; /**< Fallback string used by on-disk cache*/
2655
2656 GLchar *InfoLog;
2657
2658 unsigned Version; /**< GLSL version used for linking */
2659
2660 /**
2661 * A bitmask of gl_advanced_blend_mode values
2662 */
2663 GLbitfield BlendSupport;
2664
2665 struct exec_list *ir;
2666 struct glsl_symbol_table *symbols;
2667
2668 /**
2669 * Whether early fragment tests are enabled as defined by
2670 * ARB_shader_image_load_store.
2671 */
2672 bool EarlyFragmentTests;
2673
2674 bool ARB_fragment_coord_conventions_enable;
2675
2676 bool redeclares_gl_fragcoord;
2677 bool uses_gl_fragcoord;
2678
2679 bool PostDepthCoverage;
2680 bool InnerCoverage;
2681
2682 /**
2683 * Fragment shader state from GLSL 1.50 layout qualifiers.
2684 */
2685 bool origin_upper_left;
2686 bool pixel_center_integer;
2687
2688 /**
2689 * Whether bindless_sampler/bindless_image, and respectively
2690 * bound_sampler/bound_image are declared at global scope as defined by
2691 * ARB_bindless_texture.
2692 */
2693 bool bindless_sampler;
2694 bool bindless_image;
2695 bool bound_sampler;
2696 bool bound_image;
2697
2698 /** Global xfb_stride out qualifier if any */
2699 GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
2700
2701 struct gl_shader_info info;
2702
2703 /* ARB_gl_spirv related data */
2704 struct gl_shader_spirv_data *spirv_data;
2705 };
2706
2707
2708 struct gl_uniform_buffer_variable
2709 {
2710 char *Name;
2711
2712 /**
2713 * Name of the uniform as seen by glGetUniformIndices.
2714 *
2715 * glGetUniformIndices requires that the block instance index \b not be
2716 * present in the name of queried uniforms.
2717 *
2718 * \note
2719 * \c gl_uniform_buffer_variable::IndexName and
2720 * \c gl_uniform_buffer_variable::Name may point to identical storage.
2721 */
2722 char *IndexName;
2723
2724 const struct glsl_type *Type;
2725 unsigned int Offset;
2726 GLboolean RowMajor;
2727 };
2728
2729
2730 struct gl_uniform_block
2731 {
2732 /** Declared name of the uniform block */
2733 char *Name;
2734
2735 /** Array of supplemental information about UBO ir_variables. */
2736 struct gl_uniform_buffer_variable *Uniforms;
2737 GLuint NumUniforms;
2738
2739 /**
2740 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
2741 * with glBindBufferBase to bind a buffer object to this uniform block.
2742 */
2743 GLuint Binding;
2744
2745 /**
2746 * Minimum size (in bytes) of a buffer object to back this uniform buffer
2747 * (GL_UNIFORM_BLOCK_DATA_SIZE).
2748 */
2749 GLuint UniformBufferSize;
2750
2751 /** Stages that reference this block */
2752 uint8_t stageref;
2753
2754 /**
2755 * Linearized array index for uniform block instance arrays
2756 *
2757 * Given a uniform block instance array declared with size
2758 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
2759 * have the linearized array index
2760 *
2761 * m-1 m
2762 * i_m + ∑ i_j * ∏ s_k
2763 * j=0 k=j+1
2764 *
2765 * For a uniform block instance that is not an array, this is always 0.
2766 */
2767 uint8_t linearized_array_index;
2768
2769 /**
2770 * Layout specified in the shader
2771 *
2772 * This isn't accessible through the API, but it is used while
2773 * cross-validating uniform blocks.
2774 */
2775 enum glsl_interface_packing _Packing;
2776 GLboolean _RowMajor;
2777 };
2778
2779 /**
2780 * Structure that represents a reference to an atomic buffer from some
2781 * shader program.
2782 */
2783 struct gl_active_atomic_buffer
2784 {
2785 /** Uniform indices of the atomic counters declared within it. */
2786 GLuint *Uniforms;
2787 GLuint NumUniforms;
2788
2789 /** Binding point index associated with it. */
2790 GLuint Binding;
2791
2792 /** Minimum reasonable size it is expected to have. */
2793 GLuint MinimumSize;
2794
2795 /** Shader stages making use of it. */
2796 GLboolean StageReferences[MESA_SHADER_STAGES];
2797 };
2798
2799 /**
2800 * Data container for shader queries. This holds only the minimal
2801 * amount of required information for resource queries to work.
2802 */
2803 struct gl_shader_variable
2804 {
2805 /**
2806 * Declared type of the variable
2807 */
2808 const struct glsl_type *type;
2809
2810 /**
2811 * If the variable is in an interface block, this is the type of the block.
2812 */
2813 const struct glsl_type *interface_type;
2814
2815 /**
2816 * For variables inside structs (possibly recursively), this is the
2817 * outermost struct type.
2818 */
2819 const struct glsl_type *outermost_struct_type;
2820
2821 /**
2822 * Declared name of the variable
2823 */
2824 char *name;
2825
2826 /**
2827 * Storage location of the base of this variable
2828 *
2829 * The precise meaning of this field depends on the nature of the variable.
2830 *
2831 * - Vertex shader input: one of the values from \c gl_vert_attrib.
2832 * - Vertex shader output: one of the values from \c gl_varying_slot.
2833 * - Geometry shader input: one of the values from \c gl_varying_slot.
2834 * - Geometry shader output: one of the values from \c gl_varying_slot.
2835 * - Fragment shader input: one of the values from \c gl_varying_slot.
2836 * - Fragment shader output: one of the values from \c gl_frag_result.
2837 * - Uniforms: Per-stage uniform slot number for default uniform block.
2838 * - Uniforms: Index within the uniform block definition for UBO members.
2839 * - Non-UBO Uniforms: explicit location until linking then reused to
2840 * store uniform slot number.
2841 * - Other: This field is not currently used.
2842 *
2843 * If the variable is a uniform, shader input, or shader output, and the
2844 * slot has not been assigned, the value will be -1.
2845 */
2846 int location;
2847
2848 /**
2849 * Specifies the first component the variable is stored in as per
2850 * ARB_enhanced_layouts.
2851 */
2852 unsigned component:2;
2853
2854 /**
2855 * Output index for dual source blending.
2856 *
2857 * \note
2858 * The GLSL spec only allows the values 0 or 1 for the index in \b dual
2859 * source blending.
2860 */
2861 unsigned index:1;
2862
2863 /**
2864 * Specifies whether a shader input/output is per-patch in tessellation
2865 * shader stages.
2866 */
2867 unsigned patch:1;
2868
2869 /**
2870 * Storage class of the variable.
2871 *
2872 * \sa (n)ir_variable_mode
2873 */
2874 unsigned mode:4;
2875
2876 /**
2877 * Interpolation mode for shader inputs / outputs
2878 *
2879 * \sa glsl_interp_mode
2880 */
2881 unsigned interpolation:2;
2882
2883 /**
2884 * Was the location explicitly set in the shader?
2885 *
2886 * If the location is explicitly set in the shader, it \b cannot be changed
2887 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
2888 * no effect).
2889 */
2890 unsigned explicit_location:1;
2891
2892 /**
2893 * Precision qualifier.
2894 */
2895 unsigned precision:2;
2896 };
2897
2898 /**
2899 * Active resource in a gl_shader_program
2900 */
2901 struct gl_program_resource
2902 {
2903 GLenum16 Type; /** Program interface type. */
2904 const void *Data; /** Pointer to resource associated data structure. */
2905 uint8_t StageReferences; /** Bitmask of shader stage references. */
2906 };
2907
2908 /**
2909 * Link status enum. LINKING_SKIPPED is used to indicate linking
2910 * was skipped due to the shader being loaded from the on-disk cache.
2911 */
2912 enum gl_link_status
2913 {
2914 LINKING_FAILURE = 0,
2915 LINKING_SUCCESS,
2916 LINKING_SKIPPED
2917 };
2918
2919 /**
2920 * A data structure to be shared by gl_shader_program and gl_program.
2921 */
2922 struct gl_shader_program_data
2923 {
2924 GLint RefCount; /**< Reference count */
2925
2926 /** SHA1 hash of linked shader program */
2927 unsigned char sha1[20];
2928
2929 unsigned NumUniformStorage;
2930 unsigned NumHiddenUniforms;
2931 struct gl_uniform_storage *UniformStorage;
2932
2933 unsigned NumUniformBlocks;
2934 unsigned NumShaderStorageBlocks;
2935
2936 struct gl_uniform_block *UniformBlocks;
2937 struct gl_uniform_block *ShaderStorageBlocks;
2938
2939 struct gl_active_atomic_buffer *AtomicBuffers;
2940 unsigned NumAtomicBuffers;
2941
2942 /* Shader cache variables used during restore */
2943 unsigned NumUniformDataSlots;
2944 union gl_constant_value *UniformDataSlots;
2945
2946 /* Used to hold initial uniform values for program binary restores.
2947 *
2948 * From the ARB_get_program_binary spec:
2949 *
2950 * "A successful call to ProgramBinary will reset all uniform
2951 * variables to their initial values. The initial value is either
2952 * the value of the variable's initializer as specified in the
2953 * original shader source, or 0 if no initializer was present.
2954 */
2955 union gl_constant_value *UniformDataDefaults;
2956
2957 GLboolean Validated;
2958
2959 /** List of all active resources after linking. */
2960 struct gl_program_resource *ProgramResourceList;
2961 unsigned NumProgramResourceList;
2962
2963 enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
2964 GLchar *InfoLog;
2965
2966 unsigned Version; /**< GLSL version used for linking */
2967
2968 /* Mask of stages this program was linked against */
2969 unsigned linked_stages;
2970 };
2971
2972 /**
2973 * A GLSL program object.
2974 * Basically a linked collection of vertex and fragment shaders.
2975 */
2976 struct gl_shader_program
2977 {
2978 GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */
2979 GLuint Name; /**< aka handle or ID */
2980 GLchar *Label; /**< GL_KHR_debug */
2981 GLint RefCount; /**< Reference count */
2982 GLboolean DeletePending;
2983
2984 /**
2985 * Is the application intending to glGetProgramBinary this program?
2986 */
2987 GLboolean BinaryRetreivableHint;
2988
2989 /**
2990 * Indicates whether program can be bound for individual pipeline stages
2991 * using UseProgramStages after it is next linked.
2992 */
2993 GLboolean SeparateShader;
2994
2995 GLuint NumShaders; /**< number of attached shaders */
2996 struct gl_shader **Shaders; /**< List of attached the shaders */
2997
2998 /**
2999 * User-defined attribute bindings
3000 *
3001 * These are set via \c glBindAttribLocation and are used to direct the
3002 * GLSL linker. These are \b not the values used in the compiled shader,
3003 * and they are \b not the values returned by \c glGetAttribLocation.
3004 */
3005 struct string_to_uint_map *AttributeBindings;
3006
3007 /**
3008 * User-defined fragment data bindings
3009 *
3010 * These are set via \c glBindFragDataLocation and are used to direct the
3011 * GLSL linker. These are \b not the values used in the compiled shader,
3012 * and they are \b not the values returned by \c glGetFragDataLocation.
3013 */
3014 struct string_to_uint_map *FragDataBindings;
3015 struct string_to_uint_map *FragDataIndexBindings;
3016
3017 /**
3018 * Transform feedback varyings last specified by
3019 * glTransformFeedbackVaryings().
3020 *
3021 * For the current set of transform feedback varyings used for transform
3022 * feedback output, see LinkedTransformFeedback.
3023 */
3024 struct {
3025 GLenum16 BufferMode;
3026 /** Global xfb_stride out qualifier if any */
3027 GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
3028 GLuint NumVarying;
3029 GLchar **VaryingNames; /**< Array [NumVarying] of char * */
3030 } TransformFeedback;
3031
3032 struct gl_program *last_vert_prog;
3033
3034 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
3035 enum gl_frag_depth_layout FragDepthLayout;
3036
3037 /**
3038 * Geometry shader state - copied into gl_program by
3039 * _mesa_copy_linked_program_data().
3040 */
3041 struct {
3042 GLint VerticesIn;
3043
3044 bool UsesEndPrimitive;
3045 bool UsesStreams;
3046 } Geom;
3047
3048 /**
3049 * Compute shader state - copied into gl_program by
3050 * _mesa_copy_linked_program_data().
3051 */
3052 struct {
3053 /**
3054 * Size of shared variables accessed by the compute shader.
3055 */
3056 unsigned SharedSize;
3057 } Comp;
3058
3059 /** Data shared by gl_program and gl_shader_program */
3060 struct gl_shader_program_data *data;
3061
3062 /**
3063 * Mapping from GL uniform locations returned by \c glUniformLocation to
3064 * UniformStorage entries. Arrays will have multiple contiguous slots
3065 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
3066 */
3067 unsigned NumUniformRemapTable;
3068 struct gl_uniform_storage **UniformRemapTable;
3069
3070 /**
3071 * Sometimes there are empty slots left over in UniformRemapTable after we
3072 * allocate slots to explicit locations. This list stores the blocks of
3073 * continuous empty slots inside UniformRemapTable.
3074 */
3075 struct exec_list EmptyUniformLocations;
3076
3077 /**
3078 * Total number of explicit uniform location including inactive uniforms.
3079 */
3080 unsigned NumExplicitUniformLocations;
3081
3082 /**
3083 * Map of active uniform names to locations
3084 *
3085 * Maps any active uniform that is not an array element to a location.
3086 * Each active uniform, including individual structure members will appear
3087 * in this map. This roughly corresponds to the set of names that would be
3088 * enumerated by \c glGetActiveUniform.
3089 */
3090 struct string_to_uint_map *UniformHash;
3091
3092 GLboolean SamplersValidated; /**< Samplers validated against texture units? */
3093
3094 bool IsES; /**< True if this program uses GLSL ES */
3095
3096 /**
3097 * Per-stage shaders resulting from the first stage of linking.
3098 *
3099 * Set of linked shaders for this program. The array is accessed using the
3100 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3101 * \c NULL.
3102 */
3103 struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
3104
3105 /**
3106 * True if any of the fragment shaders attached to this program use:
3107 * #extension ARB_fragment_coord_conventions: enable
3108 */
3109 GLboolean ARB_fragment_coord_conventions_enable;
3110 };
3111
3112
3113 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3114 #define GLSL_LOG 0x2 /**< Write shaders to files */
3115 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3116 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3117 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3118 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3119 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3120 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3121 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3122 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3123
3124
3125 /**
3126 * Context state for GLSL vertex/fragment shaders.
3127 * Extended to support pipeline object
3128 */
3129 struct gl_pipeline_object
3130 {
3131 /** Name of the pipeline object as received from glGenProgramPipelines.
3132 * It would be 0 for shaders without separate shader objects.
3133 */
3134 GLuint Name;
3135
3136 GLint RefCount;
3137
3138 GLchar *Label; /**< GL_KHR_debug */
3139
3140 /**
3141 * Programs used for rendering
3142 *
3143 * There is a separate program set for each shader stage.
3144 */
3145 struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
3146
3147 struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
3148
3149 /**
3150 * Program used by glUniform calls.
3151 *
3152 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3153 */
3154 struct gl_shader_program *ActiveProgram;
3155
3156 GLbitfield Flags; /**< Mask of GLSL_x flags */
3157 GLboolean EverBound; /**< Has the pipeline object been created */
3158 GLboolean Validated; /**< Pipeline Validation status */
3159
3160 GLchar *InfoLog;
3161 };
3162
3163 /**
3164 * Context state for GLSL pipeline shaders.
3165 */
3166 struct gl_pipeline_shader_state
3167 {
3168 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3169 struct gl_pipeline_object *Current;
3170
3171 /** Default Object to ensure that _Shader is never NULL */
3172 struct gl_pipeline_object *Default;
3173
3174 /** Pipeline objects */
3175 struct _mesa_HashTable *Objects;
3176 };
3177
3178 /**
3179 * Compiler options for a single GLSL shaders type
3180 */
3181 struct gl_shader_compiler_options
3182 {
3183 /** Driver-selectable options: */
3184 GLboolean EmitNoLoops;
3185 GLboolean EmitNoCont; /**< Emit CONT opcode? */
3186 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
3187 GLboolean EmitNoPow; /**< Emit POW opcodes? */
3188 GLboolean EmitNoSat; /**< Emit SAT opcodes? */
3189 GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
3190 * gl_CullDistance together from
3191 * float[8] to vec4[2]
3192 **/
3193
3194 /**
3195 * \name Forms of indirect addressing the driver cannot do.
3196 */
3197 /*@{*/
3198 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
3199 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
3200 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
3201 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
3202 GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
3203 /*@}*/
3204
3205 GLuint MaxIfDepth; /**< Maximum nested IF blocks */
3206 GLuint MaxUnrollIterations;
3207
3208 /**
3209 * Optimize code for array of structures backends.
3210 *
3211 * This is a proxy for:
3212 * - preferring DP4 instructions (rather than MUL/MAD) for
3213 * matrix * vector operations, such as position transformation.
3214 */
3215 GLboolean OptimizeForAOS;
3216
3217 /** Lower UBO and SSBO access to intrinsics. */
3218 GLboolean LowerBufferInterfaceBlocks;
3219
3220 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3221 GLboolean ClampBlockIndicesToArrayBounds;
3222
3223 const struct nir_shader_compiler_options *NirOptions;
3224 };
3225
3226
3227 /**
3228 * Occlusion/timer query object.
3229 */
3230 struct gl_query_object
3231 {
3232 GLenum Target; /**< The query target, when active */
3233 GLuint Id; /**< hash table ID/name */
3234 GLchar *Label; /**< GL_KHR_debug */
3235 GLuint64EXT Result; /**< the counter */
3236 GLboolean Active; /**< inside Begin/EndQuery */
3237 GLboolean Ready; /**< result is ready? */
3238 GLboolean EverBound;/**< has query object ever been bound */
3239 GLuint Stream; /**< The stream */
3240 };
3241
3242
3243 /**
3244 * Context state for query objects.
3245 */
3246 struct gl_query_state
3247 {
3248 struct _mesa_HashTable *QueryObjects;
3249 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
3250 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
3251
3252 /** GL_NV_conditional_render */
3253 struct gl_query_object *CondRenderQuery;
3254
3255 /** GL_EXT_transform_feedback */
3256 struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
3257 struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
3258
3259 /** GL_ARB_transform_feedback_overflow_query */
3260 struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS];
3261 struct gl_query_object *TransformFeedbackOverflowAny;
3262
3263 /** GL_ARB_timer_query */
3264 struct gl_query_object *TimeElapsed;
3265
3266 /** GL_ARB_pipeline_statistics_query */
3267 struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
3268
3269 GLenum16 CondRenderMode;
3270 };
3271
3272
3273 /** Sync object state */
3274 struct gl_sync_object
3275 {
3276 GLuint Name; /**< Fence name */
3277 GLint RefCount; /**< Reference count */
3278 GLchar *Label; /**< GL_KHR_debug */
3279 GLboolean DeletePending; /**< Object was deleted while there were still
3280 * live references (e.g., sync not yet finished)
3281 */
3282 GLenum16 SyncCondition;
3283 GLbitfield Flags; /**< Flags passed to glFenceSync */
3284 GLuint StatusFlag:1; /**< Has the sync object been signaled? */
3285 };
3286
3287
3288 /**
3289 * State which can be shared by multiple contexts:
3290 */
3291 struct gl_shared_state
3292 {
3293 simple_mtx_t Mutex; /**< for thread safety */
3294 GLint RefCount; /**< Reference count */
3295 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
3296 struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */
3297 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
3298
3299 /** Default texture objects (shared by all texture units) */
3300 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
3301
3302 /** Fallback texture used when a bound texture is incomplete */
3303 struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
3304
3305 /**
3306 * \name Thread safety and statechange notification for texture
3307 * objects.
3308 *
3309 * \todo Improve the granularity of locking.
3310 */
3311 /*@{*/
3312 mtx_t TexMutex; /**< texobj thread safety */
3313 GLuint TextureStateStamp; /**< state notification for shared tex */
3314 /*@}*/
3315
3316 /** Default buffer object for vertex arrays that aren't in VBOs */
3317 struct gl_buffer_object *NullBufferObj;
3318
3319 /**
3320 * \name Vertex/geometry/fragment programs
3321 */
3322 /*@{*/
3323 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
3324 struct gl_program *DefaultVertexProgram;
3325 struct gl_program *DefaultFragmentProgram;
3326 /*@}*/
3327
3328 /* GL_ATI_fragment_shader */
3329 struct _mesa_HashTable *ATIShaders;
3330 struct ati_fragment_shader *DefaultFragmentShader;
3331
3332 struct _mesa_HashTable *BufferObjects;
3333
3334 /** Table of both gl_shader and gl_shader_program objects */
3335 struct _mesa_HashTable *ShaderObjects;
3336
3337 /* GL_EXT_framebuffer_object */
3338 struct _mesa_HashTable *RenderBuffers;
3339 struct _mesa_HashTable *FrameBuffers;
3340
3341 /* GL_ARB_sync */
3342 struct set *SyncObjects;
3343
3344 /** GL_ARB_sampler_objects */
3345 struct _mesa_HashTable *SamplerObjects;
3346
3347 /* GL_ARB_bindless_texture */
3348 struct hash_table_u64 *TextureHandles;
3349 struct hash_table_u64 *ImageHandles;
3350 mtx_t HandlesMutex; /**< For texture/image handles safety */
3351
3352 /**
3353 * Some context in this share group was affected by a GPU reset
3354 *
3355 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3356 * been affected by a GPU reset must also return
3357 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3358 *
3359 * Once this field becomes true, it is never reset to false.
3360 */
3361 bool ShareGroupReset;
3362
3363 /** EXT_external_objects */
3364 struct _mesa_HashTable *MemoryObjects;
3365
3366 /** EXT_semaphore */
3367 struct _mesa_HashTable *SemaphoreObjects;
3368
3369 /**
3370 * Some context in this share group was affected by a disjoint
3371 * operation. This operation can be anything that has effects on
3372 * values of timer queries in such manner that they become invalid for
3373 * performance metrics. As example gpu reset, counter overflow or gpu
3374 * frequency changes.
3375 */
3376 bool DisjointOperation;
3377 };
3378
3379
3380
3381 /**
3382 * Renderbuffers represent drawing surfaces such as color, depth and/or
3383 * stencil. A framebuffer object has a set of renderbuffers.
3384 * Drivers will typically derive subclasses of this type.
3385 */
3386 struct gl_renderbuffer
3387 {
3388 simple_mtx_t Mutex; /**< for thread safety */
3389 GLuint ClassID; /**< Useful for drivers */
3390 GLuint Name;
3391 GLchar *Label; /**< GL_KHR_debug */
3392 GLint RefCount;
3393 GLuint Width, Height;
3394 GLuint Depth;
3395 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
3396 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
3397 /**
3398 * True for renderbuffers that wrap textures, giving the driver a chance to
3399 * flush render caches through the FinishRenderTexture hook.
3400 *
3401 * Drivers may also set this on renderbuffers other than those generated by
3402 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3403 * called without a rb->TexImage.
3404 */
3405 GLboolean NeedsFinishRenderTexture;
3406 GLubyte NumSamples; /**< zero means not multisampled */
3407 GLenum16 InternalFormat; /**< The user-specified format */
3408 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3409 GL_STENCIL_INDEX. */
3410 mesa_format Format; /**< The actual renderbuffer memory format */
3411 /**
3412 * Pointer to the texture image if this renderbuffer wraps a texture,
3413 * otherwise NULL.
3414 *
3415 * Note that the reference on the gl_texture_object containing this
3416 * TexImage is held by the gl_renderbuffer_attachment.
3417 */
3418 struct gl_texture_image *TexImage;
3419
3420 /** Delete this renderbuffer */
3421 void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
3422
3423 /** Allocate new storage for this renderbuffer */
3424 GLboolean (*AllocStorage)(struct gl_context *ctx,
3425 struct gl_renderbuffer *rb,
3426 GLenum internalFormat,
3427 GLuint width, GLuint height);
3428 };
3429
3430
3431 /**
3432 * A renderbuffer attachment points to either a texture object (and specifies
3433 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3434 */
3435 struct gl_renderbuffer_attachment
3436 {
3437 GLenum16 Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3438 GLboolean Complete;
3439
3440 /**
3441 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3442 * application supplied renderbuffer object.
3443 */
3444 struct gl_renderbuffer *Renderbuffer;
3445
3446 /**
3447 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3448 * supplied texture object.
3449 */
3450 struct gl_texture_object *Texture;
3451 GLuint TextureLevel; /**< Attached mipmap level. */
3452 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
3453 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
3454 * and 2D array textures */
3455 GLboolean Layered;
3456 };
3457
3458
3459 /**
3460 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3461 * In C++ terms, think of this as a base class from which device drivers
3462 * will make derived classes.
3463 */
3464 struct gl_framebuffer
3465 {
3466 simple_mtx_t Mutex; /**< for thread safety */
3467 /**
3468 * If zero, this is a window system framebuffer. If non-zero, this
3469 * is a FBO framebuffer; note that for some devices (i.e. those with
3470 * a natural pixel coordinate system for FBOs that differs from the
3471 * OpenGL/Mesa coordinate system), this means that the viewport,
3472 * polygon face orientation, and polygon stipple will have to be inverted.
3473 */
3474 GLuint Name;
3475 GLint RefCount;
3476
3477 GLchar *Label; /**< GL_KHR_debug */
3478
3479 GLboolean DeletePending;
3480
3481 /**
3482 * The framebuffer's visual. Immutable if this is a window system buffer.
3483 * Computed from attachments if user-made FBO.
3484 */
3485 struct gl_config Visual;
3486
3487 /**
3488 * Size of frame buffer in pixels. If there are no attachments, then both
3489 * of these are 0.
3490 */
3491 GLuint Width, Height;
3492
3493 /**
3494 * In the case that the framebuffer has no attachment (i.e.
3495 * GL_ARB_framebuffer_no_attachments) then the geometry of
3496 * the framebuffer is specified by the default values.
3497 */
3498 struct {
3499 GLuint Width, Height, Layers, NumSamples;
3500 GLboolean FixedSampleLocations;
3501 /* Derived from NumSamples by the driver so that it can choose a valid
3502 * value for the hardware.
3503 */
3504 GLuint _NumSamples;
3505 } DefaultGeometry;
3506
3507 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3508 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3509 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3510 */
3511 /*@{*/
3512 GLint _Xmin, _Xmax;
3513 GLint _Ymin, _Ymax;
3514 /*@}*/
3515
3516 /** \name Derived Z buffer stuff */
3517 /*@{*/
3518 GLuint _DepthMax; /**< Max depth buffer value */
3519 GLfloat _DepthMaxF; /**< Float max depth buffer value */
3520 GLfloat _MRD; /**< minimum resolvable difference in Z values */
3521 /*@}*/
3522
3523 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3524 GLenum16 _Status;
3525
3526 /** Whether one of Attachment has Type != GL_NONE
3527 * NOTE: the values for Width and Height are set to 0 in case of having
3528 * no attachments, a backend driver supporting the extension
3529 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3530 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3531 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3532 * _Ymax do NOT take into account _HasAttachments being false). To get the
3533 * geometry of the framebuffer, the helper functions
3534 * _mesa_geometric_width(),
3535 * _mesa_geometric_height(),
3536 * _mesa_geometric_samples() and
3537 * _mesa_geometric_layers()
3538 * are available that check _HasAttachments.
3539 */
3540 bool _HasAttachments;
3541
3542 GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
3543
3544 /* ARB_color_buffer_float */
3545 GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
3546 GLboolean _HasSNormOrFloatColorBuffer;
3547
3548 /**
3549 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3550 * is not layered. For cube maps and cube map arrays, each cube face
3551 * counts as a layer. As the case for Width, Height a backend driver
3552 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3553 * in the case that _HasAttachments is false
3554 */
3555 GLuint MaxNumLayers;
3556
3557 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3558 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
3559
3560 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3561 * attribute group and GL_PIXEL attribute group, respectively.
3562 */
3563 GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS];
3564 GLenum16 ColorReadBuffer;
3565
3566 /** Computed from ColorDraw/ReadBuffer above */
3567 GLuint _NumColorDrawBuffers;
3568 gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
3569 gl_buffer_index _ColorReadBufferIndex;
3570 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
3571 struct gl_renderbuffer *_ColorReadBuffer;
3572
3573 /** Delete this framebuffer */
3574 void (*Delete)(struct gl_framebuffer *fb);
3575 };
3576
3577
3578 /**
3579 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3580 */
3581 struct gl_precision
3582 {
3583 GLushort RangeMin; /**< min value exponent */
3584 GLushort RangeMax; /**< max value exponent */
3585 GLushort Precision; /**< number of mantissa bits */
3586 };
3587
3588
3589 /**
3590 * Limits for vertex, geometry and fragment programs/shaders.
3591 */
3592 struct gl_program_constants
3593 {
3594 /* logical limits */
3595 GLuint MaxInstructions;
3596 GLuint MaxAluInstructions;
3597 GLuint MaxTexInstructions;
3598 GLuint MaxTexIndirections;
3599 GLuint MaxAttribs;
3600 GLuint MaxTemps;
3601 GLuint MaxAddressRegs;
3602 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3603 GLuint MaxParameters;
3604 GLuint MaxLocalParams;
3605 GLuint MaxEnvParams;
3606 /* native/hardware limits */
3607 GLuint MaxNativeInstructions;
3608 GLuint MaxNativeAluInstructions;
3609 GLuint MaxNativeTexInstructions;
3610 GLuint MaxNativeTexIndirections;
3611 GLuint MaxNativeAttribs;
3612 GLuint MaxNativeTemps;
3613 GLuint MaxNativeAddressRegs;
3614 GLuint MaxNativeParameters;
3615 /* For shaders */
3616 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
3617
3618 /**
3619 * \name Per-stage input / output limits
3620 *
3621 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3622 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3623 * ES). This is stored as \c gl_constants::MaxVarying.
3624 *
3625 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3626 * variables. Each stage as a certain number of outputs that it can feed
3627 * to the next stage and a certain number inputs that it can consume from
3628 * the previous stage.
3629 *
3630 * Vertex shader inputs do not participate this in this accounting.
3631 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3632 *
3633 * Fragment shader outputs do not participate this in this accounting.
3634 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3635 */
3636 /*@{*/
3637 GLuint MaxInputComponents;
3638 GLuint MaxOutputComponents;
3639 /*@}*/
3640
3641 /* ES 2.0 and GL_ARB_ES2_compatibility */
3642 struct gl_precision LowFloat, MediumFloat, HighFloat;
3643 struct gl_precision LowInt, MediumInt, HighInt;
3644 /* GL_ARB_uniform_buffer_object */
3645 GLuint MaxUniformBlocks;
3646 GLuint MaxCombinedUniformComponents;
3647 GLuint MaxTextureImageUnits;
3648
3649 /* GL_ARB_shader_atomic_counters */
3650 GLuint MaxAtomicBuffers;
3651 GLuint MaxAtomicCounters;
3652
3653 /* GL_ARB_shader_image_load_store */
3654 GLuint MaxImageUniforms;
3655
3656 /* GL_ARB_shader_storage_buffer_object */
3657 GLuint MaxShaderStorageBlocks;
3658 };
3659
3660 /**
3661 * Constants which may be overridden by device driver during context creation
3662 * but are never changed after that.
3663 */
3664 struct gl_constants
3665 {
3666 GLuint MaxTextureMbytes; /**< Max memory per image, in MB */
3667 GLuint MaxTextureLevels; /**< Max mipmap levels. */
3668 GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
3669 GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
3670 GLuint MaxArrayTextureLayers; /**< Max layers in array textures */
3671 GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */
3672 GLuint MaxTextureCoordUnits;
3673 GLuint MaxCombinedTextureImageUnits;
3674 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3675 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
3676 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
3677 GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
3678
3679 GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
3680
3681 GLuint MaxArrayLockSize;
3682
3683 GLint SubPixelBits;
3684
3685 GLfloat MinPointSize, MaxPointSize; /**< aliased */
3686 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
3687 GLfloat PointSizeGranularity;
3688 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
3689 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
3690 GLfloat LineWidthGranularity;
3691
3692 GLuint MaxClipPlanes;
3693 GLuint MaxLights;
3694 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
3695 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
3696
3697 GLuint MaxViewportWidth, MaxViewportHeight;
3698 GLuint MaxViewports; /**< GL_ARB_viewport_array */
3699 GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
3700 struct {
3701 GLfloat Min;
3702 GLfloat Max;
3703 } ViewportBounds; /**< GL_ARB_viewport_array */
3704 GLuint MaxWindowRectangles; /**< GL_EXT_window_rectangles */
3705
3706 struct gl_program_constants Program[MESA_SHADER_STAGES];
3707 GLuint MaxProgramMatrices;
3708 GLuint MaxProgramMatrixStackDepth;
3709
3710 struct {
3711 GLuint SamplesPassed;
3712 GLuint TimeElapsed;
3713 GLuint Timestamp;
3714 GLuint PrimitivesGenerated;
3715 GLuint PrimitivesWritten;
3716 GLuint VerticesSubmitted;
3717 GLuint PrimitivesSubmitted;
3718 GLuint VsInvocations;
3719 GLuint TessPatches;
3720 GLuint TessInvocations;
3721 GLuint GsInvocations;
3722 GLuint GsPrimitives;
3723 GLuint FsInvocations;
3724 GLuint ComputeInvocations;
3725 GLuint ClInPrimitives;
3726 GLuint ClOutPrimitives;
3727 } QueryCounterBits;
3728
3729 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
3730
3731 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
3732 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
3733 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
3734
3735 /**
3736 * GL_ARB_framebuffer_no_attachments
3737 */
3738 GLuint MaxFramebufferWidth;
3739 GLuint MaxFramebufferHeight;
3740 GLuint MaxFramebufferLayers;
3741 GLuint MaxFramebufferSamples;
3742
3743 /** Number of varying vectors between any two shader stages. */
3744 GLuint MaxVarying;
3745
3746 /** @{
3747 * GL_ARB_uniform_buffer_object
3748 */
3749 GLuint MaxCombinedUniformBlocks;
3750 GLuint MaxUniformBufferBindings;
3751 GLuint MaxUniformBlockSize;
3752 GLuint UniformBufferOffsetAlignment;
3753 /** @} */
3754
3755 /** @{
3756 * GL_ARB_shader_storage_buffer_object
3757 */
3758 GLuint MaxCombinedShaderStorageBlocks;
3759 GLuint MaxShaderStorageBufferBindings;
3760 GLuint MaxShaderStorageBlockSize;
3761 GLuint ShaderStorageBufferOffsetAlignment;
3762 /** @} */
3763
3764 /**
3765 * GL_ARB_explicit_uniform_location
3766 */
3767 GLuint MaxUserAssignableUniformLocations;
3768
3769 /** geometry shader */
3770 GLuint MaxGeometryOutputVertices;
3771 GLuint MaxGeometryTotalOutputComponents;
3772
3773 GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3774
3775 /**
3776 * Changes default GLSL extension behavior from "error" to "warn". It's out
3777 * of spec, but it can make some apps work that otherwise wouldn't.
3778 */
3779 GLboolean ForceGLSLExtensionsWarn;
3780
3781 /**
3782 * If non-zero, forces GLSL shaders to behave as if they began
3783 * with "#version ForceGLSLVersion".
3784 */
3785 GLuint ForceGLSLVersion;
3786
3787 /**
3788 * Allow GLSL #extension directives in the middle of shaders.
3789 */
3790 GLboolean AllowGLSLExtensionDirectiveMidShader;
3791
3792 /**
3793 * Allow GLSL built-in variables to be redeclared verbatim
3794 */
3795 GLboolean AllowGLSLBuiltinVariableRedeclaration;
3796
3797 /**
3798 * Allow GLSL interpolation qualifier mismatch across shader stages.
3799 */
3800 GLboolean AllowGLSLCrossStageInterpolationMismatch;
3801
3802 /**
3803 * Allow creating a higher compat profile (version 3.1+) for apps that
3804 * request it. Be careful when adding that driconf option because some
3805 * features are unimplemented and might not work correctly.
3806 */
3807 GLboolean AllowHigherCompatVersion;
3808
3809 /**
3810 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3811 * D3D9 when apps rely on this behaviour.
3812 */
3813 GLboolean ForceGLSLAbsSqrt;
3814
3815 /**
3816 * Force uninitialized variables to default to zero.
3817 */
3818 GLboolean GLSLZeroInit;
3819
3820 /**
3821 * Does the driver support real 32-bit integers? (Otherwise, integers are
3822 * simulated via floats.)
3823 */
3824 GLboolean NativeIntegers;
3825
3826 /**
3827 * Does VertexID count from zero or from base vertex?
3828 *
3829 * \note
3830 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3831 * ignored and need not be set.
3832 */
3833 bool VertexID_is_zero_based;
3834
3835 /**
3836 * If the driver supports real 32-bit integers, what integer value should be
3837 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3838 */
3839 GLuint UniformBooleanTrue;
3840
3841 /**
3842 * Maximum amount of time, measured in nanseconds, that the server can wait.
3843 */
3844 GLuint64 MaxServerWaitTimeout;
3845
3846 /** GL_EXT_provoking_vertex */
3847 GLboolean QuadsFollowProvokingVertexConvention;
3848
3849 /** GL_ARB_viewport_array */
3850 GLenum16 LayerAndVPIndexProvokingVertex;
3851
3852 /** OpenGL version 3.0 */
3853 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3854
3855 /** OpenGL version 3.2 */
3856 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
3857
3858 /** OpenGL version 4.4 */
3859 GLuint MaxVertexAttribStride;
3860
3861 /** GL_EXT_transform_feedback */
3862 GLuint MaxTransformFeedbackBuffers;
3863 GLuint MaxTransformFeedbackSeparateComponents;
3864 GLuint MaxTransformFeedbackInterleavedComponents;
3865 GLuint MaxVertexStreams;
3866
3867 /** GL_EXT_gpu_shader4 */
3868 GLint MinProgramTexelOffset, MaxProgramTexelOffset;
3869
3870 /** GL_ARB_texture_gather */
3871 GLuint MinProgramTextureGatherOffset;
3872 GLuint MaxProgramTextureGatherOffset;
3873 GLuint MaxProgramTextureGatherComponents;
3874
3875 /* GL_ARB_robustness */
3876 GLenum16 ResetStrategy;
3877
3878 /* GL_KHR_robustness */
3879 GLboolean RobustAccess;
3880
3881 /* GL_ARB_blend_func_extended */
3882 GLuint MaxDualSourceDrawBuffers;
3883
3884 /**
3885 * Whether the implementation strips out and ignores texture borders.
3886 *
3887 * Many GPU hardware implementations don't support rendering with texture
3888 * borders and mipmapped textures. (Note: not static border color, but the
3889 * old 1-pixel border around each edge). Implementations then have to do
3890 * slow fallbacks to be correct, or just ignore the border and be fast but
3891 * wrong. Setting the flag strips the border off of TexImage calls,
3892 * providing "fast but wrong" at significantly reduced driver complexity.
3893 *
3894 * Texture borders are deprecated in GL 3.0.
3895 **/
3896 GLboolean StripTextureBorder;
3897
3898 /**
3899 * For drivers which can do a better job at eliminating unused uniforms
3900 * than the GLSL compiler.
3901 *
3902 * XXX Remove these as soon as a better solution is available.
3903 */
3904 GLboolean GLSLSkipStrictMaxUniformLimitCheck;
3905
3906 /** Whether gl_FragCoord and gl_FrontFacing are system values. */
3907 bool GLSLFragCoordIsSysVal;
3908 bool GLSLFrontFacingIsSysVal;
3909
3910 /**
3911 * Run the minimum amount of GLSL optimizations to be able to link
3912 * shaders optimally (eliminate dead varyings and uniforms) and just do
3913 * all the necessary lowering.
3914 */
3915 bool GLSLOptimizeConservatively;
3916
3917 /**
3918 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3919 * (otherwise, they're system values).
3920 */
3921 bool GLSLTessLevelsAsInputs;
3922
3923 /**
3924 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3925 * than passing the transform feedback object to the drawing function.
3926 */
3927 GLboolean AlwaysUseGetTransformFeedbackVertexCount;
3928
3929 /** GL_ARB_map_buffer_alignment */
3930 GLuint MinMapBufferAlignment;
3931
3932 /**
3933 * Disable varying packing. This is out of spec, but potentially useful
3934 * for older platforms that supports a limited number of texture
3935 * indirections--on these platforms, unpacking the varyings in the fragment
3936 * shader increases the number of texture indirections by 1, which might
3937 * make some shaders not executable at all.
3938 *
3939 * Drivers that support transform feedback must set this value to GL_FALSE.
3940 */
3941 GLboolean DisableVaryingPacking;
3942
3943 /**
3944 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3945 * layout is set as shared (the default) or packed. However most Mesa drivers
3946 * just use STD140 for these layouts. This flag allows drivers to use STD430
3947 * for packed and shared layouts which allows arrays to be packed more
3948 * tightly.
3949 */
3950 bool UseSTD430AsDefaultPacking;
3951
3952 /**
3953 * Should meaningful names be generated for compiler temporary variables?
3954 *
3955 * Generally, it is not useful to have the compiler generate "meaningful"
3956 * names for temporary variables that it creates. This can, however, be a
3957 * useful debugging aid. In Mesa debug builds or release builds when
3958 * MESA_GLSL is set at run-time, meaningful names will be generated.
3959 * Drivers can also force names to be generated by setting this field.
3960 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
3961 * vertex shader assembly) is set at run-time.
3962 */
3963 bool GenerateTemporaryNames;
3964
3965 /*
3966 * Maximum value supported for an index in DrawElements and friends.
3967 *
3968 * This must be at least (1ull<<24)-1. The default value is
3969 * (1ull<<32)-1.
3970 *
3971 * \since ES 3.0 or GL_ARB_ES3_compatibility
3972 * \sa _mesa_init_constants
3973 */
3974 GLuint64 MaxElementIndex;
3975
3976 /**
3977 * Disable interpretation of line continuations (lines ending with a
3978 * backslash character ('\') in GLSL source.
3979 */
3980 GLboolean DisableGLSLLineContinuations;
3981
3982 /** GL_ARB_texture_multisample */
3983 GLint MaxColorTextureSamples;
3984 GLint MaxDepthTextureSamples;
3985 GLint MaxIntegerSamples;
3986
3987 /**
3988 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
3989 * samples are laid out in a rectangular grid roughly corresponding to
3990 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
3991 * are used to map indices of rectangular grid to sample numbers within
3992 * a pixel. This mapping of indices to sample numbers must be initialized
3993 * by the driver for the target hardware. For example, if we have the 8X
3994 * MSAA sample number layout (sample positions) for XYZ hardware:
3995 *
3996 * sample indices layout sample number layout
3997 * --------- ---------
3998 * | 0 | 1 | | a | b |
3999 * --------- ---------
4000 * | 2 | 3 | | c | d |
4001 * --------- ---------
4002 * | 4 | 5 | | e | f |
4003 * --------- ---------
4004 * | 6 | 7 | | g | h |
4005 * --------- ---------
4006 *
4007 * Where a,b,c,d,e,f,g,h are integers between [0-7].
4008 *
4009 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
4010 * below:
4011 * SampleMap8x = {a, b, c, d, e, f, g, h};
4012 *
4013 * Follow the logic for sample counts 2-8.
4014 *
4015 * For 16x the sample indices layout as a 4x4 grid as follows:
4016 *
4017 * -----------------
4018 * | 0 | 1 | 2 | 3 |
4019 * -----------------
4020 * | 4 | 5 | 6 | 7 |
4021 * -----------------
4022 * | 8 | 9 |10 |11 |
4023 * -----------------
4024 * |12 |13 |14 |15 |
4025 * -----------------
4026 */
4027 uint8_t SampleMap2x[2];
4028 uint8_t SampleMap4x[4];
4029 uint8_t SampleMap8x[8];
4030 uint8_t SampleMap16x[16];
4031
4032 /** GL_ARB_shader_atomic_counters */
4033 GLuint MaxAtomicBufferBindings;
4034 GLuint MaxAtomicBufferSize;
4035 GLuint MaxCombinedAtomicBuffers;
4036 GLuint MaxCombinedAtomicCounters;
4037
4038 /** GL_ARB_vertex_attrib_binding */
4039 GLint MaxVertexAttribRelativeOffset;
4040 GLint MaxVertexAttribBindings;
4041
4042 /* GL_ARB_shader_image_load_store */
4043 GLuint MaxImageUnits;
4044 GLuint MaxCombinedShaderOutputResources;
4045 GLuint MaxImageSamples;
4046 GLuint MaxCombinedImageUniforms;
4047
4048 /** GL_ARB_compute_shader */
4049 GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
4050 GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
4051 GLuint MaxComputeWorkGroupInvocations;
4052 GLuint MaxComputeSharedMemorySize;
4053
4054 /** GL_ARB_compute_variable_group_size */
4055 GLuint MaxComputeVariableGroupSize[3]; /* Array of x, y, z dimensions */
4056 GLuint MaxComputeVariableGroupInvocations;
4057
4058 /** GL_ARB_gpu_shader5 */
4059 GLfloat MinFragmentInterpolationOffset;
4060 GLfloat MaxFragmentInterpolationOffset;
4061
4062 GLboolean FakeSWMSAA;
4063
4064 /** GL_KHR_context_flush_control */
4065 GLenum16 ContextReleaseBehavior;
4066
4067 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
4068
4069 /** GL_ARB_tessellation_shader */
4070 GLuint MaxPatchVertices;
4071 GLuint MaxTessGenLevel;
4072 GLuint MaxTessPatchComponents;
4073 GLuint MaxTessControlTotalOutputComponents;
4074 bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
4075 bool PrimitiveRestartForPatches;
4076 bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
4077 * gl_LocalInvocationIndex based on
4078 * other builtin variables. */
4079
4080 /** GL_OES_primitive_bounding_box */
4081 bool NoPrimitiveBoundingBoxOutput;
4082
4083 /** GL_ARB_sparse_buffer */
4084 GLuint SparseBufferPageSize;
4085
4086 /** Used as an input for sha1 generation in the on-disk shader cache */
4087 unsigned char *dri_config_options_sha1;
4088
4089 /** When drivers are OK with mapped buffers during draw and other calls. */
4090 bool AllowMappedBuffersDuringExecution;
4091
4092 /** GL_ARB_get_program_binary */
4093 GLuint NumProgramBinaryFormats;
4094 };
4095
4096
4097 /**
4098 * Enable flag for each OpenGL extension. Different device drivers will
4099 * enable different extensions at runtime.
4100 */
4101 struct gl_extensions
4102 {
4103 GLboolean dummy; /* don't remove this! */
4104 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
4105 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
4106 GLboolean ANGLE_texture_compression_dxt;
4107 GLboolean ARB_ES2_compatibility;
4108 GLboolean ARB_ES3_compatibility;
4109 GLboolean ARB_ES3_1_compatibility;
4110 GLboolean ARB_ES3_2_compatibility;
4111 GLboolean ARB_arrays_of_arrays;
4112 GLboolean ARB_base_instance;
4113 GLboolean ARB_bindless_texture;
4114 GLboolean ARB_blend_func_extended;
4115 GLboolean ARB_buffer_storage;
4116 GLboolean ARB_clear_texture;
4117 GLboolean ARB_clip_control;
4118 GLboolean ARB_color_buffer_float;
4119 GLboolean ARB_compute_shader;
4120 GLboolean ARB_compute_variable_group_size;
4121 GLboolean ARB_conditional_render_inverted;
4122 GLboolean ARB_conservative_depth;
4123 GLboolean ARB_copy_image;
4124 GLboolean ARB_cull_distance;
4125 GLboolean ARB_depth_buffer_float;
4126 GLboolean ARB_depth_clamp;
4127 GLboolean ARB_depth_texture;
4128 GLboolean ARB_derivative_control;
4129 GLboolean ARB_draw_buffers_blend;
4130 GLboolean ARB_draw_elements_base_vertex;
4131 GLboolean ARB_draw_indirect;
4132 GLboolean ARB_draw_instanced;
4133 GLboolean ARB_fragment_coord_conventions;
4134 GLboolean ARB_fragment_layer_viewport;
4135 GLboolean ARB_fragment_program;
4136 GLboolean ARB_fragment_program_shadow;
4137 GLboolean ARB_fragment_shader;
4138 GLboolean ARB_framebuffer_no_attachments;
4139 GLboolean ARB_framebuffer_object;
4140 GLboolean ARB_enhanced_layouts;
4141 GLboolean ARB_explicit_attrib_location;
4142 GLboolean ARB_explicit_uniform_location;
4143 GLboolean ARB_gl_spirv;
4144 GLboolean ARB_gpu_shader5;
4145 GLboolean ARB_gpu_shader_fp64;
4146 GLboolean ARB_gpu_shader_int64;
4147 GLboolean ARB_half_float_vertex;
4148 GLboolean ARB_indirect_parameters;
4149 GLboolean ARB_instanced_arrays;
4150 GLboolean ARB_internalformat_query;
4151 GLboolean ARB_internalformat_query2;
4152 GLboolean ARB_map_buffer_range;
4153 GLboolean ARB_occlusion_query;
4154 GLboolean ARB_occlusion_query2;
4155 GLboolean ARB_pipeline_statistics_query;
4156 GLboolean ARB_point_sprite;
4157 GLboolean ARB_polygon_offset_clamp;
4158 GLboolean ARB_post_depth_coverage;
4159 GLboolean ARB_query_buffer_object;
4160 GLboolean ARB_robust_buffer_access_behavior;
4161 GLboolean ARB_sample_shading;
4162 GLboolean ARB_seamless_cube_map;
4163 GLboolean ARB_shader_atomic_counter_ops;
4164 GLboolean ARB_shader_atomic_counters;
4165 GLboolean ARB_shader_ballot;
4166 GLboolean ARB_shader_bit_encoding;
4167 GLboolean ARB_shader_clock;
4168 GLboolean ARB_shader_draw_parameters;
4169 GLboolean ARB_shader_group_vote;
4170 GLboolean ARB_shader_image_load_store;
4171 GLboolean ARB_shader_image_size;
4172 GLboolean ARB_shader_precision;
4173 GLboolean ARB_shader_stencil_export;
4174 GLboolean ARB_shader_storage_buffer_object;
4175 GLboolean ARB_shader_texture_image_samples;
4176 GLboolean ARB_shader_texture_lod;
4177 GLboolean ARB_shader_viewport_layer_array;
4178 GLboolean ARB_shading_language_packing;
4179 GLboolean ARB_shading_language_420pack;
4180 GLboolean ARB_shadow;
4181 GLboolean ARB_sparse_buffer;
4182 GLboolean ARB_stencil_texturing;
4183 GLboolean ARB_sync;
4184 GLboolean ARB_tessellation_shader;
4185 GLboolean ARB_texture_border_clamp;
4186 GLboolean ARB_texture_buffer_object;
4187 GLboolean ARB_texture_buffer_object_rgb32;
4188 GLboolean ARB_texture_buffer_range;
4189 GLboolean ARB_texture_compression_bptc;
4190 GLboolean ARB_texture_compression_rgtc;
4191 GLboolean ARB_texture_cube_map;
4192 GLboolean ARB_texture_cube_map_array;
4193 GLboolean ARB_texture_env_combine;
4194 GLboolean ARB_texture_env_crossbar;
4195 GLboolean ARB_texture_env_dot3;
4196 GLboolean ARB_texture_filter_anisotropic;
4197 GLboolean ARB_texture_float;
4198 GLboolean ARB_texture_gather;
4199 GLboolean ARB_texture_mirror_clamp_to_edge;
4200 GLboolean ARB_texture_multisample;
4201 GLboolean ARB_texture_non_power_of_two;
4202 GLboolean ARB_texture_stencil8;
4203 GLboolean ARB_texture_query_levels;
4204 GLboolean ARB_texture_query_lod;
4205 GLboolean ARB_texture_rg;
4206 GLboolean ARB_texture_rgb10_a2ui;
4207 GLboolean ARB_texture_view;
4208 GLboolean ARB_timer_query;
4209 GLboolean ARB_transform_feedback2;
4210 GLboolean ARB_transform_feedback3;
4211 GLboolean ARB_transform_feedback_instanced;
4212 GLboolean ARB_transform_feedback_overflow_query;
4213 GLboolean ARB_uniform_buffer_object;
4214 GLboolean ARB_vertex_attrib_64bit;
4215 GLboolean ARB_vertex_program;
4216 GLboolean ARB_vertex_shader;
4217 GLboolean ARB_vertex_type_10f_11f_11f_rev;
4218 GLboolean ARB_vertex_type_2_10_10_10_rev;
4219 GLboolean ARB_viewport_array;
4220 GLboolean EXT_blend_color;
4221 GLboolean EXT_blend_equation_separate;
4222 GLboolean EXT_blend_func_separate;
4223 GLboolean EXT_blend_minmax;
4224 GLboolean EXT_depth_bounds_test;
4225 GLboolean EXT_disjoint_timer_query;
4226 GLboolean EXT_draw_buffers2;
4227 GLboolean EXT_framebuffer_multisample;
4228 GLboolean EXT_framebuffer_multisample_blit_scaled;
4229 GLboolean EXT_framebuffer_sRGB;
4230 GLboolean EXT_gpu_program_parameters;
4231 GLboolean EXT_gpu_shader4;
4232 GLboolean EXT_memory_object;
4233 GLboolean EXT_memory_object_fd;
4234 GLboolean EXT_packed_float;
4235 GLboolean EXT_pixel_buffer_object;
4236 GLboolean EXT_point_parameters;
4237 GLboolean EXT_provoking_vertex;
4238 GLboolean EXT_semaphore;
4239 GLboolean EXT_semaphore_fd;
4240 GLboolean EXT_shader_integer_mix;
4241 GLboolean EXT_shader_samples_identical;
4242 GLboolean EXT_stencil_two_side;
4243 GLboolean EXT_texture_array;
4244 GLboolean EXT_texture_compression_latc;
4245 GLboolean EXT_texture_compression_s3tc;
4246 GLboolean EXT_texture_env_dot3;
4247 GLboolean EXT_texture_filter_anisotropic;
4248 GLboolean EXT_texture_integer;
4249 GLboolean EXT_texture_mirror_clamp;
4250 GLboolean EXT_texture_shared_exponent;
4251 GLboolean EXT_texture_snorm;
4252 GLboolean EXT_texture_sRGB;
4253 GLboolean EXT_texture_sRGB_decode;
4254 GLboolean EXT_texture_swizzle;
4255 GLboolean EXT_texture_type_2_10_10_10_REV;
4256 GLboolean EXT_transform_feedback;
4257 GLboolean EXT_timer_query;
4258 GLboolean EXT_vertex_array_bgra;
4259 GLboolean EXT_window_rectangles;
4260 GLboolean OES_copy_image;
4261 GLboolean OES_primitive_bounding_box;
4262 GLboolean OES_sample_variables;
4263 GLboolean OES_standard_derivatives;
4264 GLboolean OES_texture_buffer;
4265 GLboolean OES_texture_cube_map_array;
4266 GLboolean OES_viewport_array;
4267 /* vendor extensions */
4268 GLboolean AMD_performance_monitor;
4269 GLboolean AMD_pinned_memory;
4270 GLboolean AMD_seamless_cubemap_per_texture;
4271 GLboolean AMD_vertex_shader_layer;
4272 GLboolean AMD_vertex_shader_viewport_index;
4273 GLboolean ANDROID_extension_pack_es31a;
4274 GLboolean APPLE_object_purgeable;
4275 GLboolean ATI_meminfo;
4276 GLboolean ATI_texture_compression_3dc;
4277 GLboolean ATI_texture_mirror_once;
4278 GLboolean ATI_texture_env_combine3;
4279 GLboolean ATI_fragment_shader;
4280 GLboolean ATI_separate_stencil;
4281 GLboolean GREMEDY_string_marker;
4282 GLboolean INTEL_conservative_rasterization;
4283 GLboolean INTEL_performance_query;
4284 GLboolean KHR_blend_equation_advanced;
4285 GLboolean KHR_blend_equation_advanced_coherent;
4286 GLboolean KHR_robustness;
4287 GLboolean KHR_texture_compression_astc_hdr;
4288 GLboolean KHR_texture_compression_astc_ldr;
4289 GLboolean KHR_texture_compression_astc_sliced_3d;
4290 GLboolean MESA_tile_raster_order;
4291 GLboolean MESA_pack_invert;
4292 GLboolean MESA_shader_framebuffer_fetch;
4293 GLboolean MESA_shader_framebuffer_fetch_non_coherent;
4294 GLboolean MESA_shader_integer_functions;
4295 GLboolean MESA_ycbcr_texture;
4296 GLboolean NV_conditional_render;
4297 GLboolean NV_fill_rectangle;
4298 GLboolean NV_fog_distance;
4299 GLboolean NV_point_sprite;
4300 GLboolean NV_primitive_restart;
4301 GLboolean NV_texture_barrier;
4302 GLboolean NV_texture_env_combine4;
4303 GLboolean NV_texture_rectangle;
4304 GLboolean NV_vdpau_interop;
4305 GLboolean NVX_gpu_memory_info;
4306 GLboolean TDFX_texture_compression_FXT1;
4307 GLboolean OES_EGL_image;
4308 GLboolean OES_draw_texture;
4309 GLboolean OES_depth_texture_cube_map;
4310 GLboolean OES_EGL_image_external;
4311 GLboolean OES_texture_float;
4312 GLboolean OES_texture_float_linear;
4313 GLboolean OES_texture_half_float;
4314 GLboolean OES_texture_half_float_linear;
4315 GLboolean OES_compressed_ETC1_RGB8_texture;
4316 GLboolean OES_geometry_shader;
4317 GLboolean OES_texture_compression_astc;
4318 GLboolean extension_sentinel;
4319 /** The extension string */
4320 const GLubyte *String;
4321 /** Number of supported extensions */
4322 GLuint Count;
4323 /**
4324 * The context version which extension helper functions compare against.
4325 * By default, the value is equal to ctx->Version. This changes to ~0
4326 * while meta is in progress.
4327 */
4328 GLubyte Version;
4329 /**
4330 * Force-enabled, yet unrecognized, extensions.
4331 * See _mesa_one_time_init_extension_overrides()
4332 */
4333 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4334 const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
4335 };
4336
4337
4338 /**
4339 * A stack of matrices (projection, modelview, color, texture, etc).
4340 */
4341 struct gl_matrix_stack
4342 {
4343 GLmatrix *Top; /**< points into Stack */
4344 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
4345 unsigned StackSize; /**< Number of elements in Stack */
4346 GLuint Depth; /**< 0 <= Depth < MaxDepth */
4347 GLuint MaxDepth; /**< size of Stack[] array */
4348 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4349 };
4350
4351
4352 /**
4353 * \name Bits for image transfer operations
4354 * \sa __struct gl_contextRec::ImageTransferState.
4355 */
4356 /*@{*/
4357 #define IMAGE_SCALE_BIAS_BIT 0x1
4358 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4359 #define IMAGE_MAP_COLOR_BIT 0x4
4360 #define IMAGE_CLAMP_BIT 0x800
4361
4362
4363 /** Pixel Transfer ops */
4364 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4365 IMAGE_SHIFT_OFFSET_BIT | \
4366 IMAGE_MAP_COLOR_BIT)
4367
4368
4369 /**
4370 * \name Bits to indicate what state has changed.
4371 */
4372 /*@{*/
4373 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4374 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4375 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4376 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4377 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4378 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4379 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4380 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4381 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4382 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4383 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4384 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4385 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4386 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4387 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4388 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4389 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4390 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4391 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4392 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4393 #define _NEW_ARRAY (1u << 20) /**< gl_context::Array */
4394 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4395 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4396 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4397 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4398 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4399 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4400 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4401 /* gap */
4402 #define _NEW_FRAG_CLAMP (1u << 29)
4403 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4404 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4405 #define _NEW_ALL ~0
4406 /*@}*/
4407
4408
4409 /**
4410 * Composite state flags
4411 */
4412 /*@{*/
4413 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4414
4415 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4416 _NEW_TEXTURE_STATE | \
4417 _NEW_POINT | \
4418 _NEW_PROGRAM | \
4419 _NEW_MODELVIEW)
4420
4421 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4422 _NEW_FOG | \
4423 _NEW_PROGRAM)
4424
4425
4426 /*@}*/
4427
4428
4429
4430
4431 /* This has to be included here. */
4432 #include "dd.h"
4433
4434
4435 /** Opaque declaration of display list payload data type */
4436 union gl_dlist_node;
4437
4438
4439 /**
4440 * Per-display list information.
4441 */
4442 struct gl_display_list
4443 {
4444 GLuint Name;
4445 GLbitfield Flags; /**< DLIST_x flags */
4446 GLchar *Label; /**< GL_KHR_debug */
4447 /** The dlist commands are in a linked list of nodes */
4448 union gl_dlist_node *Head;
4449 };
4450
4451
4452 /**
4453 * State used during display list compilation and execution.
4454 */
4455 struct gl_dlist_state
4456 {
4457 struct gl_display_list *CurrentList; /**< List currently being compiled */
4458 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
4459 GLuint CurrentPos; /**< Index into current block of nodes */
4460 GLuint CallDepth; /**< Current recursion calling depth */
4461
4462 GLvertexformat ListVtxfmt;
4463
4464 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
4465 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
4466
4467 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
4468 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
4469
4470 struct {
4471 /* State known to have been set by the currently-compiling display
4472 * list. Used to eliminate some redundant state changes.
4473 */
4474 GLenum16 ShadeModel;
4475 } Current;
4476 };
4477
4478 /** @{
4479 *
4480 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
4481 * to small enums suitable for use as an array index.
4482 */
4483
4484 enum mesa_debug_source
4485 {
4486 MESA_DEBUG_SOURCE_API,
4487 MESA_DEBUG_SOURCE_WINDOW_SYSTEM,
4488 MESA_DEBUG_SOURCE_SHADER_COMPILER,
4489 MESA_DEBUG_SOURCE_THIRD_PARTY,
4490 MESA_DEBUG_SOURCE_APPLICATION,
4491 MESA_DEBUG_SOURCE_OTHER,
4492 MESA_DEBUG_SOURCE_COUNT
4493 };
4494
4495 enum mesa_debug_type
4496 {
4497 MESA_DEBUG_TYPE_ERROR,
4498 MESA_DEBUG_TYPE_DEPRECATED,
4499 MESA_DEBUG_TYPE_UNDEFINED,
4500 MESA_DEBUG_TYPE_PORTABILITY,
4501 MESA_DEBUG_TYPE_PERFORMANCE,
4502 MESA_DEBUG_TYPE_OTHER,
4503 MESA_DEBUG_TYPE_MARKER,
4504 MESA_DEBUG_TYPE_PUSH_GROUP,
4505 MESA_DEBUG_TYPE_POP_GROUP,
4506 MESA_DEBUG_TYPE_COUNT
4507 };
4508
4509 enum mesa_debug_severity
4510 {
4511 MESA_DEBUG_SEVERITY_LOW,
4512 MESA_DEBUG_SEVERITY_MEDIUM,
4513 MESA_DEBUG_SEVERITY_HIGH,
4514 MESA_DEBUG_SEVERITY_NOTIFICATION,
4515 MESA_DEBUG_SEVERITY_COUNT
4516 };
4517
4518 /** @} */
4519
4520 /**
4521 * Driver-specific state flags.
4522 *
4523 * These are or'd with gl_context::NewDriverState to notify a driver about
4524 * a state change. The driver sets the flags at context creation and
4525 * the meaning of the bits set is opaque to core Mesa.
4526 */
4527 struct gl_driver_flags
4528 {
4529 /** gl_context::Array::_DrawArrays (vertex array state) */
4530 uint64_t NewArray;
4531
4532 /** gl_context::TransformFeedback::CurrentObject */
4533 uint64_t NewTransformFeedback;
4534
4535 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4536 uint64_t NewTransformFeedbackProg;
4537
4538 /** gl_context::RasterDiscard */
4539 uint64_t NewRasterizerDiscard;
4540
4541 /** gl_context::TileRasterOrder* */
4542 uint64_t NewTileRasterOrder;
4543
4544 /**
4545 * gl_context::UniformBufferBindings
4546 * gl_shader_program::UniformBlocks
4547 */
4548 uint64_t NewUniformBuffer;
4549
4550 /**
4551 * gl_context::ShaderStorageBufferBindings
4552 * gl_shader_program::ShaderStorageBlocks
4553 */
4554 uint64_t NewShaderStorageBuffer;
4555
4556 uint64_t NewTextureBuffer;
4557
4558 /**
4559 * gl_context::AtomicBufferBindings
4560 */
4561 uint64_t NewAtomicBuffer;
4562
4563 /**
4564 * gl_context::ImageUnits
4565 */
4566 uint64_t NewImageUnits;
4567
4568 /**
4569 * gl_context::TessCtrlProgram::patch_default_*
4570 */
4571 uint64_t NewDefaultTessLevels;
4572
4573 /**
4574 * gl_context::IntelConservativeRasterization
4575 */
4576 uint64_t NewIntelConservativeRasterization;
4577
4578 /**
4579 * gl_context::Scissor::WindowRects
4580 */
4581 uint64_t NewWindowRectangles;
4582
4583 /** gl_context::Color::sRGBEnabled */
4584 uint64_t NewFramebufferSRGB;
4585
4586 /** gl_context::Scissor::EnableFlags */
4587 uint64_t NewScissorTest;
4588
4589 /** gl_context::Scissor::ScissorArray */
4590 uint64_t NewScissorRect;
4591
4592 /** gl_context::Color::Alpha* */
4593 uint64_t NewAlphaTest;
4594
4595 /** gl_context::Color::Blend/Dither */
4596 uint64_t NewBlend;
4597
4598 /** gl_context::Color::BlendColor */
4599 uint64_t NewBlendColor;
4600
4601 /** gl_context::Color::Color/Index */
4602 uint64_t NewColorMask;
4603
4604 /** gl_context::Depth */
4605 uint64_t NewDepth;
4606
4607 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4608 uint64_t NewLogicOp;
4609
4610 /** gl_context::Multisample::Enabled */
4611 uint64_t NewMultisampleEnable;
4612
4613 /** gl_context::Multisample::SampleAlphaTo* */
4614 uint64_t NewSampleAlphaToXEnable;
4615
4616 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4617 uint64_t NewSampleMask;
4618
4619 /** gl_context::Multisample::(Min)SampleShading */
4620 uint64_t NewSampleShading;
4621
4622 /** gl_context::Stencil */
4623 uint64_t NewStencil;
4624
4625 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4626 uint64_t NewClipControl;
4627
4628 /** gl_context::Transform::EyeUserPlane */
4629 uint64_t NewClipPlane;
4630
4631 /** gl_context::Transform::ClipPlanesEnabled */
4632 uint64_t NewClipPlaneEnable;
4633
4634 /** gl_context::Transform::DepthClamp */
4635 uint64_t NewDepthClamp;
4636
4637 /** gl_context::Line */
4638 uint64_t NewLineState;
4639
4640 /** gl_context::Polygon */
4641 uint64_t NewPolygonState;
4642
4643 /** gl_context::PolygonStipple */
4644 uint64_t NewPolygonStipple;
4645
4646 /** gl_context::ViewportArray */
4647 uint64_t NewViewport;
4648
4649 /** Shader constants (uniforms, program parameters, state constants) */
4650 uint64_t NewShaderConstants[MESA_SHADER_STAGES];
4651 };
4652
4653 struct gl_buffer_binding
4654 {
4655 struct gl_buffer_object *BufferObject;
4656 /** Start of uniform block data in the buffer */
4657 GLintptr Offset;
4658 /** Size of data allowed to be referenced from the buffer (in bytes) */
4659 GLsizeiptr Size;
4660 /**
4661 * glBindBufferBase() indicates that the Size should be ignored and only
4662 * limited by the current size of the BufferObject.
4663 */
4664 GLboolean AutomaticSize;
4665 };
4666
4667 /**
4668 * ARB_shader_image_load_store image unit.
4669 */
4670 struct gl_image_unit
4671 {
4672 /**
4673 * Texture object bound to this unit.
4674 */
4675 struct gl_texture_object *TexObj;
4676
4677 /**
4678 * Level of the texture object bound to this unit.
4679 */
4680 GLuint Level;
4681
4682 /**
4683 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4684 * GL_FALSE if only some specific layer of the texture is bound.
4685 * \sa Layer
4686 */
4687 GLboolean Layered;
4688
4689 /**
4690 * Layer of the texture object bound to this unit as specified by the
4691 * application.
4692 */
4693 GLuint Layer;
4694
4695 /**
4696 * Layer of the texture object bound to this unit, or zero if the
4697 * whole level is bound.
4698 */
4699 GLuint _Layer;
4700
4701 /**
4702 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4703 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4704 */
4705 GLenum16 Access;
4706
4707 /**
4708 * GL internal format that determines the interpretation of the
4709 * image memory when shader image operations are performed through
4710 * this unit.
4711 */
4712 GLenum16 Format;
4713
4714 /**
4715 * Mesa format corresponding to \c Format.
4716 */
4717 mesa_format _ActualFormat;
4718
4719 };
4720
4721 /**
4722 * Shader subroutines storage
4723 */
4724 struct gl_subroutine_index_binding
4725 {
4726 GLuint NumIndex;
4727 GLuint *IndexPtr;
4728 };
4729
4730 struct gl_texture_handle_object
4731 {
4732 struct gl_texture_object *texObj;
4733 struct gl_sampler_object *sampObj;
4734 GLuint64 handle;
4735 };
4736
4737 struct gl_image_handle_object
4738 {
4739 struct gl_image_unit imgObj;
4740 GLuint64 handle;
4741 };
4742
4743 struct gl_memory_object
4744 {
4745 GLuint Name; /**< hash table ID/name */
4746 GLboolean Immutable; /**< denotes mutability state of parameters */
4747 GLboolean Dedicated; /**< import memory from a dedicated allocation */
4748 };
4749
4750 struct gl_semaphore_object
4751 {
4752 GLuint Name; /**< hash table ID/name */
4753 };
4754
4755 /**
4756 * Mesa rendering context.
4757 *
4758 * This is the central context data structure for Mesa. Almost all
4759 * OpenGL state is contained in this structure.
4760 * Think of this as a base class from which device drivers will derive
4761 * sub classes.
4762 */
4763 struct gl_context
4764 {
4765 /** State possibly shared with other contexts in the address space */
4766 struct gl_shared_state *Shared;
4767
4768 /** \name API function pointer tables */
4769 /*@{*/
4770 gl_api API;
4771
4772 /**
4773 * The current dispatch table for non-displaylist-saving execution, either
4774 * BeginEnd or OutsideBeginEnd
4775 */
4776 struct _glapi_table *Exec;
4777 /**
4778 * The normal dispatch table for non-displaylist-saving, non-begin/end
4779 */
4780 struct _glapi_table *OutsideBeginEnd;
4781 /** The dispatch table used between glNewList() and glEndList() */
4782 struct _glapi_table *Save;
4783 /**
4784 * The dispatch table used between glBegin() and glEnd() (outside of a
4785 * display list). Only valid functions between those two are set, which is
4786 * mostly just the set in a GLvertexformat struct.
4787 */
4788 struct _glapi_table *BeginEnd;
4789 /**
4790 * Dispatch table for when a graphics reset has happened.
4791 */
4792 struct _glapi_table *ContextLost;
4793 /**
4794 * Dispatch table used to marshal API calls from the client program to a
4795 * separate server thread. NULL if API calls are not being marshalled to
4796 * another thread.
4797 */
4798 struct _glapi_table *MarshalExec;
4799 /**
4800 * Dispatch table currently in use for fielding API calls from the client
4801 * program. If API calls are being marshalled to another thread, this ==
4802 * MarshalExec. Otherwise it == CurrentServerDispatch.
4803 */
4804 struct _glapi_table *CurrentClientDispatch;
4805
4806 /**
4807 * Dispatch table currently in use for performing API calls. == Save or
4808 * Exec.
4809 */
4810 struct _glapi_table *CurrentServerDispatch;
4811
4812 /*@}*/
4813
4814 struct glthread_state *GLThread;
4815
4816 struct gl_config Visual;
4817 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
4818 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
4819 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
4820 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
4821
4822 /**
4823 * Device driver function pointer table
4824 */
4825 struct dd_function_table Driver;
4826
4827 /** Core/Driver constants */
4828 struct gl_constants Const;
4829
4830 /** \name The various 4x4 matrix stacks */
4831 /*@{*/
4832 struct gl_matrix_stack ModelviewMatrixStack;
4833 struct gl_matrix_stack ProjectionMatrixStack;
4834 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
4835 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
4836 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
4837 /*@}*/
4838
4839 /** Combined modelview and projection matrix */
4840 GLmatrix _ModelProjectMatrix;
4841
4842 /** \name Display lists */
4843 struct gl_dlist_state ListState;
4844
4845 GLboolean ExecuteFlag; /**< Execute GL commands? */
4846 GLboolean CompileFlag; /**< Compile GL commands into display list? */
4847
4848 /** Extension information */
4849 struct gl_extensions Extensions;
4850
4851 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4852 GLuint Version;
4853 char *VersionString;
4854
4855 /** \name State attribute stack (for glPush/PopAttrib) */
4856 /*@{*/
4857 GLuint AttribStackDepth;
4858 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
4859 /*@}*/
4860
4861 /** \name Renderer attribute groups
4862 *
4863 * We define a struct for each attribute group to make pushing and popping
4864 * attributes easy. Also it's a good organization.
4865 */
4866 /*@{*/
4867 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
4868 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
4869 struct gl_current_attrib Current; /**< Current attributes */
4870 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
4871 struct gl_eval_attrib Eval; /**< Eval attributes */
4872 struct gl_fog_attrib Fog; /**< Fog attributes */
4873 struct gl_hint_attrib Hint; /**< Hint attributes */
4874 struct gl_light_attrib Light; /**< Light attributes */
4875 struct gl_line_attrib Line; /**< Line attributes */
4876 struct gl_list_attrib List; /**< List attributes */
4877 struct gl_multisample_attrib Multisample;
4878 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
4879 struct gl_point_attrib Point; /**< Point attributes */
4880 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
4881 GLuint PolygonStipple[32]; /**< Polygon stipple */
4882 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
4883 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
4884 struct gl_texture_attrib Texture; /**< Texture attributes */
4885 struct gl_transform_attrib Transform; /**< Transformation attributes */
4886 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
4887 /*@}*/
4888
4889 /** \name Client attribute stack */
4890 /*@{*/
4891 GLuint ClientAttribStackDepth;
4892 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
4893 /*@}*/
4894
4895 /** \name Client attribute groups */
4896 /*@{*/
4897 struct gl_array_attrib Array; /**< Vertex arrays */
4898 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
4899 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
4900 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
4901 /*@}*/
4902
4903 /** \name Other assorted state (not pushed/popped on attribute stack) */
4904 /*@{*/
4905 struct gl_pixelmaps PixelMaps;
4906
4907 struct gl_evaluators EvalMap; /**< All evaluators */
4908 struct gl_feedback Feedback; /**< Feedback */
4909 struct gl_selection Select; /**< Selection */
4910
4911 struct gl_program_state Program; /**< general program state */
4912 struct gl_vertex_program_state VertexProgram;
4913 struct gl_fragment_program_state FragmentProgram;
4914 struct gl_geometry_program_state GeometryProgram;
4915 struct gl_compute_program_state ComputeProgram;
4916 struct gl_tess_ctrl_program_state TessCtrlProgram;
4917 struct gl_tess_eval_program_state TessEvalProgram;
4918 struct gl_ati_fragment_shader_state ATIFragmentShader;
4919
4920 struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
4921 struct gl_pipeline_object Shader; /**< GLSL shader object state */
4922
4923 /**
4924 * Current active shader pipeline state
4925 *
4926 * Almost all internal users want ::_Shader instead of ::Shader. The
4927 * exceptions are bits of legacy GLSL API that do not know about separate
4928 * shader objects.
4929 *
4930 * If a program is active via \c glUseProgram, this will point to
4931 * \c ::Shader.
4932 *
4933 * If a program pipeline is active via \c glBindProgramPipeline, this will
4934 * point to \c ::Pipeline.Current.
4935 *
4936 * If neither a program nor a program pipeline is active, this will point to
4937 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
4938 * \c NULL.
4939 */
4940 struct gl_pipeline_object *_Shader;
4941
4942 struct gl_query_state Query; /**< occlusion, timer queries */
4943
4944 struct gl_transform_feedback_state TransformFeedback;
4945
4946 struct gl_perf_monitor_state PerfMonitor;
4947 struct gl_perf_query_state PerfQuery;
4948
4949 struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
4950 struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */
4951 struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */
4952
4953 struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
4954 struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
4955
4956 struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
4957
4958 /**
4959 * Current GL_ARB_uniform_buffer_object binding referenced by
4960 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
4961 */
4962 struct gl_buffer_object *UniformBuffer;
4963
4964 /**
4965 * Current GL_ARB_shader_storage_buffer_object binding referenced by
4966 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
4967 */
4968 struct gl_buffer_object *ShaderStorageBuffer;
4969
4970 /**
4971 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
4972 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
4973 * associated with uniform blocks by glUniformBlockBinding()'s state in the
4974 * shader program.
4975 */
4976 struct gl_buffer_binding
4977 UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
4978
4979 /**
4980 * Array of shader storage buffers for ARB_shader_storage_buffer_object
4981 * and GL 4.3. This is set up using glBindBufferRange() or
4982 * glBindBufferBase(). They are associated with shader storage blocks by
4983 * glShaderStorageBlockBinding()'s state in the shader program.
4984 */
4985 struct gl_buffer_binding
4986 ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
4987
4988 /**
4989 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
4990 * target.
4991 */
4992 struct gl_buffer_object *AtomicBuffer;
4993
4994 /**
4995 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
4996 * target.
4997 */
4998 struct gl_buffer_object *ExternalVirtualMemoryBuffer;
4999
5000 /**
5001 * Array of atomic counter buffer binding points.
5002 */
5003 struct gl_buffer_binding
5004 AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
5005
5006 /**
5007 * Array of image units for ARB_shader_image_load_store.
5008 */
5009 struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
5010
5011 struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES];
5012 /*@}*/
5013
5014 struct gl_meta_state *Meta; /**< for "meta" operations */
5015
5016 /* GL_EXT_framebuffer_object */
5017 struct gl_renderbuffer *CurrentRenderbuffer;
5018
5019 GLenum16 ErrorValue; /**< Last error code */
5020
5021 /**
5022 * Recognize and silence repeated error debug messages in buggy apps.
5023 */
5024 const char *ErrorDebugFmtString;
5025 GLuint ErrorDebugCount;
5026
5027 /* GL_ARB_debug_output/GL_KHR_debug */
5028 simple_mtx_t DebugMutex;
5029 struct gl_debug_state *Debug;
5030
5031 GLenum16 RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
5032 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
5033 uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */
5034
5035 struct gl_driver_flags DriverFlags;
5036
5037 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
5038
5039 GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
5040
5041 /** \name Derived state */
5042 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
5043 GLfloat _EyeZDir[3];
5044 GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
5045 GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
5046 GLboolean _NeedEyeCoords;
5047 GLboolean _ForceEyeCoords;
5048
5049 GLuint TextureStateTimestamp; /**< detect changes to shared state */
5050
5051 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
5052
5053 /** \name For debugging/development only */
5054 /*@{*/
5055 GLboolean FirstTimeCurrent;
5056 /*@}*/
5057
5058 /**
5059 * False if this context was created without a config. This is needed
5060 * because the initial state of glDrawBuffers depends on this
5061 */
5062 GLboolean HasConfig;
5063
5064 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
5065
5066 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
5067 GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
5068
5069 /** Does glVertexAttrib(0) alias glVertex()? */
5070 bool _AttribZeroAliasesVertex;
5071
5072 /**
5073 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
5074 * renderer's tiles should be excecuted, to meet the requirements of
5075 * GL_MESA_tile_raster_order.
5076 */
5077 GLboolean TileRasterOrderFixed;
5078 GLboolean TileRasterOrderIncreasingX;
5079 GLboolean TileRasterOrderIncreasingY;
5080
5081 /**
5082 * \name Hooks for module contexts.
5083 *
5084 * These will eventually live in the driver or elsewhere.
5085 */
5086 /*@{*/
5087 void *swrast_context;
5088 void *swsetup_context;
5089 void *swtnl_context;
5090 struct vbo_context *vbo_context;
5091 struct st_context *st;
5092 void *aelt_context;
5093 /*@}*/
5094
5095 /**
5096 * \name NV_vdpau_interop
5097 */
5098 /*@{*/
5099 const void *vdpDevice;
5100 const void *vdpGetProcAddress;
5101 struct set *vdpSurfaces;
5102 /*@}*/
5103
5104 /**
5105 * Has this context observed a GPU reset in any context in the share group?
5106 *
5107 * Once this field becomes true, it is never reset to false.
5108 */
5109 GLboolean ShareGroupReset;
5110
5111 /**
5112 * \name OES_primitive_bounding_box
5113 *
5114 * Stores the arguments to glPrimitiveBoundingBox
5115 */
5116 GLfloat PrimitiveBoundingBox[8];
5117
5118 struct disk_cache *Cache;
5119
5120 /**
5121 * \name GL_ARB_bindless_texture
5122 */
5123 /*@{*/
5124 struct hash_table_u64 *ResidentTextureHandles;
5125 struct hash_table_u64 *ResidentImageHandles;
5126 /*@}*/
5127 };
5128
5129 /**
5130 * Information about memory usage. All sizes are in kilobytes.
5131 */
5132 struct gl_memory_info
5133 {
5134 unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
5135 unsigned avail_device_memory; /**< free device memory at the moment */
5136 unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
5137 unsigned avail_staging_memory; /**< free staging memory at the moment */
5138 unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
5139 unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
5140 };
5141
5142 #ifdef DEBUG
5143 extern int MESA_VERBOSE;
5144 extern int MESA_DEBUG_FLAGS;
5145 #else
5146 # define MESA_VERBOSE 0
5147 # define MESA_DEBUG_FLAGS 0
5148 #endif
5149
5150
5151 /** The MESA_VERBOSE var is a bitmask of these flags */
5152 enum _verbose
5153 {
5154 VERBOSE_VARRAY = 0x0001,
5155 VERBOSE_TEXTURE = 0x0002,
5156 VERBOSE_MATERIAL = 0x0004,
5157 VERBOSE_PIPELINE = 0x0008,
5158 VERBOSE_DRIVER = 0x0010,
5159 VERBOSE_STATE = 0x0020,
5160 VERBOSE_API = 0x0040,
5161 VERBOSE_DISPLAY_LIST = 0x0100,
5162 VERBOSE_LIGHTING = 0x0200,
5163 VERBOSE_PRIMS = 0x0400,
5164 VERBOSE_VERTS = 0x0800,
5165 VERBOSE_DISASSEM = 0x1000,
5166 VERBOSE_DRAW = 0x2000,
5167 VERBOSE_SWAPBUFFERS = 0x4000
5168 };
5169
5170
5171 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5172 enum _debug
5173 {
5174 DEBUG_SILENT = (1 << 0),
5175 DEBUG_ALWAYS_FLUSH = (1 << 1),
5176 DEBUG_INCOMPLETE_TEXTURE = (1 << 2),
5177 DEBUG_INCOMPLETE_FBO = (1 << 3),
5178 DEBUG_CONTEXT = (1 << 4)
5179 };
5180
5181 #ifdef __cplusplus
5182 }
5183 #endif
5184
5185 #endif /* MTYPES_H */