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