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