mesa/spirv: move and rename nir_spirv_supported_capabilities
[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 GLboolean Validated;
2890
2891 /** List of all active resources after linking. */
2892 struct gl_program_resource *ProgramResourceList;
2893 unsigned NumProgramResourceList;
2894
2895 enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
2896 GLchar *InfoLog;
2897
2898 unsigned Version; /**< GLSL version used for linking */
2899
2900 /* Mask of stages this program was linked against */
2901 unsigned linked_stages;
2902 };
2903
2904 /**
2905 * A GLSL program object.
2906 * Basically a linked collection of vertex and fragment shaders.
2907 */
2908 struct gl_shader_program
2909 {
2910 GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
2911 GLuint Name; /**< aka handle or ID */
2912 GLchar *Label; /**< GL_KHR_debug */
2913 GLint RefCount; /**< Reference count */
2914 GLboolean DeletePending;
2915
2916 /**
2917 * Is the application intending to glGetProgramBinary this program?
2918 */
2919 GLboolean BinaryRetreivableHint;
2920
2921 /**
2922 * Indicates whether program can be bound for individual pipeline stages
2923 * using UseProgramStages after it is next linked.
2924 */
2925 GLboolean SeparateShader;
2926
2927 GLuint NumShaders; /**< number of attached shaders */
2928 struct gl_shader **Shaders; /**< List of attached the shaders */
2929
2930 /**
2931 * User-defined attribute bindings
2932 *
2933 * These are set via \c glBindAttribLocation and are used to direct the
2934 * GLSL linker. These are \b not the values used in the compiled shader,
2935 * and they are \b not the values returned by \c glGetAttribLocation.
2936 */
2937 struct string_to_uint_map *AttributeBindings;
2938
2939 /**
2940 * User-defined fragment data bindings
2941 *
2942 * These are set via \c glBindFragDataLocation and are used to direct the
2943 * GLSL linker. These are \b not the values used in the compiled shader,
2944 * and they are \b not the values returned by \c glGetFragDataLocation.
2945 */
2946 struct string_to_uint_map *FragDataBindings;
2947 struct string_to_uint_map *FragDataIndexBindings;
2948
2949 /**
2950 * Transform feedback varyings last specified by
2951 * glTransformFeedbackVaryings().
2952 *
2953 * For the current set of transform feedback varyings used for transform
2954 * feedback output, see LinkedTransformFeedback.
2955 */
2956 struct {
2957 GLenum BufferMode;
2958 /** Global xfb_stride out qualifier if any */
2959 GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
2960 GLuint NumVarying;
2961 GLchar **VaryingNames; /**< Array [NumVarying] of char * */
2962 } TransformFeedback;
2963
2964 struct gl_program *last_vert_prog;
2965
2966 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
2967 enum gl_frag_depth_layout FragDepthLayout;
2968
2969 /**
2970 * Geometry shader state - copied into gl_program by
2971 * _mesa_copy_linked_program_data().
2972 */
2973 struct {
2974 GLint VerticesIn;
2975
2976 bool UsesEndPrimitive;
2977 bool UsesStreams;
2978 } Geom;
2979
2980 /**
2981 * Compute shader state - copied into gl_program by
2982 * _mesa_copy_linked_program_data().
2983 */
2984 struct {
2985 /**
2986 * Size of shared variables accessed by the compute shader.
2987 */
2988 unsigned SharedSize;
2989 } Comp;
2990
2991 /** Data shared by gl_program and gl_shader_program */
2992 struct gl_shader_program_data *data;
2993
2994 /**
2995 * Mapping from GL uniform locations returned by \c glUniformLocation to
2996 * UniformStorage entries. Arrays will have multiple contiguous slots
2997 * in the UniformRemapTable, all pointing to the same UniformStorage entry.
2998 */
2999 unsigned NumUniformRemapTable;
3000 struct gl_uniform_storage **UniformRemapTable;
3001
3002 /**
3003 * Sometimes there are empty slots left over in UniformRemapTable after we
3004 * allocate slots to explicit locations. This list stores the blocks of
3005 * continuous empty slots inside UniformRemapTable.
3006 */
3007 struct exec_list EmptyUniformLocations;
3008
3009 /**
3010 * Total number of explicit uniform location including inactive uniforms.
3011 */
3012 unsigned NumExplicitUniformLocations;
3013
3014 /**
3015 * Map of active uniform names to locations
3016 *
3017 * Maps any active uniform that is not an array element to a location.
3018 * Each active uniform, including individual structure members will appear
3019 * in this map. This roughly corresponds to the set of names that would be
3020 * enumerated by \c glGetActiveUniform.
3021 */
3022 struct string_to_uint_map *UniformHash;
3023
3024 GLboolean SamplersValidated; /**< Samplers validated against texture units? */
3025
3026 bool IsES; /**< True if this program uses GLSL ES */
3027
3028 /**
3029 * Per-stage shaders resulting from the first stage of linking.
3030 *
3031 * Set of linked shaders for this program. The array is accessed using the
3032 * \c MESA_SHADER_* defines. Entries for non-existent stages will be
3033 * \c NULL.
3034 */
3035 struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
3036
3037 /* True if any of the fragment shaders attached to this program use:
3038 * #extension ARB_fragment_coord_conventions: enable
3039 */
3040 GLboolean ARB_fragment_coord_conventions_enable;
3041 };
3042
3043
3044 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
3045 #define GLSL_LOG 0x2 /**< Write shaders to files */
3046 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
3047 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
3048 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
3049 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
3050 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
3051 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
3052 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
3053 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
3054
3055
3056 /**
3057 * Context state for GLSL vertex/fragment shaders.
3058 * Extended to support pipeline object
3059 */
3060 struct gl_pipeline_object
3061 {
3062 /** Name of the pipeline object as received from glGenProgramPipelines.
3063 * It would be 0 for shaders without separate shader objects.
3064 */
3065 GLuint Name;
3066
3067 GLint RefCount;
3068
3069 GLchar *Label; /**< GL_KHR_debug */
3070
3071 /**
3072 * Programs used for rendering
3073 *
3074 * There is a separate program set for each shader stage.
3075 */
3076 struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
3077
3078 struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
3079
3080 /**
3081 * Program used by glUniform calls.
3082 *
3083 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
3084 */
3085 struct gl_shader_program *ActiveProgram;
3086
3087 GLbitfield Flags; /**< Mask of GLSL_x flags */
3088
3089 GLboolean EverBound; /**< Has the pipeline object been created */
3090
3091 GLboolean Validated; /**< Pipeline Validation status */
3092
3093 GLchar *InfoLog;
3094 };
3095
3096 /**
3097 * Context state for GLSL pipeline shaders.
3098 */
3099 struct gl_pipeline_shader_state
3100 {
3101 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
3102 struct gl_pipeline_object *Current;
3103
3104 /* Default Object to ensure that _Shader is never NULL */
3105 struct gl_pipeline_object *Default;
3106
3107 /** Pipeline objects */
3108 struct _mesa_HashTable *Objects;
3109 };
3110
3111 /**
3112 * Compiler options for a single GLSL shaders type
3113 */
3114 struct gl_shader_compiler_options
3115 {
3116 /** Driver-selectable options: */
3117 GLboolean EmitNoLoops;
3118 GLboolean EmitNoCont; /**< Emit CONT opcode? */
3119 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
3120 GLboolean EmitNoPow; /**< Emit POW opcodes? */
3121 GLboolean EmitNoSat; /**< Emit SAT opcodes? */
3122 GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
3123 * gl_CullDistance together from
3124 * float[8] to vec4[2]
3125 **/
3126
3127 /**
3128 * \name Forms of indirect addressing the driver cannot do.
3129 */
3130 /*@{*/
3131 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
3132 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
3133 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
3134 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
3135 GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
3136 /*@}*/
3137
3138 GLuint MaxIfDepth; /**< Maximum nested IF blocks */
3139 GLuint MaxUnrollIterations;
3140
3141 /**
3142 * Optimize code for array of structures backends.
3143 *
3144 * This is a proxy for:
3145 * - preferring DP4 instructions (rather than MUL/MAD) for
3146 * matrix * vector operations, such as position transformation.
3147 */
3148 GLboolean OptimizeForAOS;
3149
3150 GLboolean LowerBufferInterfaceBlocks; /**< Lower UBO and SSBO access to intrinsics. */
3151
3152 /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
3153 GLboolean ClampBlockIndicesToArrayBounds;
3154
3155 const struct nir_shader_compiler_options *NirOptions;
3156 };
3157
3158
3159 /**
3160 * Occlusion/timer query object.
3161 */
3162 struct gl_query_object
3163 {
3164 GLenum Target; /**< The query target, when active */
3165 GLuint Id; /**< hash table ID/name */
3166 GLchar *Label; /**< GL_KHR_debug */
3167 GLuint64EXT Result; /**< the counter */
3168 GLboolean Active; /**< inside Begin/EndQuery */
3169 GLboolean Ready; /**< result is ready? */
3170 GLboolean EverBound;/**< has query object ever been bound */
3171 GLuint Stream; /**< The stream */
3172 };
3173
3174
3175 /**
3176 * Context state for query objects.
3177 */
3178 struct gl_query_state
3179 {
3180 struct _mesa_HashTable *QueryObjects;
3181 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
3182 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
3183
3184 /** GL_NV_conditional_render */
3185 struct gl_query_object *CondRenderQuery;
3186
3187 /** GL_EXT_transform_feedback */
3188 struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
3189 struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
3190
3191 /** GL_ARB_transform_feedback_overflow_query */
3192 struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS];
3193 struct gl_query_object *TransformFeedbackOverflowAny;
3194
3195 /** GL_ARB_timer_query */
3196 struct gl_query_object *TimeElapsed;
3197
3198 /** GL_ARB_pipeline_statistics_query */
3199 struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
3200
3201 GLenum CondRenderMode;
3202 };
3203
3204
3205 /** Sync object state */
3206 struct gl_sync_object
3207 {
3208 GLuint Name; /**< Fence name */
3209 GLint RefCount; /**< Reference count */
3210 GLchar *Label; /**< GL_KHR_debug */
3211 GLboolean DeletePending; /**< Object was deleted while there were still
3212 * live references (e.g., sync not yet finished)
3213 */
3214 GLenum SyncCondition;
3215 GLbitfield Flags; /**< Flags passed to glFenceSync */
3216 GLuint StatusFlag:1; /**< Has the sync object been signaled? */
3217 };
3218
3219
3220 /**
3221 * State which can be shared by multiple contexts:
3222 */
3223 struct gl_shared_state
3224 {
3225 simple_mtx_t Mutex; /**< for thread safety */
3226 GLint RefCount; /**< Reference count */
3227 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
3228 struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */
3229 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
3230
3231 /** Default texture objects (shared by all texture units) */
3232 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
3233
3234 /** Fallback texture used when a bound texture is incomplete */
3235 struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
3236
3237 /**
3238 * \name Thread safety and statechange notification for texture
3239 * objects.
3240 *
3241 * \todo Improve the granularity of locking.
3242 */
3243 /*@{*/
3244 mtx_t TexMutex; /**< texobj thread safety */
3245 GLuint TextureStateStamp; /**< state notification for shared tex */
3246 /*@}*/
3247
3248 /** Default buffer object for vertex arrays that aren't in VBOs */
3249 struct gl_buffer_object *NullBufferObj;
3250
3251 /**
3252 * \name Vertex/geometry/fragment programs
3253 */
3254 /*@{*/
3255 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
3256 struct gl_program *DefaultVertexProgram;
3257 struct gl_program *DefaultFragmentProgram;
3258 /*@}*/
3259
3260 /* GL_ATI_fragment_shader */
3261 struct _mesa_HashTable *ATIShaders;
3262 struct ati_fragment_shader *DefaultFragmentShader;
3263
3264 struct _mesa_HashTable *BufferObjects;
3265
3266 /** Table of both gl_shader and gl_shader_program objects */
3267 struct _mesa_HashTable *ShaderObjects;
3268
3269 /* GL_EXT_framebuffer_object */
3270 struct _mesa_HashTable *RenderBuffers;
3271 struct _mesa_HashTable *FrameBuffers;
3272
3273 /* GL_ARB_sync */
3274 struct set *SyncObjects;
3275
3276 /** GL_ARB_sampler_objects */
3277 struct _mesa_HashTable *SamplerObjects;
3278
3279 /* GL_ARB_bindless_texture */
3280 struct hash_table_u64 *TextureHandles;
3281 struct hash_table_u64 *ImageHandles;
3282 mtx_t HandlesMutex; /**< For texture/image handles safety */
3283
3284 /**
3285 * Some context in this share group was affected by a GPU reset
3286 *
3287 * On the next call to \c glGetGraphicsResetStatus, contexts that have not
3288 * been affected by a GPU reset must also return
3289 * \c GL_INNOCENT_CONTEXT_RESET_ARB.
3290 *
3291 * Once this field becomes true, it is never reset to false.
3292 */
3293 bool ShareGroupReset;
3294
3295 /** EXT_external_objects */
3296 struct _mesa_HashTable *MemoryObjects;
3297
3298 };
3299
3300
3301
3302 /**
3303 * Renderbuffers represent drawing surfaces such as color, depth and/or
3304 * stencil. A framebuffer object has a set of renderbuffers.
3305 * Drivers will typically derive subclasses of this type.
3306 */
3307 struct gl_renderbuffer
3308 {
3309 simple_mtx_t Mutex; /**< for thread safety */
3310 GLuint ClassID; /**< Useful for drivers */
3311 GLuint Name;
3312 GLchar *Label; /**< GL_KHR_debug */
3313 GLint RefCount;
3314 GLuint Width, Height;
3315 GLuint Depth;
3316 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
3317 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
3318 /**
3319 * True for renderbuffers that wrap textures, giving the driver a chance to
3320 * flush render caches through the FinishRenderTexture hook.
3321 *
3322 * Drivers may also set this on renderbuffers other than those generated by
3323 * glFramebufferTexture(), though it means FinishRenderTexture() would be
3324 * called without a rb->TexImage.
3325 */
3326 GLboolean NeedsFinishRenderTexture;
3327 GLubyte NumSamples; /**< zero means not multisampled */
3328 GLenum InternalFormat; /**< The user-specified format */
3329 GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
3330 GL_STENCIL_INDEX. */
3331 mesa_format Format; /**< The actual renderbuffer memory format */
3332 /**
3333 * Pointer to the texture image if this renderbuffer wraps a texture,
3334 * otherwise NULL.
3335 *
3336 * Note that the reference on the gl_texture_object containing this
3337 * TexImage is held by the gl_renderbuffer_attachment.
3338 */
3339 struct gl_texture_image *TexImage;
3340
3341 /** Delete this renderbuffer */
3342 void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
3343
3344 /** Allocate new storage for this renderbuffer */
3345 GLboolean (*AllocStorage)(struct gl_context *ctx,
3346 struct gl_renderbuffer *rb,
3347 GLenum internalFormat,
3348 GLuint width, GLuint height);
3349 };
3350
3351
3352 /**
3353 * A renderbuffer attachment points to either a texture object (and specifies
3354 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
3355 */
3356 struct gl_renderbuffer_attachment
3357 {
3358 GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
3359 GLboolean Complete;
3360
3361 /**
3362 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
3363 * application supplied renderbuffer object.
3364 */
3365 struct gl_renderbuffer *Renderbuffer;
3366
3367 /**
3368 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
3369 * supplied texture object.
3370 */
3371 struct gl_texture_object *Texture;
3372 GLuint TextureLevel; /**< Attached mipmap level. */
3373 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
3374 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
3375 * and 2D array textures */
3376 GLboolean Layered;
3377 };
3378
3379
3380 /**
3381 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
3382 * In C++ terms, think of this as a base class from which device drivers
3383 * will make derived classes.
3384 */
3385 struct gl_framebuffer
3386 {
3387 simple_mtx_t Mutex; /**< for thread safety */
3388 /**
3389 * If zero, this is a window system framebuffer. If non-zero, this
3390 * is a FBO framebuffer; note that for some devices (i.e. those with
3391 * a natural pixel coordinate system for FBOs that differs from the
3392 * OpenGL/Mesa coordinate system), this means that the viewport,
3393 * polygon face orientation, and polygon stipple will have to be inverted.
3394 */
3395 GLuint Name;
3396 GLint RefCount;
3397
3398 GLchar *Label; /**< GL_KHR_debug */
3399
3400 GLboolean DeletePending;
3401
3402 /**
3403 * The framebuffer's visual. Immutable if this is a window system buffer.
3404 * Computed from attachments if user-made FBO.
3405 */
3406 struct gl_config Visual;
3407
3408 /**
3409 * Size of frame buffer in pixels. If there are no attachments, then both
3410 * of these are 0.
3411 */
3412 GLuint Width, Height;
3413
3414 /**
3415 * In the case that the framebuffer has no attachment (i.e.
3416 * GL_ARB_framebuffer_no_attachments) then the geometry of
3417 * the framebuffer is specified by the default values.
3418 */
3419 struct {
3420 GLuint Width, Height, Layers, NumSamples;
3421 GLboolean FixedSampleLocations;
3422 /* Derived from NumSamples by the driver so that it can choose a valid
3423 * value for the hardware.
3424 */
3425 GLuint _NumSamples;
3426 } DefaultGeometry;
3427
3428 /** \name Drawing bounds (Intersection of buffer size and scissor box)
3429 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
3430 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
3431 */
3432 /*@{*/
3433 GLint _Xmin, _Xmax;
3434 GLint _Ymin, _Ymax;
3435 /*@}*/
3436
3437 /** \name Derived Z buffer stuff */
3438 /*@{*/
3439 GLuint _DepthMax; /**< Max depth buffer value */
3440 GLfloat _DepthMaxF; /**< Float max depth buffer value */
3441 GLfloat _MRD; /**< minimum resolvable difference in Z values */
3442 /*@}*/
3443
3444 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
3445 GLenum _Status;
3446
3447 /** Whether one of Attachment has Type != GL_NONE
3448 * NOTE: the values for Width and Height are set to 0 in case of having
3449 * no attachments, a backend driver supporting the extension
3450 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
3451 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
3452 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
3453 * _Ymax do NOT take into account _HasAttachments being false). To get the
3454 * geometry of the framebuffer, the helper functions
3455 * _mesa_geometric_width(),
3456 * _mesa_geometric_height(),
3457 * _mesa_geometric_samples() and
3458 * _mesa_geometric_layers()
3459 * are available that check _HasAttachments.
3460 */
3461 bool _HasAttachments;
3462
3463 GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
3464
3465 /* ARB_color_buffer_float */
3466 GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
3467 GLboolean _HasSNormOrFloatColorBuffer;
3468
3469 /**
3470 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
3471 * is not layered. For cube maps and cube map arrays, each cube face
3472 * counts as a layer. As the case for Width, Height a backend driver
3473 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
3474 * in the case that _HasAttachments is false
3475 */
3476 GLuint MaxNumLayers;
3477
3478 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
3479 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
3480
3481 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
3482 * attribute group and GL_PIXEL attribute group, respectively.
3483 */
3484 GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
3485 GLenum ColorReadBuffer;
3486
3487 /** Computed from ColorDraw/ReadBuffer above */
3488 GLuint _NumColorDrawBuffers;
3489 gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
3490 gl_buffer_index _ColorReadBufferIndex;
3491 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
3492 struct gl_renderbuffer *_ColorReadBuffer;
3493
3494 /** Delete this framebuffer */
3495 void (*Delete)(struct gl_framebuffer *fb);
3496 };
3497
3498
3499 /**
3500 * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
3501 */
3502 struct gl_precision
3503 {
3504 GLushort RangeMin; /**< min value exponent */
3505 GLushort RangeMax; /**< max value exponent */
3506 GLushort Precision; /**< number of mantissa bits */
3507 };
3508
3509
3510 /**
3511 * Limits for vertex, geometry and fragment programs/shaders.
3512 */
3513 struct gl_program_constants
3514 {
3515 /* logical limits */
3516 GLuint MaxInstructions;
3517 GLuint MaxAluInstructions;
3518 GLuint MaxTexInstructions;
3519 GLuint MaxTexIndirections;
3520 GLuint MaxAttribs;
3521 GLuint MaxTemps;
3522 GLuint MaxAddressRegs;
3523 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
3524 GLuint MaxParameters;
3525 GLuint MaxLocalParams;
3526 GLuint MaxEnvParams;
3527 /* native/hardware limits */
3528 GLuint MaxNativeInstructions;
3529 GLuint MaxNativeAluInstructions;
3530 GLuint MaxNativeTexInstructions;
3531 GLuint MaxNativeTexIndirections;
3532 GLuint MaxNativeAttribs;
3533 GLuint MaxNativeTemps;
3534 GLuint MaxNativeAddressRegs;
3535 GLuint MaxNativeParameters;
3536 /* For shaders */
3537 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
3538
3539 /**
3540 * \name Per-stage input / output limits
3541 *
3542 * Previous to OpenGL 3.2, the intrastage data limits were advertised with
3543 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
3544 * ES). This is stored as \c gl_constants::MaxVarying.
3545 *
3546 * Starting with OpenGL 3.2, the limits are advertised with per-stage
3547 * variables. Each stage as a certain number of outputs that it can feed
3548 * to the next stage and a certain number inputs that it can consume from
3549 * the previous stage.
3550 *
3551 * Vertex shader inputs do not participate this in this accounting.
3552 * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
3553 *
3554 * Fragment shader outputs do not participate this in this accounting.
3555 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
3556 */
3557 /*@{*/
3558 GLuint MaxInputComponents;
3559 GLuint MaxOutputComponents;
3560 /*@}*/
3561
3562 /* ES 2.0 and GL_ARB_ES2_compatibility */
3563 struct gl_precision LowFloat, MediumFloat, HighFloat;
3564 struct gl_precision LowInt, MediumInt, HighInt;
3565 /* GL_ARB_uniform_buffer_object */
3566 GLuint MaxUniformBlocks;
3567 GLuint MaxCombinedUniformComponents;
3568 GLuint MaxTextureImageUnits;
3569
3570 /* GL_ARB_shader_atomic_counters */
3571 GLuint MaxAtomicBuffers;
3572 GLuint MaxAtomicCounters;
3573
3574 /* GL_ARB_shader_image_load_store */
3575 GLuint MaxImageUniforms;
3576
3577 /* GL_ARB_shader_storage_buffer_object */
3578 GLuint MaxShaderStorageBlocks;
3579 };
3580
3581 /**
3582 * Constants which may be overridden by device driver during context creation
3583 * but are never changed after that.
3584 */
3585 struct gl_constants
3586 {
3587 GLuint MaxTextureMbytes; /**< Max memory per image, in MB */
3588 GLuint MaxTextureLevels; /**< Max mipmap levels. */
3589 GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
3590 GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
3591 GLuint MaxArrayTextureLayers; /**< Max layers in array textures */
3592 GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */
3593 GLuint MaxTextureCoordUnits;
3594 GLuint MaxCombinedTextureImageUnits;
3595 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
3596 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
3597 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
3598 GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
3599
3600 GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
3601
3602 GLuint MaxArrayLockSize;
3603
3604 GLint SubPixelBits;
3605
3606 GLfloat MinPointSize, MaxPointSize; /**< aliased */
3607 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
3608 GLfloat PointSizeGranularity;
3609 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
3610 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
3611 GLfloat LineWidthGranularity;
3612
3613 GLuint MaxClipPlanes;
3614 GLuint MaxLights;
3615 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
3616 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
3617
3618 GLuint MaxViewportWidth, MaxViewportHeight;
3619 GLuint MaxViewports; /**< GL_ARB_viewport_array */
3620 GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
3621 struct {
3622 GLfloat Min;
3623 GLfloat Max;
3624 } ViewportBounds; /**< GL_ARB_viewport_array */
3625 GLuint MaxWindowRectangles; /**< GL_EXT_window_rectangles */
3626
3627 struct gl_program_constants Program[MESA_SHADER_STAGES];
3628 GLuint MaxProgramMatrices;
3629 GLuint MaxProgramMatrixStackDepth;
3630
3631 struct {
3632 GLuint SamplesPassed;
3633 GLuint TimeElapsed;
3634 GLuint Timestamp;
3635 GLuint PrimitivesGenerated;
3636 GLuint PrimitivesWritten;
3637 GLuint VerticesSubmitted;
3638 GLuint PrimitivesSubmitted;
3639 GLuint VsInvocations;
3640 GLuint TessPatches;
3641 GLuint TessInvocations;
3642 GLuint GsInvocations;
3643 GLuint GsPrimitives;
3644 GLuint FsInvocations;
3645 GLuint ComputeInvocations;
3646 GLuint ClInPrimitives;
3647 GLuint ClOutPrimitives;
3648 } QueryCounterBits;
3649
3650 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
3651
3652 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
3653 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
3654 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
3655
3656 /**
3657 * GL_ARB_framebuffer_no_attachments
3658 */
3659 GLuint MaxFramebufferWidth;
3660 GLuint MaxFramebufferHeight;
3661 GLuint MaxFramebufferLayers;
3662 GLuint MaxFramebufferSamples;
3663
3664 /** Number of varying vectors between any two shader stages. */
3665 GLuint MaxVarying;
3666
3667 /** @{
3668 * GL_ARB_uniform_buffer_object
3669 */
3670 GLuint MaxCombinedUniformBlocks;
3671 GLuint MaxUniformBufferBindings;
3672 GLuint MaxUniformBlockSize;
3673 GLuint UniformBufferOffsetAlignment;
3674 /** @} */
3675
3676 /** @{
3677 * GL_ARB_shader_storage_buffer_object
3678 */
3679 GLuint MaxCombinedShaderStorageBlocks;
3680 GLuint MaxShaderStorageBufferBindings;
3681 GLuint MaxShaderStorageBlockSize;
3682 GLuint ShaderStorageBufferOffsetAlignment;
3683 /** @} */
3684
3685 /**
3686 * GL_ARB_explicit_uniform_location
3687 */
3688 GLuint MaxUserAssignableUniformLocations;
3689
3690 /** geometry shader */
3691 GLuint MaxGeometryOutputVertices;
3692 GLuint MaxGeometryTotalOutputComponents;
3693
3694 GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
3695
3696 /**
3697 * Changes default GLSL extension behavior from "error" to "warn". It's out
3698 * of spec, but it can make some apps work that otherwise wouldn't.
3699 */
3700 GLboolean ForceGLSLExtensionsWarn;
3701
3702 /**
3703 * If non-zero, forces GLSL shaders to behave as if they began
3704 * with "#version ForceGLSLVersion".
3705 */
3706 GLuint ForceGLSLVersion;
3707
3708 /**
3709 * Allow GLSL #extension directives in the middle of shaders.
3710 */
3711 GLboolean AllowGLSLExtensionDirectiveMidShader;
3712
3713 /**
3714 * Allow GLSL built-in variables to be redeclared verbatim
3715 */
3716 GLboolean AllowGLSLBuiltinVariableRedeclaration;
3717
3718 /**
3719 * Allow GLSL interpolation qualifier mismatch across shader stages.
3720 */
3721 GLboolean AllowGLSLCrossStageInterpolationMismatch;
3722
3723 /**
3724 * Allow creating a higher compat profile (version 3.1+) for apps that
3725 * request it. Be careful when adding that driconf option because some
3726 * features are unimplemented and might not work correctly.
3727 */
3728 GLboolean AllowHigherCompatVersion;
3729
3730 /**
3731 * Force computing the absolute value for sqrt() and inversesqrt() to follow
3732 * D3D9 when apps rely on this behaviour.
3733 */
3734 GLboolean ForceGLSLAbsSqrt;
3735
3736 /**
3737 * Force uninitialized variables to default to zero.
3738 */
3739 GLboolean GLSLZeroInit;
3740
3741 /**
3742 * Does the driver support real 32-bit integers? (Otherwise, integers are
3743 * simulated via floats.)
3744 */
3745 GLboolean NativeIntegers;
3746
3747 /**
3748 * Does VertexID count from zero or from base vertex?
3749 *
3750 * \note
3751 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
3752 * ignored and need not be set.
3753 */
3754 bool VertexID_is_zero_based;
3755
3756 /**
3757 * If the driver supports real 32-bit integers, what integer value should be
3758 * used for boolean true in uniform uploads? (Usually 1 or ~0.)
3759 */
3760 GLuint UniformBooleanTrue;
3761
3762 /**
3763 * Maximum amount of time, measured in nanseconds, that the server can wait.
3764 */
3765 GLuint64 MaxServerWaitTimeout;
3766
3767 /** GL_EXT_provoking_vertex */
3768 GLboolean QuadsFollowProvokingVertexConvention;
3769
3770 /** GL_ARB_viewport_array */
3771 GLenum LayerAndVPIndexProvokingVertex;
3772
3773 /** OpenGL version 3.0 */
3774 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
3775
3776 /** OpenGL version 3.2 */
3777 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
3778
3779 /** OpenGL version 4.4 */
3780 GLuint MaxVertexAttribStride;
3781
3782 /** GL_EXT_transform_feedback */
3783 GLuint MaxTransformFeedbackBuffers;
3784 GLuint MaxTransformFeedbackSeparateComponents;
3785 GLuint MaxTransformFeedbackInterleavedComponents;
3786 GLuint MaxVertexStreams;
3787
3788 /** GL_EXT_gpu_shader4 */
3789 GLint MinProgramTexelOffset, MaxProgramTexelOffset;
3790
3791 /** GL_ARB_texture_gather */
3792 GLuint MinProgramTextureGatherOffset;
3793 GLuint MaxProgramTextureGatherOffset;
3794 GLuint MaxProgramTextureGatherComponents;
3795
3796 /* GL_ARB_robustness */
3797 GLenum ResetStrategy;
3798
3799 /* GL_KHR_robustness */
3800 GLboolean RobustAccess;
3801
3802 /* GL_ARB_blend_func_extended */
3803 GLuint MaxDualSourceDrawBuffers;
3804
3805 /**
3806 * Whether the implementation strips out and ignores texture borders.
3807 *
3808 * Many GPU hardware implementations don't support rendering with texture
3809 * borders and mipmapped textures. (Note: not static border color, but the
3810 * old 1-pixel border around each edge). Implementations then have to do
3811 * slow fallbacks to be correct, or just ignore the border and be fast but
3812 * wrong. Setting the flag strips the border off of TexImage calls,
3813 * providing "fast but wrong" at significantly reduced driver complexity.
3814 *
3815 * Texture borders are deprecated in GL 3.0.
3816 **/
3817 GLboolean StripTextureBorder;
3818
3819 /**
3820 * For drivers which can do a better job at eliminating unused uniforms
3821 * than the GLSL compiler.
3822 *
3823 * XXX Remove these as soon as a better solution is available.
3824 */
3825 GLboolean GLSLSkipStrictMaxUniformLimitCheck;
3826
3827 /** Whether gl_FragCoord and gl_FrontFacing are system values. */
3828 bool GLSLFragCoordIsSysVal;
3829 bool GLSLFrontFacingIsSysVal;
3830
3831 /**
3832 * Run the minimum amount of GLSL optimizations to be able to link
3833 * shaders optimally (eliminate dead varyings and uniforms) and just do
3834 * all the necessary lowering.
3835 */
3836 bool GLSLOptimizeConservatively;
3837
3838 /**
3839 * True if gl_TessLevelInner/Outer[] in the TES should be inputs
3840 * (otherwise, they're system values).
3841 */
3842 bool GLSLTessLevelsAsInputs;
3843
3844 /**
3845 * Always use the GetTransformFeedbackVertexCount() driver hook, rather
3846 * than passing the transform feedback object to the drawing function.
3847 */
3848 GLboolean AlwaysUseGetTransformFeedbackVertexCount;
3849
3850 /** GL_ARB_map_buffer_alignment */
3851 GLuint MinMapBufferAlignment;
3852
3853 /**
3854 * Disable varying packing. This is out of spec, but potentially useful
3855 * for older platforms that supports a limited number of texture
3856 * indirections--on these platforms, unpacking the varyings in the fragment
3857 * shader increases the number of texture indirections by 1, which might
3858 * make some shaders not executable at all.
3859 *
3860 * Drivers that support transform feedback must set this value to GL_FALSE.
3861 */
3862 GLboolean DisableVaryingPacking;
3863
3864 /**
3865 * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
3866 * layout is set as shared (the default) or packed. However most Mesa drivers
3867 * just use STD140 for these layouts. This flag allows drivers to use STD430
3868 * for packed and shared layouts which allows arrays to be packed more
3869 * tightly.
3870 */
3871 bool UseSTD430AsDefaultPacking;
3872
3873 /**
3874 * Should meaningful names be generated for compiler temporary variables?
3875 *
3876 * Generally, it is not useful to have the compiler generate "meaningful"
3877 * names for temporary variables that it creates. This can, however, be a
3878 * useful debugging aid. In Mesa debug builds or release builds when
3879 * MESA_GLSL is set at run-time, meaningful names will be generated.
3880 * Drivers can also force names to be generated by setting this field.
3881 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
3882 * vertex shader assembly) is set at run-time.
3883 */
3884 bool GenerateTemporaryNames;
3885
3886 /*
3887 * Maximum value supported for an index in DrawElements and friends.
3888 *
3889 * This must be at least (1ull<<24)-1. The default value is
3890 * (1ull<<32)-1.
3891 *
3892 * \since ES 3.0 or GL_ARB_ES3_compatibility
3893 * \sa _mesa_init_constants
3894 */
3895 GLuint64 MaxElementIndex;
3896
3897 /**
3898 * Disable interpretation of line continuations (lines ending with a
3899 * backslash character ('\') in GLSL source.
3900 */
3901 GLboolean DisableGLSLLineContinuations;
3902
3903 /** GL_ARB_texture_multisample */
3904 GLint MaxColorTextureSamples;
3905 GLint MaxDepthTextureSamples;
3906 GLint MaxIntegerSamples;
3907
3908 /**
3909 * GL_EXT_texture_multisample_blit_scaled implementation assumes that
3910 * samples are laid out in a rectangular grid roughly corresponding to
3911 * sample locations within a pixel. Below SampleMap{2,4,8}x variables
3912 * are used to map indices of rectangular grid to sample numbers within
3913 * a pixel. This mapping of indices to sample numbers must be initialized
3914 * by the driver for the target hardware. For example, if we have the 8X
3915 * MSAA sample number layout (sample positions) for XYZ hardware:
3916 *
3917 * sample indices layout sample number layout
3918 * --------- ---------
3919 * | 0 | 1 | | a | b |
3920 * --------- ---------
3921 * | 2 | 3 | | c | d |
3922 * --------- ---------
3923 * | 4 | 5 | | e | f |
3924 * --------- ---------
3925 * | 6 | 7 | | g | h |
3926 * --------- ---------
3927 *
3928 * Where a,b,c,d,e,f,g,h are integers between [0-7].
3929 *
3930 * Then, initialize the SampleMap8x variable for XYZ hardware as shown
3931 * below:
3932 * SampleMap8x = {a, b, c, d, e, f, g, h};
3933 *
3934 * Follow the logic for sample counts 2-8.
3935 *
3936 * For 16x the sample indices layout as a 4x4 grid as follows:
3937 *
3938 * -----------------
3939 * | 0 | 1 | 2 | 3 |
3940 * -----------------
3941 * | 4 | 5 | 6 | 7 |
3942 * -----------------
3943 * | 8 | 9 |10 |11 |
3944 * -----------------
3945 * |12 |13 |14 |15 |
3946 * -----------------
3947 */
3948 uint8_t SampleMap2x[2];
3949 uint8_t SampleMap4x[4];
3950 uint8_t SampleMap8x[8];
3951 uint8_t SampleMap16x[16];
3952
3953 /** GL_ARB_shader_atomic_counters */
3954 GLuint MaxAtomicBufferBindings;
3955 GLuint MaxAtomicBufferSize;
3956 GLuint MaxCombinedAtomicBuffers;
3957 GLuint MaxCombinedAtomicCounters;
3958
3959 /** GL_ARB_vertex_attrib_binding */
3960 GLint MaxVertexAttribRelativeOffset;
3961 GLint MaxVertexAttribBindings;
3962
3963 /* GL_ARB_shader_image_load_store */
3964 GLuint MaxImageUnits;
3965 GLuint MaxCombinedShaderOutputResources;
3966 GLuint MaxImageSamples;
3967 GLuint MaxCombinedImageUniforms;
3968
3969 /** GL_ARB_compute_shader */
3970 GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
3971 GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
3972 GLuint MaxComputeWorkGroupInvocations;
3973 GLuint MaxComputeSharedMemorySize;
3974
3975 /** GL_ARB_compute_variable_group_size */
3976 GLuint MaxComputeVariableGroupSize[3]; /* Array of x, y, z dimensions */
3977 GLuint MaxComputeVariableGroupInvocations;
3978
3979 /** GL_ARB_gpu_shader5 */
3980 GLfloat MinFragmentInterpolationOffset;
3981 GLfloat MaxFragmentInterpolationOffset;
3982
3983 GLboolean FakeSWMSAA;
3984
3985 /** GL_KHR_context_flush_control */
3986 GLenum ContextReleaseBehavior;
3987
3988 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
3989
3990 /** GL_ARB_tessellation_shader */
3991 GLuint MaxPatchVertices;
3992 GLuint MaxTessGenLevel;
3993 GLuint MaxTessPatchComponents;
3994 GLuint MaxTessControlTotalOutputComponents;
3995 bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
3996 bool LowerTCSPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
3997 bool LowerTESPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
3998 bool PrimitiveRestartForPatches;
3999 bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
4000 * gl_LocalInvocationIndex based on
4001 * other builtin variables. */
4002
4003 /** GL_OES_primitive_bounding_box */
4004 bool NoPrimitiveBoundingBoxOutput;
4005
4006 /** GL_ARB_sparse_buffer */
4007 GLuint SparseBufferPageSize;
4008
4009 /** Used as an input for sha1 generation in the on-disk shader cache */
4010 unsigned char *dri_config_options_sha1;
4011
4012 /** When drivers are OK with mapped buffers during draw and other calls. */
4013 bool AllowMappedBuffersDuringExecution;
4014 };
4015
4016
4017 /**
4018 * Enable flag for each OpenGL extension. Different device drivers will
4019 * enable different extensions at runtime.
4020 */
4021 struct gl_extensions
4022 {
4023 GLboolean dummy; /* don't remove this! */
4024 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
4025 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
4026 GLboolean ANGLE_texture_compression_dxt;
4027 GLboolean ARB_ES2_compatibility;
4028 GLboolean ARB_ES3_compatibility;
4029 GLboolean ARB_ES3_1_compatibility;
4030 GLboolean ARB_ES3_2_compatibility;
4031 GLboolean ARB_arrays_of_arrays;
4032 GLboolean ARB_base_instance;
4033 GLboolean ARB_bindless_texture;
4034 GLboolean ARB_blend_func_extended;
4035 GLboolean ARB_buffer_storage;
4036 GLboolean ARB_clear_texture;
4037 GLboolean ARB_clip_control;
4038 GLboolean ARB_color_buffer_float;
4039 GLboolean ARB_compute_shader;
4040 GLboolean ARB_compute_variable_group_size;
4041 GLboolean ARB_conditional_render_inverted;
4042 GLboolean ARB_conservative_depth;
4043 GLboolean ARB_copy_image;
4044 GLboolean ARB_cull_distance;
4045 GLboolean ARB_depth_buffer_float;
4046 GLboolean ARB_depth_clamp;
4047 GLboolean ARB_depth_texture;
4048 GLboolean ARB_derivative_control;
4049 GLboolean ARB_draw_buffers_blend;
4050 GLboolean ARB_draw_elements_base_vertex;
4051 GLboolean ARB_draw_indirect;
4052 GLboolean ARB_draw_instanced;
4053 GLboolean ARB_fragment_coord_conventions;
4054 GLboolean ARB_fragment_layer_viewport;
4055 GLboolean ARB_fragment_program;
4056 GLboolean ARB_fragment_program_shadow;
4057 GLboolean ARB_fragment_shader;
4058 GLboolean ARB_framebuffer_no_attachments;
4059 GLboolean ARB_framebuffer_object;
4060 GLboolean ARB_enhanced_layouts;
4061 GLboolean ARB_explicit_attrib_location;
4062 GLboolean ARB_explicit_uniform_location;
4063 GLboolean ARB_gpu_shader5;
4064 GLboolean ARB_gpu_shader_fp64;
4065 GLboolean ARB_gpu_shader_int64;
4066 GLboolean ARB_half_float_vertex;
4067 GLboolean ARB_indirect_parameters;
4068 GLboolean ARB_instanced_arrays;
4069 GLboolean ARB_internalformat_query;
4070 GLboolean ARB_internalformat_query2;
4071 GLboolean ARB_map_buffer_range;
4072 GLboolean ARB_occlusion_query;
4073 GLboolean ARB_occlusion_query2;
4074 GLboolean ARB_pipeline_statistics_query;
4075 GLboolean ARB_point_sprite;
4076 GLboolean ARB_polygon_offset_clamp;
4077 GLboolean ARB_post_depth_coverage;
4078 GLboolean ARB_query_buffer_object;
4079 GLboolean ARB_robust_buffer_access_behavior;
4080 GLboolean ARB_sample_shading;
4081 GLboolean ARB_seamless_cube_map;
4082 GLboolean ARB_shader_atomic_counter_ops;
4083 GLboolean ARB_shader_atomic_counters;
4084 GLboolean ARB_shader_ballot;
4085 GLboolean ARB_shader_bit_encoding;
4086 GLboolean ARB_shader_clock;
4087 GLboolean ARB_shader_draw_parameters;
4088 GLboolean ARB_shader_group_vote;
4089 GLboolean ARB_shader_image_load_store;
4090 GLboolean ARB_shader_image_size;
4091 GLboolean ARB_shader_precision;
4092 GLboolean ARB_shader_stencil_export;
4093 GLboolean ARB_shader_storage_buffer_object;
4094 GLboolean ARB_shader_texture_image_samples;
4095 GLboolean ARB_shader_texture_lod;
4096 GLboolean ARB_shader_viewport_layer_array;
4097 GLboolean ARB_shading_language_packing;
4098 GLboolean ARB_shading_language_420pack;
4099 GLboolean ARB_shadow;
4100 GLboolean ARB_sparse_buffer;
4101 GLboolean ARB_stencil_texturing;
4102 GLboolean ARB_sync;
4103 GLboolean ARB_tessellation_shader;
4104 GLboolean ARB_texture_border_clamp;
4105 GLboolean ARB_texture_buffer_object;
4106 GLboolean ARB_texture_buffer_object_rgb32;
4107 GLboolean ARB_texture_buffer_range;
4108 GLboolean ARB_texture_compression_bptc;
4109 GLboolean ARB_texture_compression_rgtc;
4110 GLboolean ARB_texture_cube_map;
4111 GLboolean ARB_texture_cube_map_array;
4112 GLboolean ARB_texture_env_combine;
4113 GLboolean ARB_texture_env_crossbar;
4114 GLboolean ARB_texture_env_dot3;
4115 GLboolean ARB_texture_filter_anisotropic;
4116 GLboolean ARB_texture_float;
4117 GLboolean ARB_texture_gather;
4118 GLboolean ARB_texture_mirror_clamp_to_edge;
4119 GLboolean ARB_texture_multisample;
4120 GLboolean ARB_texture_non_power_of_two;
4121 GLboolean ARB_texture_stencil8;
4122 GLboolean ARB_texture_query_levels;
4123 GLboolean ARB_texture_query_lod;
4124 GLboolean ARB_texture_rg;
4125 GLboolean ARB_texture_rgb10_a2ui;
4126 GLboolean ARB_texture_view;
4127 GLboolean ARB_timer_query;
4128 GLboolean ARB_transform_feedback2;
4129 GLboolean ARB_transform_feedback3;
4130 GLboolean ARB_transform_feedback_instanced;
4131 GLboolean ARB_transform_feedback_overflow_query;
4132 GLboolean ARB_uniform_buffer_object;
4133 GLboolean ARB_vertex_attrib_64bit;
4134 GLboolean ARB_vertex_program;
4135 GLboolean ARB_vertex_shader;
4136 GLboolean ARB_vertex_type_10f_11f_11f_rev;
4137 GLboolean ARB_vertex_type_2_10_10_10_rev;
4138 GLboolean ARB_viewport_array;
4139 GLboolean EXT_blend_color;
4140 GLboolean EXT_blend_equation_separate;
4141 GLboolean EXT_blend_func_separate;
4142 GLboolean EXT_blend_minmax;
4143 GLboolean EXT_depth_bounds_test;
4144 GLboolean EXT_draw_buffers2;
4145 GLboolean EXT_framebuffer_multisample;
4146 GLboolean EXT_framebuffer_multisample_blit_scaled;
4147 GLboolean EXT_framebuffer_sRGB;
4148 GLboolean EXT_gpu_program_parameters;
4149 GLboolean EXT_gpu_shader4;
4150 GLboolean EXT_memory_object;
4151 GLboolean EXT_memory_object_fd;
4152 GLboolean EXT_packed_float;
4153 GLboolean EXT_pixel_buffer_object;
4154 GLboolean EXT_point_parameters;
4155 GLboolean EXT_provoking_vertex;
4156 GLboolean EXT_shader_integer_mix;
4157 GLboolean EXT_shader_samples_identical;
4158 GLboolean EXT_stencil_two_side;
4159 GLboolean EXT_texture_array;
4160 GLboolean EXT_texture_compression_latc;
4161 GLboolean EXT_texture_compression_s3tc;
4162 GLboolean EXT_texture_env_dot3;
4163 GLboolean EXT_texture_filter_anisotropic;
4164 GLboolean EXT_texture_integer;
4165 GLboolean EXT_texture_mirror_clamp;
4166 GLboolean EXT_texture_shared_exponent;
4167 GLboolean EXT_texture_snorm;
4168 GLboolean EXT_texture_sRGB;
4169 GLboolean EXT_texture_sRGB_decode;
4170 GLboolean EXT_texture_swizzle;
4171 GLboolean EXT_texture_type_2_10_10_10_REV;
4172 GLboolean EXT_transform_feedback;
4173 GLboolean EXT_timer_query;
4174 GLboolean EXT_vertex_array_bgra;
4175 GLboolean EXT_window_rectangles;
4176 GLboolean OES_copy_image;
4177 GLboolean OES_primitive_bounding_box;
4178 GLboolean OES_sample_variables;
4179 GLboolean OES_standard_derivatives;
4180 GLboolean OES_texture_buffer;
4181 GLboolean OES_texture_cube_map_array;
4182 GLboolean OES_viewport_array;
4183 /* vendor extensions */
4184 GLboolean AMD_performance_monitor;
4185 GLboolean AMD_pinned_memory;
4186 GLboolean AMD_seamless_cubemap_per_texture;
4187 GLboolean AMD_vertex_shader_layer;
4188 GLboolean AMD_vertex_shader_viewport_index;
4189 GLboolean ANDROID_extension_pack_es31a;
4190 GLboolean APPLE_object_purgeable;
4191 GLboolean ATI_meminfo;
4192 GLboolean ATI_texture_compression_3dc;
4193 GLboolean ATI_texture_mirror_once;
4194 GLboolean ATI_texture_env_combine3;
4195 GLboolean ATI_fragment_shader;
4196 GLboolean ATI_separate_stencil;
4197 GLboolean GREMEDY_string_marker;
4198 GLboolean INTEL_conservative_rasterization;
4199 GLboolean INTEL_performance_query;
4200 GLboolean KHR_blend_equation_advanced;
4201 GLboolean KHR_blend_equation_advanced_coherent;
4202 GLboolean KHR_robustness;
4203 GLboolean KHR_texture_compression_astc_hdr;
4204 GLboolean KHR_texture_compression_astc_ldr;
4205 GLboolean KHR_texture_compression_astc_sliced_3d;
4206 GLboolean MESA_tile_raster_order;
4207 GLboolean MESA_pack_invert;
4208 GLboolean MESA_shader_framebuffer_fetch;
4209 GLboolean MESA_shader_framebuffer_fetch_non_coherent;
4210 GLboolean MESA_shader_integer_functions;
4211 GLboolean MESA_ycbcr_texture;
4212 GLboolean NV_conditional_render;
4213 GLboolean NV_fill_rectangle;
4214 GLboolean NV_fog_distance;
4215 GLboolean NV_point_sprite;
4216 GLboolean NV_primitive_restart;
4217 GLboolean NV_texture_barrier;
4218 GLboolean NV_texture_env_combine4;
4219 GLboolean NV_texture_rectangle;
4220 GLboolean NV_vdpau_interop;
4221 GLboolean NVX_gpu_memory_info;
4222 GLboolean TDFX_texture_compression_FXT1;
4223 GLboolean OES_EGL_image;
4224 GLboolean OES_draw_texture;
4225 GLboolean OES_depth_texture_cube_map;
4226 GLboolean OES_EGL_image_external;
4227 GLboolean OES_texture_float;
4228 GLboolean OES_texture_float_linear;
4229 GLboolean OES_texture_half_float;
4230 GLboolean OES_texture_half_float_linear;
4231 GLboolean OES_compressed_ETC1_RGB8_texture;
4232 GLboolean OES_geometry_shader;
4233 GLboolean OES_texture_compression_astc;
4234 GLboolean extension_sentinel;
4235 /** The extension string */
4236 const GLubyte *String;
4237 /** Number of supported extensions */
4238 GLuint Count;
4239 /**
4240 * The context version which extension helper functions compare against.
4241 * By default, the value is equal to ctx->Version. This changes to ~0
4242 * while meta is in progress.
4243 */
4244 GLubyte Version;
4245 /**
4246 * Force-enabled, yet unrecognized, extensions.
4247 * See _mesa_one_time_init_extension_overrides()
4248 */
4249 #define MAX_UNRECOGNIZED_EXTENSIONS 16
4250 const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
4251 };
4252
4253
4254 /**
4255 * A stack of matrices (projection, modelview, color, texture, etc).
4256 */
4257 struct gl_matrix_stack
4258 {
4259 GLmatrix *Top; /**< points into Stack */
4260 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
4261 unsigned StackSize; /**< Number of elements in Stack */
4262 GLuint Depth; /**< 0 <= Depth < MaxDepth */
4263 GLuint MaxDepth; /**< size of Stack[] array */
4264 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
4265 };
4266
4267
4268 /**
4269 * \name Bits for image transfer operations
4270 * \sa __struct gl_contextRec::ImageTransferState.
4271 */
4272 /*@{*/
4273 #define IMAGE_SCALE_BIAS_BIT 0x1
4274 #define IMAGE_SHIFT_OFFSET_BIT 0x2
4275 #define IMAGE_MAP_COLOR_BIT 0x4
4276 #define IMAGE_CLAMP_BIT 0x800
4277
4278
4279 /** Pixel Transfer ops */
4280 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
4281 IMAGE_SHIFT_OFFSET_BIT | \
4282 IMAGE_MAP_COLOR_BIT)
4283
4284 /**
4285 * \name Bits to indicate what state has changed.
4286 */
4287 /*@{*/
4288 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
4289 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
4290 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
4291 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */
4292 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
4293 #define _NEW_EVAL (1u << 5) /**< gl_context::Eval, EvalMap */
4294 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */
4295 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */
4296 #define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
4297 #define _NEW_LINE (1u << 9) /**< gl_context::Line */
4298 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
4299 #define _NEW_POINT (1u << 11) /**< gl_context::Point */
4300 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
4301 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
4302 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
4303 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
4304 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
4305 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
4306 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
4307 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
4308 #define _NEW_ARRAY (1u << 20) /**< gl_context::Array */
4309 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
4310 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
4311 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
4312 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
4313 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
4314 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
4315 #define _NEW_PROGRAM_CONSTANTS (1u << 27)
4316 /* gap */
4317 #define _NEW_FRAG_CLAMP (1u << 29)
4318 /* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
4319 #define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
4320 #define _NEW_ALL ~0
4321 /*@}*/
4322
4323
4324 /**
4325 * Composite state flags
4326 */
4327 /*@{*/
4328 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
4329
4330 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
4331 _NEW_TEXTURE_STATE | \
4332 _NEW_POINT | \
4333 _NEW_PROGRAM | \
4334 _NEW_MODELVIEW)
4335
4336 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
4337 _NEW_FOG | \
4338 _NEW_PROGRAM)
4339
4340
4341 /*@}*/
4342
4343
4344
4345
4346 /* This has to be included here. */
4347 #include "dd.h"
4348
4349
4350 /**
4351 * Display list flags.
4352 * Strictly this is a tnl-private concept, but it doesn't seem
4353 * worthwhile adding a tnl private structure just to hold this one bit
4354 * of information:
4355 */
4356 #define DLIST_DANGLING_REFS 0x1
4357
4358
4359 /** Opaque declaration of display list payload data type */
4360 union gl_dlist_node;
4361
4362
4363 /**
4364 * Provide a location where information about a display list can be
4365 * collected. Could be extended with driverPrivate structures,
4366 * etc. in the future.
4367 */
4368 struct gl_display_list
4369 {
4370 GLuint Name;
4371 GLbitfield Flags; /**< DLIST_x flags */
4372 GLchar *Label; /**< GL_KHR_debug */
4373 /** The dlist commands are in a linked list of nodes */
4374 union gl_dlist_node *Head;
4375 };
4376
4377
4378 /**
4379 * State used during display list compilation and execution.
4380 */
4381 struct gl_dlist_state
4382 {
4383 struct gl_display_list *CurrentList; /**< List currently being compiled */
4384 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
4385 GLuint CurrentPos; /**< Index into current block of nodes */
4386 GLuint CallDepth; /**< Current recursion calling depth */
4387
4388 GLvertexformat ListVtxfmt;
4389
4390 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
4391 GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
4392
4393 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
4394 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
4395
4396 struct {
4397 /* State known to have been set by the currently-compiling display
4398 * list. Used to eliminate some redundant state changes.
4399 */
4400 GLenum ShadeModel;
4401 } Current;
4402 };
4403
4404 /** @{
4405 *
4406 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
4407 * to small enums suitable for use as an array index.
4408 */
4409
4410 enum mesa_debug_source {
4411 MESA_DEBUG_SOURCE_API,
4412 MESA_DEBUG_SOURCE_WINDOW_SYSTEM,
4413 MESA_DEBUG_SOURCE_SHADER_COMPILER,
4414 MESA_DEBUG_SOURCE_THIRD_PARTY,
4415 MESA_DEBUG_SOURCE_APPLICATION,
4416 MESA_DEBUG_SOURCE_OTHER,
4417 MESA_DEBUG_SOURCE_COUNT
4418 };
4419
4420 enum mesa_debug_type {
4421 MESA_DEBUG_TYPE_ERROR,
4422 MESA_DEBUG_TYPE_DEPRECATED,
4423 MESA_DEBUG_TYPE_UNDEFINED,
4424 MESA_DEBUG_TYPE_PORTABILITY,
4425 MESA_DEBUG_TYPE_PERFORMANCE,
4426 MESA_DEBUG_TYPE_OTHER,
4427 MESA_DEBUG_TYPE_MARKER,
4428 MESA_DEBUG_TYPE_PUSH_GROUP,
4429 MESA_DEBUG_TYPE_POP_GROUP,
4430 MESA_DEBUG_TYPE_COUNT
4431 };
4432
4433 enum mesa_debug_severity {
4434 MESA_DEBUG_SEVERITY_LOW,
4435 MESA_DEBUG_SEVERITY_MEDIUM,
4436 MESA_DEBUG_SEVERITY_HIGH,
4437 MESA_DEBUG_SEVERITY_NOTIFICATION,
4438 MESA_DEBUG_SEVERITY_COUNT
4439 };
4440
4441 /** @} */
4442
4443 /**
4444 * Driver-specific state flags.
4445 *
4446 * These are or'd with gl_context::NewDriverState to notify a driver about
4447 * a state change. The driver sets the flags at context creation and
4448 * the meaning of the bits set is opaque to core Mesa.
4449 */
4450 struct gl_driver_flags
4451 {
4452 /** gl_context::Array::_DrawArrays (vertex array state) */
4453 uint64_t NewArray;
4454
4455 /** gl_context::TransformFeedback::CurrentObject */
4456 uint64_t NewTransformFeedback;
4457
4458 /** gl_context::TransformFeedback::CurrentObject::shader_program */
4459 uint64_t NewTransformFeedbackProg;
4460
4461 /** gl_context::RasterDiscard */
4462 uint64_t NewRasterizerDiscard;
4463
4464 /** gl_context::TileRasterOrder* */
4465 uint64_t NewTileRasterOrder;
4466
4467 /**
4468 * gl_context::UniformBufferBindings
4469 * gl_shader_program::UniformBlocks
4470 */
4471 uint64_t NewUniformBuffer;
4472
4473 /**
4474 * gl_context::ShaderStorageBufferBindings
4475 * gl_shader_program::ShaderStorageBlocks
4476 */
4477 uint64_t NewShaderStorageBuffer;
4478
4479 uint64_t NewTextureBuffer;
4480
4481 /**
4482 * gl_context::AtomicBufferBindings
4483 */
4484 uint64_t NewAtomicBuffer;
4485
4486 /**
4487 * gl_context::ImageUnits
4488 */
4489 uint64_t NewImageUnits;
4490
4491 /**
4492 * gl_context::TessCtrlProgram::patch_default_*
4493 */
4494 uint64_t NewDefaultTessLevels;
4495
4496 /**
4497 * gl_context::IntelConservativeRasterization
4498 */
4499 uint64_t NewIntelConservativeRasterization;
4500
4501 /**
4502 * gl_context::Scissor::WindowRects
4503 */
4504 uint64_t NewWindowRectangles;
4505
4506 /** gl_context::Color::sRGBEnabled */
4507 uint64_t NewFramebufferSRGB;
4508
4509 /** gl_context::Scissor::EnableFlags */
4510 uint64_t NewScissorTest;
4511
4512 /** gl_context::Scissor::ScissorArray */
4513 uint64_t NewScissorRect;
4514
4515 /** gl_context::Color::Alpha* */
4516 uint64_t NewAlphaTest;
4517
4518 /** gl_context::Color::Blend/Dither */
4519 uint64_t NewBlend;
4520
4521 /** gl_context::Color::BlendColor */
4522 uint64_t NewBlendColor;
4523
4524 /** gl_context::Color::Color/Index */
4525 uint64_t NewColorMask;
4526
4527 /** gl_context::Depth */
4528 uint64_t NewDepth;
4529
4530 /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
4531 uint64_t NewLogicOp;
4532
4533 /** gl_context::Multisample::Enabled */
4534 uint64_t NewMultisampleEnable;
4535
4536 /** gl_context::Multisample::SampleAlphaTo* */
4537 uint64_t NewSampleAlphaToXEnable;
4538
4539 /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
4540 uint64_t NewSampleMask;
4541
4542 /** gl_context::Multisample::(Min)SampleShading */
4543 uint64_t NewSampleShading;
4544
4545 /** gl_context::Stencil */
4546 uint64_t NewStencil;
4547
4548 /** gl_context::Transform::ClipOrigin/ClipDepthMode */
4549 uint64_t NewClipControl;
4550
4551 /** gl_context::Transform::EyeUserPlane */
4552 uint64_t NewClipPlane;
4553
4554 /** gl_context::Transform::ClipPlanesEnabled */
4555 uint64_t NewClipPlaneEnable;
4556
4557 /** gl_context::Transform::DepthClamp */
4558 uint64_t NewDepthClamp;
4559
4560 /** gl_context::Line */
4561 uint64_t NewLineState;
4562
4563 /** gl_context::Polygon */
4564 uint64_t NewPolygonState;
4565
4566 /** gl_context::PolygonStipple */
4567 uint64_t NewPolygonStipple;
4568
4569 /** gl_context::ViewportArray */
4570 uint64_t NewViewport;
4571
4572 /** Shader constants (uniforms, program parameters, state constants) */
4573 uint64_t NewShaderConstants[MESA_SHADER_STAGES];
4574 };
4575
4576 struct gl_buffer_binding
4577 {
4578 struct gl_buffer_object *BufferObject;
4579 /** Start of uniform block data in the buffer */
4580 GLintptr Offset;
4581 /** Size of data allowed to be referenced from the buffer (in bytes) */
4582 GLsizeiptr Size;
4583 /**
4584 * glBindBufferBase() indicates that the Size should be ignored and only
4585 * limited by the current size of the BufferObject.
4586 */
4587 GLboolean AutomaticSize;
4588 };
4589
4590 /**
4591 * ARB_shader_image_load_store image unit.
4592 */
4593 struct gl_image_unit
4594 {
4595 /**
4596 * Texture object bound to this unit.
4597 */
4598 struct gl_texture_object *TexObj;
4599
4600 /**
4601 * Level of the texture object bound to this unit.
4602 */
4603 GLuint Level;
4604
4605 /**
4606 * \c GL_TRUE if the whole level is bound as an array of layers, \c
4607 * GL_FALSE if only some specific layer of the texture is bound.
4608 * \sa Layer
4609 */
4610 GLboolean Layered;
4611
4612 /**
4613 * Layer of the texture object bound to this unit as specified by the
4614 * application.
4615 */
4616 GLuint Layer;
4617
4618 /**
4619 * Layer of the texture object bound to this unit, or zero if the
4620 * whole level is bound.
4621 */
4622 GLuint _Layer;
4623
4624 /**
4625 * Access allowed to this texture image. Either \c GL_READ_ONLY,
4626 * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
4627 */
4628 GLenum Access;
4629
4630 /**
4631 * GL internal format that determines the interpretation of the
4632 * image memory when shader image operations are performed through
4633 * this unit.
4634 */
4635 GLenum Format;
4636
4637 /**
4638 * Mesa format corresponding to \c Format.
4639 */
4640 mesa_format _ActualFormat;
4641
4642 };
4643
4644 /**
4645 * Shader subroutines storage
4646 */
4647 struct gl_subroutine_index_binding
4648 {
4649 GLuint NumIndex;
4650 GLuint *IndexPtr;
4651 };
4652
4653 struct gl_texture_handle_object
4654 {
4655 struct gl_texture_object *texObj;
4656 struct gl_sampler_object *sampObj;
4657 GLuint64 handle;
4658 };
4659
4660 struct gl_image_handle_object
4661 {
4662 struct gl_image_unit imgObj;
4663 GLuint64 handle;
4664 };
4665
4666 struct gl_memory_object
4667 {
4668 GLuint Name; /**< hash table ID/name */
4669 GLboolean Immutable; /**< denotes mutability state of parameters */
4670 GLboolean Dedicated; /**< import memory from a dedicated allocation */
4671 };
4672
4673 /**
4674 * Mesa rendering context.
4675 *
4676 * This is the central context data structure for Mesa. Almost all
4677 * OpenGL state is contained in this structure.
4678 * Think of this as a base class from which device drivers will derive
4679 * sub classes.
4680 */
4681 struct gl_context
4682 {
4683 /** State possibly shared with other contexts in the address space */
4684 struct gl_shared_state *Shared;
4685
4686 /** \name API function pointer tables */
4687 /*@{*/
4688 gl_api API;
4689
4690 /**
4691 * The current dispatch table for non-displaylist-saving execution, either
4692 * BeginEnd or OutsideBeginEnd
4693 */
4694 struct _glapi_table *Exec;
4695 /**
4696 * The normal dispatch table for non-displaylist-saving, non-begin/end
4697 */
4698 struct _glapi_table *OutsideBeginEnd;
4699 /** The dispatch table used between glNewList() and glEndList() */
4700 struct _glapi_table *Save;
4701 /**
4702 * The dispatch table used between glBegin() and glEnd() (outside of a
4703 * display list). Only valid functions between those two are set, which is
4704 * mostly just the set in a GLvertexformat struct.
4705 */
4706 struct _glapi_table *BeginEnd;
4707 /**
4708 * Dispatch table for when a graphics reset has happened.
4709 */
4710 struct _glapi_table *ContextLost;
4711 /**
4712 * Dispatch table used to marshal API calls from the client program to a
4713 * separate server thread. NULL if API calls are not being marshalled to
4714 * another thread.
4715 */
4716 struct _glapi_table *MarshalExec;
4717 /**
4718 * Dispatch table currently in use for fielding API calls from the client
4719 * program. If API calls are being marshalled to another thread, this ==
4720 * MarshalExec. Otherwise it == CurrentServerDispatch.
4721 */
4722 struct _glapi_table *CurrentClientDispatch;
4723
4724 /**
4725 * Dispatch table currently in use for performing API calls. == Save or
4726 * Exec.
4727 */
4728 struct _glapi_table *CurrentServerDispatch;
4729
4730 /*@}*/
4731
4732 struct glthread_state *GLThread;
4733
4734 struct gl_config Visual;
4735 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
4736 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
4737 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
4738 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
4739
4740 /**
4741 * Device driver function pointer table
4742 */
4743 struct dd_function_table Driver;
4744
4745 /** Core/Driver constants */
4746 struct gl_constants Const;
4747
4748 /** \name The various 4x4 matrix stacks */
4749 /*@{*/
4750 struct gl_matrix_stack ModelviewMatrixStack;
4751 struct gl_matrix_stack ProjectionMatrixStack;
4752 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
4753 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
4754 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
4755 /*@}*/
4756
4757 /** Combined modelview and projection matrix */
4758 GLmatrix _ModelProjectMatrix;
4759
4760 /** \name Display lists */
4761 struct gl_dlist_state ListState;
4762
4763 GLboolean ExecuteFlag; /**< Execute GL commands? */
4764 GLboolean CompileFlag; /**< Compile GL commands into display list? */
4765
4766 /** Extension information */
4767 struct gl_extensions Extensions;
4768
4769 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
4770 GLuint Version;
4771 char *VersionString;
4772
4773 /** \name State attribute stack (for glPush/PopAttrib) */
4774 /*@{*/
4775 GLuint AttribStackDepth;
4776 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
4777 /*@}*/
4778
4779 /** \name Renderer attribute groups
4780 *
4781 * We define a struct for each attribute group to make pushing and popping
4782 * attributes easy. Also it's a good organization.
4783 */
4784 /*@{*/
4785 struct gl_accum_attrib Accum; /**< Accum buffer attributes */
4786 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
4787 struct gl_current_attrib Current; /**< Current attributes */
4788 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
4789 struct gl_eval_attrib Eval; /**< Eval attributes */
4790 struct gl_fog_attrib Fog; /**< Fog attributes */
4791 struct gl_hint_attrib Hint; /**< Hint attributes */
4792 struct gl_light_attrib Light; /**< Light attributes */
4793 struct gl_line_attrib Line; /**< Line attributes */
4794 struct gl_list_attrib List; /**< List attributes */
4795 struct gl_multisample_attrib Multisample;
4796 struct gl_pixel_attrib Pixel; /**< Pixel attributes */
4797 struct gl_point_attrib Point; /**< Point attributes */
4798 struct gl_polygon_attrib Polygon; /**< Polygon attributes */
4799 GLuint PolygonStipple[32]; /**< Polygon stipple */
4800 struct gl_scissor_attrib Scissor; /**< Scissor attributes */
4801 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
4802 struct gl_texture_attrib Texture; /**< Texture attributes */
4803 struct gl_transform_attrib Transform; /**< Transformation attributes */
4804 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
4805 /*@}*/
4806
4807 /** \name Client attribute stack */
4808 /*@{*/
4809 GLuint ClientAttribStackDepth;
4810 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
4811 /*@}*/
4812
4813 /** \name Client attribute groups */
4814 /*@{*/
4815 struct gl_array_attrib Array; /**< Vertex arrays */
4816 struct gl_pixelstore_attrib Pack; /**< Pixel packing */
4817 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
4818 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
4819 /*@}*/
4820
4821 /** \name Other assorted state (not pushed/popped on attribute stack) */
4822 /*@{*/
4823 struct gl_pixelmaps PixelMaps;
4824
4825 struct gl_evaluators EvalMap; /**< All evaluators */
4826 struct gl_feedback Feedback; /**< Feedback */
4827 struct gl_selection Select; /**< Selection */
4828
4829 struct gl_program_state Program; /**< general program state */
4830 struct gl_vertex_program_state VertexProgram;
4831 struct gl_fragment_program_state FragmentProgram;
4832 struct gl_geometry_program_state GeometryProgram;
4833 struct gl_compute_program_state ComputeProgram;
4834 struct gl_tess_ctrl_program_state TessCtrlProgram;
4835 struct gl_tess_eval_program_state TessEvalProgram;
4836 struct gl_ati_fragment_shader_state ATIFragmentShader;
4837
4838 struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
4839 struct gl_pipeline_object Shader; /**< GLSL shader object state */
4840
4841 /**
4842 * Current active shader pipeline state
4843 *
4844 * Almost all internal users want ::_Shader instead of ::Shader. The
4845 * exceptions are bits of legacy GLSL API that do not know about separate
4846 * shader objects.
4847 *
4848 * If a program is active via \c glUseProgram, this will point to
4849 * \c ::Shader.
4850 *
4851 * If a program pipeline is active via \c glBindProgramPipeline, this will
4852 * point to \c ::Pipeline.Current.
4853 *
4854 * If neither a program nor a program pipeline is active, this will point to
4855 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
4856 * \c NULL.
4857 */
4858 struct gl_pipeline_object *_Shader;
4859
4860 struct gl_query_state Query; /**< occlusion, timer queries */
4861
4862 struct gl_transform_feedback_state TransformFeedback;
4863
4864 struct gl_perf_monitor_state PerfMonitor;
4865 struct gl_perf_query_state PerfQuery;
4866
4867 struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
4868 struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */
4869 struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */
4870
4871 struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
4872 struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
4873
4874 struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
4875
4876 /**
4877 * Current GL_ARB_uniform_buffer_object binding referenced by
4878 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
4879 */
4880 struct gl_buffer_object *UniformBuffer;
4881
4882 /**
4883 * Current GL_ARB_shader_storage_buffer_object binding referenced by
4884 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
4885 */
4886 struct gl_buffer_object *ShaderStorageBuffer;
4887
4888 /**
4889 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
4890 * This is set up using glBindBufferRange() or glBindBufferBase(). They are
4891 * associated with uniform blocks by glUniformBlockBinding()'s state in the
4892 * shader program.
4893 */
4894 struct gl_buffer_binding
4895 UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
4896
4897 /**
4898 * Array of shader storage buffers for ARB_shader_storage_buffer_object
4899 * and GL 4.3. This is set up using glBindBufferRange() or
4900 * glBindBufferBase(). They are associated with shader storage blocks by
4901 * glShaderStorageBlockBinding()'s state in the shader program.
4902 */
4903 struct gl_buffer_binding
4904 ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
4905
4906 /**
4907 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
4908 * target.
4909 */
4910 struct gl_buffer_object *AtomicBuffer;
4911
4912 /**
4913 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
4914 * target.
4915 */
4916 struct gl_buffer_object *ExternalVirtualMemoryBuffer;
4917
4918 /**
4919 * Array of atomic counter buffer binding points.
4920 */
4921 struct gl_buffer_binding
4922 AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
4923
4924 /**
4925 * Array of image units for ARB_shader_image_load_store.
4926 */
4927 struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
4928
4929 struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES];
4930 /*@}*/
4931
4932 struct gl_meta_state *Meta; /**< for "meta" operations */
4933
4934 /* GL_EXT_framebuffer_object */
4935 struct gl_renderbuffer *CurrentRenderbuffer;
4936
4937 GLenum ErrorValue; /**< Last error code */
4938
4939 /**
4940 * Recognize and silence repeated error debug messages in buggy apps.
4941 */
4942 const char *ErrorDebugFmtString;
4943 GLuint ErrorDebugCount;
4944
4945 /* GL_ARB_debug_output/GL_KHR_debug */
4946 simple_mtx_t DebugMutex;
4947 struct gl_debug_state *Debug;
4948
4949 GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
4950 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
4951 uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */
4952
4953 struct gl_driver_flags DriverFlags;
4954
4955 GLboolean ViewportInitialized; /**< has viewport size been initialized? */
4956
4957 GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
4958
4959 /** \name Derived state */
4960 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
4961 GLfloat _EyeZDir[3];
4962 GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
4963 GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
4964 GLboolean _NeedEyeCoords;
4965 GLboolean _ForceEyeCoords;
4966
4967 GLuint TextureStateTimestamp; /**< detect changes to shared state */
4968
4969 struct gl_list_extensions *ListExt; /**< driver dlist extensions */
4970
4971 /** \name For debugging/development only */
4972 /*@{*/
4973 GLboolean FirstTimeCurrent;
4974 /*@}*/
4975
4976 /**
4977 * False if this context was created without a config. This is needed
4978 * because the initial state of glDrawBuffers depends on this
4979 */
4980 GLboolean HasConfig;
4981
4982 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
4983
4984 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
4985 GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
4986
4987 /** Does glVertexAttrib(0) alias glVertex()? */
4988 bool _AttribZeroAliasesVertex;
4989
4990 /**
4991 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
4992 * renderer's tiles should be excecuted, to meet the requirements of
4993 * GL_MESA_tile_raster_order.
4994 */
4995 GLboolean TileRasterOrderFixed;
4996 GLboolean TileRasterOrderIncreasingX;
4997 GLboolean TileRasterOrderIncreasingY;
4998
4999 /**
5000 * \name Hooks for module contexts.
5001 *
5002 * These will eventually live in the driver or elsewhere.
5003 */
5004 /*@{*/
5005 void *swrast_context;
5006 void *swsetup_context;
5007 void *swtnl_context;
5008 struct vbo_context *vbo_context;
5009 struct st_context *st;
5010 void *aelt_context;
5011 /*@}*/
5012
5013 /**
5014 * \name NV_vdpau_interop
5015 */
5016 /*@{*/
5017 const void *vdpDevice;
5018 const void *vdpGetProcAddress;
5019 struct set *vdpSurfaces;
5020 /*@}*/
5021
5022 /**
5023 * Has this context observed a GPU reset in any context in the share group?
5024 *
5025 * Once this field becomes true, it is never reset to false.
5026 */
5027 GLboolean ShareGroupReset;
5028
5029 /**
5030 * \name OES_primitive_bounding_box
5031 *
5032 * Stores the arguments to glPrimitiveBoundingBox
5033 */
5034 GLfloat PrimitiveBoundingBox[8];
5035
5036 struct disk_cache *Cache;
5037
5038 /**
5039 * \name GL_ARB_bindless_texture
5040 */
5041 /*@{*/
5042 struct hash_table_u64 *ResidentTextureHandles;
5043 struct hash_table_u64 *ResidentImageHandles;
5044 /*@}*/
5045 };
5046
5047 /**
5048 * Information about memory usage. All sizes are in kilobytes.
5049 */
5050 struct gl_memory_info
5051 {
5052 unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
5053 unsigned avail_device_memory; /**< free device memory at the moment */
5054 unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
5055 unsigned avail_staging_memory; /**< free staging memory at the moment */
5056 unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
5057 unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
5058 };
5059
5060 #ifdef DEBUG
5061 extern int MESA_VERBOSE;
5062 extern int MESA_DEBUG_FLAGS;
5063 # define MESA_FUNCTION __func__
5064 #else
5065 # define MESA_VERBOSE 0
5066 # define MESA_DEBUG_FLAGS 0
5067 # define MESA_FUNCTION "a function"
5068 #endif
5069
5070
5071 /** The MESA_VERBOSE var is a bitmask of these flags */
5072 enum _verbose
5073 {
5074 VERBOSE_VARRAY = 0x0001,
5075 VERBOSE_TEXTURE = 0x0002,
5076 VERBOSE_MATERIAL = 0x0004,
5077 VERBOSE_PIPELINE = 0x0008,
5078 VERBOSE_DRIVER = 0x0010,
5079 VERBOSE_STATE = 0x0020,
5080 VERBOSE_API = 0x0040,
5081 VERBOSE_DISPLAY_LIST = 0x0100,
5082 VERBOSE_LIGHTING = 0x0200,
5083 VERBOSE_PRIMS = 0x0400,
5084 VERBOSE_VERTS = 0x0800,
5085 VERBOSE_DISASSEM = 0x1000,
5086 VERBOSE_DRAW = 0x2000,
5087 VERBOSE_SWAPBUFFERS = 0x4000
5088 };
5089
5090
5091 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
5092 enum _debug
5093 {
5094 DEBUG_SILENT = (1 << 0),
5095 DEBUG_ALWAYS_FLUSH = (1 << 1),
5096 DEBUG_INCOMPLETE_TEXTURE = (1 << 2),
5097 DEBUG_INCOMPLETE_FBO = (1 << 3),
5098 DEBUG_CONTEXT = (1 << 4)
5099 };
5100
5101 #ifdef __cplusplus
5102 }
5103 #endif
5104
5105 #endif /* MTYPES_H */