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 shader_types.h 28 * All the GL shader/program types. 29 */ 30 31 #ifndef SHADER_TYPES_H 32 #define SHADER_TYPES_H 33 34 #include "main/config.h" /* for MAX_FEEDBACK_BUFFERS */ 35 #include "util/glheader.h" 36 #include "main/menums.h" 37 #include "util/mesa-sha1.h" 38 #include "util/mesa-blake3.h" 39 #include "compiler/shader_info.h" 40 #include "compiler/glsl/list.h" 41 #include "compiler/glsl/ir_uniform.h" 42 43 #include "pipe/p_state.h" 44 45 /** 46 * Shader information needed by both gl_shader and gl_linked shader. 47 */ 48 struct gl_shader_info 49 { 50 /** 51 * Tessellation Control shader state from layout qualifiers. 52 */ 53 struct { 54 /** 55 * 0 - vertices not declared in shader, or 56 * 1 .. GL_MAX_PATCH_VERTICES 57 */ 58 GLint VerticesOut; 59 } TessCtrl; 60 61 /** 62 * Tessellation Evaluation shader state from layout qualifiers. 63 */ 64 struct { 65 enum tess_primitive_mode _PrimitiveMode; 66 67 enum gl_tess_spacing Spacing; 68 69 /** 70 * GL_CW, GL_CCW, or 0 if it's not set in this shader. 71 */ 72 GLenum16 VertexOrder; 73 /** 74 * 1, 0, or -1 if it's not set in this shader. 75 */ 76 int PointMode; 77 } TessEval; 78 79 /** 80 * Geometry shader state from GLSL 1.50 layout qualifiers. 81 */ 82 struct { 83 GLint VerticesOut; 84 /** 85 * 0 - Invocations count not declared in shader, or 86 * 1 .. Const.MaxGeometryShaderInvocations 87 */ 88 GLint Invocations; 89 /** 90 * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or 91 * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this 92 * shader. 93 */ 94 enum mesa_prim InputType; 95 /** 96 * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if 97 * it's not set in this shader. 98 */ 99 enum mesa_prim OutputType; 100 } Geom; 101 102 /** 103 * Compute shader state from ARB_compute_shader and 104 * ARB_compute_variable_group_size layout qualifiers. 105 */ 106 struct { 107 /** 108 * Size specified using local_size_{x,y,z}, or all 0's to indicate that 109 * it's not set in this shader. 110 */ 111 unsigned LocalSize[3]; 112 113 /** 114 * Whether a variable work group size has been specified as defined by 115 * ARB_compute_variable_group_size. 116 */ 117 bool LocalSizeVariable; 118 119 /* 120 * Arrangement of invocations used to calculate derivatives in a compute 121 * shader. From NV_compute_shader_derivatives. 122 */ 123 enum gl_derivative_group DerivativeGroup; 124 } Comp; 125 }; 126 127 /** 128 * Compile status enum. COMPILE_SKIPPED is used to indicate the compile 129 * was skipped due to the shader matching one that's been seen before by 130 * the on-disk cache. 131 */ 132 enum gl_compile_status 133 { 134 COMPILE_FAILURE = 0, 135 COMPILE_SUCCESS, 136 COMPILE_SKIPPED 137 }; 138 139 /** 140 * A GLSL shader object. 141 */ 142 struct gl_shader 143 { 144 /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB || 145 * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER. 146 * Must be the first field. 147 */ 148 GLenum16 Type; 149 gl_shader_stage Stage; 150 GLuint Name; /**< AKA the handle */ 151 GLint RefCount; /**< Reference count */ 152 GLchar *Label; /**< GL_KHR_debug */ 153 GLboolean DeletePending; 154 bool IsES; /**< True if this shader uses GLSL ES */ 155 bool has_implicit_conversions; 156 bool has_implicit_int_to_uint_conversion; 157 158 enum gl_compile_status CompileStatus; 159 160 /** SHA1 of the pre-processed source used by the disk cache. */ 161 uint8_t disk_cache_sha1[SHA1_DIGEST_LENGTH]; 162 /** BLAKE3 of the original source before replacement, set by glShaderSource. */ 163 blake3_hash source_blake3; 164 /** BLAKE3 of FallbackSource (a copy of some original source before replacement). */ 165 blake3_hash fallback_source_blake3; 166 /** BLAKE3 of the current compiled source, set by successful glCompileShader. */ 167 blake3_hash compiled_source_blake3; 168 169 const GLchar *Source; /**< Source code string */ 170 const GLchar *FallbackSource; /**< Fallback string used by on-disk cache*/ 171 172 GLchar *InfoLog; 173 174 unsigned Version; /**< GLSL version used for linking */ 175 176 /** 177 * A bitmask of gl_advanced_blend_mode values 178 */ 179 GLbitfield BlendSupport; 180 181 struct exec_list *ir; 182 struct glsl_symbol_table *symbols; 183 184 /** 185 * Whether early fragment tests are enabled as defined by 186 * ARB_shader_image_load_store. 187 */ 188 bool EarlyFragmentTests; 189 190 bool ARB_fragment_coord_conventions_enable; 191 bool KHR_shader_subgroup_basic_enable; 192 193 bool redeclares_gl_fragcoord; 194 bool uses_gl_fragcoord; 195 196 bool PostDepthCoverage; 197 bool PixelInterlockOrdered; 198 bool PixelInterlockUnordered; 199 bool SampleInterlockOrdered; 200 bool SampleInterlockUnordered; 201 bool InnerCoverage; 202 203 /** 204 * Fragment shader state from GLSL 1.50 layout qualifiers. 205 */ 206 bool origin_upper_left; 207 bool pixel_center_integer; 208 209 /** 210 * Whether bindless_sampler/bindless_image, and respectively 211 * bound_sampler/bound_image are declared at global scope as defined by 212 * ARB_bindless_texture. 213 */ 214 bool bindless_sampler; 215 bool bindless_image; 216 bool bound_sampler; 217 bool bound_image; 218 219 /** 220 * Whether layer output is viewport-relative. 221 */ 222 bool redeclares_gl_layer; 223 bool layer_viewport_relative; 224 225 /** Global xfb_stride out qualifier if any */ 226 GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS]; 227 228 struct gl_shader_info info; 229 230 /* ARB_gl_spirv related data */ 231 struct gl_shader_spirv_data *spirv_data; 232 }; 233 234 /** 235 * A linked GLSL shader object. 236 */ 237 struct gl_linked_shader 238 { 239 gl_shader_stage Stage; 240 241 /** All gl_shader::compiled_source_blake3 combined. */ 242 blake3_hash linked_source_blake3; 243 244 struct gl_program *Program; /**< Post-compile assembly code */ 245 246 /** 247 * \name Sampler tracking 248 * 249 * \note Each of these fields is only set post-linking. 250 */ 251 /*@{*/ 252 GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */ 253 /*@}*/ 254 255 /** 256 * Number of default uniform block components used by this shader. 257 * 258 * This field is only set post-linking. 259 */ 260 unsigned num_uniform_components; 261 262 /** 263 * Number of combined uniform components used by this shader. 264 * 265 * This field is only set post-linking. It is the sum of the uniform block 266 * sizes divided by sizeof(float), and num_uniform_compoennts. 267 */ 268 unsigned num_combined_uniform_components; 269 270 struct exec_list *ir; 271 struct glsl_symbol_table *symbols; 272 273 /** 274 * ARB_gl_spirv related data. 275 * 276 * This is actually a reference to the gl_shader::spirv_data, which 277 * stores information that is also needed during linking. 278 */ 279 struct gl_shader_spirv_data *spirv_data; 280 }; 281 282 283 /** 284 * Link status enum. LINKING_SKIPPED is used to indicate linking 285 * was skipped due to the shader being loaded from the on-disk cache. 286 */ 287 enum gl_link_status 288 { 289 LINKING_FAILURE = 0, 290 LINKING_SUCCESS, 291 LINKING_SKIPPED 292 }; 293 294 /* All GLSL program resource types are next to each other, so we can use that 295 * to make them 0-based like this: 296 */ 297 #define GET_PROGRAM_RESOURCE_TYPE_FROM_GLENUM(x) ((x) - GL_UNIFORM) 298 #define NUM_PROGRAM_RESOURCE_TYPES (GL_TRANSFORM_FEEDBACK_VARYING - GL_UNIFORM + 1) 299 300 /** 301 * A data structure to be shared by gl_shader_program and gl_program. 302 */ 303 struct gl_shader_program_data 304 { 305 GLint RefCount; /**< Reference count */ 306 307 /** SHA1 hash of linked shader program */ 308 unsigned char sha1[20]; 309 310 unsigned NumUniformStorage; 311 unsigned NumHiddenUniforms; 312 struct gl_uniform_storage *UniformStorage; 313 314 unsigned NumUniformBlocks; 315 unsigned NumShaderStorageBlocks; 316 317 struct gl_uniform_block *UniformBlocks; 318 struct gl_uniform_block *ShaderStorageBlocks; 319 320 struct gl_active_atomic_buffer *AtomicBuffers; 321 unsigned NumAtomicBuffers; 322 323 /* Shader cache variables used during restore */ 324 unsigned NumUniformDataSlots; 325 union gl_constant_value *UniformDataSlots; 326 327 /* Used to hold initial uniform values for program binary restores. 328 * 329 * From the ARB_get_program_binary spec: 330 * 331 * "A successful call to ProgramBinary will reset all uniform 332 * variables to their initial values. The initial value is either 333 * the value of the variable's initializer as specified in the 334 * original shader source, or 0 if no initializer was present. 335 */ 336 union gl_constant_value *UniformDataDefaults; 337 338 /** Hash for quick search by name. */ 339 struct hash_table *ProgramResourceHash[NUM_PROGRAM_RESOURCE_TYPES]; 340 341 GLboolean Validated; 342 343 /** List of all active resources after linking. */ 344 struct gl_program_resource *ProgramResourceList; 345 unsigned NumProgramResourceList; 346 347 enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */ 348 GLchar *InfoLog; 349 350 /* Mask of stages this program was linked against */ 351 unsigned linked_stages; 352 353 /* Whether the shaders of this program are loaded from SPIR-V binaries 354 * (all have the SPIR_V_BINARY_ARB state). This was introduced by the 355 * ARB_gl_spirv extension. 356 */ 357 bool spirv; 358 }; 359 360 /** 361 * A GLSL program object. 362 * Basically a linked collection of vertex and fragment shaders. 363 */ 364 struct gl_shader_program 365 { 366 GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */ 367 GLuint Name; /**< aka handle or ID */ 368 GLchar *Label; /**< GL_KHR_debug */ 369 GLint RefCount; /**< Reference count */ 370 GLboolean DeletePending; 371 372 /** 373 * Is the application intending to glGetProgramBinary this program? 374 * 375 * BinaryRetrievableHint is the currently active hint that gets set 376 * during initialization and after linking and BinaryRetrievableHintPending 377 * is the hint set by the user to be active when program is linked next time. 378 */ 379 GLboolean BinaryRetrievableHint; 380 GLboolean BinaryRetrievableHintPending; 381 382 /** 383 * Indicates whether program can be bound for individual pipeline stages 384 * using UseProgramStages after it is next linked. 385 */ 386 GLboolean SeparateShader; 387 388 GLuint NumShaders; /**< number of attached shaders */ 389 struct gl_shader **Shaders; /**< List of attached the shaders */ 390 391 /** 392 * User-defined attribute bindings 393 * 394 * These are set via \c glBindAttribLocation and are used to direct the 395 * GLSL linker. These are \b not the values used in the compiled shader, 396 * and they are \b not the values returned by \c glGetAttribLocation. 397 */ 398 struct string_to_uint_map *AttributeBindings; 399 400 /** 401 * User-defined fragment data bindings 402 * 403 * These are set via \c glBindFragDataLocation and are used to direct the 404 * GLSL linker. These are \b not the values used in the compiled shader, 405 * and they are \b not the values returned by \c glGetFragDataLocation. 406 */ 407 struct string_to_uint_map *FragDataBindings; 408 struct string_to_uint_map *FragDataIndexBindings; 409 410 /** 411 * Transform feedback varyings last specified by 412 * glTransformFeedbackVaryings(). 413 * 414 * For the current set of transform feedback varyings used for transform 415 * feedback output, see LinkedTransformFeedback. 416 */ 417 struct { 418 GLenum16 BufferMode; 419 /** Global xfb_stride out qualifier if any */ 420 GLuint BufferStride[MAX_FEEDBACK_BUFFERS]; 421 GLuint NumVarying; 422 GLchar **VaryingNames; /**< Array [NumVarying] of char * */ 423 } TransformFeedback; 424 425 struct gl_program *last_vert_prog; 426 427 /** Data shared by gl_program and gl_shader_program */ 428 struct gl_shader_program_data *data; 429 430 /** 431 * Mapping from GL uniform locations returned by \c glUniformLocation to 432 * UniformStorage entries. Arrays will have multiple contiguous slots 433 * in the UniformRemapTable, all pointing to the same UniformStorage entry. 434 */ 435 unsigned NumUniformRemapTable; 436 struct gl_uniform_storage **UniformRemapTable; 437 438 /** 439 * Sometimes there are empty slots left over in UniformRemapTable after we 440 * allocate slots to explicit locations. This list stores the blocks of 441 * continuous empty slots inside UniformRemapTable. 442 */ 443 struct exec_list EmptyUniformLocations; 444 445 /** 446 * Total number of explicit uniform location including inactive uniforms. 447 */ 448 unsigned NumExplicitUniformLocations; 449 450 GLboolean SamplersValidated; /**< Samplers validated against texture units? */ 451 452 bool IsES; /**< True if this program uses GLSL ES */ 453 454 /** 455 * Per-stage shaders resulting from the first stage of linking. 456 * 457 * Set of linked shaders for this program. The array is accessed using the 458 * \c MESA_SHADER_* defines. Entries for non-existent stages will be 459 * \c NULL. 460 */ 461 struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES]; 462 463 unsigned GLSL_Version; /**< GLSL version used for linking */ 464 }; 465 466 /** 467 * Base class for any kind of program object 468 */ 469 struct gl_program 470 { 471 /** FIXME: This must be first until we split shader_info from nir_shader */ 472 struct shader_info info; 473 474 GLuint Id; 475 GLint RefCount; 476 GLubyte *String; /**< Null-terminated program text */ 477 478 /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */ 479 GLenum16 Target; 480 GLenum16 Format; /**< String encoding format */ 481 482 GLboolean _Used; /**< Ever used for drawing? Used for debugging */ 483 484 struct nir_shader *nir; 485 void *base_serialized_nir; 486 size_t base_serialized_nir_size; 487 488 /* Saved and restored with metadata. Freed with ralloc. */ 489 void *driver_cache_blob; 490 size_t driver_cache_blob_size; 491 492 /** whether to skip VARYING_SLOT_PSIZ in st_translate_stream_output_info() */ 493 bool skip_pointsize_xfb; 494 495 /** A bitfield indicating which vertex shader inputs consume two slots 496 * 497 * This is used for mapping from single-slot input locations in the GL API 498 * to dual-slot double input locations in the shader. This field is set 499 * once as part of linking and never updated again to ensure the mapping 500 * remains consistent. 501 * 502 * Note: There may be dual-slot variables in the original shader source 503 * which do not appear in this bitfield due to having been eliminated by 504 * the compiler prior to DualSlotInputs being calculated. There may also 505 * be bits set in this bitfield which are set but which the shader never 506 * reads due to compiler optimizations eliminating such variables after 507 * DualSlotInputs is calculated. 508 */ 509 GLbitfield64 DualSlotInputs; 510 /** Subset of OutputsWritten outputs written with non-zero index. */ 511 GLbitfield64 SecondaryOutputsWritten; 512 /** TEXTURE_x_BIT bitmask */ 513 GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; 514 /** Bitfield of which samplers are used */ 515 GLbitfield SamplersUsed; 516 /** Texture units used for shadow sampling. */ 517 GLbitfield ShadowSamplers; 518 /** Texture units used for samplerExternalOES */ 519 GLbitfield ExternalSamplersUsed; 520 521 /** Named parameters, constants, etc. from program text */ 522 struct gl_program_parameter_list *Parameters; 523 524 /** Map from sampler unit to texture unit (set by glUniform1i()) */ 525 GLubyte SamplerUnits[MAX_SAMPLERS]; 526 527 struct pipe_shader_state state; 528 struct ati_fragment_shader *ati_fs; 529 uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */ 530 531 void *serialized_nir; 532 unsigned serialized_nir_size; 533 534 struct gl_shader_program *shader_program; 535 536 struct st_variant *variants; 537 538 union { 539 /** Fields used by GLSL programs */ 540 struct { 541 /** Data shared by gl_program and gl_shader_program */ 542 struct gl_shader_program_data *data; 543 544 struct gl_active_atomic_buffer **AtomicBuffers; 545 546 /** Post-link transform feedback info. */ 547 struct gl_transform_feedback_info *LinkedTransformFeedback; 548 549 /** 550 * Number of types for subroutine uniforms. 551 */ 552 GLuint NumSubroutineUniformTypes; 553 554 /** 555 * Subroutine uniform remap table 556 * based on the program level uniform remap table. 557 */ 558 GLuint NumSubroutineUniforms; /* non-sparse total */ 559 GLuint NumSubroutineUniformRemapTable; 560 struct gl_uniform_storage **SubroutineUniformRemapTable; 561 562 /** 563 * Num of subroutine functions for this stage and storage for them. 564 */ 565 GLuint NumSubroutineFunctions; 566 GLuint MaxSubroutineFunctionIndex; 567 struct gl_subroutine_function *SubroutineFunctions; 568 569 /** 570 * Map from image uniform index to image unit (set by glUniform1i()) 571 * 572 * An image uniform index is associated with each image uniform by 573 * the linker. The image index associated with each uniform is 574 * stored in the \c gl_uniform_storage::image field. 575 */ 576 GLubyte ImageUnits[MAX_IMAGE_UNIFORMS]; 577 578 /** Access qualifier from linked shader 579 */ 580 enum gl_access_qualifier image_access[MAX_IMAGE_UNIFORMS]; 581 582 GLuint NumUniformBlocks; 583 struct gl_uniform_block **UniformBlocks; 584 struct gl_uniform_block **ShaderStorageBlocks; 585 586 /** 587 * Bitmask of shader storage blocks not declared as read-only. 588 */ 589 unsigned ShaderStorageBlocksWriteAccess; 590 591 /** Which texture target is being sampled 592 * (TEXTURE_1D/2D/3D/etc_INDEX) 593 */ 594 GLubyte SamplerTargets[MAX_SAMPLERS]; 595 596 /** 597 * Number of samplers declared with the bindless_sampler layout 598 * qualifier as specified by ARB_bindless_texture. 599 */ 600 GLuint NumBindlessSamplers; 601 GLboolean HasBoundBindlessSampler; 602 struct gl_bindless_sampler *BindlessSamplers; 603 604 /** 605 * Number of images declared with the bindless_image layout qualifier 606 * as specified by ARB_bindless_texture. 607 */ 608 GLuint NumBindlessImages; 609 GLboolean HasBoundBindlessImage; 610 struct gl_bindless_image *BindlessImages; 611 } sh; 612 613 /** ARB assembly-style program fields */ 614 struct { 615 struct prog_instruction *Instructions; 616 617 /** 618 * Local parameters used by the program. 619 * 620 * It's dynamically allocated because it is rarely used (just 621 * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries 622 * once it's allocated. 623 */ 624 GLfloat (*LocalParams)[4]; 625 unsigned MaxLocalParams; 626 627 /** Bitmask of which register files are read/written with indirect 628 * addressing. Mask of (1 << PROGRAM_x) bits. 629 */ 630 GLbitfield IndirectRegisterFiles; 631 632 /** Logical counts */ 633 /*@{*/ 634 GLuint NumInstructions; 635 GLuint NumTemporaries; 636 GLuint NumParameters; 637 GLuint NumAttributes; 638 GLuint NumAddressRegs; 639 GLuint NumAluInstructions; 640 GLuint NumTexInstructions; 641 GLuint NumTexIndirections; 642 /*@}*/ 643 /** Native, actual h/w counts */ 644 /*@{*/ 645 GLuint NumNativeInstructions; 646 GLuint NumNativeTemporaries; 647 GLuint NumNativeParameters; 648 GLuint NumNativeAttributes; 649 GLuint NumNativeAddressRegs; 650 GLuint NumNativeAluInstructions; 651 GLuint NumNativeTexInstructions; 652 GLuint NumNativeTexIndirections; 653 /*@}*/ 654 655 /** Used by ARB assembly-style programs. Can only be true for vertex 656 * programs. 657 */ 658 GLboolean IsPositionInvariant; 659 660 /** Used by ARB_fp programs, enum gl_fog_mode */ 661 unsigned Fog; 662 } arb; 663 }; 664 }; 665 666 /* 667 * State/IR translators needs to store some extra vp info. 668 */ 669 struct gl_vertex_program 670 { 671 struct gl_program Base; 672 673 uint32_t vert_attrib_mask; /**< mask of sourced vertex attribs */ 674 uint8_t num_inputs; 675 676 /** Maps VARYING_SLOT_x to slot */ 677 uint8_t result_to_output[VARYING_SLOT_MAX]; 678 }; 679 680 /** 681 * Structure that represents a reference to an atomic buffer from some 682 * shader program. 683 */ 684 struct gl_active_atomic_buffer 685 { 686 /** Uniform indices of the atomic counters declared within it. */ 687 GLuint *Uniforms; 688 GLuint NumUniforms; 689 690 /** Binding point index associated with it. */ 691 GLuint Binding; 692 693 /** Minimum reasonable size it is expected to have. */ 694 GLuint MinimumSize; 695 696 /** Shader stages making use of it. */ 697 GLboolean StageReferences[MESA_SHADER_STAGES]; 698 }; 699 700 struct gl_transform_feedback_varying_info 701 { 702 struct gl_resource_name name; 703 GLenum16 Type; 704 GLint BufferIndex; 705 GLint Size; 706 GLint Offset; 707 }; 708 709 710 /** 711 * Per-output info vertex shaders for transform feedback. 712 */ 713 struct gl_transform_feedback_output 714 { 715 uint32_t OutputRegister; 716 uint32_t OutputBuffer; 717 uint32_t NumComponents; 718 uint32_t StreamId; 719 720 /** offset (in DWORDs) of this output within the interleaved structure */ 721 uint32_t DstOffset; 722 723 /** 724 * Offset into the output register of the data to output. For example, 725 * if NumComponents is 2 and ComponentOffset is 1, then the data to 726 * offset is in the y and z components of the output register. 727 */ 728 uint32_t ComponentOffset; 729 }; 730 731 732 struct gl_transform_feedback_buffer 733 { 734 uint32_t Binding; 735 736 uint32_t NumVaryings; 737 738 /** 739 * Total number of components stored in each buffer. This may be used by 740 * hardware back-ends to determine the correct stride when interleaving 741 * multiple transform feedback outputs in the same buffer. 742 */ 743 uint32_t Stride; 744 745 /** 746 * Which transform feedback stream this buffer binding is associated with. 747 */ 748 uint32_t Stream; 749 }; 750 751 752 /** Post-link transform feedback info. */ 753 struct gl_transform_feedback_info 754 { 755 unsigned NumOutputs; 756 757 /* Bitmask of active buffer indices. */ 758 unsigned ActiveBuffers; 759 760 struct gl_transform_feedback_output *Outputs; 761 762 /** Transform feedback varyings used for the linking of this shader program. 763 * 764 * Use for glGetTransformFeedbackVarying(). 765 */ 766 struct gl_transform_feedback_varying_info *Varyings; 767 GLint NumVarying; 768 769 struct gl_transform_feedback_buffer Buffers[MAX_FEEDBACK_BUFFERS]; 770 }; 771 772 /** 773 * Shader subroutine function definition 774 */ 775 struct gl_subroutine_function 776 { 777 struct gl_resource_name name; 778 int index; 779 int num_compat_types; 780 const struct glsl_type **types; 781 }; 782 783 /** 784 * Active resource in a gl_shader_program 785 */ 786 struct gl_program_resource 787 { 788 GLenum16 Type; /** Program interface type. */ 789 const void *Data; /** Pointer to resource associated data structure. */ 790 uint8_t StageReferences; /** Bitmask of shader stage references. */ 791 }; 792 793 struct gl_uniform_buffer_variable 794 { 795 char *Name; 796 797 /** 798 * Name of the uniform as seen by glGetUniformIndices. 799 * 800 * glGetUniformIndices requires that the block instance index \b not be 801 * present in the name of queried uniforms. 802 * 803 * \note 804 * \c gl_uniform_buffer_variable::IndexName and 805 * \c gl_uniform_buffer_variable::Name may point to identical storage. 806 */ 807 char *IndexName; 808 809 const struct glsl_type *Type; 810 unsigned int Offset; 811 GLboolean RowMajor; 812 }; 813 814 815 struct gl_uniform_block 816 { 817 /** Declared name of the uniform block */ 818 struct gl_resource_name name; 819 820 /** Array of supplemental information about UBO ir_variables. */ 821 struct gl_uniform_buffer_variable *Uniforms; 822 GLuint NumUniforms; 823 824 /** 825 * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use 826 * with glBindBufferBase to bind a buffer object to this uniform block. 827 */ 828 GLuint Binding; 829 830 /** 831 * Minimum size (in bytes) of a buffer object to back this uniform buffer 832 * (GL_UNIFORM_BLOCK_DATA_SIZE). 833 */ 834 GLuint UniformBufferSize; 835 836 /** Stages that reference this block */ 837 uint8_t stageref; 838 839 /** 840 * Linearized array index for uniform block instance arrays 841 * 842 * Given a uniform block instance array declared with size 843 * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will 844 * have the linearized array index 845 * 846 * m-1 m 847 * i_m + ∑ i_j * ∏ s_k 848 * j=0 k=j+1 849 * 850 * For a uniform block instance that is not an array, this is always 0. 851 */ 852 uint8_t linearized_array_index; 853 854 /** 855 * Layout specified in the shader 856 * 857 * This isn't accessible through the API, but it is used while 858 * cross-validating uniform blocks. 859 */ 860 enum glsl_interface_packing _Packing; 861 GLboolean _RowMajor; 862 }; 863 864 /** 865 * A bindless sampler object. 866 */ 867 struct gl_bindless_sampler 868 { 869 /** Texture unit (set by glUniform1()). */ 870 GLubyte unit; 871 872 /** Whether this bindless sampler is bound to a unit. */ 873 GLboolean bound; 874 875 /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */ 876 gl_texture_index target; 877 878 /** Pointer to the base of the data. */ 879 GLvoid *data; 880 }; 881 882 883 /** 884 * A bindless image object. 885 */ 886 struct gl_bindless_image 887 { 888 /** Image unit (set by glUniform1()). */ 889 GLubyte unit; 890 891 /** Whether this bindless image is bound to a unit. */ 892 GLboolean bound; 893 894 /** Access qualifier from linked shader 895 */ 896 enum gl_access_qualifier image_access; 897 898 /** Pointer to the base of the data. */ 899 GLvoid *data; 900 }; 901 902 /** 903 * Data container for shader queries. This holds only the minimal 904 * amount of required information for resource queries to work. 905 */ 906 struct gl_shader_variable 907 { 908 /** 909 * Declared type of the variable 910 */ 911 const struct glsl_type *type; 912 913 /** 914 * If the variable is in an interface block, this is the type of the block. 915 */ 916 const struct glsl_type *interface_type; 917 918 /** 919 * For variables inside structs (possibly recursively), this is the 920 * outermost struct type. 921 */ 922 const struct glsl_type *outermost_struct_type; 923 924 /** 925 * Declared name of the variable 926 */ 927 struct gl_resource_name name; 928 929 /** 930 * Storage location of the base of this variable 931 * 932 * The precise meaning of this field depends on the nature of the variable. 933 * 934 * - Vertex shader input: one of the values from \c gl_vert_attrib. 935 * - Vertex shader output: one of the values from \c gl_varying_slot. 936 * - Geometry shader input: one of the values from \c gl_varying_slot. 937 * - Geometry shader output: one of the values from \c gl_varying_slot. 938 * - Fragment shader input: one of the values from \c gl_varying_slot. 939 * - Fragment shader output: one of the values from \c gl_frag_result. 940 * - Uniforms: Per-stage uniform slot number for default uniform block. 941 * - Uniforms: Index within the uniform block definition for UBO members. 942 * - Non-UBO Uniforms: explicit location until linking then reused to 943 * store uniform slot number. 944 * - Other: This field is not currently used. 945 * 946 * If the variable is a uniform, shader input, or shader output, and the 947 * slot has not been assigned, the value will be -1. 948 */ 949 int location; 950 951 /** 952 * Specifies the first component the variable is stored in as per 953 * ARB_enhanced_layouts. 954 */ 955 unsigned component:2; 956 957 /** 958 * Output index for dual source blending. 959 * 960 * \note 961 * The GLSL spec only allows the values 0 or 1 for the index in \b dual 962 * source blending. 963 */ 964 unsigned index:1; 965 966 /** 967 * Specifies whether a shader input/output is per-patch in tessellation 968 * shader stages. 969 */ 970 unsigned patch:1; 971 972 /** 973 * Storage class of the variable. 974 * 975 * \sa (n)ir_variable_mode 976 */ 977 unsigned mode:4; 978 979 /** 980 * Interpolation mode for shader inputs / outputs 981 * 982 * \sa glsl_interp_mode 983 */ 984 unsigned interpolation:2; 985 986 /** 987 * Was the location explicitly set in the shader? 988 * 989 * If the location is explicitly set in the shader, it \b cannot be changed 990 * by the linker or by the API (e.g., calls to \c glBindAttribLocation have 991 * no effect). 992 */ 993 unsigned explicit_location:1; 994 995 /** 996 * Precision qualifier. 997 */ 998 unsigned precision:2; 999 }; 1000 1001 #endif 1002