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/glthread.h" 43 #include "main/consts_exts.h" 44 #include "main/shader_types.h" 45 #include "main/glconfig.h" 46 #include "main/menums.h" 47 #include "main/config.h" 48 #include "glapi/glapi.h" 49 #include "math/m_matrix.h" /* GLmatrix */ 50 #include "compiler/shader_enums.h" 51 #include "compiler/shader_info.h" 52 #include "main/formats.h" /* MESA_FORMAT_COUNT */ 53 #include "compiler/glsl/list.h" 54 #include "compiler/glsl/ir_uniform.h" 55 #include "util/u_idalloc.h" 56 #include "util/simple_mtx.h" 57 #include "util/u_dynarray.h" 58 #include "util/mesa-sha1.h" 59 #include "vbo/vbo.h" 60 61 #include "pipe/p_state.h" 62 63 #include "frontend/api.h" 64 65 #ifdef __cplusplus 66 extern "C" { 67 #endif 68 69 #define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1) 70 #define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf) 71 72 73 /** 74 * \name Some forward type declarations 75 */ 76 /*@{*/ 77 struct _mesa_HashTable; 78 struct gl_attrib_node; 79 struct gl_list_extensions; 80 struct gl_meta_state; 81 struct gl_program_cache; 82 struct gl_texture_object; 83 struct gl_debug_state; 84 struct gl_context; 85 struct st_context; 86 struct gl_uniform_storage; 87 struct prog_instruction; 88 struct gl_program_parameter_list; 89 struct gl_shader_spirv_data; 90 struct set; 91 struct shader_includes; 92 /*@}*/ 93 94 95 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ 96 #define PRIM_MAX GL_PATCHES 97 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1) 98 #define PRIM_UNKNOWN (PRIM_MAX + 2) 99 100 /** 101 * Bit flags for all renderbuffers 102 */ 103 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) 104 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) 105 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) 106 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) 107 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) 108 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) 109 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) 110 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) 111 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) 112 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) 113 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) 114 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) 115 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) 116 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) 117 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) 118 119 /** 120 * Mask of all the color buffer bits (but not accum). 121 */ 122 #define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ 123 BUFFER_BIT_BACK_LEFT | \ 124 BUFFER_BIT_FRONT_RIGHT | \ 125 BUFFER_BIT_BACK_RIGHT | \ 126 BUFFER_BIT_COLOR0 | \ 127 BUFFER_BIT_COLOR1 | \ 128 BUFFER_BIT_COLOR2 | \ 129 BUFFER_BIT_COLOR3 | \ 130 BUFFER_BIT_COLOR4 | \ 131 BUFFER_BIT_COLOR5 | \ 132 BUFFER_BIT_COLOR6 | \ 133 BUFFER_BIT_COLOR7) 134 135 /* Mask of bits for depth+stencil buffers */ 136 #define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL) 137 138 139 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \ 140 MAT_BIT_FRONT_AMBIENT | \ 141 MAT_BIT_FRONT_DIFFUSE | \ 142 MAT_BIT_FRONT_SPECULAR | \ 143 MAT_BIT_FRONT_SHININESS | \ 144 MAT_BIT_FRONT_INDEXES) 145 146 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \ 147 MAT_BIT_BACK_AMBIENT | \ 148 MAT_BIT_BACK_DIFFUSE | \ 149 MAT_BIT_BACK_SPECULAR | \ 150 MAT_BIT_BACK_SHININESS | \ 151 MAT_BIT_BACK_INDEXES) 152 153 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS) 154 /*@}*/ 155 156 157 /** 158 * Material state. 159 */ 160 struct gl_material 161 { 162 GLfloat Attrib[MAT_ATTRIB_MAX][4]; 163 }; 164 165 166 /** 167 * Light state flags. 168 */ 169 /*@{*/ 170 #define LIGHT_SPOT 0x1 171 #define LIGHT_LOCAL_VIEWER 0x2 172 #define LIGHT_POSITIONAL 0x4 173 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) 174 /*@}*/ 175 176 177 /** 178 * Light source state. 179 */ 180 struct gl_light 181 { 182 GLboolean Enabled; /**< On/off flag */ 183 184 /** 185 * \name Derived fields 186 */ 187 /*@{*/ 188 GLbitfield _Flags; /**< Mask of LIGHT_x bits defined above */ 189 190 GLfloat _Position[4]; /**< position in eye/obj coordinates */ 191 GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */ 192 GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */ 193 GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ 194 GLfloat _VP_inf_spot_attenuation; 195 196 GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ 197 GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ 198 GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ 199 /*@}*/ 200 }; 201 202 203 /** 204 * Light model state. 205 */ 206 struct gl_lightmodel 207 { 208 GLfloat Ambient[4]; /**< ambient color */ 209 GLboolean LocalViewer; /**< Local (or infinite) view point? */ 210 GLboolean TwoSide; /**< Two (or one) sided lighting? */ 211 GLenum16 ColorControl; /**< either GL_SINGLE_COLOR 212 or GL_SEPARATE_SPECULAR_COLOR */ 213 }; 214 215 216 /** 217 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) 218 */ 219 struct gl_accum_attrib 220 { 221 GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ 222 }; 223 224 225 /** 226 * Used for storing clear color, texture border color, etc. 227 * The float values are typically unclamped. 228 */ 229 union gl_color_union 230 { 231 GLfloat f[4]; 232 GLint i[4]; 233 GLuint ui[4]; 234 }; 235 236 237 /** 238 * Color buffer attribute group (GL_COLOR_BUFFER_BIT). 239 */ 240 struct gl_colorbuffer_attrib 241 { 242 GLuint ClearIndex; /**< Index for glClear */ 243 union gl_color_union ClearColor; /**< Color for glClear, unclamped */ 244 GLuint IndexMask; /**< Color index write mask */ 245 246 /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */ 247 GLbitfield ColorMask; 248 249 GLenum16 DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ 250 251 /** 252 * \name alpha testing 253 */ 254 /*@{*/ 255 GLboolean AlphaEnabled; /**< Alpha test enabled flag */ 256 GLenum16 AlphaFunc; /**< Alpha test function */ 257 GLfloat AlphaRefUnclamped; 258 GLclampf AlphaRef; /**< Alpha reference value */ 259 /*@}*/ 260 261 /** 262 * \name Blending 263 */ 264 /*@{*/ 265 GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ 266 267 /* NOTE: this does _not_ depend on fragment clamping or any other clamping 268 * control, only on the fixed-pointness of the render target. 269 * The query does however depend on fragment color clamping. 270 */ 271 GLfloat BlendColorUnclamped[4]; /**< Blending color */ 272 GLfloat BlendColor[4]; /**< Blending color */ 273 274 struct 275 { 276 GLenum16 SrcRGB; /**< RGB blend source term */ 277 GLenum16 DstRGB; /**< RGB blend dest term */ 278 GLenum16 SrcA; /**< Alpha blend source term */ 279 GLenum16 DstA; /**< Alpha blend dest term */ 280 GLenum16 EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */ 281 GLenum16 EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */ 282 } Blend[MAX_DRAW_BUFFERS]; 283 /** Bitfield of color buffers with enabled dual source blending. */ 284 GLbitfield _BlendUsesDualSrc; 285 /** Are the blend func terms currently different for each buffer/target? */ 286 GLboolean _BlendFuncPerBuffer; 287 /** Are the blend equations currently different for each buffer/target? */ 288 GLboolean _BlendEquationPerBuffer; 289 290 /** 291 * Which advanced blending mode is in use (or BLEND_NONE). 292 * 293 * KHR_blend_equation_advanced only allows advanced blending with a single 294 * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still 295 * requires all draw buffers to match, so we only need a single value. 296 */ 297 enum gl_advanced_blend_mode _AdvancedBlendMode; 298 299 /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */ 300 bool BlendCoherent; 301 /*@}*/ 302 303 /** 304 * \name Logic op 305 */ 306 /*@{*/ 307 GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ 308 GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ 309 GLenum16 LogicOp; /**< Logic operator */ 310 enum gl_logicop_mode _LogicOp; 311 /*@}*/ 312 313 GLboolean DitherFlag; /**< Dither enable flag */ 314 315 GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ 316 GLenum16 ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ 317 GLenum16 ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ 318 319 GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ 320 }; 321 322 323 /** 324 * Vertex format to describe a vertex element. 325 */ 326 struct gl_vertex_format 327 { 328 GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */ 329 GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */ 330 enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */ 331 GLubyte Size:5; /**< components per element (1,2,3,4) */ 332 GLubyte Normalized:1; /**< GL_ARB_vertex_program */ 333 GLubyte Integer:1; /**< Integer-valued? */ 334 GLubyte Doubles:1; /**< double values are not converted to floats */ 335 GLubyte _ElementSize; /**< Size of each element in bytes */ 336 }; 337 338 339 /** 340 * Current attribute group (GL_CURRENT_BIT). 341 */ 342 struct gl_current_attrib 343 { 344 /** 345 * \name Current vertex attributes (color, texcoords, etc). 346 * \note Values are valid only after FLUSH_VERTICES has been called. 347 * \note Index and Edgeflag current values are stored as floats in the 348 * SIX and SEVEN attribute slots. 349 * \note We need double storage for 64-bit vertex attributes 350 */ 351 GLfloat Attrib[VERT_ATTRIB_MAX][4*2]; 352 353 /** 354 * \name Current raster position attributes (always up to date after a 355 * glRasterPos call). 356 */ 357 GLfloat RasterPos[4]; 358 GLfloat RasterDistance; 359 GLfloat RasterColor[4]; 360 GLfloat RasterSecondaryColor[4]; 361 GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; 362 GLboolean RasterPosValid; 363 }; 364 365 366 /** 367 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). 368 */ 369 struct gl_depthbuffer_attrib 370 { 371 GLenum16 Func; /**< Function for depth buffer compare */ 372 GLclampd Clear; /**< Value to clear depth buffer to */ 373 GLboolean Test; /**< Depth buffering enabled flag */ 374 GLboolean Mask; /**< Depth buffer writable? */ 375 GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ 376 GLclampd BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ 377 }; 378 379 380 /** 381 * Evaluator attribute group (GL_EVAL_BIT). 382 */ 383 struct gl_eval_attrib 384 { 385 /** 386 * \name Enable bits 387 */ 388 /*@{*/ 389 GLboolean Map1Color4; 390 GLboolean Map1Index; 391 GLboolean Map1Normal; 392 GLboolean Map1TextureCoord1; 393 GLboolean Map1TextureCoord2; 394 GLboolean Map1TextureCoord3; 395 GLboolean Map1TextureCoord4; 396 GLboolean Map1Vertex3; 397 GLboolean Map1Vertex4; 398 GLboolean Map2Color4; 399 GLboolean Map2Index; 400 GLboolean Map2Normal; 401 GLboolean Map2TextureCoord1; 402 GLboolean Map2TextureCoord2; 403 GLboolean Map2TextureCoord3; 404 GLboolean Map2TextureCoord4; 405 GLboolean Map2Vertex3; 406 GLboolean Map2Vertex4; 407 GLboolean AutoNormal; 408 /*@}*/ 409 410 /** 411 * \name Map Grid endpoints and divisions and calculated du values 412 */ 413 /*@{*/ 414 GLint MapGrid1un; 415 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; 416 GLint MapGrid2un, MapGrid2vn; 417 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; 418 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; 419 /*@}*/ 420 }; 421 422 423 /** 424 * Compressed fog mode. 425 */ 426 enum gl_fog_mode 427 { 428 FOG_NONE, 429 FOG_LINEAR, 430 FOG_EXP, 431 FOG_EXP2, 432 }; 433 434 435 /** 436 * Fog attribute group (GL_FOG_BIT). 437 */ 438 struct gl_fog_attrib 439 { 440 GLboolean Enabled; /**< Fog enabled flag */ 441 GLboolean ColorSumEnabled; 442 uint8_t _PackedMode; /**< Fog mode as 2 bits */ 443 uint8_t _PackedEnabledMode; /**< Masked CompressedMode */ 444 GLfloat ColorUnclamped[4]; /**< Fog color */ 445 GLfloat Color[4]; /**< Fog color */ 446 GLfloat Density; /**< Density >= 0.0 */ 447 GLfloat Start; /**< Start distance in eye coords */ 448 GLfloat End; /**< End distance in eye coords */ 449 GLfloat Index; /**< Fog index */ 450 GLenum16 Mode; /**< Fog mode */ 451 GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */ 452 GLenum16 FogDistanceMode; /**< GL_NV_fog_distance */ 453 }; 454 455 456 /** 457 * Hint attribute group (GL_HINT_BIT). 458 * 459 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. 460 */ 461 struct gl_hint_attrib 462 { 463 GLenum16 PerspectiveCorrection; 464 GLenum16 PointSmooth; 465 GLenum16 LineSmooth; 466 GLenum16 PolygonSmooth; 467 GLenum16 Fog; 468 GLenum16 TextureCompression; /**< GL_ARB_texture_compression */ 469 GLenum16 GenerateMipmap; /**< GL_SGIS_generate_mipmap */ 470 GLenum16 FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ 471 GLuint MaxShaderCompilerThreads; /**< GL_ARB_parallel_shader_compile */ 472 }; 473 474 475 struct gl_light_uniforms { 476 /* These must be in the same order as the STATE_* enums, 477 * which should also match the order of gl_LightSource members. 478 */ 479 GLfloat Ambient[4]; /**< STATE_AMBIENT */ 480 GLfloat Diffuse[4]; /**< STATE_DIFFUSE */ 481 GLfloat Specular[4]; /**< STATE_SPECULAR */ 482 GLfloat EyePosition[4]; /**< STATE_POSITION in eye coordinates */ 483 GLfloat _HalfVector[4]; /**< STATE_HALF_VECTOR */ 484 GLfloat SpotDirection[3]; /**< STATE_SPOT_DIRECTION in eye coordinates */ 485 GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */ 486 GLfloat ConstantAttenuation; /**< STATE_ATTENUATION */ 487 GLfloat LinearAttenuation; 488 GLfloat QuadraticAttenuation; 489 GLfloat SpotExponent; 490 GLfloat SpotCutoff; /**< STATE_SPOT_CUTOFF in degrees */ 491 }; 492 493 494 /** 495 * Lighting attribute group (GL_LIGHT_BIT). 496 */ 497 struct gl_light_attrib 498 { 499 /* gl_LightSource uniforms */ 500 union { 501 struct gl_light_uniforms LightSource[MAX_LIGHTS]; 502 GLfloat LightSourceData[(sizeof(struct gl_light_uniforms) / 4) * MAX_LIGHTS]; 503 }; 504 505 struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ 506 struct gl_lightmodel Model; /**< Lighting model */ 507 508 /** 509 * Front and back material values. 510 * Note: must call FLUSH_VERTICES() before using. 511 */ 512 struct gl_material Material; 513 514 GLboolean Enabled; /**< Lighting enabled flag */ 515 GLboolean ColorMaterialEnabled; 516 517 GLenum16 ShadeModel; /**< GL_FLAT or GL_SMOOTH */ 518 GLenum16 ProvokingVertex; /**< GL_EXT_provoking_vertex */ 519 GLenum16 ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ 520 GLenum16 ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ 521 GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ 522 523 524 GLboolean _ClampVertexColor; 525 GLenum16 ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */ 526 527 /** 528 * Derived state for optimizations: 529 */ 530 /*@{*/ 531 GLbitfield _EnabledLights; /**< bitmask containing enabled lights */ 532 533 GLboolean _NeedEyeCoords; 534 GLboolean _NeedVertices; /**< Use fast shader? */ 535 536 GLfloat _BaseColor[2][3]; 537 /*@}*/ 538 }; 539 540 541 /** 542 * Line attribute group (GL_LINE_BIT). 543 */ 544 struct gl_line_attrib 545 { 546 GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ 547 GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ 548 GLushort StipplePattern; /**< Stipple pattern */ 549 GLint StippleFactor; /**< Stipple repeat factor */ 550 GLfloat Width; /**< Line width */ 551 }; 552 553 554 /** 555 * Display list attribute group (GL_LIST_BIT). 556 */ 557 struct gl_list_attrib 558 { 559 GLuint ListBase; 560 }; 561 562 563 /** 564 * Multisample attribute group (GL_MULTISAMPLE_BIT). 565 */ 566 struct gl_multisample_attrib 567 { 568 GLboolean Enabled; 569 GLboolean SampleAlphaToCoverage; 570 GLboolean SampleAlphaToOne; 571 GLboolean SampleCoverage; 572 GLboolean SampleCoverageInvert; 573 GLboolean SampleShading; 574 575 /* ARB_texture_multisample / GL3.2 additions */ 576 GLboolean SampleMask; 577 578 GLfloat SampleCoverageValue; /**< In range [0, 1] */ 579 GLfloat MinSampleShadingValue; /**< In range [0, 1] */ 580 581 /** The GL spec defines this as an array but >32x MSAA is madness */ 582 GLbitfield SampleMaskValue; 583 584 /* NV_alpha_to_coverage_dither_control */ 585 GLenum SampleAlphaToCoverageDitherControl; 586 }; 587 588 589 /** 590 * A pixelmap (see glPixelMap) 591 */ 592 struct gl_pixelmap 593 { 594 GLint Size; 595 GLfloat Map[MAX_PIXEL_MAP_TABLE]; 596 }; 597 598 599 /** 600 * Collection of all pixelmaps 601 */ 602 struct gl_pixelmaps 603 { 604 struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ 605 struct gl_pixelmap GtoG; 606 struct gl_pixelmap BtoB; 607 struct gl_pixelmap AtoA; 608 struct gl_pixelmap ItoR; 609 struct gl_pixelmap ItoG; 610 struct gl_pixelmap ItoB; 611 struct gl_pixelmap ItoA; 612 struct gl_pixelmap ItoI; 613 struct gl_pixelmap StoS; 614 }; 615 616 617 /** 618 * Pixel attribute group (GL_PIXEL_MODE_BIT). 619 */ 620 struct gl_pixel_attrib 621 { 622 GLenum16 ReadBuffer; /**< source buffer for glRead/CopyPixels() */ 623 624 /*--- Begin Pixel Transfer State ---*/ 625 /* Fields are in the order in which they're applied... */ 626 627 /** Scale & Bias (index shift, offset) */ 628 /*@{*/ 629 GLfloat RedBias, RedScale; 630 GLfloat GreenBias, GreenScale; 631 GLfloat BlueBias, BlueScale; 632 GLfloat AlphaBias, AlphaScale; 633 GLfloat DepthBias, DepthScale; 634 GLint IndexShift, IndexOffset; 635 /*@}*/ 636 637 /* Pixel Maps */ 638 /* Note: actual pixel maps are not part of this attrib group */ 639 GLboolean MapColorFlag; 640 GLboolean MapStencilFlag; 641 642 /*--- End Pixel Transfer State ---*/ 643 644 /** glPixelZoom */ 645 GLfloat ZoomX, ZoomY; 646 }; 647 648 649 /** 650 * Point attribute group (GL_POINT_BIT). 651 */ 652 struct gl_point_attrib 653 { 654 GLfloat Size; /**< User-specified point size */ 655 GLfloat Params[3]; /**< GL_EXT_point_parameters */ 656 GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ 657 GLfloat Threshold; /**< GL_EXT_point_parameters */ 658 GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ 659 GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ 660 GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ 661 GLbitfield CoordReplace; /**< GL_ARB_point_sprite*/ 662 GLenum16 SpriteOrigin; /**< GL_ARB_point_sprite */ 663 }; 664 665 666 /** 667 * Polygon attribute group (GL_POLYGON_BIT). 668 */ 669 struct gl_polygon_attrib 670 { 671 GLenum16 FrontFace; /**< Either GL_CW or GL_CCW */ 672 GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ 673 GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ 674 GLboolean CullFlag; /**< Culling on/off flag */ 675 GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ 676 GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ 677 GLenum16 CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ 678 GLfloat OffsetFactor; /**< Polygon offset factor, from user */ 679 GLfloat OffsetUnits; /**< Polygon offset units, from user */ 680 GLfloat OffsetClamp; /**< Polygon offset clamp, from user */ 681 GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ 682 GLboolean OffsetLine; /**< Offset in GL_LINE mode */ 683 GLboolean OffsetFill; /**< Offset in GL_FILL mode */ 684 }; 685 686 687 /** 688 * Scissor attributes (GL_SCISSOR_BIT). 689 */ 690 struct gl_scissor_rect 691 { 692 GLint X, Y; /**< Lower left corner of box */ 693 GLsizei Width, Height; /**< Size of box */ 694 }; 695 696 697 struct gl_scissor_attrib 698 { 699 GLbitfield EnableFlags; /**< Scissor test enabled? */ 700 struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS]; 701 GLint NumWindowRects; /**< Count of enabled window rectangles */ 702 GLenum16 WindowRectMode; /**< Whether to include or exclude the rects */ 703 struct gl_scissor_rect WindowRects[MAX_WINDOW_RECTANGLES]; 704 }; 705 706 707 /** 708 * Stencil attribute group (GL_STENCIL_BUFFER_BIT). 709 * 710 * Three sets of stencil data are tracked so that OpenGL 2.0, 711 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported 712 * simultaneously. In each of the stencil state arrays, element 0 corresponds 713 * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / 714 * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the 715 * GL_EXT_stencil_two_side GL_BACK state. 716 * 717 * The derived value \c _BackFace is either 1 or 2 depending on whether or 718 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. 719 * 720 * The derived value \c _TestTwoSide is set when the front-face and back-face 721 * stencil state are different. 722 */ 723 struct gl_stencil_attrib 724 { 725 GLboolean Enabled; /**< Enabled flag */ 726 GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ 727 GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ 728 GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ 729 GLenum16 Function[3]; /**< Stencil function */ 730 GLenum16 FailFunc[3]; /**< Fail function */ 731 GLenum16 ZPassFunc[3]; /**< Depth buffer pass function */ 732 GLenum16 ZFailFunc[3]; /**< Depth buffer fail function */ 733 GLint Ref[3]; /**< Reference value */ 734 GLuint ValueMask[3]; /**< Value mask */ 735 GLuint WriteMask[3]; /**< Write mask */ 736 GLuint Clear; /**< Clear value */ 737 }; 738 739 740 /** 741 * Bit flags for each type of texture object 742 */ 743 /*@{*/ 744 #define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX) 745 #define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX) 746 #define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX) 747 #define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX) 748 #define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) 749 #define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) 750 #define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX) 751 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) 752 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) 753 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) 754 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) 755 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) 756 /*@}*/ 757 758 759 /** 760 * Texture image state. Drivers will typically create a subclass of this 761 * with extra fields for memory buffers, etc. 762 */ 763 struct gl_texture_image 764 { 765 GLint InternalFormat; /**< Internal format as given by the user */ 766 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, 767 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, 768 * GL_INTENSITY, GL_DEPTH_COMPONENT or 769 * GL_DEPTH_STENCIL_EXT only. Used for 770 * choosing TexEnv arithmetic. 771 */ 772 mesa_format TexFormat; /**< The actual texture memory format */ 773 774 GLuint Border; /**< 0 or 1 */ 775 GLuint Width; /**< = 2^WidthLog2 + 2*Border */ 776 GLuint Height; /**< = 2^HeightLog2 + 2*Border */ 777 GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ 778 GLuint Width2; /**< = Width - 2*Border */ 779 GLuint Height2; /**< = Height - 2*Border */ 780 GLuint Depth2; /**< = Depth - 2*Border */ 781 GLuint WidthLog2; /**< = log2(Width2) */ 782 GLuint HeightLog2; /**< = log2(Height2) */ 783 GLuint DepthLog2; /**< = log2(Depth2) */ 784 GLuint MaxNumLevels; /**< = maximum possible number of mipmap 785 levels, computed from the dimensions */ 786 787 struct gl_texture_object *TexObject; /**< Pointer back to parent object */ 788 GLuint Level; /**< Which mipmap level am I? */ 789 /** Cube map face: index into gl_texture_object::Image[] array */ 790 GLuint Face; 791 792 /** GL_ARB_texture_multisample */ 793 GLuint NumSamples; /**< Sample count, or 0 for non-multisample */ 794 GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */ 795 796 /* If stImage->pt != NULL, image data is stored here. 797 * Else there is no image data. 798 */ 799 struct pipe_resource *pt; 800 801 /* List of transfers, allocated on demand. 802 * transfer[layer] is a mapping for that layer. 803 */ 804 struct st_texture_image_transfer *transfer; 805 unsigned num_transfers; 806 807 /* For compressed images unsupported by the driver. Keep track of 808 * the original data. This is necessary for mapping/unmapping, 809 * as well as image copies. 810 */ 811 struct st_compressed_data* compressed_data; 812 }; 813 814 815 /** 816 * Indexes for cube map faces. 817 */ 818 typedef enum 819 { 820 FACE_POS_X = 0, 821 FACE_NEG_X = 1, 822 FACE_POS_Y = 2, 823 FACE_NEG_Y = 3, 824 FACE_POS_Z = 4, 825 FACE_NEG_Z = 5, 826 MAX_FACES = 6 827 } gl_face_index; 828 829 /** 830 * Sampler state saved and restore by glPush/PopAttrib. 831 * 832 * Don't put fields here that glPushAttrib shouldn't save. 833 * E.g. no GLES fields because GLES doesn't have glPushAttrib. 834 */ 835 struct gl_sampler_attrib 836 { 837 GLenum16 WrapS; /**< S-axis texture image wrap mode */ 838 GLenum16 WrapT; /**< T-axis texture image wrap mode */ 839 GLenum16 WrapR; /**< R-axis texture image wrap mode */ 840 GLenum16 MinFilter; /**< minification filter */ 841 GLenum16 MagFilter; /**< magnification filter */ 842 GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ 843 GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ 844 GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ 845 GLfloat LodBias; /**< OpenGL 1.4 */ 846 GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ 847 GLenum16 CompareMode; /**< GL_ARB_shadow */ 848 GLenum16 CompareFunc; /**< GL_ARB_shadow */ 849 GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ 850 GLboolean IsBorderColorNonZero; /**< Does the border color have any effect? */ 851 GLenum16 ReductionMode; /**< GL_EXT_texture_filter_minmax */ 852 853 struct pipe_sampler_state state; /**< Gallium representation */ 854 }; 855 856 /** 857 * Texture state saved and restored by glPush/PopAttrib. 858 * 859 * Don't put fields here that glPushAttrib shouldn't save. 860 * E.g. no GLES fields because GLES doesn't have glPushAttrib. 861 */ 862 struct gl_texture_object_attrib 863 { 864 GLfloat Priority; /**< in [0,1] */ 865 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ 866 GLint MaxLevel; /**< max mipmap level (max=1000), OpenGL 1.2 */ 867 GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ 868 GLushort _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ 869 GLenum16 DepthMode; /**< GL_ARB_depth_texture */ 870 GLenum16 ImageFormatCompatibilityType; /**< GL_ARB_shader_image_load_store */ 871 GLushort MinLayer; /**< GL_ARB_texture_view */ 872 GLushort NumLayers; /**< GL_ARB_texture_view */ 873 GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ 874 GLbyte ImmutableLevels; /**< ES 3.0 / ARB_texture_view */ 875 GLubyte MinLevel; /**< GL_ARB_texture_view */ 876 GLubyte NumLevels; /**< GL_ARB_texture_view */ 877 }; 878 879 /** 880 * Sampler object state. These objects are new with GL_ARB_sampler_objects 881 * and OpenGL 3.3. Legacy texture objects also contain a sampler object. 882 */ 883 struct gl_sampler_object 884 { 885 GLuint Name; 886 GLchar *Label; /**< GL_KHR_debug */ 887 GLint RefCount; 888 889 struct gl_sampler_attrib Attrib; /**< State saved by glPushAttrib */ 890 891 /** GL_ARB_bindless_texture */ 892 bool HandleAllocated; 893 struct util_dynarray Handles; 894 }; 895 896 897 /** 898 * Texture object state. Contains the array of mipmap images, border color, 899 * wrap modes, filter modes, and shadow/texcompare state. 900 */ 901 struct gl_texture_object 902 { 903 GLint RefCount; /**< reference count */ 904 GLuint Name; /**< the user-visible texture object ID */ 905 GLenum16 Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ 906 GLchar *Label; /**< GL_KHR_debug */ 907 908 struct gl_sampler_object Sampler; 909 struct gl_texture_object_attrib Attrib; /**< State saved by glPushAttrib */ 910 911 gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index. 912 Only valid when Target is valid. */ 913 GLbyte _MaxLevel; /**< actual max mipmap level (q in the spec) */ 914 GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - p in spec) */ 915 GLint CropRect[4]; /**< GL_OES_draw_texture */ 916 GLboolean _BaseComplete; /**< Is the base texture level valid? */ 917 GLboolean _MipmapComplete; /**< Is the whole mipmap valid? */ 918 GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */ 919 GLboolean _RenderToTexture; /**< Any rendering to this texture? */ 920 GLboolean Purgeable; /**< Is the buffer purgeable under memory 921 pressure? */ 922 GLboolean Immutable; /**< GL_ARB_texture_storage */ 923 GLboolean _IsFloat; /**< GL_OES_float_texture */ 924 GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */ 925 bool HandleAllocated; /**< GL_ARB_bindless_texture */ 926 927 /* This should not be restored by glPopAttrib: */ 928 bool StencilSampling; /**< Should we sample stencil instead of depth? */ 929 930 /** GL_OES_EGL_image_external */ 931 GLboolean External; 932 GLubyte RequiredTextureImageUnits; 933 934 /** GL_EXT_memory_object */ 935 GLenum16 TextureTiling; 936 937 /** GL_ARB_texture_buffer_object */ 938 GLenum16 BufferObjectFormat; 939 /** Equivalent Mesa format for BufferObjectFormat. */ 940 mesa_format _BufferObjectFormat; 941 /* TODO: BufferObject->Name should be restored by glPopAttrib(GL_TEXTURE_BIT); */ 942 struct gl_buffer_object *BufferObject; 943 944 /** GL_ARB_texture_buffer_range */ 945 GLintptr BufferOffset; 946 GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */ 947 948 /** Actual texture images, indexed by [cube face] and [mipmap level] */ 949 struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; 950 951 /** GL_ARB_bindless_texture */ 952 struct util_dynarray SamplerHandles; 953 struct util_dynarray ImageHandles; 954 955 /** GL_ARB_sparse_texture */ 956 GLboolean IsSparse; 957 GLint VirtualPageSizeIndex; 958 GLint NumSparseLevels; 959 960 /* The texture must include at levels [0..lastLevel] once validated: 961 */ 962 GLuint lastLevel; 963 964 unsigned int validated_first_level; 965 unsigned int validated_last_level; 966 967 /* On validation any active images held in main memory or in other 968 * textures will be copied to this texture and the old storage freed. 969 */ 970 struct pipe_resource *pt; 971 972 /* Protect modifications of the sampler_views array */ 973 simple_mtx_t validate_mutex; 974 975 /* Container of sampler views (one per context) attached to this texture 976 * object. Created lazily on first binding in context. 977 * 978 * Purely read-only accesses to the current context's own sampler view 979 * require no locking. Another thread may simultaneously replace the 980 * container object in order to grow the array, but the old container will 981 * be kept alive. 982 * 983 * Writing to the container (even for modifying the current context's own 984 * sampler view) always requires taking the validate_mutex to protect against 985 * concurrent container switches. 986 * 987 * NULL'ing another context's sampler view is allowed only while 988 * implementing an API call that modifies the texture: an application which 989 * calls those while simultaneously reading the texture in another context 990 * invokes undefined behavior. (TODO: a dubious violation of this rule is 991 * st_finalize_texture, which is a lazy operation that corresponds to a 992 * texture modification.) 993 */ 994 struct st_sampler_views *sampler_views; 995 996 /* Old sampler views container objects that have not been freed yet because 997 * other threads/contexts may still be reading from them. 998 */ 999 struct st_sampler_views *sampler_views_old; 1000 1001 /* True if this texture comes from the window system. Such a texture 1002 * cannot be reallocated and the format can only be changed with a sampler 1003 * view or a surface. 1004 */ 1005 GLboolean surface_based; 1006 1007 /* If surface_based is true, this format should be used for all sampler 1008 * views and surfaces instead of pt->format. 1009 */ 1010 enum pipe_format surface_format; 1011 1012 /* When non-negative, samplers should use this level instead of the level 1013 * range specified by the GL state. 1014 * 1015 * This is used for EGL images, which may correspond to a single level out 1016 * of an imported pipe_resources with multiple mip levels. 1017 */ 1018 int level_override; 1019 1020 /* When non-negative, samplers should use this layer instead of the one 1021 * specified by the GL state. 1022 * 1023 * This is used for EGL images and VDPAU interop, where imported 1024 * pipe_resources may be cube, 3D, or array textures (containing layers 1025 * with different fields in the case of VDPAU) even though the GL state 1026 * describes one non-array texture per field. 1027 */ 1028 int layer_override; 1029 1030 /** 1031 * Set when the texture images of this texture object might not all be in 1032 * the pipe_resource *pt above. 1033 */ 1034 bool needs_validation; 1035 }; 1036 1037 1038 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ 1039 #define MAX_COMBINER_TERMS 4 1040 1041 1042 /** 1043 * Texture combine environment state. 1044 */ 1045 struct gl_tex_env_combine_state 1046 { 1047 GLenum16 ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ 1048 GLenum16 ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ 1049 /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ 1050 GLenum16 SourceRGB[MAX_COMBINER_TERMS]; 1051 GLenum16 SourceA[MAX_COMBINER_TERMS]; 1052 /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ 1053 GLenum16 OperandRGB[MAX_COMBINER_TERMS]; 1054 GLenum16 OperandA[MAX_COMBINER_TERMS]; 1055 GLubyte ScaleShiftRGB; /**< 0, 1 or 2 */ 1056 GLubyte ScaleShiftA; /**< 0, 1 or 2 */ 1057 GLubyte _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ 1058 GLubyte _NumArgsA; /**< Number of inputs used for the A combiner */ 1059 }; 1060 1061 1062 /** Compressed TexEnv effective Combine mode */ 1063 enum gl_tex_env_mode 1064 { 1065 TEXENV_MODE_REPLACE, /* r = a0 */ 1066 TEXENV_MODE_MODULATE, /* r = a0 * a1 */ 1067 TEXENV_MODE_ADD, /* r = a0 + a1 */ 1068 TEXENV_MODE_ADD_SIGNED, /* r = a0 + a1 - 0.5 */ 1069 TEXENV_MODE_INTERPOLATE, /* r = a0 * a2 + a1 * (1 - a2) */ 1070 TEXENV_MODE_SUBTRACT, /* r = a0 - a1 */ 1071 TEXENV_MODE_DOT3_RGB, /* r = a0 . a1 */ 1072 TEXENV_MODE_DOT3_RGB_EXT, /* r = a0 . a1 */ 1073 TEXENV_MODE_DOT3_RGBA, /* r = a0 . a1 */ 1074 TEXENV_MODE_DOT3_RGBA_EXT, /* r = a0 . a1 */ 1075 TEXENV_MODE_MODULATE_ADD_ATI, /* r = a0 * a2 + a1 */ 1076 TEXENV_MODE_MODULATE_SIGNED_ADD_ATI, /* r = a0 * a2 + a1 - 0.5 */ 1077 TEXENV_MODE_MODULATE_SUBTRACT_ATI, /* r = a0 * a2 - a1 */ 1078 TEXENV_MODE_ADD_PRODUCTS_NV, /* r = a0 * a1 + a2 * a3 */ 1079 TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV, /* r = a0 * a1 + a2 * a3 - 0.5 */ 1080 }; 1081 1082 1083 /** Compressed TexEnv Combine source */ 1084 enum gl_tex_env_source 1085 { 1086 TEXENV_SRC_TEXTURE0, 1087 TEXENV_SRC_TEXTURE1, 1088 TEXENV_SRC_TEXTURE2, 1089 TEXENV_SRC_TEXTURE3, 1090 TEXENV_SRC_TEXTURE4, 1091 TEXENV_SRC_TEXTURE5, 1092 TEXENV_SRC_TEXTURE6, 1093 TEXENV_SRC_TEXTURE7, 1094 TEXENV_SRC_TEXTURE, 1095 TEXENV_SRC_PREVIOUS, 1096 TEXENV_SRC_PRIMARY_COLOR, 1097 TEXENV_SRC_CONSTANT, 1098 TEXENV_SRC_ZERO, 1099 TEXENV_SRC_ONE, 1100 }; 1101 1102 1103 /** Compressed TexEnv Combine operand */ 1104 enum gl_tex_env_operand 1105 { 1106 TEXENV_OPR_COLOR, 1107 TEXENV_OPR_ONE_MINUS_COLOR, 1108 TEXENV_OPR_ALPHA, 1109 TEXENV_OPR_ONE_MINUS_ALPHA, 1110 }; 1111 1112 1113 /** Compressed TexEnv Combine argument */ 1114 struct gl_tex_env_argument 1115 { 1116 #ifdef __GNUC__ 1117 __extension__ uint8_t Source:4; /**< TEXENV_SRC_x */ 1118 __extension__ uint8_t Operand:2; /**< TEXENV_OPR_x */ 1119 #else 1120 uint8_t Source; /**< SRC_x */ 1121 uint8_t Operand; /**< OPR_x */ 1122 #endif 1123 }; 1124 1125 1126 /*** 1127 * Compressed TexEnv Combine state. 1128 */ 1129 struct gl_tex_env_combine_packed 1130 { 1131 uint32_t ModeRGB:4; /**< Effective mode for RGB as 4 bits */ 1132 uint32_t ModeA:4; /**< Effective mode for RGB as 4 bits */ 1133 uint32_t ScaleShiftRGB:2; /**< 0, 1 or 2 */ 1134 uint32_t ScaleShiftA:2; /**< 0, 1 or 2 */ 1135 uint32_t NumArgsRGB:3; /**< Number of inputs used for the RGB combiner */ 1136 uint32_t NumArgsA:3; /**< Number of inputs used for the A combiner */ 1137 /** Source arguments in a packed manner */ 1138 struct gl_tex_env_argument ArgsRGB[MAX_COMBINER_TERMS]; 1139 struct gl_tex_env_argument ArgsA[MAX_COMBINER_TERMS]; 1140 }; 1141 1142 1143 /** 1144 * TexGenEnabled flags. 1145 */ 1146 /*@{*/ 1147 #define S_BIT 1 1148 #define T_BIT 2 1149 #define R_BIT 4 1150 #define Q_BIT 8 1151 #define STR_BITS (S_BIT | T_BIT | R_BIT) 1152 /*@}*/ 1153 1154 1155 /** 1156 * Bit flag versions of the corresponding GL_ constants. 1157 */ 1158 /*@{*/ 1159 #define TEXGEN_SPHERE_MAP 0x1 1160 #define TEXGEN_OBJ_LINEAR 0x2 1161 #define TEXGEN_EYE_LINEAR 0x4 1162 #define TEXGEN_REFLECTION_MAP_NV 0x8 1163 #define TEXGEN_NORMAL_MAP_NV 0x10 1164 1165 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ 1166 TEXGEN_REFLECTION_MAP_NV | \ 1167 TEXGEN_NORMAL_MAP_NV) 1168 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ 1169 TEXGEN_REFLECTION_MAP_NV | \ 1170 TEXGEN_NORMAL_MAP_NV | \ 1171 TEXGEN_EYE_LINEAR) 1172 /*@}*/ 1173 1174 1175 1176 /** Tex-gen enabled for texture unit? */ 1177 #define ENABLE_TEXGEN(unit) (1 << (unit)) 1178 1179 /** Non-identity texture matrix for texture unit? */ 1180 #define ENABLE_TEXMAT(unit) (1 << (unit)) 1181 1182 1183 /** 1184 * Texture coord generation state. 1185 */ 1186 struct gl_texgen 1187 { 1188 GLenum16 Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ 1189 GLbitfield8 _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ 1190 }; 1191 1192 1193 /** 1194 * Sampler-related subset of a texture unit, like current texture objects. 1195 */ 1196 struct gl_texture_unit 1197 { 1198 GLfloat LodBias; /**< for biasing mipmap levels */ 1199 float LodBiasQuantized; /**< to reduce pipe_sampler_state variants */ 1200 1201 /** Texture targets that have a non-default texture bound */ 1202 GLbitfield _BoundTextures; 1203 1204 /** Current sampler object (GL_ARB_sampler_objects) */ 1205 struct gl_sampler_object *Sampler; 1206 1207 /** Current texture object pointers */ 1208 struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; 1209 1210 /** Points to highest priority, complete and enabled texture object */ 1211 struct gl_texture_object *_Current; 1212 }; 1213 1214 enum { 1215 GEN_S, 1216 GEN_T, 1217 GEN_R, 1218 GEN_Q, 1219 NUM_GEN, 1220 }; 1221 1222 /** 1223 * Fixed-function-related subset of a texture unit, like enable flags, 1224 * texture environment/function/combiners, and texgen state. 1225 */ 1226 struct gl_fixedfunc_texture_unit 1227 { 1228 GLbitfield16 Enabled; /**< bitmask of TEXTURE_*_BIT flags */ 1229 1230 GLenum16 EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ 1231 GLclampf EnvColor[4]; 1232 GLfloat EnvColorUnclamped[4]; 1233 1234 struct gl_texgen GenS; 1235 struct gl_texgen GenT; 1236 struct gl_texgen GenR; 1237 struct gl_texgen GenQ; 1238 1239 GLfloat EyePlane[NUM_GEN][4]; 1240 GLfloat ObjectPlane[NUM_GEN][4]; 1241 1242 GLbitfield8 TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ 1243 GLbitfield8 _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ 1244 1245 /** 1246 * \name GL_EXT_texture_env_combine 1247 */ 1248 struct gl_tex_env_combine_state Combine; 1249 1250 /** 1251 * Derived state based on \c EnvMode and the \c BaseFormat of the 1252 * currently enabled texture. 1253 */ 1254 struct gl_tex_env_combine_state _EnvMode; 1255 1256 /** Current compressed TexEnv & Combine state */ 1257 struct gl_tex_env_combine_packed _CurrentCombinePacked; 1258 1259 /** 1260 * Currently enabled combiner state. This will point to either 1261 * \c Combine or \c _EnvMode. 1262 */ 1263 struct gl_tex_env_combine_state *_CurrentCombine; 1264 }; 1265 1266 1267 /** 1268 * Texture attribute group (GL_TEXTURE_BIT). 1269 */ 1270 struct gl_texture_attrib 1271 { 1272 struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; 1273 1274 /** GL_ARB_texture_buffer_object */ 1275 struct gl_buffer_object *BufferObject; 1276 1277 GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ 1278 1279 /** Texture coord units/sets used for fragment texturing */ 1280 GLbitfield8 _EnabledCoordUnits; 1281 1282 /** Texture coord units that have texgen enabled */ 1283 GLbitfield8 _TexGenEnabled; 1284 1285 /** Texture coord units that have non-identity matrices */ 1286 GLbitfield8 _TexMatEnabled; 1287 1288 /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ 1289 GLbitfield8 _GenFlags; 1290 1291 /** Largest index of a texture unit with _Current != NULL. */ 1292 GLshort _MaxEnabledTexImageUnit; 1293 1294 /** Largest index + 1 of texture units that have had any CurrentTex set. */ 1295 GLubyte NumCurrentTexUsed; 1296 1297 /** GL_ARB_seamless_cubemap */ 1298 GLboolean CubeMapSeamless; 1299 1300 struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; 1301 struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS]; 1302 }; 1303 1304 1305 /** 1306 * Data structure representing a single clip plane (e.g. one of the elements 1307 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array). 1308 */ 1309 typedef GLfloat gl_clip_plane[4]; 1310 1311 1312 /** 1313 * Transformation attribute group (GL_TRANSFORM_BIT). 1314 */ 1315 struct gl_transform_attrib 1316 { 1317 GLenum16 MatrixMode; /**< Matrix mode */ 1318 gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */ 1319 gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */ 1320 GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ 1321 GLboolean Normalize; /**< Normalize all normals? */ 1322 GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ 1323 GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ 1324 GLboolean DepthClampNear; /**< GL_AMD_depth_clamp_separate */ 1325 GLboolean DepthClampFar; /**< GL_AMD_depth_clamp_separate */ 1326 /** GL_ARB_clip_control */ 1327 GLenum16 ClipOrigin; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */ 1328 GLenum16 ClipDepthMode;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */ 1329 }; 1330 1331 1332 /** 1333 * Viewport attribute group (GL_VIEWPORT_BIT). 1334 */ 1335 struct gl_viewport_attrib 1336 { 1337 GLfloat X, Y; /**< position */ 1338 GLfloat Width, Height; /**< size */ 1339 GLfloat Near, Far; /**< Depth buffer range */ 1340 1341 /**< GL_NV_viewport_swizzle */ 1342 GLenum16 SwizzleX, SwizzleY, SwizzleZ, SwizzleW; 1343 }; 1344 1345 1346 /** 1347 * Fields describing a mapped buffer range. 1348 */ 1349 struct gl_buffer_mapping 1350 { 1351 GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ 1352 GLvoid *Pointer; /**< User-space address of mapping */ 1353 GLintptr Offset; /**< Mapped offset */ 1354 GLsizeiptr Length; /**< Mapped length */ 1355 }; 1356 1357 1358 /** 1359 * Usages we've seen for a buffer object. 1360 */ 1361 typedef enum 1362 { 1363 USAGE_UNIFORM_BUFFER = 0x1, 1364 USAGE_TEXTURE_BUFFER = 0x2, 1365 USAGE_ATOMIC_COUNTER_BUFFER = 0x4, 1366 USAGE_SHADER_STORAGE_BUFFER = 0x8, 1367 USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10, 1368 USAGE_PIXEL_PACK_BUFFER = 0x20, 1369 USAGE_ARRAY_BUFFER = 0x40, 1370 USAGE_DISABLE_MINMAX_CACHE = 0x100, 1371 } gl_buffer_usage; 1372 1373 1374 /** 1375 * GL_ARB_vertex/pixel_buffer_object buffer object 1376 */ 1377 struct gl_buffer_object 1378 { 1379 GLint RefCount; 1380 GLuint Name; 1381 GLchar *Label; /**< GL_KHR_debug */ 1382 1383 /** 1384 * The context that holds a global buffer reference for the lifetime of 1385 * the GL buffer ID to skip refcounting for all its private bind points. 1386 * Other contexts must still do refcounting as usual. Shared binding points 1387 * like TBO within gl_texture_object are always refcounted. 1388 * 1389 * Implementation details: 1390 * - Only the context that creates the buffer ("creating context") skips 1391 * refcounting. 1392 * - Only buffers represented by an OpenGL buffer ID skip refcounting. 1393 * Other internal buffers don't. (glthread requires refcounting for 1394 * internal buffers, etc.) 1395 * - glDeleteBuffers removes the global buffer reference and increments 1396 * RefCount for all private bind points where the deleted buffer is bound 1397 * (e.g. unbound VAOs that are not changed by glDeleteBuffers), 1398 * effectively enabling refcounting for that context. This is the main 1399 * point where the global buffer reference is removed. 1400 * - glDeleteBuffers called from a different context adds the buffer into 1401 * the ZombieBufferObjects list, which is a way to notify the creating 1402 * context that it should remove its global buffer reference to allow 1403 * freeing the buffer. The creating context walks over that list in a few 1404 * GL functions. 1405 * - xxxDestroyContext walks over all buffers and removes its global 1406 * reference from those buffers that it created. 1407 */ 1408 struct gl_context *Ctx; 1409 GLint CtxRefCount; /**< Non-atomic references held by Ctx. */ 1410 1411 GLenum16 Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ 1412 GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */ 1413 GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ 1414 GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ 1415 GLboolean DeletePending; /**< true if buffer object is removed from the hash */ 1416 GLboolean Written; /**< Ever written to? (for debugging) */ 1417 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ 1418 GLboolean Immutable; /**< GL_ARB_buffer_storage */ 1419 gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */ 1420 1421 /** Counters used for buffer usage warnings */ 1422 GLuint NumSubDataCalls; 1423 GLuint NumMapBufferWriteCalls; 1424 1425 struct gl_buffer_mapping Mappings[MAP_COUNT]; 1426 1427 /** Memoization of min/max index computations for static index buffers */ 1428 simple_mtx_t MinMaxCacheMutex; 1429 struct hash_table *MinMaxCache; 1430 unsigned MinMaxCacheHitIndices; 1431 unsigned MinMaxCacheMissIndices; 1432 bool MinMaxCacheDirty; 1433 1434 bool HandleAllocated; /**< GL_ARB_bindless_texture */ 1435 1436 struct pipe_resource *buffer; 1437 struct gl_context *private_refcount_ctx; 1438 /* This mechanism allows passing buffer references to the driver without 1439 * using atomics to increase the reference count. 1440 * 1441 * This private refcount can be decremented without atomics but only one 1442 * context (ctx above) can use this counter to be thread-safe. 1443 * 1444 * This number is atomically added to buffer->reference.count at 1445 * initialization. If it's never used, the same number is atomically 1446 * subtracted from buffer->reference.count before destruction. If this 1447 * number is decremented, we can pass that reference to the driver without 1448 * touching reference.count. At buffer destruction we only subtract 1449 * the number of references we did not return. This can possibly turn 1450 * a million atomic increments into 1 add and 1 subtract atomic op. 1451 */ 1452 int private_refcount; 1453 1454 struct pipe_transfer *transfer[MAP_COUNT]; 1455 }; 1456 1457 1458 /** 1459 * Client pixel packing/unpacking attributes 1460 */ 1461 struct gl_pixelstore_attrib 1462 { 1463 GLint Alignment; 1464 GLint RowLength; 1465 GLint SkipPixels; 1466 GLint SkipRows; 1467 GLint ImageHeight; 1468 GLint SkipImages; 1469 GLboolean SwapBytes; 1470 GLboolean LsbFirst; 1471 GLboolean Invert; /**< GL_MESA_pack_invert */ 1472 GLint CompressedBlockWidth; /**< GL_ARB_compressed_texture_pixel_storage */ 1473 GLint CompressedBlockHeight; 1474 GLint CompressedBlockDepth; 1475 GLint CompressedBlockSize; 1476 struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ 1477 }; 1478 1479 1480 /** 1481 * Enum for defining the mapping for the position/generic0 attribute. 1482 * 1483 * Do not change the order of the values as these are used as 1484 * array indices. 1485 */ 1486 typedef enum 1487 { 1488 ATTRIBUTE_MAP_MODE_IDENTITY, /**< 1:1 mapping */ 1489 ATTRIBUTE_MAP_MODE_POSITION, /**< get position and generic0 from position */ 1490 ATTRIBUTE_MAP_MODE_GENERIC0, /**< get position and generic0 from generic0 */ 1491 ATTRIBUTE_MAP_MODE_MAX /**< for sizing arrays */ 1492 } gl_attribute_map_mode; 1493 1494 1495 /** 1496 * Attributes to describe a vertex array. 1497 * 1498 * Contains the size, type, format and normalization flag, 1499 * along with the index of a vertex buffer binding point. 1500 * 1501 * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE 1502 * and is only present for backwards compatibility reasons. 1503 * Rendering always uses VERTEX_BINDING_STRIDE. 1504 * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE 1505 * and VERTEX_BINDING_STRIDE to the same value, while 1506 * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE. 1507 */ 1508 struct gl_array_attributes 1509 { 1510 /** Points to client array data. Not used when a VBO is bound */ 1511 const GLubyte *Ptr; 1512 /** Offset of the first element relative to the binding offset */ 1513 GLuint RelativeOffset; 1514 /** Vertex format */ 1515 struct gl_vertex_format Format; 1516 /** Stride as specified with gl*Pointer() */ 1517 GLshort Stride; 1518 /** Index into gl_vertex_array_object::BufferBinding[] array */ 1519 GLubyte BufferBindingIndex; 1520 1521 /** 1522 * Derived effective buffer binding index 1523 * 1524 * Index into the gl_vertex_buffer_binding array of the vao. 1525 * Similar to BufferBindingIndex, but with the mapping of the 1526 * position/generic0 attributes applied and with identical 1527 * gl_vertex_buffer_binding entries collapsed to a single 1528 * entry within the vao. 1529 * 1530 * The value is valid past calling _mesa_update_vao_derived_arrays. 1531 * Note that _mesa_update_vao_derived_arrays is called when binding 1532 * the VAO to Array._DrawVAO. 1533 */ 1534 GLubyte _EffBufferBindingIndex; 1535 /** 1536 * Derived effective relative offset. 1537 * 1538 * Relative offset to the effective buffers offset in 1539 * gl_vertex_buffer_binding::_EffOffset. 1540 * 1541 * The value is valid past calling _mesa_update_vao_derived_arrays. 1542 * Note that _mesa_update_vao_derived_arrays is called when binding 1543 * the VAO to Array._DrawVAO. 1544 */ 1545 GLushort _EffRelativeOffset; 1546 }; 1547 1548 1549 /** 1550 * This describes the buffer object used for a vertex array (or 1551 * multiple vertex arrays). If BufferObj points to the default/null 1552 * buffer object, then the vertex array lives in user memory and not a VBO. 1553 */ 1554 struct gl_vertex_buffer_binding 1555 { 1556 GLintptr Offset; /**< User-specified offset */ 1557 GLsizei Stride; /**< User-specified stride */ 1558 GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ 1559 struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */ 1560 GLbitfield _BoundArrays; /**< Arrays bound to this binding point */ 1561 1562 /** 1563 * Derived effective bound arrays. 1564 * 1565 * The effective binding handles enabled arrays past the 1566 * position/generic0 attribute mapping and reduces the refered 1567 * gl_vertex_buffer_binding entries to a unique subset. 1568 * 1569 * The value is valid past calling _mesa_update_vao_derived_arrays. 1570 * Note that _mesa_update_vao_derived_arrays is called when binding 1571 * the VAO to Array._DrawVAO. 1572 */ 1573 GLbitfield _EffBoundArrays; 1574 /** 1575 * Derived offset. 1576 * 1577 * The absolute offset to that we can collapse some attributes 1578 * to this unique effective binding. 1579 * For user space array bindings this contains the smallest pointer value 1580 * in the bound and interleaved arrays. 1581 * For VBO bindings this contains an offset that lets the attributes 1582 * _EffRelativeOffset stay positive and in bounds with 1583 * Const.MaxVertexAttribRelativeOffset 1584 * 1585 * The value is valid past calling _mesa_update_vao_derived_arrays. 1586 * Note that _mesa_update_vao_derived_arrays is called when binding 1587 * the VAO to Array._DrawVAO. 1588 */ 1589 GLintptr _EffOffset; 1590 }; 1591 1592 1593 /** 1594 * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ / 1595 * the GL_ARB_vertex_array_object extension. 1596 */ 1597 struct gl_vertex_array_object 1598 { 1599 /** Name of the VAO as received from glGenVertexArray. */ 1600 GLuint Name; 1601 1602 GLint RefCount; 1603 1604 GLchar *Label; /**< GL_KHR_debug */ 1605 1606 /** 1607 * Has this array object been bound? 1608 */ 1609 GLboolean EverBound; 1610 1611 /** 1612 * Whether the VAO is changed by the application so often that some of 1613 * the derived fields are not updated at all to decrease overhead. 1614 * Also, interleaved arrays are not detected, because it's too expensive 1615 * to do that before every draw call. 1616 */ 1617 bool IsDynamic; 1618 1619 /** 1620 * Marked to true if the object is shared between contexts and immutable. 1621 * Then reference counting is done using atomics and thread safe. 1622 * Is used for dlist VAOs. 1623 */ 1624 bool SharedAndImmutable; 1625 1626 /** 1627 * Number of updates that were done by the application. This is used to 1628 * decide whether the VAO is static or dynamic. 1629 */ 1630 unsigned NumUpdates; 1631 1632 /** Vertex attribute arrays */ 1633 struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX]; 1634 1635 /** Vertex buffer bindings */ 1636 struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX]; 1637 1638 /** Mask indicating which vertex arrays have vertex buffer associated. */ 1639 GLbitfield VertexAttribBufferMask; 1640 1641 /** Mask indicating which vertex arrays have a non-zero instance divisor. */ 1642 GLbitfield NonZeroDivisorMask; 1643 1644 /** Mask of VERT_BIT_* values indicating which arrays are enabled */ 1645 GLbitfield Enabled; 1646 1647 /** 1648 * Mask indicating which VertexAttrib and BufferBinding structures have 1649 * been changed since the VAO creation. No bit is ever cleared to 0 by 1650 * state updates. Setting to the default state doesn't update this. 1651 * (e.g. unbinding) Setting the derived state (_* fields) doesn't update 1652 * this either. 1653 */ 1654 GLbitfield NonDefaultStateMask; 1655 1656 /** 1657 * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping 1658 * 1659 * The value is valid past calling _mesa_update_vao_derived_arrays. 1660 * Note that _mesa_update_vao_derived_arrays is called when binding 1661 * the VAO to Array._DrawVAO. 1662 */ 1663 GLbitfield _EffEnabledVBO; 1664 1665 /** Same as _EffEnabledVBO, but for instance divisors. */ 1666 GLbitfield _EffEnabledNonZeroDivisor; 1667 1668 /** Denotes the way the position/generic0 attribute is mapped */ 1669 gl_attribute_map_mode _AttributeMapMode; 1670 1671 /** "Enabled" with the position/generic0 attribute aliasing resolved */ 1672 GLbitfield _EnabledWithMapMode; 1673 1674 /** Which states have been changed according to the gallium definitions. */ 1675 bool NewVertexBuffers; 1676 bool NewVertexElements; 1677 1678 /** The index buffer (also known as the element array buffer in OpenGL). */ 1679 struct gl_buffer_object *IndexBufferObj; 1680 }; 1681 1682 1683 /** 1684 * Vertex array state 1685 */ 1686 struct gl_array_attrib 1687 { 1688 /** Currently bound array object. */ 1689 struct gl_vertex_array_object *VAO; 1690 1691 /** The default vertex array object */ 1692 struct gl_vertex_array_object *DefaultVAO; 1693 1694 /** The last VAO accessed by a DSA function */ 1695 struct gl_vertex_array_object *LastLookedUpVAO; 1696 1697 /** These contents are copied to newly created VAOs. */ 1698 struct gl_vertex_array_object DefaultVAOState; 1699 1700 /** Array objects (GL_ARB_vertex_array_object) */ 1701 struct _mesa_HashTable *Objects; 1702 1703 GLint ActiveTexture; /**< Client Active Texture */ 1704 GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ 1705 GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ 1706 1707 /** 1708 * \name Primitive restart controls 1709 * 1710 * Primitive restart is enabled if either \c PrimitiveRestart or 1711 * \c PrimitiveRestartFixedIndex is set. 1712 */ 1713 /*@{*/ 1714 GLboolean PrimitiveRestart; 1715 GLboolean PrimitiveRestartFixedIndex; 1716 GLboolean _PrimitiveRestart[3]; /**< Enable indexed by index_size_shift. */ 1717 GLuint RestartIndex; 1718 GLuint _RestartIndex[3]; /**< Restart indices indexed by index_size_shift. */ 1719 /*@}*/ 1720 1721 /* GL_ARB_vertex_buffer_object */ 1722 struct gl_buffer_object *ArrayBufferObj; 1723 1724 /** 1725 * Vertex array object that is used with the currently active draw command. 1726 * The _DrawVAO is either set to the currently bound VAO for array type 1727 * draws or to internal VAO's set up by the vbo module to execute immediate 1728 * mode or display list draws. 1729 */ 1730 struct gl_vertex_array_object *_DrawVAO; 1731 /** 1732 * The VERT_BIT_* bits effectively enabled from the current _DrawVAO. 1733 * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO) 1734 * but may omit those arrays that shall not be referenced by the current 1735 * gl_vertex_program_state::_VPMode. For example the generic attributes are 1736 * maked out form the _DrawVAO's enabled arrays when a fixed function 1737 * array draw is executed. 1738 */ 1739 GLbitfield _DrawVAOEnabledAttribs; 1740 1741 /** 1742 * If gallium vertex buffers are dirty, this flag indicates whether gallium 1743 * vertex elements are dirty too. If this is false, GL states corresponding 1744 * to vertex elements have not been changed. Thus, this affects what will 1745 * happen when ST_NEW_VERTEX_ARRAYS is set. 1746 * 1747 * The driver should clear this when it's done. 1748 */ 1749 bool NewVertexElements; 1750 1751 /** 1752 * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO 1753 * pointer is set to the _EmptyVAO which is just an empty VAO all the time. 1754 */ 1755 struct gl_vertex_array_object *_EmptyVAO; 1756 1757 /** Legal array datatypes and the API for which they have been computed */ 1758 GLbitfield LegalTypesMask; 1759 gl_api LegalTypesMaskAPI; 1760 }; 1761 1762 1763 /** 1764 * Feedback buffer state 1765 */ 1766 struct gl_feedback 1767 { 1768 GLenum16 Type; 1769 GLbitfield _Mask; /**< FB_* bits */ 1770 GLfloat *Buffer; 1771 GLuint BufferSize; 1772 GLuint Count; 1773 }; 1774 1775 1776 /** 1777 * Selection buffer state 1778 */ 1779 struct gl_selection 1780 { 1781 GLuint *Buffer; /**< selection buffer */ 1782 GLuint BufferSize; /**< size of the selection buffer */ 1783 GLuint BufferCount; /**< number of values in the selection buffer */ 1784 GLuint Hits; /**< number of records in the selection buffer */ 1785 GLuint NameStackDepth; /**< name stack depth */ 1786 GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ 1787 GLboolean HitFlag; /**< hit flag */ 1788 GLfloat HitMinZ; /**< minimum hit depth */ 1789 GLfloat HitMaxZ; /**< maximum hit depth */ 1790 }; 1791 1792 1793 /** 1794 * 1-D Evaluator control points 1795 */ 1796 struct gl_1d_map 1797 { 1798 GLuint Order; /**< Number of control points */ 1799 GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ 1800 GLfloat *Points; /**< Points to contiguous control points */ 1801 }; 1802 1803 1804 /** 1805 * 2-D Evaluator control points 1806 */ 1807 struct gl_2d_map 1808 { 1809 GLuint Uorder; /**< Number of control points in U dimension */ 1810 GLuint Vorder; /**< Number of control points in V dimension */ 1811 GLfloat u1, u2, du; 1812 GLfloat v1, v2, dv; 1813 GLfloat *Points; /**< Points to contiguous control points */ 1814 }; 1815 1816 1817 /** 1818 * All evaluator control point state 1819 */ 1820 struct gl_evaluators 1821 { 1822 /** 1823 * \name 1-D maps 1824 */ 1825 /*@{*/ 1826 struct gl_1d_map Map1Vertex3; 1827 struct gl_1d_map Map1Vertex4; 1828 struct gl_1d_map Map1Index; 1829 struct gl_1d_map Map1Color4; 1830 struct gl_1d_map Map1Normal; 1831 struct gl_1d_map Map1Texture1; 1832 struct gl_1d_map Map1Texture2; 1833 struct gl_1d_map Map1Texture3; 1834 struct gl_1d_map Map1Texture4; 1835 /*@}*/ 1836 1837 /** 1838 * \name 2-D maps 1839 */ 1840 /*@{*/ 1841 struct gl_2d_map Map2Vertex3; 1842 struct gl_2d_map Map2Vertex4; 1843 struct gl_2d_map Map2Index; 1844 struct gl_2d_map Map2Color4; 1845 struct gl_2d_map Map2Normal; 1846 struct gl_2d_map Map2Texture1; 1847 struct gl_2d_map Map2Texture2; 1848 struct gl_2d_map Map2Texture3; 1849 struct gl_2d_map Map2Texture4; 1850 /*@}*/ 1851 }; 1852 1853 1854 /** 1855 * Transform feedback object state 1856 */ 1857 struct gl_transform_feedback_object 1858 { 1859 GLuint Name; /**< AKA the object ID */ 1860 GLint RefCount; 1861 GLchar *Label; /**< GL_KHR_debug */ 1862 GLboolean Active; /**< Is transform feedback enabled? */ 1863 GLboolean Paused; /**< Is transform feedback paused? */ 1864 GLboolean EndedAnytime; /**< Has EndTransformFeedback been called 1865 at least once? */ 1866 GLboolean EverBound; /**< Has this object been bound? */ 1867 1868 /** 1869 * GLES: if Active is true, remaining number of primitives which can be 1870 * rendered without overflow. This is necessary to track because GLES 1871 * requires us to generate INVALID_OPERATION if a call to glDrawArrays or 1872 * glDrawArraysInstanced would overflow transform feedback buffers. 1873 * Undefined if Active is false. 1874 * 1875 * Not tracked for desktop GL since it's unnecessary. 1876 */ 1877 unsigned GlesRemainingPrims; 1878 1879 /** 1880 * The program active when BeginTransformFeedback() was called. 1881 * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage], 1882 * where stage is the pipeline stage that is the source of data for 1883 * transform feedback. 1884 */ 1885 struct gl_program *program; 1886 1887 /** The feedback buffers */ 1888 GLuint BufferNames[MAX_FEEDBACK_BUFFERS]; 1889 struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS]; 1890 1891 /** Start of feedback data in dest buffer */ 1892 GLintptr Offset[MAX_FEEDBACK_BUFFERS]; 1893 1894 /** 1895 * Max data to put into dest buffer (in bytes). Computed based on 1896 * RequestedSize and the actual size of the buffer. 1897 */ 1898 GLsizeiptr Size[MAX_FEEDBACK_BUFFERS]; 1899 1900 /** 1901 * Size that was specified when the buffer was bound. If the buffer was 1902 * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is 1903 * zero. 1904 */ 1905 GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS]; 1906 1907 unsigned num_targets; 1908 struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS]; 1909 1910 /* This encapsulates the count that can be used as a source for draw_vbo. 1911 * It contains stream output targets from the last call of 1912 * EndTransformFeedback for each stream. */ 1913 struct pipe_stream_output_target *draw_count[MAX_VERTEX_STREAMS]; 1914 }; 1915 1916 1917 /** 1918 * Context state for transform feedback. 1919 */ 1920 struct gl_transform_feedback_state 1921 { 1922 GLenum16 Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ 1923 1924 /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ 1925 struct gl_buffer_object *CurrentBuffer; 1926 1927 /** The table of all transform feedback objects */ 1928 struct _mesa_HashTable *Objects; 1929 1930 /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ 1931 struct gl_transform_feedback_object *CurrentObject; 1932 1933 /** The default xform-fb object (Name==0) */ 1934 struct gl_transform_feedback_object *DefaultObject; 1935 }; 1936 1937 1938 /** 1939 * A "performance monitor" as described in AMD_performance_monitor. 1940 */ 1941 struct gl_perf_monitor_object 1942 { 1943 GLuint Name; 1944 1945 /** True if the monitor is currently active (Begin called but not End). */ 1946 GLboolean Active; 1947 1948 /** 1949 * True if the monitor has ended. 1950 * 1951 * This is distinct from !Active because it may never have began. 1952 */ 1953 GLboolean Ended; 1954 1955 /** 1956 * A list of groups with currently active counters. 1957 * 1958 * ActiveGroups[g] == n if there are n counters active from group 'g'. 1959 */ 1960 unsigned *ActiveGroups; 1961 1962 /** 1963 * An array of bitsets, subscripted by group ID, then indexed by counter ID. 1964 * 1965 * Checking whether counter 'c' in group 'g' is active can be done via: 1966 * 1967 * BITSET_TEST(ActiveCounters[g], c) 1968 */ 1969 GLuint **ActiveCounters; 1970 1971 unsigned num_active_counters; 1972 1973 struct gl_perf_counter_object { 1974 struct pipe_query *query; 1975 int id; 1976 int group_id; 1977 unsigned batch_index; 1978 } *active_counters; 1979 1980 struct pipe_query *batch_query; 1981 union pipe_query_result *batch_result; 1982 }; 1983 1984 1985 union gl_perf_monitor_counter_value 1986 { 1987 float f; 1988 uint64_t u64; 1989 uint32_t u32; 1990 }; 1991 1992 1993 struct gl_perf_monitor_counter 1994 { 1995 /** Human readable name for the counter. */ 1996 const char *Name; 1997 1998 /** 1999 * Data type of the counter. Valid values are FLOAT, UNSIGNED_INT, 2000 * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD. 2001 */ 2002 GLenum16 Type; 2003 2004 /** Minimum counter value. */ 2005 union gl_perf_monitor_counter_value Minimum; 2006 2007 /** Maximum counter value. */ 2008 union gl_perf_monitor_counter_value Maximum; 2009 2010 unsigned query_type; 2011 unsigned flags; 2012 }; 2013 2014 2015 struct gl_perf_monitor_group 2016 { 2017 /** Human readable name for the group. */ 2018 const char *Name; 2019 2020 /** 2021 * Maximum number of counters in this group which can be active at the 2022 * same time. 2023 */ 2024 GLuint MaxActiveCounters; 2025 2026 /** Array of counters within this group. */ 2027 const struct gl_perf_monitor_counter *Counters; 2028 GLuint NumCounters; 2029 2030 bool has_batch; 2031 }; 2032 2033 /** 2034 * A query object instance as described in INTEL_performance_query. 2035 * 2036 * NB: We want to keep this and the corresponding backend structure 2037 * relatively lean considering that applications may expect to 2038 * allocate enough objects to be able to query around all draw calls 2039 * in a frame. 2040 */ 2041 struct gl_perf_query_object 2042 { 2043 GLuint Id; /**< hash table ID/name */ 2044 unsigned Used:1; /**< has been used for 1 or more queries */ 2045 unsigned Active:1; /**< inside Begin/EndPerfQuery */ 2046 unsigned Ready:1; /**< result is ready? */ 2047 }; 2048 2049 2050 /** 2051 * Context state for AMD_performance_monitor. 2052 */ 2053 struct gl_perf_monitor_state 2054 { 2055 /** Array of performance monitor groups (indexed by group ID) */ 2056 const struct gl_perf_monitor_group *Groups; 2057 GLuint NumGroups; 2058 2059 /** The table of all performance monitors. */ 2060 struct _mesa_HashTable *Monitors; 2061 }; 2062 2063 2064 /** 2065 * Context state for INTEL_performance_query. 2066 */ 2067 struct gl_perf_query_state 2068 { 2069 struct _mesa_HashTable *Objects; /**< The table of all performance query objects */ 2070 }; 2071 2072 2073 /** 2074 * State common to vertex and fragment programs. 2075 */ 2076 struct gl_program_state 2077 { 2078 GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ 2079 const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ 2080 }; 2081 2082 2083 /** 2084 * Context state for vertex programs. 2085 */ 2086 struct gl_vertex_program_state 2087 { 2088 GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ 2089 GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ 2090 GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ 2091 /** Whether the fixed-func program is being used right now. */ 2092 GLboolean _UsesTnlProgram; 2093 2094 struct gl_program *Current; /**< User-bound vertex program */ 2095 2096 /** Currently enabled and valid vertex program (including internal 2097 * programs, user-defined vertex programs and GLSL vertex shaders). 2098 * This is the program we must use when rendering. 2099 */ 2100 struct gl_program *_Current; 2101 2102 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ 2103 2104 /** Program to emulate fixed-function T&L (see above) */ 2105 struct gl_program *_TnlProgram; 2106 2107 /** Cache of fixed-function programs */ 2108 struct gl_program_cache *Cache; 2109 2110 GLboolean _Overriden; 2111 2112 bool _VPModeOptimizesConstantAttribs; 2113 2114 /** 2115 * If we have a vertex program, a TNL program or no program at all. 2116 * Note that this value should be kept up to date all the time, 2117 * nevertheless its correctness is asserted in _mesa_update_state. 2118 * The reason is to avoid calling _mesa_update_state twice we need 2119 * this value on draw *before* actually calling _mesa_update_state. 2120 * Also it should need to get recomputed only on changes to the 2121 * vertex program which are heavyweight already. 2122 */ 2123 gl_vertex_processing_mode _VPMode; 2124 2125 GLbitfield _VaryingInputs; /**< mask of VERT_BIT_* flags */ 2126 GLbitfield _VPModeInputFilter; 2127 }; 2128 2129 /** 2130 * Context state for tessellation control programs. 2131 */ 2132 struct gl_tess_ctrl_program_state 2133 { 2134 /** Currently bound and valid shader. */ 2135 struct gl_program *_Current; 2136 2137 GLint patch_vertices; 2138 GLfloat patch_default_outer_level[4]; 2139 GLfloat patch_default_inner_level[2]; 2140 }; 2141 2142 /** 2143 * Context state for tessellation evaluation programs. 2144 */ 2145 struct gl_tess_eval_program_state 2146 { 2147 /** Currently bound and valid shader. */ 2148 struct gl_program *_Current; 2149 }; 2150 2151 /** 2152 * Context state for geometry programs. 2153 */ 2154 struct gl_geometry_program_state 2155 { 2156 /** 2157 * Currently enabled and valid program (including internal programs 2158 * and compiled shader programs). 2159 */ 2160 struct gl_program *_Current; 2161 }; 2162 2163 /** 2164 * Context state for fragment programs. 2165 */ 2166 struct gl_fragment_program_state 2167 { 2168 GLboolean Enabled; /**< User-set fragment program enable flag */ 2169 /** Whether the fixed-func program is being used right now. */ 2170 GLboolean _UsesTexEnvProgram; 2171 2172 struct gl_program *Current; /**< User-bound fragment program */ 2173 2174 /** 2175 * Currently enabled and valid fragment program (including internal 2176 * programs, user-defined fragment programs and GLSL fragment shaders). 2177 * This is the program we must use when rendering. 2178 */ 2179 struct gl_program *_Current; 2180 2181 GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ 2182 2183 /** Program to emulate fixed-function texture env/combine (see above) */ 2184 struct gl_program *_TexEnvProgram; 2185 2186 /** Cache of fixed-function programs */ 2187 struct gl_program_cache *Cache; 2188 }; 2189 2190 2191 /** 2192 * Context state for compute programs. 2193 */ 2194 struct gl_compute_program_state 2195 { 2196 /** Currently enabled and valid program (including internal programs 2197 * and compiled shader programs). 2198 */ 2199 struct gl_program *_Current; 2200 }; 2201 2202 2203 /** 2204 * ATI_fragment_shader runtime state 2205 */ 2206 2207 struct atifs_instruction; 2208 struct atifs_setupinst; 2209 2210 /** 2211 * ATI fragment shader 2212 */ 2213 struct ati_fragment_shader 2214 { 2215 GLuint Id; 2216 GLint RefCount; 2217 struct atifs_instruction *Instructions[2]; 2218 struct atifs_setupinst *SetupInst[2]; 2219 GLfloat Constants[8][4]; 2220 GLbitfield LocalConstDef; /**< Indicates which constants have been set */ 2221 GLubyte numArithInstr[2]; 2222 GLubyte regsAssigned[2]; 2223 GLubyte NumPasses; /**< 1 or 2 */ 2224 /** 2225 * Current compile stage: 0 setup pass1, 1 arith pass1, 2226 * 2 setup pass2, 3 arith pass2. 2227 */ 2228 GLubyte cur_pass; 2229 GLubyte last_optype; 2230 GLboolean interpinp1; 2231 GLboolean isValid; 2232 /** 2233 * Array of 2 bit values for each tex unit to remember whether 2234 * STR or STQ swizzle was used 2235 */ 2236 GLuint swizzlerq; 2237 struct gl_program *Program; 2238 }; 2239 2240 /** 2241 * Context state for GL_ATI_fragment_shader 2242 */ 2243 struct gl_ati_fragment_shader_state 2244 { 2245 GLboolean Enabled; 2246 GLboolean Compiling; 2247 GLfloat GlobalConstants[8][4]; 2248 struct ati_fragment_shader *Current; 2249 }; 2250 2251 #define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ 2252 #define GLSL_LOG 0x2 /**< Write shaders to files */ 2253 #define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */ 2254 #define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */ 2255 #define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */ 2256 #define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */ 2257 #define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */ 2258 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */ 2259 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */ 2260 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */ 2261 2262 2263 /** 2264 * Context state for GLSL vertex/fragment shaders. 2265 * Extended to support pipeline object 2266 */ 2267 struct gl_pipeline_object 2268 { 2269 /** Name of the pipeline object as received from glGenProgramPipelines. 2270 * It would be 0 for shaders without separate shader objects. 2271 */ 2272 GLuint Name; 2273 2274 GLint RefCount; 2275 2276 GLchar *Label; /**< GL_KHR_debug */ 2277 2278 /** 2279 * Programs used for rendering 2280 * 2281 * There is a separate program set for each shader stage. 2282 */ 2283 struct gl_program *CurrentProgram[MESA_SHADER_STAGES]; 2284 2285 struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES]; 2286 2287 /** 2288 * Program used by glUniform calls. 2289 * 2290 * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. 2291 */ 2292 struct gl_shader_program *ActiveProgram; 2293 2294 GLbitfield Flags; /**< Mask of GLSL_x flags */ 2295 GLboolean EverBound; /**< Has the pipeline object been created */ 2296 GLboolean Validated; /**< Pipeline Validation status */ 2297 GLboolean UserValidated; /**< Validation status initiated by the user */ 2298 2299 GLchar *InfoLog; 2300 }; 2301 2302 /** 2303 * Context state for GLSL pipeline shaders. 2304 */ 2305 struct gl_pipeline_shader_state 2306 { 2307 /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */ 2308 struct gl_pipeline_object *Current; 2309 2310 /** Default Object to ensure that _Shader is never NULL */ 2311 struct gl_pipeline_object *Default; 2312 2313 /** Pipeline objects */ 2314 struct _mesa_HashTable *Objects; 2315 }; 2316 2317 /** 2318 * Occlusion/timer query object. 2319 */ 2320 struct gl_query_object 2321 { 2322 GLenum16 Target; /**< The query target, when active */ 2323 GLuint Id; /**< hash table ID/name */ 2324 GLchar *Label; /**< GL_KHR_debug */ 2325 GLuint64EXT Result; /**< the counter */ 2326 GLboolean Active; /**< inside Begin/EndQuery */ 2327 GLboolean Ready; /**< result is ready? */ 2328 GLboolean EverBound;/**< has query object ever been bound */ 2329 GLuint Stream; /**< The stream */ 2330 2331 struct pipe_query *pq; 2332 2333 /* Begin TIMESTAMP query for GL_TIME_ELAPSED_EXT queries */ 2334 struct pipe_query *pq_begin; 2335 2336 unsigned type; /**< PIPE_QUERY_x */ 2337 }; 2338 2339 2340 /** 2341 * Context state for query objects. 2342 */ 2343 struct gl_query_state 2344 { 2345 struct _mesa_HashTable *QueryObjects; 2346 struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ 2347 struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ 2348 2349 /** GL_NV_conditional_render */ 2350 struct gl_query_object *CondRenderQuery; 2351 2352 /** GL_EXT_transform_feedback */ 2353 struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS]; 2354 struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS]; 2355 2356 /** GL_ARB_transform_feedback_overflow_query */ 2357 struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS]; 2358 struct gl_query_object *TransformFeedbackOverflowAny; 2359 2360 /** GL_ARB_timer_query */ 2361 struct gl_query_object *TimeElapsed; 2362 2363 /** GL_ARB_pipeline_statistics_query */ 2364 struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS]; 2365 2366 GLenum16 CondRenderMode; 2367 }; 2368 2369 2370 /** Sync object state */ 2371 struct gl_sync_object 2372 { 2373 GLuint Name; /**< Fence name */ 2374 GLint RefCount; /**< Reference count */ 2375 GLchar *Label; /**< GL_KHR_debug */ 2376 GLboolean DeletePending; /**< Object was deleted while there were still 2377 * live references (e.g., sync not yet finished) 2378 */ 2379 GLenum16 SyncCondition; 2380 GLbitfield Flags; /**< Flags passed to glFenceSync */ 2381 GLuint StatusFlag:1; /**< Has the sync object been signaled? */ 2382 2383 struct pipe_fence_handle *fence; 2384 simple_mtx_t mutex; /**< protects "fence" */ 2385 }; 2386 2387 2388 /** 2389 * State which can be shared by multiple contexts: 2390 */ 2391 struct gl_shared_state 2392 { 2393 simple_mtx_t Mutex; /**< for thread safety */ 2394 GLint RefCount; /**< Reference count */ 2395 bool DisplayListsAffectGLThread; 2396 2397 struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ 2398 struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */ 2399 struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ 2400 2401 /** Default texture objects (shared by all texture units) */ 2402 struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; 2403 2404 /** Fallback texture used when a bound texture is incomplete */ 2405 struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS]; 2406 2407 /** 2408 * \name Thread safety and statechange notification for texture 2409 * objects. 2410 * 2411 * \todo Improve the granularity of locking. 2412 */ 2413 /*@{*/ 2414 simple_mtx_t TexMutex; /**< texobj thread safety */ 2415 GLuint TextureStateStamp; /**< state notification for shared tex */ 2416 /*@}*/ 2417 2418 /** 2419 * \name Vertex/geometry/fragment programs 2420 */ 2421 /*@{*/ 2422 struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ 2423 struct gl_program *DefaultVertexProgram; 2424 struct gl_program *DefaultFragmentProgram; 2425 /*@}*/ 2426 2427 /* GL_ATI_fragment_shader */ 2428 struct _mesa_HashTable *ATIShaders; 2429 struct ati_fragment_shader *DefaultFragmentShader; 2430 2431 struct _mesa_HashTable *BufferObjects; 2432 2433 /* Buffer objects released by a different context than the one that 2434 * created them. Since the creating context holds one global buffer 2435 * reference for each buffer it created and skips reference counting, 2436 * deleting a buffer by another context can't touch the buffer reference 2437 * held by the context that created it. Only the creating context can 2438 * remove its global buffer reference. 2439 * 2440 * This list contains all buffers that were deleted by a different context 2441 * than the one that created them. This list should be probed by all 2442 * contexts regularly and remove references of those buffers that they own. 2443 */ 2444 struct set *ZombieBufferObjects; 2445 2446 /** Table of both gl_shader and gl_shader_program objects */ 2447 struct _mesa_HashTable *ShaderObjects; 2448 2449 /* GL_EXT_framebuffer_object */ 2450 struct _mesa_HashTable *RenderBuffers; 2451 struct _mesa_HashTable *FrameBuffers; 2452 2453 /* GL_ARB_sync */ 2454 struct set *SyncObjects; 2455 2456 /** GL_ARB_sampler_objects */ 2457 struct _mesa_HashTable *SamplerObjects; 2458 2459 /* GL_ARB_bindless_texture */ 2460 struct hash_table_u64 *TextureHandles; 2461 struct hash_table_u64 *ImageHandles; 2462 mtx_t HandlesMutex; /**< For texture/image handles safety */ 2463 2464 /* GL_ARB_shading_language_include */ 2465 struct shader_includes *ShaderIncludes; 2466 /* glCompileShaderInclude expects ShaderIncludes not to change while it is 2467 * in progress. 2468 */ 2469 simple_mtx_t ShaderIncludeMutex; 2470 2471 /** 2472 * Some context in this share group was affected by a GPU reset 2473 * 2474 * On the next call to \c glGetGraphicsResetStatus, contexts that have not 2475 * been affected by a GPU reset must also return 2476 * \c GL_INNOCENT_CONTEXT_RESET_ARB. 2477 * 2478 * Once this field becomes true, it is never reset to false. 2479 */ 2480 bool ShareGroupReset; 2481 2482 /** EXT_external_objects */ 2483 struct _mesa_HashTable *MemoryObjects; 2484 2485 /** EXT_semaphore */ 2486 struct _mesa_HashTable *SemaphoreObjects; 2487 2488 /** 2489 * Some context in this share group was affected by a disjoint 2490 * operation. This operation can be anything that has effects on 2491 * values of timer queries in such manner that they become invalid for 2492 * performance metrics. As example gpu reset, counter overflow or gpu 2493 * frequency changes. 2494 */ 2495 bool DisjointOperation; 2496 2497 /** 2498 * Whether at least one image has been imported or exported, excluding 2499 * the default framebuffer. If this is false, glFlush can be executed 2500 * asynchronously because there is no invisible dependency on external 2501 * users. 2502 */ 2503 bool HasExternallySharedImages; 2504 2505 /* Small display list storage */ 2506 struct { 2507 union gl_dlist_node *ptr; 2508 struct util_idalloc free_idx; 2509 unsigned size; 2510 } small_dlist_store; 2511 }; 2512 2513 2514 2515 /** 2516 * Renderbuffers represent drawing surfaces such as color, depth and/or 2517 * stencil. A framebuffer object has a set of renderbuffers. 2518 * Drivers will typically derive subclasses of this type. 2519 */ 2520 struct gl_renderbuffer 2521 { 2522 GLuint ClassID; /**< Useful for drivers */ 2523 GLuint Name; 2524 GLchar *Label; /**< GL_KHR_debug */ 2525 GLint RefCount; 2526 GLuint Width, Height; 2527 GLuint Depth; 2528 GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ 2529 GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ 2530 GLubyte NumSamples; /**< zero means not multisampled */ 2531 GLubyte NumStorageSamples; /**< for AMD_framebuffer_multisample_advanced */ 2532 GLenum16 InternalFormat; /**< The user-specified format */ 2533 GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or 2534 GL_STENCIL_INDEX. */ 2535 mesa_format Format; /**< The actual renderbuffer memory format */ 2536 /** 2537 * Pointer to the texture image if this renderbuffer wraps a texture, 2538 * otherwise NULL. 2539 * 2540 * Note that the reference on the gl_texture_object containing this 2541 * TexImage is held by the gl_renderbuffer_attachment. 2542 */ 2543 struct gl_texture_image *TexImage; 2544 2545 /** Delete this renderbuffer */ 2546 void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb); 2547 2548 /** Allocate new storage for this renderbuffer */ 2549 GLboolean (*AllocStorage)(struct gl_context *ctx, 2550 struct gl_renderbuffer *rb, 2551 GLenum internalFormat, 2552 GLuint width, GLuint height); 2553 2554 struct pipe_resource *texture; 2555 /* This points to either "surface_linear" or "surface_srgb". 2556 * It doesn't hold the pipe_surface reference. The other two do. 2557 */ 2558 struct pipe_surface *surface; 2559 struct pipe_surface *surface_linear; 2560 struct pipe_surface *surface_srgb; 2561 GLboolean defined; /**< defined contents? */ 2562 2563 struct pipe_transfer *transfer; /**< only used when mapping the resource */ 2564 2565 /** 2566 * Used only when hardware accumulation buffers are not supported. 2567 */ 2568 boolean software; 2569 void *data; 2570 2571 bool use_readpix_cache; 2572 2573 /* Inputs from Driver.RenderTexture, don't use directly. */ 2574 boolean is_rtt; /**< whether Driver.RenderTexture was called */ 2575 unsigned rtt_face, rtt_slice; 2576 boolean rtt_layered; /**< whether glFramebufferTexture was called */ 2577 unsigned rtt_nr_samples; /**< from FramebufferTexture2DMultisampleEXT */ 2578 }; 2579 2580 2581 /** 2582 * A renderbuffer attachment points to either a texture object (and specifies 2583 * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. 2584 */ 2585 struct gl_renderbuffer_attachment 2586 { 2587 GLenum16 Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ 2588 GLboolean Complete; 2589 2590 /** 2591 * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the 2592 * application supplied renderbuffer object. 2593 */ 2594 struct gl_renderbuffer *Renderbuffer; 2595 2596 /** 2597 * If \c Type is \c GL_TEXTURE, this stores a pointer to the application 2598 * supplied texture object. 2599 */ 2600 struct gl_texture_object *Texture; 2601 GLuint TextureLevel; /**< Attached mipmap level. */ 2602 GLsizei NumSamples; /**< from FramebufferTexture2DMultisampleEXT */ 2603 GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ 2604 GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D 2605 * and 2D array textures */ 2606 GLboolean Layered; 2607 }; 2608 2609 2610 /** 2611 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). 2612 * In C++ terms, think of this as a base class from which device drivers 2613 * will make derived classes. 2614 */ 2615 struct gl_framebuffer 2616 { 2617 simple_mtx_t Mutex; /**< for thread safety */ 2618 /** 2619 * If zero, this is a window system framebuffer. If non-zero, this 2620 * is a FBO framebuffer; note that for some devices (i.e. those with 2621 * a natural pixel coordinate system for FBOs that differs from the 2622 * OpenGL/Mesa coordinate system), this means that the viewport, 2623 * polygon face orientation, and polygon stipple will have to be inverted. 2624 */ 2625 GLuint Name; 2626 GLint RefCount; 2627 2628 GLchar *Label; /**< GL_KHR_debug */ 2629 2630 GLboolean DeletePending; 2631 2632 /** 2633 * The framebuffer's visual. Immutable if this is a window system buffer. 2634 * Computed from attachments if user-made FBO. 2635 */ 2636 struct gl_config Visual; 2637 2638 /** 2639 * Size of frame buffer in pixels. If there are no attachments, then both 2640 * of these are 0. 2641 */ 2642 GLuint Width, Height; 2643 2644 /** 2645 * In the case that the framebuffer has no attachment (i.e. 2646 * GL_ARB_framebuffer_no_attachments) then the geometry of 2647 * the framebuffer is specified by the default values. 2648 */ 2649 struct { 2650 GLuint Width, Height, Layers, NumSamples; 2651 GLboolean FixedSampleLocations; 2652 /* Derived from NumSamples by the driver so that it can choose a valid 2653 * value for the hardware. 2654 */ 2655 GLuint _NumSamples; 2656 } DefaultGeometry; 2657 2658 /** \name Drawing bounds (Intersection of buffer size and scissor box) 2659 * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax), 2660 * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax) 2661 */ 2662 /*@{*/ 2663 GLint _Xmin, _Xmax; 2664 GLint _Ymin, _Ymax; 2665 /*@}*/ 2666 2667 /** \name Derived Z buffer stuff */ 2668 /*@{*/ 2669 GLuint _DepthMax; /**< Max depth buffer value */ 2670 GLfloat _DepthMaxF; /**< Float max depth buffer value */ 2671 GLfloat _MRD; /**< minimum resolvable difference in Z values */ 2672 /*@}*/ 2673 2674 /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ 2675 GLenum16 _Status; 2676 2677 /** Whether one of Attachment has Type != GL_NONE 2678 * NOTE: the values for Width and Height are set to 0 in case of having 2679 * no attachments, a backend driver supporting the extension 2680 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments 2681 * and if GL_FALSE, must then use the values in DefaultGeometry to initialize 2682 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and 2683 * _Ymax do NOT take into account _HasAttachments being false). To get the 2684 * geometry of the framebuffer, the helper functions 2685 * _mesa_geometric_width(), 2686 * _mesa_geometric_height(), 2687 * _mesa_geometric_samples() and 2688 * _mesa_geometric_layers() 2689 * are available that check _HasAttachments. 2690 */ 2691 bool _HasAttachments; 2692 2693 GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */ 2694 GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */ 2695 GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */ 2696 2697 /* ARB_color_buffer_float */ 2698 GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */ 2699 GLboolean _HasSNormOrFloatColorBuffer; 2700 2701 /** 2702 * The maximum number of layers in the framebuffer, or 0 if the framebuffer 2703 * is not layered. For cube maps and cube map arrays, each cube face 2704 * counts as a layer. As the case for Width, Height a backend driver 2705 * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry 2706 * in the case that _HasAttachments is false 2707 */ 2708 GLuint MaxNumLayers; 2709 2710 /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ 2711 struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; 2712 2713 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER 2714 * attribute group and GL_PIXEL attribute group, respectively. 2715 */ 2716 GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS]; 2717 GLenum16 ColorReadBuffer; 2718 2719 /* GL_ARB_sample_locations */ 2720 GLfloat *SampleLocationTable; /**< If NULL, no table has been specified */ 2721 GLboolean ProgrammableSampleLocations; 2722 GLboolean SampleLocationPixelGrid; 2723 2724 /** Computed from ColorDraw/ReadBuffer above */ 2725 GLuint _NumColorDrawBuffers; 2726 gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; 2727 gl_buffer_index _ColorReadBufferIndex; 2728 struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; 2729 struct gl_renderbuffer *_ColorReadBuffer; 2730 2731 /* GL_MESA_framebuffer_flip_y */ 2732 bool FlipY; 2733 2734 /** Delete this framebuffer */ 2735 void (*Delete)(struct gl_framebuffer *fb); 2736 2737 struct st_framebuffer_iface *iface; 2738 enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; 2739 unsigned num_statts; 2740 int32_t stamp; 2741 int32_t iface_stamp; 2742 uint32_t iface_ID; 2743 2744 /* list of framebuffer objects */ 2745 struct list_head head; 2746 }; 2747 2748 /** 2749 * A stack of matrices (projection, modelview, color, texture, etc). 2750 */ 2751 struct gl_matrix_stack 2752 { 2753 GLmatrix *Top; /**< points into Stack */ 2754 GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ 2755 unsigned StackSize; /**< Number of elements in Stack */ 2756 GLuint Depth; /**< 0 <= Depth < MaxDepth */ 2757 GLuint MaxDepth; /**< size of Stack[] array */ 2758 GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ 2759 }; 2760 2761 2762 /** 2763 * \name Bits for image transfer operations 2764 * \sa __struct gl_contextRec::ImageTransferState. 2765 */ 2766 /*@{*/ 2767 #define IMAGE_SCALE_BIAS_BIT 0x1 2768 #define IMAGE_SHIFT_OFFSET_BIT 0x2 2769 #define IMAGE_MAP_COLOR_BIT 0x4 2770 #define IMAGE_CLAMP_BIT 0x800 2771 2772 2773 /** Pixel Transfer ops */ 2774 #define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ 2775 IMAGE_SHIFT_OFFSET_BIT | \ 2776 IMAGE_MAP_COLOR_BIT) 2777 2778 2779 /** 2780 * \name Bits to indicate what state has changed. 2781 */ 2782 /*@{*/ 2783 #define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */ 2784 #define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */ 2785 #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */ 2786 #define _NEW_COLOR (1u << 3) /**< gl_context::Color */ 2787 #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */ 2788 #define _NEW_TNL_SPACES (1u << 5) /**< _mesa_update_tnl_spaces */ 2789 #define _NEW_FOG (1u << 6) /**< gl_context::Fog */ 2790 #define _NEW_HINT (1u << 7) /**< gl_context::Hint */ 2791 #define _NEW_LIGHT_CONSTANTS (1u << 8) /**< gl_context::Light */ 2792 #define _NEW_LINE (1u << 9) /**< gl_context::Line */ 2793 #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */ 2794 #define _NEW_POINT (1u << 11) /**< gl_context::Point */ 2795 #define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */ 2796 #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */ 2797 #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */ 2798 #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */ 2799 #define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */ 2800 #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */ 2801 #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */ 2802 #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */ 2803 #define _NEW_LIGHT_STATE (1u << 20) /**< gl_context::Light */ 2804 #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */ 2805 #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */ 2806 #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */ 2807 #define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */ 2808 #define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */ 2809 #define _NEW_PROGRAM (1u << 26) /**< New program/shader state */ 2810 #define _NEW_PROGRAM_CONSTANTS (1u << 27) 2811 #define _NEW_FF_VERT_PROGRAM (1u << 28) 2812 #define _NEW_FRAG_CLAMP (1u << 29) 2813 #define _NEW_MATERIAL (1u << 30) /**< gl_context::Light.Material */ 2814 #define _NEW_FF_FRAG_PROGRAM (1u << 31) 2815 #define _NEW_ALL ~0 2816 /*@}*/ 2817 2818 2819 /** 2820 * Composite state flags, deprecated and inefficient, do not use. 2821 */ 2822 /*@{*/ 2823 #define _NEW_LIGHT (_NEW_LIGHT_CONSTANTS | /* state parameters */ \ 2824 _NEW_LIGHT_STATE | /* rasterizer state */ \ 2825 _NEW_MATERIAL | /* light materials */ \ 2826 _NEW_FF_VERT_PROGRAM | \ 2827 _NEW_FF_FRAG_PROGRAM) 2828 2829 #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE | \ 2830 _NEW_FF_VERT_PROGRAM | _NEW_FF_FRAG_PROGRAM) 2831 2832 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_FF_VERT_PROGRAM | \ 2833 _NEW_FF_FRAG_PROGRAM | \ 2834 _NEW_LIGHT_CONSTANTS | \ 2835 _NEW_TEXTURE_STATE | \ 2836 _NEW_POINT | \ 2837 _NEW_PROGRAM | \ 2838 _NEW_MODELVIEW) 2839 2840 #define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \ 2841 _NEW_FOG | \ 2842 _NEW_PROGRAM) 2843 2844 2845 /*@}*/ 2846 2847 2848 2849 2850 /* This has to be included here. */ 2851 #include "dd.h" 2852 2853 2854 /** Opaque declaration of display list payload data type */ 2855 union gl_dlist_node; 2856 2857 2858 /** 2859 * Per-display list information. 2860 */ 2861 struct gl_display_list 2862 { 2863 GLuint Name; 2864 bool execute_glthread; 2865 bool small_list; 2866 GLchar *Label; /**< GL_KHR_debug */ 2867 /** The dlist commands are in a linked list of nodes */ 2868 union { 2869 /* Big lists allocate their own storage */ 2870 union gl_dlist_node *Head; 2871 /* Small lists use ctx->Shared->small_dlist_store */ 2872 struct { 2873 unsigned start; 2874 unsigned count; 2875 }; 2876 }; 2877 }; 2878 2879 2880 /** 2881 * State used during display list compilation and execution. 2882 */ 2883 struct gl_dlist_state 2884 { 2885 struct gl_display_list *CurrentList; /**< List currently being compiled */ 2886 union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ 2887 GLuint CurrentPos; /**< Index into current block of nodes */ 2888 GLuint CallDepth; /**< Current recursion calling depth */ 2889 GLuint LastInstSize; /**< Size of the last node. */ 2890 2891 GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; 2892 uint32_t CurrentAttrib[VERT_ATTRIB_MAX][8]; 2893 2894 GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; 2895 GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; 2896 2897 struct { 2898 /* State known to have been set by the currently-compiling display 2899 * list. Used to eliminate some redundant state changes. 2900 */ 2901 GLenum16 ShadeModel; 2902 bool UseLoopback; 2903 } Current; 2904 }; 2905 2906 /** 2907 * Driver-specific state flags. 2908 * 2909 * These are or'd with gl_context::NewDriverState to notify a driver about 2910 * a state change. The driver sets the flags at context creation and 2911 * the meaning of the bits set is opaque to core Mesa. 2912 */ 2913 struct gl_driver_flags 2914 { 2915 /** 2916 * gl_context::AtomicBufferBindings 2917 */ 2918 uint64_t NewAtomicBuffer; 2919 2920 /** gl_context::Color::Alpha* */ 2921 uint64_t NewAlphaTest; 2922 2923 /** gl_context::Multisample::Enabled */ 2924 uint64_t NewMultisampleEnable; 2925 2926 /** gl_context::Multisample::(Min)SampleShading */ 2927 uint64_t NewSampleShading; 2928 2929 /** gl_context::Transform::ClipPlanesEnabled */ 2930 uint64_t NewClipPlaneEnable; 2931 2932 /** gl_context::Color::ClampFragmentColor */ 2933 uint64_t NewFragClamp; 2934 2935 /** Shader constants (uniforms, program parameters, state constants) */ 2936 uint64_t NewShaderConstants[MESA_SHADER_STAGES]; 2937 2938 /** For GL_CLAMP emulation */ 2939 uint64_t NewSamplersWithClamp; 2940 }; 2941 2942 struct gl_buffer_binding 2943 { 2944 struct gl_buffer_object *BufferObject; 2945 /** Start of uniform block data in the buffer */ 2946 GLintptr Offset; 2947 /** Size of data allowed to be referenced from the buffer (in bytes) */ 2948 GLsizeiptr Size; 2949 /** 2950 * glBindBufferBase() indicates that the Size should be ignored and only 2951 * limited by the current size of the BufferObject. 2952 */ 2953 GLboolean AutomaticSize; 2954 }; 2955 2956 /** 2957 * ARB_shader_image_load_store image unit. 2958 */ 2959 struct gl_image_unit 2960 { 2961 /** 2962 * Texture object bound to this unit. 2963 */ 2964 struct gl_texture_object *TexObj; 2965 2966 /** 2967 * Level of the texture object bound to this unit. 2968 */ 2969 GLubyte Level; 2970 2971 /** 2972 * \c GL_TRUE if the whole level is bound as an array of layers, \c 2973 * GL_FALSE if only some specific layer of the texture is bound. 2974 * \sa Layer 2975 */ 2976 GLboolean Layered; 2977 2978 /** 2979 * Layer of the texture object bound to this unit as specified by the 2980 * application. 2981 */ 2982 GLushort Layer; 2983 2984 /** 2985 * Layer of the texture object bound to this unit, or zero if 2986 * Layered == false. 2987 */ 2988 GLushort _Layer; 2989 2990 /** 2991 * Access allowed to this texture image. Either \c GL_READ_ONLY, 2992 * \c GL_WRITE_ONLY or \c GL_READ_WRITE. 2993 */ 2994 GLenum16 Access; 2995 2996 /** 2997 * GL internal format that determines the interpretation of the 2998 * image memory when shader image operations are performed through 2999 * this unit. 3000 */ 3001 GLenum16 Format; 3002 3003 /** 3004 * Mesa format corresponding to \c Format. 3005 */ 3006 mesa_format _ActualFormat:16; 3007 }; 3008 3009 /** 3010 * Shader subroutines storage 3011 */ 3012 struct gl_subroutine_index_binding 3013 { 3014 GLuint NumIndex; 3015 GLuint *IndexPtr; 3016 }; 3017 3018 struct gl_texture_handle_object 3019 { 3020 struct gl_texture_object *texObj; 3021 struct gl_sampler_object *sampObj; 3022 GLuint64 handle; 3023 }; 3024 3025 struct gl_image_handle_object 3026 { 3027 struct gl_image_unit imgObj; 3028 GLuint64 handle; 3029 }; 3030 3031 struct gl_memory_object 3032 { 3033 GLuint Name; /**< hash table ID/name */ 3034 GLboolean Immutable; /**< denotes mutability state of parameters */ 3035 GLboolean Dedicated; /**< import memory from a dedicated allocation */ 3036 3037 struct pipe_memory_object *memory; 3038 3039 /* TEXTURE_TILING_EXT param from gl_texture_object */ 3040 GLuint TextureTiling; 3041 }; 3042 3043 struct gl_semaphore_object 3044 { 3045 GLuint Name; /**< hash table ID/name */ 3046 struct pipe_fence_handle *fence; 3047 }; 3048 3049 /** 3050 * One element of the client attrib stack. 3051 */ 3052 struct gl_client_attrib_node 3053 { 3054 GLbitfield Mask; 3055 struct gl_array_attrib Array; 3056 struct gl_vertex_array_object VAO; 3057 struct gl_pixelstore_attrib Pack; 3058 struct gl_pixelstore_attrib Unpack; 3059 }; 3060 3061 /** 3062 * The VBO module implemented in src/vbo. 3063 */ 3064 struct vbo_context { 3065 struct gl_vertex_buffer_binding binding; 3066 struct gl_array_attributes current[VBO_ATTRIB_MAX]; 3067 3068 struct gl_vertex_array_object *VAO; 3069 3070 struct vbo_exec_context exec; 3071 struct vbo_save_context save; 3072 }; 3073 3074 /** 3075 * glEnable node for the attribute stack. (glPushAttrib/glPopAttrib) 3076 */ 3077 struct gl_enable_attrib_node 3078 { 3079 GLboolean AlphaTest; 3080 GLboolean AutoNormal; 3081 GLboolean Blend; 3082 GLbitfield ClipPlanes; 3083 GLboolean ColorMaterial; 3084 GLboolean CullFace; 3085 GLboolean DepthClampNear; 3086 GLboolean DepthClampFar; 3087 GLboolean DepthTest; 3088 GLboolean Dither; 3089 GLboolean Fog; 3090 GLboolean Light[MAX_LIGHTS]; 3091 GLboolean Lighting; 3092 GLboolean LineSmooth; 3093 GLboolean LineStipple; 3094 GLboolean IndexLogicOp; 3095 GLboolean ColorLogicOp; 3096 3097 GLboolean Map1Color4; 3098 GLboolean Map1Index; 3099 GLboolean Map1Normal; 3100 GLboolean Map1TextureCoord1; 3101 GLboolean Map1TextureCoord2; 3102 GLboolean Map1TextureCoord3; 3103 GLboolean Map1TextureCoord4; 3104 GLboolean Map1Vertex3; 3105 GLboolean Map1Vertex4; 3106 GLboolean Map2Color4; 3107 GLboolean Map2Index; 3108 GLboolean Map2Normal; 3109 GLboolean Map2TextureCoord1; 3110 GLboolean Map2TextureCoord2; 3111 GLboolean Map2TextureCoord3; 3112 GLboolean Map2TextureCoord4; 3113 GLboolean Map2Vertex3; 3114 GLboolean Map2Vertex4; 3115 3116 GLboolean Normalize; 3117 GLboolean PixelTexture; 3118 GLboolean PointSmooth; 3119 GLboolean PolygonOffsetPoint; 3120 GLboolean PolygonOffsetLine; 3121 GLboolean PolygonOffsetFill; 3122 GLboolean PolygonSmooth; 3123 GLboolean PolygonStipple; 3124 GLboolean RescaleNormals; 3125 GLbitfield Scissor; 3126 GLboolean Stencil; 3127 GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */ 3128 GLboolean MultisampleEnabled; /* GL_ARB_multisample */ 3129 GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ 3130 GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ 3131 GLboolean SampleCoverage; /* GL_ARB_multisample */ 3132 GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ 3133 3134 GLbitfield Texture[MAX_TEXTURE_UNITS]; 3135 GLbitfield TexGen[MAX_TEXTURE_UNITS]; 3136 3137 /* GL_ARB_vertex_program */ 3138 GLboolean VertexProgram; 3139 GLboolean VertexProgramPointSize; 3140 GLboolean VertexProgramTwoSide; 3141 3142 /* GL_ARB_fragment_program */ 3143 GLboolean FragmentProgram; 3144 3145 /* GL_ARB_point_sprite */ 3146 GLboolean PointSprite; 3147 GLboolean FragmentShaderATI; 3148 3149 /* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */ 3150 GLboolean sRGBEnabled; 3151 3152 /* GL_NV_conservative_raster */ 3153 GLboolean ConservativeRasterization; 3154 }; 3155 3156 /** 3157 * Texture node for the attribute stack. (glPushAttrib/glPopAttrib) 3158 */ 3159 struct gl_texture_attrib_node 3160 { 3161 GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ 3162 GLuint NumTexSaved; 3163 struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS]; 3164 GLfloat LodBias[MAX_TEXTURE_UNITS]; 3165 float LodBiasQuantized[MAX_TEXTURE_UNITS]; 3166 3167 /** Saved default texture object state. */ 3168 struct gl_texture_object SavedDefaultObj[NUM_TEXTURE_TARGETS]; 3169 3170 /* For saving per texture object state (wrap modes, filters, etc), 3171 * SavedObj[][].Target is unused, so the value is invalid. 3172 */ 3173 struct gl_texture_object SavedObj[MAX_COMBINED_TEXTURE_IMAGE_UNITS][NUM_TEXTURE_TARGETS]; 3174 }; 3175 3176 3177 /** 3178 * Node for the attribute stack. (glPushAttrib/glPopAttrib) 3179 */ 3180 struct gl_attrib_node 3181 { 3182 GLbitfield Mask; 3183 GLbitfield OldPopAttribStateMask; 3184 struct gl_accum_attrib Accum; 3185 struct gl_colorbuffer_attrib Color; 3186 struct gl_current_attrib Current; 3187 struct gl_depthbuffer_attrib Depth; 3188 struct gl_enable_attrib_node Enable; 3189 struct gl_eval_attrib Eval; 3190 struct gl_fog_attrib Fog; 3191 struct gl_hint_attrib Hint; 3192 struct gl_light_attrib Light; 3193 struct gl_line_attrib Line; 3194 struct gl_list_attrib List; 3195 struct gl_pixel_attrib Pixel; 3196 struct gl_point_attrib Point; 3197 struct gl_polygon_attrib Polygon; 3198 GLuint PolygonStipple[32]; 3199 struct gl_scissor_attrib Scissor; 3200 struct gl_stencil_attrib Stencil; 3201 struct gl_transform_attrib Transform; 3202 struct gl_multisample_attrib Multisample; 3203 struct gl_texture_attrib_node Texture; 3204 3205 struct viewport_state 3206 { 3207 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; 3208 GLuint SubpixelPrecisionBias[2]; 3209 } Viewport; 3210 }; 3211 3212 /** 3213 * Mesa rendering context. 3214 * 3215 * This is the central context data structure for Mesa. Almost all 3216 * OpenGL state is contained in this structure. 3217 * Think of this as a base class from which device drivers will derive 3218 * sub classes. 3219 */ 3220 struct gl_context 3221 { 3222 /** State possibly shared with other contexts in the address space */ 3223 struct gl_shared_state *Shared; 3224 3225 /** Whether Shared->BufferObjects has already been locked for this context. */ 3226 bool BufferObjectsLocked; 3227 /** Whether Shared->TexMutex has already been locked for this context. */ 3228 bool TexturesLocked; 3229 3230 /** \name API function pointer tables */ 3231 /*@{*/ 3232 gl_api API; 3233 3234 /** 3235 * The current dispatch table for non-displaylist-saving execution, either 3236 * BeginEnd or OutsideBeginEnd 3237 */ 3238 struct _glapi_table *Exec; 3239 /** 3240 * The normal dispatch table for non-displaylist-saving, non-begin/end 3241 */ 3242 struct _glapi_table *OutsideBeginEnd; 3243 /** The dispatch table used between glNewList() and glEndList() */ 3244 struct _glapi_table *Save; 3245 /** 3246 * The dispatch table used between glBegin() and glEnd() (outside of a 3247 * display list). Only valid functions between those two are set. 3248 */ 3249 struct _glapi_table *BeginEnd; 3250 /** 3251 * Dispatch table for when a graphics reset has happened. 3252 */ 3253 struct _glapi_table *ContextLost; 3254 /** 3255 * Dispatch table used to marshal API calls from the client program to a 3256 * separate server thread. 3257 */ 3258 struct _glapi_table *MarshalExec; 3259 /** 3260 * Dispatch table currently in use for fielding API calls from the client 3261 * program. If API calls are being marshalled to another thread, this == 3262 * MarshalExec. Otherwise it == CurrentServerDispatch. 3263 */ 3264 struct _glapi_table *CurrentClientDispatch; 3265 3266 /** 3267 * Dispatch table currently in use for performing API calls. == Save or 3268 * Exec. 3269 */ 3270 struct _glapi_table *CurrentServerDispatch; 3271 3272 /*@}*/ 3273 3274 struct glthread_state GLThread; 3275 3276 struct gl_config Visual; 3277 struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ 3278 struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ 3279 struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ 3280 struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ 3281 3282 /** 3283 * Device driver function pointer table 3284 */ 3285 struct dd_function_table Driver; 3286 3287 /** Core/Driver constants */ 3288 struct gl_constants Const; 3289 3290 /** 3291 * Bitmask of valid primitive types supported by this context type, 3292 * GL version, and extensions, not taking current states into account. 3293 * Current states can further reduce the final bitmask at draw time. 3294 */ 3295 GLbitfield SupportedPrimMask; 3296 3297 /** 3298 * Bitmask of valid primitive types depending on current states (such as 3299 * shaders). This is 0 if the current states should result in 3300 * GL_INVALID_OPERATION in draw calls. 3301 */ 3302 GLbitfield ValidPrimMask; 3303 3304 GLenum16 DrawGLError; /**< GL error to return from draw calls */ 3305 3306 /** 3307 * Same as ValidPrimMask, but should be applied to glDrawElements*. 3308 */ 3309 GLbitfield ValidPrimMaskIndexed; 3310 3311 /** 3312 * Whether DrawPixels/CopyPixels/Bitmap are valid to render. 3313 */ 3314 bool DrawPixValid; 3315 3316 /** \name The various 4x4 matrix stacks */ 3317 /*@{*/ 3318 struct gl_matrix_stack ModelviewMatrixStack; 3319 struct gl_matrix_stack ProjectionMatrixStack; 3320 struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; 3321 struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; 3322 struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ 3323 /*@}*/ 3324 3325 /** Combined modelview and projection matrix */ 3326 GLmatrix _ModelProjectMatrix; 3327 3328 /** \name Display lists */ 3329 struct gl_dlist_state ListState; 3330 3331 GLboolean ExecuteFlag; /**< Execute GL commands? */ 3332 GLboolean CompileFlag; /**< Compile GL commands into display list? */ 3333 3334 /** Extension information */ 3335 struct gl_extensions Extensions; 3336 3337 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */ 3338 GLuint Version; 3339 char *VersionString; 3340 3341 /** \name State attribute stack (for glPush/PopAttrib) */ 3342 /*@{*/ 3343 GLuint AttribStackDepth; 3344 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; 3345 /*@}*/ 3346 3347 /** \name Renderer attribute groups 3348 * 3349 * We define a struct for each attribute group to make pushing and popping 3350 * attributes easy. Also it's a good organization. 3351 */ 3352 /*@{*/ 3353 struct gl_accum_attrib Accum; /**< Accum buffer attributes */ 3354 struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ 3355 struct gl_current_attrib Current; /**< Current attributes */ 3356 struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ 3357 struct gl_eval_attrib Eval; /**< Eval attributes */ 3358 struct gl_fog_attrib Fog; /**< Fog attributes */ 3359 struct gl_hint_attrib Hint; /**< Hint attributes */ 3360 struct gl_light_attrib Light; /**< Light attributes */ 3361 struct gl_line_attrib Line; /**< Line attributes */ 3362 struct gl_list_attrib List; /**< List attributes */ 3363 struct gl_multisample_attrib Multisample; 3364 struct gl_pixel_attrib Pixel; /**< Pixel attributes */ 3365 struct gl_point_attrib Point; /**< Point attributes */ 3366 struct gl_polygon_attrib Polygon; /**< Polygon attributes */ 3367 GLuint PolygonStipple[32]; /**< Polygon stipple */ 3368 struct gl_scissor_attrib Scissor; /**< Scissor attributes */ 3369 struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ 3370 struct gl_texture_attrib Texture; /**< Texture attributes */ 3371 struct gl_transform_attrib Transform; /**< Transformation attributes */ 3372 struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */ 3373 GLuint SubpixelPrecisionBias[2]; /**< Viewport attributes */ 3374 /*@}*/ 3375 3376 /** \name Client attribute stack */ 3377 /*@{*/ 3378 GLuint ClientAttribStackDepth; 3379 struct gl_client_attrib_node ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; 3380 /*@}*/ 3381 3382 /** \name Client attribute groups */ 3383 /*@{*/ 3384 struct gl_array_attrib Array; /**< Vertex arrays */ 3385 struct gl_pixelstore_attrib Pack; /**< Pixel packing */ 3386 struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ 3387 struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ 3388 /*@}*/ 3389 3390 /** \name Other assorted state (not pushed/popped on attribute stack) */ 3391 /*@{*/ 3392 struct gl_pixelmaps PixelMaps; 3393 3394 struct gl_evaluators EvalMap; /**< All evaluators */ 3395 struct gl_feedback Feedback; /**< Feedback */ 3396 struct gl_selection Select; /**< Selection */ 3397 3398 struct gl_program_state Program; /**< general program state */ 3399 struct gl_vertex_program_state VertexProgram; 3400 struct gl_fragment_program_state FragmentProgram; 3401 struct gl_geometry_program_state GeometryProgram; 3402 struct gl_compute_program_state ComputeProgram; 3403 struct gl_tess_ctrl_program_state TessCtrlProgram; 3404 struct gl_tess_eval_program_state TessEvalProgram; 3405 struct gl_ati_fragment_shader_state ATIFragmentShader; 3406 3407 struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */ 3408 struct gl_pipeline_object Shader; /**< GLSL shader object state */ 3409 3410 /** 3411 * Current active shader pipeline state 3412 * 3413 * Almost all internal users want ::_Shader instead of ::Shader. The 3414 * exceptions are bits of legacy GLSL API that do not know about separate 3415 * shader objects. 3416 * 3417 * If a program is active via \c glUseProgram, this will point to 3418 * \c ::Shader. 3419 * 3420 * If a program pipeline is active via \c glBindProgramPipeline, this will 3421 * point to \c ::Pipeline.Current. 3422 * 3423 * If neither a program nor a program pipeline is active, this will point to 3424 * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be 3425 * \c NULL. 3426 */ 3427 struct gl_pipeline_object *_Shader; 3428 3429 /** 3430 * NIR containing the functions that implement software fp64 support. 3431 */ 3432 struct nir_shader *SoftFP64; 3433 3434 struct gl_query_state Query; /**< occlusion, timer queries */ 3435 3436 struct gl_transform_feedback_state TransformFeedback; 3437 3438 struct gl_perf_monitor_state PerfMonitor; 3439 struct gl_perf_query_state PerfQuery; 3440 3441 struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */ 3442 struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */ 3443 struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */ 3444 3445 struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ 3446 struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ 3447 3448 struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */ 3449 3450 /** 3451 * Current GL_ARB_uniform_buffer_object binding referenced by 3452 * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc. 3453 */ 3454 struct gl_buffer_object *UniformBuffer; 3455 3456 /** 3457 * Current GL_ARB_shader_storage_buffer_object binding referenced by 3458 * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc. 3459 */ 3460 struct gl_buffer_object *ShaderStorageBuffer; 3461 3462 /** 3463 * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1. 3464 * This is set up using glBindBufferRange() or glBindBufferBase(). They are 3465 * associated with uniform blocks by glUniformBlockBinding()'s state in the 3466 * shader program. 3467 */ 3468 struct gl_buffer_binding 3469 UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS]; 3470 3471 /** 3472 * Array of shader storage buffers for ARB_shader_storage_buffer_object 3473 * and GL 4.3. This is set up using glBindBufferRange() or 3474 * glBindBufferBase(). They are associated with shader storage blocks by 3475 * glShaderStorageBlockBinding()'s state in the shader program. 3476 */ 3477 struct gl_buffer_binding 3478 ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS]; 3479 3480 /** 3481 * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER 3482 * target. 3483 */ 3484 struct gl_buffer_object *AtomicBuffer; 3485 3486 /** 3487 * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 3488 * target. 3489 */ 3490 struct gl_buffer_object *ExternalVirtualMemoryBuffer; 3491 3492 /** 3493 * Array of atomic counter buffer binding points. 3494 */ 3495 struct gl_buffer_binding 3496 AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS]; 3497 3498 /** 3499 * Array of image units for ARB_shader_image_load_store. 3500 */ 3501 struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS]; 3502 3503 struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES]; 3504 /*@}*/ 3505 3506 struct gl_meta_state *Meta; /**< for "meta" operations */ 3507 3508 /* GL_EXT_framebuffer_object */ 3509 struct gl_renderbuffer *CurrentRenderbuffer; 3510 3511 GLenum16 ErrorValue; /**< Last error code */ 3512 3513 /** 3514 * Recognize and silence repeated error debug messages in buggy apps. 3515 */ 3516 const char *ErrorDebugFmtString; 3517 GLuint ErrorDebugCount; 3518 3519 /* GL_ARB_debug_output/GL_KHR_debug */ 3520 simple_mtx_t DebugMutex; 3521 struct gl_debug_state *Debug; 3522 3523 GLenum16 RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ 3524 GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ 3525 GLbitfield PopAttribState; /**< Updated state since glPushAttrib */ 3526 uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */ 3527 3528 struct gl_driver_flags DriverFlags; 3529 3530 GLboolean ViewportInitialized; /**< has viewport size been initialized? */ 3531 GLboolean _AllowDrawOutOfOrder; 3532 3533 /** \name Derived state */ 3534 GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ 3535 GLfloat _EyeZDir[3]; 3536 GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */ 3537 GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */ 3538 GLboolean _NeedEyeCoords; 3539 3540 GLuint TextureStateTimestamp; /**< detect changes to shared state */ 3541 3542 GLboolean LastVertexStageDirty; /**< the last vertex stage has changed */ 3543 3544 /** \name For debugging/development only */ 3545 /*@{*/ 3546 GLboolean FirstTimeCurrent; 3547 /*@}*/ 3548 3549 /** 3550 * False if this context was created without a config. This is needed 3551 * because the initial state of glDrawBuffers depends on this 3552 */ 3553 GLboolean HasConfig; 3554 3555 GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; 3556 3557 GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ 3558 GLboolean IntelConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */ 3559 GLboolean ConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_NV */ 3560 GLfloat ConservativeRasterDilate; 3561 GLenum16 ConservativeRasterMode; 3562 3563 GLboolean IntelBlackholeRender; /**< GL_INTEL_blackhole_render */ 3564 3565 /** Does glVertexAttrib(0) alias glVertex()? */ 3566 bool _AttribZeroAliasesVertex; 3567 3568 /** 3569 * When set, TileRasterOrderIncreasingX/Y control the order that a tiled 3570 * renderer's tiles should be excecuted, to meet the requirements of 3571 * GL_MESA_tile_raster_order. 3572 */ 3573 GLboolean TileRasterOrderFixed; 3574 GLboolean TileRasterOrderIncreasingX; 3575 GLboolean TileRasterOrderIncreasingY; 3576 3577 /** 3578 * \name Hooks for module contexts. 3579 * 3580 * These will eventually live in the driver or elsewhere. 3581 */ 3582 /*@{*/ 3583 struct vbo_context vbo_context; 3584 struct st_context *st; 3585 struct pipe_screen *screen; 3586 struct pipe_context *pipe; 3587 struct st_config_options *st_opts; 3588 struct cso_context *cso_context; 3589 bool has_invalidate_buffer; 3590 /* On old libGL's for linux we need to invalidate the drawables 3591 * on glViewpport calls, this is set via a option. 3592 */ 3593 bool invalidate_on_gl_viewport; 3594 3595 /*@}*/ 3596 3597 /** 3598 * \name NV_vdpau_interop 3599 */ 3600 /*@{*/ 3601 const void *vdpDevice; 3602 const void *vdpGetProcAddress; 3603 struct set *vdpSurfaces; 3604 /*@}*/ 3605 3606 /** 3607 * Has this context observed a GPU reset in any context in the share group? 3608 * 3609 * Once this field becomes true, it is never reset to false. 3610 */ 3611 GLboolean ShareGroupReset; 3612 3613 /** 3614 * \name OES_primitive_bounding_box 3615 * 3616 * Stores the arguments to glPrimitiveBoundingBox 3617 */ 3618 GLfloat PrimitiveBoundingBox[8]; 3619 3620 struct disk_cache *Cache; 3621 3622 /** 3623 * \name GL_ARB_bindless_texture 3624 */ 3625 /*@{*/ 3626 struct hash_table_u64 *ResidentTextureHandles; 3627 struct hash_table_u64 *ResidentImageHandles; 3628 /*@}*/ 3629 3630 bool shader_builtin_ref; 3631 }; 3632 3633 #ifndef NDEBUG 3634 extern int MESA_VERBOSE; 3635 extern int MESA_DEBUG_FLAGS; 3636 #else 3637 # define MESA_VERBOSE 0 3638 # define MESA_DEBUG_FLAGS 0 3639 #endif 3640 3641 3642 /** The MESA_VERBOSE var is a bitmask of these flags */ 3643 enum _verbose 3644 { 3645 VERBOSE_VARRAY = 0x0001, 3646 VERBOSE_TEXTURE = 0x0002, 3647 VERBOSE_MATERIAL = 0x0004, 3648 VERBOSE_PIPELINE = 0x0008, 3649 VERBOSE_DRIVER = 0x0010, 3650 VERBOSE_STATE = 0x0020, 3651 VERBOSE_API = 0x0040, 3652 VERBOSE_DISPLAY_LIST = 0x0100, 3653 VERBOSE_LIGHTING = 0x0200, 3654 VERBOSE_PRIMS = 0x0400, 3655 VERBOSE_VERTS = 0x0800, 3656 VERBOSE_DISASSEM = 0x1000, 3657 VERBOSE_SWAPBUFFERS = 0x4000 3658 }; 3659 3660 3661 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ 3662 enum _debug 3663 { 3664 DEBUG_SILENT = (1 << 0), 3665 DEBUG_ALWAYS_FLUSH = (1 << 1), 3666 DEBUG_INCOMPLETE_TEXTURE = (1 << 2), 3667 DEBUG_INCOMPLETE_FBO = (1 << 3), 3668 DEBUG_CONTEXT = (1 << 4) 3669 }; 3670 3671 #ifdef __cplusplus 3672 } 3673 #endif 3674 3675 #endif /* MTYPES_H */ 3676