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