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 39 #include "main/glheader.h" 40 #include "main/config.h" 41 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 48 49 /** 50 * \name Some forward type declarations 51 */ 52 /*@{*/ 53 struct gl_context; 54 struct gl_uniform_storage; 55 struct prog_instruction; 56 struct set; 57 struct set_entry; 58 /*@}*/ 59 60 61 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ 62 #define PRIM_MAX GL_TRIANGLE_STRIP_ADJACENCY 63 #define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1) 64 #define PRIM_UNKNOWN (PRIM_MAX + 2) 65 66 67 68 /** 69 * Indexes for vertex program attributes. 70 * GL_NV_vertex_program aliases generic attributes over the conventional 71 * attributes. In GL_ARB_vertex_program shader the aliasing is optional. 72 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the 73 * generic attributes are distinct/separate). 74 */ 75 typedef enum 76 { 77 VERT_ATTRIB_POS = 0, 78 VERT_ATTRIB_WEIGHT = 1, 79 VERT_ATTRIB_NORMAL = 2, 80 VERT_ATTRIB_COLOR0 = 3, 81 VERT_ATTRIB_COLOR1 = 4, 82 VERT_ATTRIB_FOG = 5, 83 VERT_ATTRIB_COLOR_INDEX = 6, 84 VERT_ATTRIB_EDGEFLAG = 7, 85 VERT_ATTRIB_TEX0 = 8, 86 VERT_ATTRIB_TEX1 = 9, 87 VERT_ATTRIB_TEX2 = 10, 88 VERT_ATTRIB_TEX3 = 11, 89 VERT_ATTRIB_TEX4 = 12, 90 VERT_ATTRIB_TEX5 = 13, 91 VERT_ATTRIB_TEX6 = 14, 92 VERT_ATTRIB_TEX7 = 15, 93 VERT_ATTRIB_POINT_SIZE = 16, 94 VERT_ATTRIB_GENERIC0 = 17, 95 VERT_ATTRIB_GENERIC1 = 18, 96 VERT_ATTRIB_GENERIC2 = 19, 97 VERT_ATTRIB_GENERIC3 = 20, 98 VERT_ATTRIB_GENERIC4 = 21, 99 VERT_ATTRIB_GENERIC5 = 22, 100 VERT_ATTRIB_GENERIC6 = 23, 101 VERT_ATTRIB_GENERIC7 = 24, 102 VERT_ATTRIB_GENERIC8 = 25, 103 VERT_ATTRIB_GENERIC9 = 26, 104 VERT_ATTRIB_GENERIC10 = 27, 105 VERT_ATTRIB_GENERIC11 = 28, 106 VERT_ATTRIB_GENERIC12 = 29, 107 VERT_ATTRIB_GENERIC13 = 30, 108 VERT_ATTRIB_GENERIC14 = 31, 109 VERT_ATTRIB_GENERIC15 = 32, 110 VERT_ATTRIB_MAX = 33 111 } gl_vert_attrib; 112 113 /** 114 * Symbolic constats to help iterating over 115 * specific blocks of vertex attributes. 116 * 117 * VERT_ATTRIB_FF 118 * includes all fixed function attributes as well as 119 * the aliased GL_NV_vertex_program shader attributes. 120 * VERT_ATTRIB_TEX 121 * include the classic texture coordinate attributes. 122 * Is a subset of VERT_ATTRIB_FF. 123 * VERT_ATTRIB_GENERIC 124 * include the OpenGL 2.0+ GLSL generic shader attributes. 125 * These alias the generic GL_ARB_vertex_shader attributes. 126 */ 127 #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i)) 128 #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0 129 130 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i)) 131 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS 132 133 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i)) 134 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS 135 136 137 138 139 /** 140 * Indexes for vertex shader outputs, geometry shader inputs/outputs, and 141 * fragment shader inputs. 142 * 143 * Note that some of these values are not available to all pipeline stages. 144 * 145 * When this enum is updated, the following code must be updated too: 146 * - vertResults (in prog_print.c's arb_output_attrib_string()) 147 * - fragAttribs (in prog_print.c's arb_input_attrib_string()) 148 * - _mesa_varying_slot_in_fs() 149 */ 150 typedef enum 151 { 152 VARYING_SLOT_POS, 153 VARYING_SLOT_COL0, /* COL0 and COL1 must be contiguous */ 154 VARYING_SLOT_COL1, 155 VARYING_SLOT_FOGC, 156 VARYING_SLOT_TEX0, /* TEX0-TEX7 must be contiguous */ 157 VARYING_SLOT_TEX1, 158 VARYING_SLOT_TEX2, 159 VARYING_SLOT_TEX3, 160 VARYING_SLOT_TEX4, 161 VARYING_SLOT_TEX5, 162 VARYING_SLOT_TEX6, 163 VARYING_SLOT_TEX7, 164 VARYING_SLOT_PSIZ, /* Does not appear in FS */ 165 VARYING_SLOT_BFC0, /* Does not appear in FS */ 166 VARYING_SLOT_BFC1, /* Does not appear in FS */ 167 VARYING_SLOT_EDGE, /* Does not appear in FS */ 168 VARYING_SLOT_CLIP_VERTEX, /* Does not appear in FS */ 169 VARYING_SLOT_CLIP_DIST0, 170 VARYING_SLOT_CLIP_DIST1, 171 VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */ 172 VARYING_SLOT_LAYER, /* Appears as VS or GS output */ 173 VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */ 174 VARYING_SLOT_FACE, /* FS only */ 175 VARYING_SLOT_PNTC, /* FS only */ 176 VARYING_SLOT_VAR0, /* First generic varying slot */ 177 VARYING_SLOT_MAX = VARYING_SLOT_VAR0 + MAX_VARYING 178 } gl_varying_slot; 179 180 181 /** 182 * Fragment program results 183 */ 184 typedef enum 185 { 186 FRAG_RESULT_DEPTH = 0, 187 FRAG_RESULT_STENCIL = 1, 188 /* If a single color should be written to all render targets, this 189 * register is written. No FRAG_RESULT_DATAn will be written. 190 */ 191 FRAG_RESULT_COLOR = 2, 192 FRAG_RESULT_SAMPLE_MASK = 3, 193 194 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] 195 * or ARB_fragment_program fragment.color[n]) color results. If 196 * any are written, FRAG_RESULT_COLOR will not be written. 197 */ 198 FRAG_RESULT_DATA0 = 4, 199 FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) 200 } gl_frag_result; 201 202 203 /** 204 * Shader stages. Note that these will become 5 with tessellation. 205 * 206 * The order must match how shaders are ordered in the pipeline. 207 * The GLSL linker assumes that if i<j, then the j-th shader is 208 * executed later than the i-th shader. 209 */ 210 typedef enum 211 { 212 MESA_SHADER_VERTEX = 0, 213 MESA_SHADER_GEOMETRY = 1, 214 MESA_SHADER_FRAGMENT = 2, 215 MESA_SHADER_COMPUTE = 3, 216 } gl_shader_stage; 217 218 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1) 219 220 221 222 /*********************************************/ 223 224 /** 225 * Indexes for geometry program attributes. 226 */ 227 typedef enum 228 { 229 GEOM_ATTRIB_VAR0 = 16, 230 GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) 231 } gl_geom_attrib; 232 233 234 235 /** 236 */ 237 typedef enum 238 { 239 FRAG_ATTRIB_WPOS = 0, 240 FRAG_ATTRIB_COL0 = 1, 241 FRAG_ATTRIB_COL1 = 2, 242 FRAG_ATTRIB_FOGC = 3, 243 FRAG_ATTRIB_TEX0 = 4, 244 FRAG_ATTRIB_TEX1 = 5, 245 FRAG_ATTRIB_TEX2 = 6, 246 FRAG_ATTRIB_TEX3 = 7, 247 FRAG_ATTRIB_TEX4 = 8, 248 FRAG_ATTRIB_TEX5 = 9, 249 FRAG_ATTRIB_TEX6 = 10, 250 FRAG_ATTRIB_TEX7 = 11, 251 FRAG_ATTRIB_FACE = 12, /**< front/back face */ 252 FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ 253 FRAG_ATTRIB_CLIP_DIST0 = 14, 254 FRAG_ATTRIB_CLIP_DIST1 = 15, 255 FRAG_ATTRIB_VAR0 = 16, /**< shader varying */ 256 FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) 257 } gl_frag_attrib; 258 259 260 /** 261 * An index for each type of texture object. These correspond to the GL 262 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. 263 * Note: the order is from highest priority to lowest priority. 264 */ 265 typedef enum 266 { 267 TEXTURE_2D_MULTISAMPLE_INDEX, 268 TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX, 269 TEXTURE_CUBE_ARRAY_INDEX, 270 TEXTURE_BUFFER_INDEX, 271 TEXTURE_2D_ARRAY_INDEX, 272 TEXTURE_1D_ARRAY_INDEX, 273 TEXTURE_EXTERNAL_INDEX, 274 TEXTURE_CUBE_INDEX, 275 TEXTURE_3D_INDEX, 276 TEXTURE_RECT_INDEX, 277 TEXTURE_2D_INDEX, 278 TEXTURE_1D_INDEX, 279 NUM_TEXTURE_TARGETS 280 } gl_texture_index; 281 282 283 284 285 286 struct gl_transform_feedback_varying_info 287 { 288 char *Name; 289 GLenum Type; 290 GLint Size; 291 }; 292 293 294 /** 295 * Per-output info vertex shaders for transform feedback. 296 */ 297 struct gl_transform_feedback_output 298 { 299 unsigned OutputRegister; 300 unsigned OutputBuffer; 301 unsigned NumComponents; 302 unsigned StreamId; 303 304 /** offset (in DWORDs) of this output within the interleaved structure */ 305 unsigned DstOffset; 306 307 /** 308 * Offset into the output register of the data to output. For example, 309 * if NumComponents is 2 and ComponentOffset is 1, then the data to 310 * offset is in the y and z components of the output register. 311 */ 312 unsigned ComponentOffset; 313 }; 314 315 316 /** Post-link transform feedback info. */ 317 struct gl_transform_feedback_info 318 { 319 unsigned NumOutputs; 320 321 /** 322 * Number of transform feedback buffers in use by this program. 323 */ 324 unsigned NumBuffers; 325 326 struct gl_transform_feedback_output *Outputs; 327 328 /** Transform feedback varyings used for the linking of this shader program. 329 * 330 * Use for glGetTransformFeedbackVarying(). 331 */ 332 struct gl_transform_feedback_varying_info *Varyings; 333 GLint NumVarying; 334 335 /** 336 * Total number of components stored in each buffer. This may be used by 337 * hardware back-ends to determine the correct stride when interleaving 338 * multiple transform feedback outputs in the same buffer. 339 */ 340 unsigned BufferStride[MAX_FEEDBACK_BUFFERS]; 341 }; 342 343 344 345 /** 346 * Names of the various vertex/fragment program register files, etc. 347 * 348 * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) 349 * All values should fit in a 4-bit field. 350 * 351 * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be 352 * considered to be "uniform" variables since they can only be set outside 353 * glBegin/End. They're also all stored in the same Parameters array. 354 */ 355 typedef enum 356 { 357 PROGRAM_TEMPORARY, /**< machine->Temporary[] */ 358 PROGRAM_ARRAY, /**< Arrays & Matrixes */ 359 PROGRAM_INPUT, /**< machine->Inputs[] */ 360 PROGRAM_OUTPUT, /**< machine->Outputs[] */ 361 PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ 362 PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ 363 PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ 364 PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ 365 PROGRAM_ADDRESS, /**< machine->AddressReg */ 366 PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ 367 PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ 368 PROGRAM_UNDEFINED, /**< Invalid/TBD value */ 369 PROGRAM_FILE_MAX 370 } gl_register_file; 371 372 373 /** 374 * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be 375 * one of these values. 376 */ 377 typedef enum 378 { 379 /** 380 * \name Vertex shader system values 381 */ 382 /*@{*/ 383 /** 384 * OpenGL-style vertex ID. 385 * 386 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the 387 * OpenGL 3.3 core profile spec says: 388 * 389 * "gl_VertexID holds the integer index i implicitly passed by 390 * DrawArrays or one of the other drawing commands defined in section 391 * 2.8.3." 392 * 393 * Section 2.8.3 (Drawing Commands) of the same spec says: 394 * 395 * "The commands....are equivalent to the commands with the same base 396 * name (without the BaseVertex suffix), except that the ith element 397 * transferred by the corresponding draw call will be taken from 398 * element indices[i] + basevertex of each enabled array." 399 * 400 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec 401 * says: 402 * 403 * "In unextended GL, vertex shaders have inputs named gl_VertexID and 404 * gl_InstanceID, which contain, respectively the index of the vertex 405 * and instance. The value of gl_VertexID is the implicitly passed 406 * index of the vertex being processed, which includes the value of 407 * baseVertex, for those commands that accept it." 408 * 409 * gl_VertexID gets basevertex added in. This differs from DirectX where 410 * SV_VertexID does \b not get basevertex added in. 411 * 412 * \note 413 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be 414 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus 415 * \c SYSTEM_VALUE_BASE_VERTEX. 416 * 417 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX 418 */ 419 SYSTEM_VALUE_VERTEX_ID, 420 421 /** 422 * Instanced ID as supplied to gl_InstanceID 423 * 424 * Values assigned to gl_InstanceID always begin with zero, regardless of 425 * the value of baseinstance. 426 * 427 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec 428 * says: 429 * 430 * "gl_InstanceID holds the integer instance number of the current 431 * primitive in an instanced draw call (see section 10.5)." 432 * 433 * Through a big chain of pseudocode, section 10.5 describes that 434 * baseinstance is not counted by gl_InstanceID. In that section, notice 435 * 436 * "If an enabled vertex attribute array is instanced (it has a 437 * non-zero divisor as specified by VertexAttribDivisor), the element 438 * index that is transferred to the GL, for all vertices, is given by 439 * 440 * floor(instance/divisor) + baseinstance 441 * 442 * If an array corresponding to an attribute required by a vertex 443 * shader is not enabled, then the corresponding element is taken from 444 * the current attribute state (see section 10.2)." 445 * 446 * Note that baseinstance is \b not included in the value of instance. 447 */ 448 SYSTEM_VALUE_INSTANCE_ID, 449 450 /** 451 * DirectX-style vertex ID. 452 * 453 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include 454 * the value of basevertex. 455 * 456 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX 457 */ 458 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, 459 460 /** 461 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar 462 * functions. 463 * 464 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE 465 */ 466 SYSTEM_VALUE_BASE_VERTEX, 467 /*@}*/ 468 469 /** 470 * \name Geometry shader system values 471 */ 472 /*@{*/ 473 SYSTEM_VALUE_INVOCATION_ID, 474 /*@}*/ 475 476 /** 477 * \name Fragment shader system values 478 */ 479 /*@{*/ 480 SYSTEM_VALUE_FRONT_FACE, /**< (not done yet) */ 481 SYSTEM_VALUE_SAMPLE_ID, 482 SYSTEM_VALUE_SAMPLE_POS, 483 SYSTEM_VALUE_SAMPLE_MASK_IN, 484 /*@}*/ 485 486 SYSTEM_VALUE_MAX /**< Number of values */ 487 } gl_system_value; 488 489 490 /** 491 * The possible interpolation qualifiers that can be applied to a fragment 492 * shader input in GLSL. 493 * 494 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the 495 * gl_fragment_program data structure to 0 causes the default behavior. 496 */ 497 enum glsl_interp_qualifier 498 { 499 INTERP_QUALIFIER_NONE = 0, 500 INTERP_QUALIFIER_SMOOTH, 501 INTERP_QUALIFIER_FLAT, 502 INTERP_QUALIFIER_NOPERSPECTIVE, 503 INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */ 504 }; 505 506 507 /** 508 * \brief Layout qualifiers for gl_FragDepth. 509 * 510 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with 511 * a layout qualifier. 512 * 513 * \see enum ir_depth_layout 514 */ 515 enum gl_frag_depth_layout 516 { 517 FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ 518 FRAG_DEPTH_LAYOUT_ANY, 519 FRAG_DEPTH_LAYOUT_GREATER, 520 FRAG_DEPTH_LAYOUT_LESS, 521 FRAG_DEPTH_LAYOUT_UNCHANGED 522 }; 523 524 525 /** 526 * Base class for any kind of program object 527 */ 528 struct gl_program 529 { 530 GLuint Id; 531 GLubyte *String; /**< Null-terminated program text */ 532 GLint RefCount; 533 GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */ 534 GLenum Format; /**< String encoding format */ 535 536 /** 537 * Local parameters used by the program. 538 * 539 * It's dynamically allocated because it is rarely used (just 540 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries once it's 541 * allocated. 542 */ 543 GLfloat (*LocalParams)[4]; 544 545 /** Map from sampler unit to texture unit (set by glUniform1i()) */ 546 GLubyte SamplerUnits[MAX_SAMPLERS]; 547 548 /** Bitmask of which register files are read/written with indirect 549 * addressing. Mask of (1 << PROGRAM_x) bits. 550 */ 551 GLbitfield IndirectRegisterFiles; 552 553 /** Logical counts */ 554 /*@{*/ 555 GLuint NumInstructions; 556 GLuint NumTemporaries; 557 GLuint NumParameters; 558 GLuint NumAttributes; 559 GLuint NumAddressRegs; 560 GLuint NumAluInstructions; 561 GLuint NumTexInstructions; 562 GLuint NumTexIndirections; 563 /*@}*/ 564 /** Native, actual h/w counts */ 565 /*@{*/ 566 GLuint NumNativeInstructions; 567 GLuint NumNativeTemporaries; 568 GLuint NumNativeParameters; 569 GLuint NumNativeAttributes; 570 GLuint NumNativeAddressRegs; 571 GLuint NumNativeAluInstructions; 572 GLuint NumNativeTexInstructions; 573 GLuint NumNativeTexIndirections; 574 /*@}*/ 575 }; 576 577 578 579 /** Set by #pragma directives */ 580 struct gl_sl_pragmas 581 { 582 GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ 583 GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ 584 GLboolean Optimize; /**< defaults on */ 585 GLboolean Debug; /**< defaults off */ 586 }; 587 588 589 /** 590 * A GLSL vertex or fragment shader object. 591 */ 592 struct gl_shader 593 { 594 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB. 595 * Must be the first field. 596 */ 597 GLenum Type; 598 gl_shader_stage Stage; 599 GLuint Name; /**< AKA the handle */ 600 GLchar *Label; /**< GL_KHR_debug */ 601 GLint RefCount; /**< Reference count */ 602 GLboolean DeletePending; 603 GLboolean CompileStatus; 604 const char *Source; /**< Source code string */ 605 GLuint SourceChecksum; /**< for debug/logging purposes */ 606 struct gl_program *Program; /**< Post-compile assembly code */ 607 char *InfoLog; 608 struct gl_sl_pragmas Pragmas; 609 610 unsigned Version; /**< GLSL version used for linking */ 611 GLboolean IsES; /**< True if this shader uses GLSL ES */ 612 613 /** 614 * \name Sampler tracking 615 * 616 * \note Each of these fields is only set post-linking. 617 */ 618 /*@{*/ 619 unsigned num_samplers; /**< Number of samplers used by this shader. */ 620 GLbitfield active_samplers; /**< Bitfield of which samplers are used */ 621 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */ 622 /*@}*/ 623 624 /** 625 * Map from sampler unit to texture unit (set by glUniform1i()) 626 * 627 * A sampler unit is associated with each sampler uniform by the linker. 628 * The sampler unit associated with each uniform is stored in the 629 * \c gl_uniform_storage::sampler field. 630 */ 631 GLubyte SamplerUnits[MAX_SAMPLERS]; 632 /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ 633 gl_texture_index SamplerTargets[MAX_SAMPLERS]; 634 635 /** 636 * Number of default uniform block components used by this shader. 637 * 638 * This field is only set post-linking. 639 */ 640 unsigned num_uniform_components; 641 642 /** 643 * Number of combined uniform components used by this shader. 644 * 645 * This field is only set post-linking. It is the sum of the uniform block 646 * sizes divided by sizeof(float), and num_uniform_compoennts. 647 */ 648 unsigned num_combined_uniform_components; 649 650 /** 651 * This shader's uniform block information. 652 * 653 * These fields are only set post-linking. 654 */ 655 struct gl_uniform_block *UniformBlocks; 656 unsigned NumUniformBlocks; 657 658 struct exec_list *ir; 659 struct glsl_symbol_table *symbols; 660 661 bool uses_builtin_functions; 662 bool uses_gl_fragcoord; 663 bool redeclares_gl_fragcoord; 664 bool ARB_fragment_coord_conventions_enable; 665 666 /** 667 * Fragment shader state from GLSL 1.50 layout qualifiers. 668 */ 669 bool origin_upper_left; 670 bool pixel_center_integer; 671 672 /** 673 * Geometry shader state from GLSL 1.50 layout qualifiers. 674 */ 675 struct { 676 GLint VerticesOut; 677 /** 678 * 0 - Invocations count not declared in shader, or 679 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS 680 */ 681 GLint Invocations; 682 /** 683 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or 684 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this 685 * shader. 686 */ 687 GLenum InputType; 688 /** 689 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if 690 * it's not set in this shader. 691 */ 692 GLenum OutputType; 693 } Geom; 694 695 /** 696 * Map from image uniform index to image unit (set by glUniform1i()) 697 * 698 * An image uniform index is associated with each image uniform by 699 * the linker. The image index associated with each uniform is 700 * stored in the \c gl_uniform_storage::image field. 701 */ 702 GLubyte ImageUnits[MAX_IMAGE_UNIFORMS]; 703 704 /** 705 * Access qualifier specified in the shader for each image uniform 706 * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c 707 * GL_READ_WRITE. 708 * 709 * It may be different, though only more strict than the value of 710 * \c gl_image_unit::Access for the corresponding image unit. 711 */ 712 GLenum ImageAccess[MAX_IMAGE_UNIFORMS]; 713 714 /** 715 * Number of image uniforms defined in the shader. It specifies 716 * the number of valid elements in the \c ImageUnits and \c 717 * ImageAccess arrays above. 718 */ 719 GLuint NumImages; 720 721 /** 722 * Compute shader state from ARB_compute_shader layout qualifiers. 723 */ 724 struct { 725 /** 726 * Size specified using local_size_{x,y,z}, or all 0's to indicate that 727 * it's not set in this shader. 728 */ 729 unsigned LocalSize[3]; 730 } Comp; 731 }; 732 733 734 struct gl_uniform_buffer_variable 735 { 736 char *Name; 737 738 /** 739 * Name of the uniform as seen by glGetUniformIndices. 740 * 741 * glGetUniformIndices requires that the block instance index \b not be 742 * present in the name of queried uniforms. 743 * 744 * \note 745 * \c gl_uniform_buffer_variable::IndexName and 746 * \c gl_uniform_buffer_variable::Name may point to identical storage. 747 */ 748 char *IndexName; 749 750 const struct glsl_type *Type; 751 unsigned int Offset; 752 GLboolean RowMajor; 753 }; 754 755 756 enum gl_uniform_block_packing 757 { 758 ubo_packing_std140, 759 ubo_packing_shared, 760 ubo_packing_packed 761 }; 762 763 764 struct gl_uniform_block 765 { 766 /** Declared name of the uniform block */ 767 char *Name; 768 769 /** Array of supplemental information about UBO ir_variables. */ 770 struct gl_uniform_buffer_variable *Uniforms; 771 GLuint NumUniforms; 772 773 /** 774 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use 775 * with glBindBufferBase to bind a buffer object to this uniform block. When 776 * updated in the program, _NEW_BUFFER_OBJECT will be set. 777 */ 778 GLuint Binding; 779 780 /** 781 * Minimum size (in bytes) of a buffer object to back this uniform buffer 782 * (GL_UNIFORM_BLOCK_DATA_SIZE). 783 */ 784 GLuint UniformBufferSize; 785 786 /** 787 * Layout specified in the shader 788 * 789 * This isn't accessible through the API, but it is used while 790 * cross-validating uniform blocks. 791 */ 792 enum gl_uniform_block_packing _Packing; 793 }; 794 795 /** 796 * Structure that represents a reference to an atomic buffer from some 797 * shader program. 798 */ 799 struct gl_active_atomic_buffer 800 { 801 /** Uniform indices of the atomic counters declared within it. */ 802 GLuint *Uniforms; 803 GLuint NumUniforms; 804 805 /** Binding point index associated with it. */ 806 GLuint Binding; 807 808 /** Minimum reasonable size it is expected to have. */ 809 GLuint MinimumSize; 810 811 /** Shader stages making use of it. */ 812 GLboolean StageReferences[MESA_SHADER_STAGES]; 813 }; 814 815 /** 816 * A GLSL program object. 817 * Basically a linked collection of vertex and fragment shaders. 818 */ 819 struct gl_shader_program 820 { 821 GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ 822 GLuint Name; /**< aka handle or ID */ 823 GLchar *Label; /**< GL_KHR_debug */ 824 GLint RefCount; /**< Reference count */ 825 GLboolean DeletePending; 826 827 /** 828 * Is the application intending to glGetProgramBinary this program? 829 */ 830 GLboolean BinaryRetreivableHint; 831 832 /** 833 * Indicates whether program can be bound for individual pipeline stages 834 * using UseProgramStages after it is next linked. 835 */ 836 GLboolean SeparateShader; 837 838 GLuint NumShaders; /**< number of attached shaders */ 839 struct gl_shader **Shaders; /**< List of attached the shaders */ 840 841 /** 842 * User-defined attribute bindings 843 * 844 * These are set via \c glBindAttribLocation and are used to direct the 845 * GLSL linker. These are \b not the values used in the compiled shader, 846 * and they are \b not the values returned by \c glGetAttribLocation. 847 */ 848 struct string_to_uint_map *AttributeBindings; 849 850 /** 851 * User-defined fragment data bindings 852 * 853 * These are set via \c glBindFragDataLocation and are used to direct the 854 * GLSL linker. These are \b not the values used in the compiled shader, 855 * and they are \b not the values returned by \c glGetFragDataLocation. 856 */ 857 struct string_to_uint_map *FragDataBindings; 858 struct string_to_uint_map *FragDataIndexBindings; 859 860 /** 861 * Transform feedback varyings last specified by 862 * glTransformFeedbackVaryings(). 863 * 864 * For the current set of transform feeedback varyings used for transform 865 * feedback output, see LinkedTransformFeedback. 866 */ 867 struct { 868 GLenum BufferMode; 869 GLuint NumVarying; 870 char **VaryingNames; /**< Array [NumVarying] of char * */ 871 } TransformFeedback; 872 873 /** Post-link transform feedback info. */ 874 struct gl_transform_feedback_info LinkedTransformFeedback; 875 876 /** Post-link gl_FragDepth layout for ARB_conservative_depth. */ 877 enum gl_frag_depth_layout FragDepthLayout; 878 879 /** 880 * Geometry shader state - copied into gl_geometry_program by 881 * _mesa_copy_linked_program_data(). 882 */ 883 struct { 884 GLint VerticesIn; 885 GLint VerticesOut; 886 /** 887 * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS 888 */ 889 GLint Invocations; 890 GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, 891 GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ 892 GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ 893 /** 894 * True if gl_ClipDistance is written to. Copied into 895 * gl_geometry_program by _mesa_copy_linked_program_data(). 896 */ 897 GLboolean UsesClipDistance; 898 GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or 899 0 if not present. */ 900 bool UsesEndPrimitive; 901 bool UsesStreams; 902 } Geom; 903 904 /** Vertex shader state */ 905 struct { 906 /** 907 * True if gl_ClipDistance is written to. Copied into gl_vertex_program 908 * by _mesa_copy_linked_program_data(). 909 */ 910 GLboolean UsesClipDistance; 911 GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or 912 0 if not present. */ 913 } Vert; 914 915 /** 916 * Compute shader state - copied into gl_compute_program by 917 * _mesa_copy_linked_program_data(). 918 */ 919 struct { 920 /** 921 * If this shader contains a compute stage, size specified using 922 * local_size_{x,y,z}. Otherwise undefined. 923 */ 924 unsigned LocalSize[3]; 925 } Comp; 926 927 /* post-link info: */ 928 unsigned NumUserUniformStorage; 929 struct gl_uniform_storage *UniformStorage; 930 931 /** 932 * Mapping from GL uniform locations returned by \c glUniformLocation to 933 * UniformStorage entries. Arrays will have multiple contiguous slots 934 * in the UniformRemapTable, all pointing to the same UniformStorage entry. 935 */ 936 unsigned NumUniformRemapTable; 937 struct gl_uniform_storage **UniformRemapTable; 938 939 /** 940 * Size of the gl_ClipDistance array that is output from the last pipeline 941 * stage before the fragment shader. 942 */ 943 unsigned LastClipDistanceArraySize; 944 945 struct gl_uniform_block *UniformBlocks; 946 unsigned NumUniformBlocks; 947 948 /** 949 * Indices into the _LinkedShaders's UniformBlocks[] array for each stage 950 * they're used in, or -1. 951 * 952 * This is used to maintain the Binding values of the stage's UniformBlocks[] 953 * and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries. 954 */ 955 int *UniformBlockStageIndex[MESA_SHADER_STAGES]; 956 957 /** 958 * Map of active uniform names to locations 959 * 960 * Maps any active uniform that is not an array element to a location. 961 * Each active uniform, including individual structure members will appear 962 * in this map. This roughly corresponds to the set of names that would be 963 * enumerated by \c glGetActiveUniform. 964 */ 965 struct string_to_uint_map *UniformHash; 966 967 struct gl_active_atomic_buffer *AtomicBuffers; 968 unsigned NumAtomicBuffers; 969 970 GLboolean LinkStatus; /**< GL_LINK_STATUS */ 971 GLboolean Validated; 972 GLboolean _Used; /**< Ever used for drawing? */ 973 GLchar *InfoLog; 974 975 unsigned Version; /**< GLSL version used for linking */ 976 GLboolean IsES; /**< True if this program uses GLSL ES */ 977 978 /** 979 * Per-stage shaders resulting from the first stage of linking. 980 * 981 * Set of linked shaders for this program. The array is accessed using the 982 * \c MESA_SHADER_* defines. Entries for non-existent stages will be 983 * \c NULL. 984 */ 985 struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES]; 986 987 /* True if any of the fragment shaders attached to this program use: 988 * #extension ARB_fragment_coord_conventions: enable 989 */ 990 GLboolean ARB_fragment_coord_conventions_enable; 991 }; 992 993 994 995 /** 996 * Compiler options for a single GLSL shaders type 997 */ 998 struct gl_shader_compiler_options 999 { 1000 /** Driver-selectable options: */ 1001 GLboolean EmitCondCodes; /**< Use condition codes? */ 1002 GLboolean EmitNoLoops; 1003 GLboolean EmitNoFunctions; 1004 GLboolean EmitNoCont; /**< Emit CONT opcode? */ 1005 GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ 1006 GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ 1007 GLboolean EmitNoPow; /**< Emit POW opcodes? */ 1008 GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */ 1009 1010 /** 1011 * \name Forms of indirect addressing the driver cannot do. 1012 */ 1013 /*@{*/ 1014 GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ 1015 GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ 1016 GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ 1017 GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ 1018 /*@}*/ 1019 1020 GLuint MaxIfDepth; /**< Maximum nested IF blocks */ 1021 GLuint MaxUnrollIterations; 1022 1023 /** 1024 * Optimize code for array of structures backends. 1025 * 1026 * This is a proxy for: 1027 * - preferring DP4 instructions (rather than MUL/MAD) for 1028 * matrix * vector operations, such as position transformation. 1029 */ 1030 GLboolean OptimizeForAOS; 1031 1032 struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ 1033 }; 1034 1035 1036 1037 1038 /** 1039 * Limits for vertex, geometry and fragment programs/shaders. 1040 */ 1041 struct gl_program_constants 1042 { 1043 /* logical limits */ 1044 GLuint MaxInstructions; 1045 GLuint MaxAluInstructions; 1046 GLuint MaxTexInstructions; 1047 GLuint MaxTexIndirections; 1048 GLuint MaxAttribs; 1049 GLuint MaxTemps; 1050 GLuint MaxAddressRegs; 1051 GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */ 1052 GLuint MaxParameters; 1053 GLuint MaxLocalParams; 1054 GLuint MaxEnvParams; 1055 /* native/hardware limits */ 1056 GLuint MaxNativeInstructions; 1057 GLuint MaxNativeAluInstructions; 1058 GLuint MaxNativeTexInstructions; 1059 GLuint MaxNativeTexIndirections; 1060 GLuint MaxNativeAttribs; 1061 GLuint MaxNativeTemps; 1062 GLuint MaxNativeAddressRegs; 1063 GLuint MaxNativeParameters; 1064 /* For shaders */ 1065 GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */ 1066 1067 /** 1068 * \name Per-stage input / output limits 1069 * 1070 * Previous to OpenGL 3.2, the intrastage data limits were advertised with 1071 * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in 1072 * ES). This is stored as \c gl_constants::MaxVarying. 1073 * 1074 * Starting with OpenGL 3.2, the limits are advertised with per-stage 1075 * variables. Each stage as a certain number of outputs that it can feed 1076 * to the next stage and a certain number inputs that it can consume from 1077 * the previous stage. 1078 * 1079 * Vertex shader inputs do not participate this in this accounting. 1080 * These are tracked exclusively by \c gl_program_constants::MaxAttribs. 1081 * 1082 * Fragment shader outputs do not participate this in this accounting. 1083 * These are tracked exclusively by \c gl_constants::MaxDrawBuffers. 1084 */ 1085 /*@{*/ 1086 GLuint MaxInputComponents; 1087 GLuint MaxOutputComponents; 1088 /*@}*/ 1089 1090 /* GL_ARB_uniform_buffer_object */ 1091 GLuint MaxUniformBlocks; 1092 GLuint MaxCombinedUniformComponents; 1093 GLuint MaxTextureImageUnits; 1094 1095 /* GL_ARB_shader_atomic_counters */ 1096 GLuint MaxAtomicBuffers; 1097 GLuint MaxAtomicCounters; 1098 1099 /* GL_ARB_shader_image_load_store */ 1100 GLuint MaxImageUniforms; 1101 }; 1102 1103 1104 /** 1105 * Constants which may be overridden by device driver during context creation 1106 * but are never changed after that. 1107 */ 1108 struct gl_constants 1109 { 1110 GLuint MaxTextureMbytes; /**< Max memory per image, in MB */ 1111 GLuint MaxTextureLevels; /**< Max mipmap levels. */ 1112 GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ 1113 GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ 1114 GLuint MaxArrayTextureLayers; /**< Max layers in array textures */ 1115 GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ 1116 GLuint MaxTextureCoordUnits; 1117 GLuint MaxCombinedTextureImageUnits; 1118 GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */ 1119 GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ 1120 GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ 1121 GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */ 1122 1123 GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */ 1124 1125 GLuint MaxArrayLockSize; 1126 1127 GLint SubPixelBits; 1128 1129 GLfloat MinPointSize, MaxPointSize; /**< aliased */ 1130 GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ 1131 GLfloat PointSizeGranularity; 1132 GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ 1133 GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ 1134 GLfloat LineWidthGranularity; 1135 1136 GLuint MaxClipPlanes; 1137 GLuint MaxLights; 1138 GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ 1139 GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ 1140 1141 GLuint MaxViewportWidth, MaxViewportHeight; 1142 GLuint MaxViewports; /**< GL_ARB_viewport_array */ 1143 GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */ 1144 struct { 1145 GLfloat Min; 1146 GLfloat Max; 1147 } ViewportBounds; /**< GL_ARB_viewport_array */ 1148 1149 struct gl_program_constants Program[MESA_SHADER_STAGES]; 1150 GLuint MaxProgramMatrices; 1151 GLuint MaxProgramMatrixStackDepth; 1152 1153 struct { 1154 GLuint SamplesPassed; 1155 GLuint TimeElapsed; 1156 GLuint Timestamp; 1157 GLuint PrimitivesGenerated; 1158 GLuint PrimitivesWritten; 1159 } QueryCounterBits; 1160 1161 GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ 1162 1163 GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ 1164 GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ 1165 GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ 1166 1167 /** Number of varying vectors between any two shader stages. */ 1168 GLuint MaxVarying; 1169 1170 /** @{ 1171 * GL_ARB_uniform_buffer_object 1172 */ 1173 GLuint MaxCombinedUniformBlocks; 1174 GLuint MaxUniformBufferBindings; 1175 GLuint MaxUniformBlockSize; 1176 GLuint UniformBufferOffsetAlignment; 1177 /** @} */ 1178 1179 /** 1180 * GL_ARB_explicit_uniform_location 1181 */ 1182 GLuint MaxUserAssignableUniformLocations; 1183 1184 /** GL_ARB_geometry_shader4 */ 1185 GLuint MaxGeometryOutputVertices; 1186 GLuint MaxGeometryTotalOutputComponents; 1187 1188 GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */ 1189 1190 /** 1191 * Changes default GLSL extension behavior from "error" to "warn". It's out 1192 * of spec, but it can make some apps work that otherwise wouldn't. 1193 */ 1194 GLboolean ForceGLSLExtensionsWarn; 1195 1196 /** 1197 * If non-zero, forces GLSL shaders without the #version directive to behave 1198 * as if they began with "#version ForceGLSLVersion". 1199 */ 1200 GLuint ForceGLSLVersion; 1201 1202 /** 1203 * Allow GLSL #extension directives in the middle of shaders. 1204 */ 1205 GLboolean AllowGLSLExtensionDirectiveMidShader; 1206 1207 /** 1208 * Does the driver support real 32-bit integers? (Otherwise, integers are 1209 * simulated via floats.) 1210 */ 1211 GLboolean NativeIntegers; 1212 1213 /** 1214 * Does VertexID count from zero or from base vertex? 1215 * 1216 * \note 1217 * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is 1218 * ignored and need not be set. 1219 */ 1220 bool VertexID_is_zero_based; 1221 1222 /** 1223 * If the driver supports real 32-bit integers, what integer value should be 1224 * used for boolean true in uniform uploads? (Usually 1 or ~0.) 1225 */ 1226 GLuint UniformBooleanTrue; 1227 1228 /** 1229 * Maximum amount of time, measured in nanseconds, that the server can wait. 1230 */ 1231 GLuint64 MaxServerWaitTimeout; 1232 1233 /** GL_EXT_provoking_vertex */ 1234 GLboolean QuadsFollowProvokingVertexConvention; 1235 1236 /** OpenGL version 3.0 */ 1237 GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ 1238 1239 /** OpenGL version 3.2 */ 1240 GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ 1241 1242 /** OpenGL version 4.4 */ 1243 GLuint MaxVertexAttribStride; 1244 1245 /** GL_EXT_transform_feedback */ 1246 GLuint MaxTransformFeedbackBuffers; 1247 GLuint MaxTransformFeedbackSeparateComponents; 1248 GLuint MaxTransformFeedbackInterleavedComponents; 1249 GLuint MaxVertexStreams; 1250 1251 /** GL_EXT_gpu_shader4 */ 1252 GLint MinProgramTexelOffset, MaxProgramTexelOffset; 1253 1254 /** GL_ARB_texture_gather */ 1255 GLuint MinProgramTextureGatherOffset; 1256 GLuint MaxProgramTextureGatherOffset; 1257 GLuint MaxProgramTextureGatherComponents; 1258 1259 /* GL_ARB_robustness */ 1260 GLenum ResetStrategy; 1261 1262 /* GL_ARB_blend_func_extended */ 1263 GLuint MaxDualSourceDrawBuffers; 1264 1265 /** 1266 * Whether the implementation strips out and ignores texture borders. 1267 * 1268 * Many GPU hardware implementations don't support rendering with texture 1269 * borders and mipmapped textures. (Note: not static border color, but the 1270 * old 1-pixel border around each edge). Implementations then have to do 1271 * slow fallbacks to be correct, or just ignore the border and be fast but 1272 * wrong. Setting the flag strips the border off of TexImage calls, 1273 * providing "fast but wrong" at significantly reduced driver complexity. 1274 * 1275 * Texture borders are deprecated in GL 3.0. 1276 **/ 1277 GLboolean StripTextureBorder; 1278 1279 /** 1280 * For drivers which can do a better job at eliminating unused uniforms 1281 * than the GLSL compiler. 1282 * 1283 * XXX Remove these as soon as a better solution is available. 1284 */ 1285 GLboolean GLSLSkipStrictMaxUniformLimitCheck; 1286 1287 /** 1288 * Always use the GetTransformFeedbackVertexCount() driver hook, rather 1289 * than passing the transform feedback object to the drawing function. 1290 */ 1291 GLboolean AlwaysUseGetTransformFeedbackVertexCount; 1292 1293 /** GL_ARB_map_buffer_alignment */ 1294 GLuint MinMapBufferAlignment; 1295 1296 /** 1297 * Disable varying packing. This is out of spec, but potentially useful 1298 * for older platforms that supports a limited number of texture 1299 * indirections--on these platforms, unpacking the varyings in the fragment 1300 * shader increases the number of texture indirections by 1, which might 1301 * make some shaders not executable at all. 1302 * 1303 * Drivers that support transform feedback must set this value to GL_FALSE. 1304 */ 1305 GLboolean DisableVaryingPacking; 1306 1307 /** 1308 * Should meaningful names be generated for compiler temporary variables? 1309 * 1310 * Generally, it is not useful to have the compiler generate "meaningful" 1311 * names for temporary variables that it creates. This can, however, be a 1312 * useful debugging aid. In Mesa debug builds or release builds when 1313 * MESA_GLSL is set at run-time, meaningful names will be generated. 1314 * Drivers can also force names to be generated by setting this field. 1315 * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump 1316 * vertex shader assembly) is set at run-time. 1317 */ 1318 bool GenerateTemporaryNames; 1319 1320 /** 1321 * Disable interpretation of line continuations (lines ending with a 1322 * backslash character ('\') in GLSL source. 1323 */ 1324 GLboolean DisableGLSLLineContinuations; 1325 1326 /** GL_ARB_texture_multisample */ 1327 GLint MaxColorTextureSamples; 1328 GLint MaxDepthTextureSamples; 1329 GLint MaxIntegerSamples; 1330 1331 /** 1332 * GL_EXT_texture_multisample_blit_scaled implementation assumes that 1333 * samples are laid out in a rectangular grid roughly corresponding to 1334 * sample locations within a pixel. Below SampleMap{2,4,8}x variables 1335 * are used to map indices of rectangular grid to sample numbers within 1336 * a pixel. This mapping of indices to sample numbers must be initialized 1337 * by the driver for the target hardware. For example, if we have the 8X 1338 * MSAA sample number layout (sample positions) for XYZ hardware: 1339 * 1340 * sample indices layout sample number layout 1341 * --------- --------- 1342 * | 0 | 1 | | a | b | 1343 * --------- --------- 1344 * | 2 | 3 | | c | d | 1345 * --------- --------- 1346 * | 4 | 5 | | e | f | 1347 * --------- --------- 1348 * | 6 | 7 | | g | h | 1349 * --------- --------- 1350 * 1351 * Where a,b,c,d,e,f,g,h are integers between [0-7]. 1352 * 1353 * Then, initialize the SampleMap8x variable for XYZ hardware as shown 1354 * below: 1355 * SampleMap8x = {a, b, c, d, e, f, g, h}; 1356 * 1357 * Follow the logic for other sample counts. 1358 */ 1359 uint8_t SampleMap2x[2]; 1360 uint8_t SampleMap4x[4]; 1361 uint8_t SampleMap8x[8]; 1362 1363 /** GL_ARB_shader_atomic_counters */ 1364 GLuint MaxAtomicBufferBindings; 1365 GLuint MaxAtomicBufferSize; 1366 GLuint MaxCombinedAtomicBuffers; 1367 GLuint MaxCombinedAtomicCounters; 1368 1369 /** GL_ARB_vertex_attrib_binding */ 1370 GLint MaxVertexAttribRelativeOffset; 1371 GLint MaxVertexAttribBindings; 1372 1373 /* GL_ARB_shader_image_load_store */ 1374 GLuint MaxImageUnits; 1375 GLuint MaxCombinedImageUnitsAndFragmentOutputs; 1376 GLuint MaxImageSamples; 1377 GLuint MaxCombinedImageUniforms; 1378 1379 /** GL_ARB_compute_shader */ 1380 GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */ 1381 GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */ 1382 GLuint MaxComputeWorkGroupInvocations; 1383 1384 /** GL_ARB_gpu_shader5 */ 1385 GLfloat MinFragmentInterpolationOffset; 1386 GLfloat MaxFragmentInterpolationOffset; 1387 1388 GLboolean FakeSWMSAA; 1389 1390 struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES]; 1391 }; 1392 1393 1394 /** 1395 * Enable flag for each OpenGL extension. Different device drivers will 1396 * enable different extensions at runtime. 1397 */ 1398 struct gl_extensions 1399 { 1400 GLboolean dummy; /* don't remove this! */ 1401 GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ 1402 GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ 1403 GLboolean ANGLE_texture_compression_dxt; 1404 GLboolean ARB_ES2_compatibility; 1405 GLboolean ARB_ES3_compatibility; 1406 GLboolean ARB_arrays_of_arrays; 1407 GLboolean ARB_base_instance; 1408 GLboolean ARB_blend_func_extended; 1409 GLboolean ARB_buffer_storage; 1410 GLboolean ARB_clear_texture; 1411 GLboolean ARB_color_buffer_float; 1412 GLboolean ARB_compute_shader; 1413 GLboolean ARB_conditional_render_inverted; 1414 GLboolean ARB_conservative_depth; 1415 GLboolean ARB_copy_image; 1416 GLboolean ARB_depth_buffer_float; 1417 GLboolean ARB_depth_clamp; 1418 GLboolean ARB_depth_texture; 1419 GLboolean ARB_derivative_control; 1420 GLboolean ARB_draw_buffers_blend; 1421 GLboolean ARB_draw_elements_base_vertex; 1422 GLboolean ARB_draw_indirect; 1423 GLboolean ARB_draw_instanced; 1424 GLboolean ARB_fragment_coord_conventions; 1425 GLboolean ARB_fragment_layer_viewport; 1426 GLboolean ARB_fragment_program; 1427 GLboolean ARB_fragment_program_shadow; 1428 GLboolean ARB_fragment_shader; 1429 GLboolean ARB_framebuffer_object; 1430 GLboolean ARB_explicit_attrib_location; 1431 GLboolean ARB_explicit_uniform_location; 1432 GLboolean ARB_geometry_shader4; 1433 GLboolean ARB_gpu_shader5; 1434 GLboolean ARB_half_float_pixel; 1435 GLboolean ARB_half_float_vertex; 1436 GLboolean ARB_instanced_arrays; 1437 GLboolean ARB_internalformat_query; 1438 GLboolean ARB_map_buffer_alignment; 1439 GLboolean ARB_map_buffer_range; 1440 GLboolean ARB_occlusion_query; 1441 GLboolean ARB_occlusion_query2; 1442 GLboolean ARB_point_sprite; 1443 GLboolean ARB_sample_shading; 1444 GLboolean ARB_seamless_cube_map; 1445 GLboolean ARB_shader_atomic_counters; 1446 GLboolean ARB_shader_bit_encoding; 1447 GLboolean ARB_shader_image_load_store; 1448 GLboolean ARB_shader_stencil_export; 1449 GLboolean ARB_shader_texture_lod; 1450 GLboolean ARB_shading_language_packing; 1451 GLboolean ARB_shading_language_420pack; 1452 GLboolean ARB_shadow; 1453 GLboolean ARB_stencil_texturing; 1454 GLboolean ARB_sync; 1455 GLboolean ARB_texture_border_clamp; 1456 GLboolean ARB_texture_buffer_object; 1457 GLboolean ARB_texture_buffer_object_rgb32; 1458 GLboolean ARB_texture_buffer_range; 1459 GLboolean ARB_texture_compression_bptc; 1460 GLboolean ARB_texture_compression_rgtc; 1461 GLboolean ARB_texture_cube_map; 1462 GLboolean ARB_texture_cube_map_array; 1463 GLboolean ARB_texture_env_combine; 1464 GLboolean ARB_texture_env_crossbar; 1465 GLboolean ARB_texture_env_dot3; 1466 GLboolean ARB_texture_float; 1467 GLboolean ARB_texture_gather; 1468 GLboolean ARB_texture_mirror_clamp_to_edge; 1469 GLboolean ARB_texture_multisample; 1470 GLboolean ARB_texture_non_power_of_two; 1471 GLboolean ARB_texture_stencil8; 1472 GLboolean ARB_texture_query_levels; 1473 GLboolean ARB_texture_query_lod; 1474 GLboolean ARB_texture_rg; 1475 GLboolean ARB_texture_rgb10_a2ui; 1476 GLboolean ARB_texture_view; 1477 GLboolean ARB_timer_query; 1478 GLboolean ARB_transform_feedback2; 1479 GLboolean ARB_transform_feedback3; 1480 GLboolean ARB_transform_feedback_instanced; 1481 GLboolean ARB_uniform_buffer_object; 1482 GLboolean ARB_vertex_program; 1483 GLboolean ARB_vertex_shader; 1484 GLboolean ARB_vertex_type_10f_11f_11f_rev; 1485 GLboolean ARB_vertex_type_2_10_10_10_rev; 1486 GLboolean ARB_viewport_array; 1487 GLboolean EXT_blend_color; 1488 GLboolean EXT_blend_equation_separate; 1489 GLboolean EXT_blend_func_separate; 1490 GLboolean EXT_blend_minmax; 1491 GLboolean EXT_depth_bounds_test; 1492 GLboolean EXT_draw_buffers; 1493 GLboolean EXT_draw_buffers2; 1494 GLboolean EXT_draw_instanced; 1495 GLboolean EXT_framebuffer_blit; 1496 GLboolean EXT_framebuffer_multisample; 1497 GLboolean EXT_framebuffer_multisample_blit_scaled; 1498 GLboolean EXT_framebuffer_sRGB; 1499 GLboolean EXT_gpu_program_parameters; 1500 GLboolean EXT_gpu_shader4; 1501 GLboolean EXT_packed_float; 1502 GLboolean EXT_pixel_buffer_object; 1503 GLboolean EXT_point_parameters; 1504 GLboolean EXT_provoking_vertex; 1505 GLboolean EXT_shader_integer_mix; 1506 GLboolean EXT_stencil_two_side; 1507 GLboolean EXT_texture3D; 1508 GLboolean EXT_texture_array; 1509 GLboolean EXT_texture_compression_latc; 1510 GLboolean EXT_texture_compression_s3tc; 1511 GLboolean EXT_texture_env_dot3; 1512 GLboolean EXT_texture_filter_anisotropic; 1513 GLboolean EXT_texture_integer; 1514 GLboolean EXT_texture_mirror_clamp; 1515 GLboolean EXT_texture_shared_exponent; 1516 GLboolean EXT_texture_snorm; 1517 GLboolean EXT_texture_sRGB; 1518 GLboolean EXT_texture_sRGB_decode; 1519 GLboolean EXT_texture_swizzle; 1520 GLboolean EXT_transform_feedback; 1521 GLboolean EXT_timer_query; 1522 GLboolean EXT_vertex_array_bgra; 1523 GLboolean OES_standard_derivatives; 1524 GLboolean EXT_shadow_samplers; 1525 GLboolean EXT_frag_depth; 1526 GLboolean EXT_shader_framebuffer_fetch; 1527 /* vendor extensions */ 1528 GLboolean AMD_performance_monitor; 1529 GLboolean AMD_seamless_cubemap_per_texture; 1530 GLboolean AMD_shader_trinary_minmax; 1531 GLboolean AMD_vertex_shader_layer; 1532 GLboolean AMD_vertex_shader_viewport_index; 1533 GLboolean APPLE_object_purgeable; 1534 GLboolean ATI_texture_compression_3dc; 1535 GLboolean ATI_texture_mirror_once; 1536 GLboolean ATI_texture_env_combine3; 1537 GLboolean ATI_fragment_shader; 1538 GLboolean ATI_separate_stencil; 1539 GLboolean INTEL_performance_query; 1540 GLboolean MESA_pack_invert; 1541 GLboolean MESA_ycbcr_texture; 1542 GLboolean NV_conditional_render; 1543 GLboolean NV_fog_distance; 1544 GLboolean NV_fragment_program_option; 1545 GLboolean NV_point_sprite; 1546 GLboolean NV_primitive_restart; 1547 GLboolean NV_texture_barrier; 1548 GLboolean NV_texture_env_combine4; 1549 GLboolean NV_texture_rectangle; 1550 GLboolean NV_vdpau_interop; 1551 GLboolean TDFX_texture_compression_FXT1; 1552 GLboolean OES_EGL_image; 1553 GLboolean OES_draw_texture; 1554 GLboolean OES_depth_texture_cube_map; 1555 GLboolean OES_EGL_image_external; 1556 GLboolean OES_compressed_ETC1_RGB8_texture; 1557 GLboolean extension_sentinel; 1558 /** The extension string */ 1559 const GLubyte *String; 1560 /** Number of supported extensions */ 1561 GLuint Count; 1562 }; 1563 1564 1565 1566 1567 1568 1569 /* This has to be included here. */ 1570 #include "dd.h" 1571 1572 1573 1574 /** @{ 1575 * 1576 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums 1577 * to small enums suitable for use as an array index. 1578 */ 1579 1580 enum mesa_debug_type { 1581 MESA_DEBUG_TYPE_ERROR, 1582 MESA_DEBUG_TYPE_DEPRECATED, 1583 MESA_DEBUG_TYPE_UNDEFINED, 1584 MESA_DEBUG_TYPE_PORTABILITY, 1585 MESA_DEBUG_TYPE_PERFORMANCE, 1586 MESA_DEBUG_TYPE_OTHER, 1587 MESA_DEBUG_TYPE_MARKER, 1588 MESA_DEBUG_TYPE_PUSH_GROUP, 1589 MESA_DEBUG_TYPE_POP_GROUP, 1590 MESA_DEBUG_TYPE_COUNT 1591 }; 1592 1593 /** 1594 * Enum for the OpenGL APIs we know about and may support. 1595 * 1596 * NOTE: This must match the api_enum table in 1597 * src/mesa/main/get_hash_generator.py 1598 */ 1599 typedef enum 1600 { 1601 API_OPENGL_COMPAT, /* legacy / compatibility contexts */ 1602 API_OPENGLES, 1603 API_OPENGLES2, 1604 API_OPENGL_CORE, 1605 API_OPENGL_LAST = API_OPENGL_CORE 1606 } gl_api; 1607 1608 1609 1610 1611 /** 1612 * Mesa rendering context. 1613 * 1614 * This is the central context data structure for Mesa. Almost all 1615 * OpenGL state is contained in this structure. 1616 * Think of this as a base class from which device drivers will derive 1617 * sub classes. 1618 */ 1619 struct gl_context 1620 { 1621 gl_api API; 1622 1623 /** 1624 * Device driver function pointer table 1625 */ 1626 struct dd_function_table Driver; 1627 1628 /** Core/Driver constants */ 1629 struct gl_constants Const; 1630 1631 /** Extension information */ 1632 struct gl_extensions Extensions; 1633 1634 /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */ 1635 GLuint Version; 1636 char *VersionString; 1637 1638 1639 GLenum ErrorValue; /**< Last error code */ 1640 }; 1641 1642 1643 #ifdef DEBUG 1644 extern int MESA_VERBOSE; 1645 extern int MESA_DEBUG_FLAGS; 1646 # define MESA_FUNCTION __FUNCTION__ 1647 #else 1648 # define MESA_VERBOSE 0 1649 # define MESA_DEBUG_FLAGS 0 1650 # define MESA_FUNCTION "a function" 1651 # ifndef NDEBUG 1652 # define NDEBUG 1653 # endif 1654 #endif 1655 1656 1657 /** The MESA_VERBOSE var is a bitmask of these flags */ 1658 enum _verbose 1659 { 1660 VERBOSE_VARRAY = 0x0001, 1661 VERBOSE_TEXTURE = 0x0002, 1662 VERBOSE_MATERIAL = 0x0004, 1663 VERBOSE_PIPELINE = 0x0008, 1664 VERBOSE_DRIVER = 0x0010, 1665 VERBOSE_STATE = 0x0020, 1666 VERBOSE_API = 0x0040, 1667 VERBOSE_DISPLAY_LIST = 0x0100, 1668 VERBOSE_LIGHTING = 0x0200, 1669 VERBOSE_PRIMS = 0x0400, 1670 VERBOSE_VERTS = 0x0800, 1671 VERBOSE_DISASSEM = 0x1000, 1672 VERBOSE_DRAW = 0x2000, 1673 VERBOSE_SWAPBUFFERS = 0x4000 1674 }; 1675 1676 1677 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ 1678 enum _debug 1679 { 1680 DEBUG_SILENT = (1 << 0), 1681 DEBUG_ALWAYS_FLUSH = (1 << 1), 1682 DEBUG_INCOMPLETE_TEXTURE = (1 << 2), 1683 DEBUG_INCOMPLETE_FBO = (1 << 3) 1684 }; 1685 1686 1687 1688 #ifdef __cplusplus 1689 } 1690 #endif 1691 1692 #endif /* MTYPES_H */ 1693