1// Copyright 2015-2024 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[interfaces]] 6= Shader Interfaces 7 8When a pipeline is created, the set of shaders specified in the 9corresponding stext:VkPipelineCreateInfo structure are implicitly linked at 10a number of different interfaces. 11 12 * <<interfaces-iointerfaces,Shader Input and Output Interface>> 13 * <<interfaces-vertexinput,Vertex Input Interface>> 14 * <<interfaces-fragmentoutput,Fragment Output Interface>> 15ifdef::VK_EXT_shader_tile_image[] 16 * <<interfaces-fragmenttileimage,Fragment Tile Image Interface>> 17endif::VK_EXT_shader_tile_image[] 18 * <<interfaces-inputattachment,Fragment Input Attachment Interface>> 19ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 20 * <<interfaces-raypipeline, Ray Tracing Pipeline Interface>> 21endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 22 * <<interfaces-resources,Shader Resource Interface>> 23ifdef::VK_NV_geometry_shader_passthrough[] 24 * <<geometry-passthrough-passthrough,Geometry Shader Passthrough>> 25endif::VK_NV_geometry_shader_passthrough[] 26 27ifdef::VKSC_VERSION_1_0[] 28In Vulkan SC, the pipeline compilation process occurs 29<<pipelines-offline-compilation,offline>> using the implementation-provided 30pipeline cache compiler. 31The set of shaders being used to create a pipeline can: be specified using 32the pipeline JSON schema. 33endif::VKSC_VERSION_1_0[] 34 35This chapter describes valid uses for a set of SPIR-V decorations. 36Any other use of one of these decorations is invalid, with the exception 37that, when using SPIR-V versions 1.4 and earlier: code:Block, 38code:BufferBlock, code:Offset, code:ArrayStride, and code:MatrixStride can 39also decorate types and type members used by variables in the code:Private 40and code:Function storage classes. 41 42[NOTE] 43.Note 44==== 45In this chapter, there are references to SPIR-V terms such as the 46code:MeshNV execution model. 47These terms will appear even in a build of the specification which does not 48support any extensions. 49This is as intended, since these terms appear in the unified SPIR-V 50specification without such qualifiers. 51==== 52 53 54[[interfaces-iointerfaces]] 55== Shader Input and Output Interfaces 56 57When multiple stages are present in a pipeline, the outputs of one stage 58form an interface with the inputs of the next stage. 59When such an interface involves a shader, shader outputs are matched against 60the inputs of the next stage, and shader inputs are matched against the 61outputs of the previous stage. 62 63All the variables forming the shader input and output _interfaces_ are 64listed as operands to the code:OpEntryPoint instruction and are declared 65with the code:Input or code:Output storage classes, respectively, in the 66SPIR-V module. 67These generally form the interfaces between consecutive shader stages, 68regardless of any non-shader stages between the consecutive shader stages. 69 70There are two classes of variables that can: be matched between shader 71stages, built-in variables and user-defined variables. 72Each class has a different set of matching criteria. 73 74code:Output variables of a shader stage have undefined: values until the 75shader writes to them or uses the code:Initializer operand when declaring 76the variable. 77 78 79[[interfaces-iointerfaces-builtin]] 80=== Built-in Interface Block 81 82Shader <<interfaces-builtin-variables,built-in>> variables meeting the 83following requirements define the _built-in interface block_. 84They must: 85 86 * be explicitly declared (there are no implicit built-ins), 87 * be identified with a code:BuiltIn decoration, 88 * form object types as described in the 89 <<interfaces-builtin-variables,Built-in Variables>> section, and 90 * be declared in a block whose top-level members are the built-ins. 91 92There must: be no more than one built-in interface block per shader per 93interface 94ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 95, except for the mesh output interface where there must: be at most one 96built-in interface block decorated with the code:PerPrimitiveEXT decoration 97and at most one built-in interface block without this decoration 98endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 99. 100 101Built-ins must: not have any code:Location or code:Component decorations. 102 103 104[[interfaces-iointerfaces-user]] 105=== User-defined Variable Interface 106 107The non-built-in variables listed by code:OpEntryPoint with the code:Input 108or code:Output storage class form the _user-defined variable interface_. 109These must: have <<formats-numericformat, numeric type>> or, recursively, 110composite types of such types. 111ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 112If an implementation supports <<features-storageInputOutput16, 113pname:storageInputOutput16>>, components can: have a width of 16 bits. 114endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 115These variables must: be identified with a code:Location decoration and can: 116also be identified with a code:Component decoration. 117 118 119[[interfaces-iointerfaces-matching]] 120=== Interface Matching 121 122An output variable, block, or structure member in a given shader stage has 123an interface match with an input variable, block, or structure member in a 124subsequent shader stage if they both adhere to the following conditions: 125 126 * They have equivalent decorations, other than: 127ifdef::VK_EXT_transform_feedback[] 128 ** code:XfbBuffer, code:XfbStride, code:Offset, and code:Stream 129endif::VK_EXT_transform_feedback[] 130 ** one is not decorated with code:Component and the other is declared with 131 a code:Component of `0` 132 ** <<shaders-interpolation-decorations,Interpolation decorations>> 133 ** code:RelaxedPrecision if one is an input variable and the other an 134 output variable 135 * Their types match as follows: 136 ** if the input is declared in a tessellation control or geometry shader 137 as an code:OpTypeArray with an code:Element code:Type equivalent to the 138 code:OpType* declaration of the output, and neither is a structure 139 member; or 140ifdef::VK_VERSION_1_3,VK_KHR_maintenance4[] 141 ** if the <<features-maintenance4, pname:maintenance4>> feature is 142 enabled, they are declared as code:OpTypeVector variables, and the 143 output has a code:Component code:Count value higher than that of the 144 input but the same code:Component code:Type; or 145endif::VK_VERSION_1_3,VK_KHR_maintenance4[] 146ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 147 ** if the output is declared in a mesh shader as an code:OpTypeArray with 148 an code:Element code:Type equivalent to the code:OpType* declaration of 149 the input, and neither is a structure member; or 150endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 151ifdef::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 152 ** if the input is decorated with code:PerVertexKHR, and is declared in a 153 fragment shader as an code:OpTypeArray with an code:Element code:Type 154 equivalent to the code:OpType* declaration of the output, and neither 155 the input nor the output is a structure member; or 156endif::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 157 ** if in any other case they are declared with an equivalent code:OpType* 158 declaration. 159 * If both are structures and every member has an interface match. 160 161[NOTE] 162.Note 163==== 164The word "`structure`" above refers to both variables that have an 165code:OpTypeStruct type and interface blocks (which are also declared as 166code:OpTypeStruct). 167==== 168 169ifdef::VK_EXT_graphics_pipeline_library[] 170If the pipeline is compiled as separate graphics pipeline libraries and the 171<<limits-graphicsPipelineLibraryIndependentInterpolationDecoration, 172pname:graphicsPipelineLibraryIndependentInterpolationDecoration>> limit is 173not supported, matches are not found if the 174<<shaders-interpolation-decorations, interpolation decorations>> differ 175between the last <<pipelines-graphics-subsets-pre-rasterization, 176pre-rasterization shader stage>> and the fragment shader stage. 177endif::VK_EXT_graphics_pipeline_library[] 178 179All input variables and blocks must: have an interface match in the 180preceding shader stage, except for built-in variables in fragment shaders. 181Shaders can: declare and write to output variables that are not declared or 182read by the subsequent stage. 183 184ifdef::VK_NV_geometry_shader_passthrough[] 185Matching rules for _passthrough geometry shaders_ are slightly different and 186are described in the <<geometry-passthrough-interface,Passthrough Interface 187Matching>> section. 188endif::VK_NV_geometry_shader_passthrough[] 189 190The value of an input variable is undefined: if the preceding stage does not 191write to a matching output variable, as described above. 192 193 194[[interfaces-iointerfaces-locations]] 195=== Location Assignment 196 197This section describes code:Location assignments for user-defined variables 198and how many code:Location slots are consumed by a given user-variable type. 199<<interfaces-iointerfaces-matching, As mentioned above>>, some inputs and 200outputs have an additional level of arrayness relative to other shader 201inputs and outputs. 202This outer array level is removed from the type before considering how many 203code:Location slots the type consumes. 204 205The code:Location value specifies an interface slot comprised of a 32-bit 206four-component vector conveyed between stages. 207The code:Component specifies <<interfaces-iointerfaces-components, word 208components>> within these vector code:Location slots. 209Only types with widths of 210ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 21116, 212endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 21332 or 64 are supported in shader interfaces. 214 215Inputs and outputs of the following types consume a single interface 216code:Location: 217 218ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 219 * 16-bit scalar and vector types, and 220endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 221 * 32-bit scalar and vector types, and 222 * 64-bit scalar and 2-component vector types. 223 22464-bit three- and four-component vectors consume two consecutive 225code:Location slots. 226 227If a declared input or output is an array of size _n_ and each element takes 228_m_ code:Location slots, it will be assigned _m_ {times} _n_ consecutive 229code:Location slots starting with the specified code:Location. 230 231If the declared input or output is an _n_ {times} _m_ 232ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 23316-, 234endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 23532- or 64-bit matrix, it will be assigned multiple code:Location slots 236starting with the specified code:Location. 237The number of code:Location slots assigned for each matrix will be the same 238as for an _n_-element array of _m_-component vectors. 239 240An code:OpVariable with a structure type that is not a block must: be 241decorated with a code:Location. 242 243When an code:OpVariable with a structure type (either block or non-block) is 244decorated with a code:Location, the members in the structure type must: not 245be decorated with a code:Location. 246The code:OpVariable's members are assigned consecutive code:Location slots 247in declaration order, starting from the first member, which is assigned the 248code:Location decoration from the code:OpVariable. 249 250When a block-type code:OpVariable is declared without a code:Location 251decoration, each member in its structure type must: be decorated with a 252code:Location. 253Types nested deeper than the top-level members must: not have code:Location 254decorations. 255 256The code:Location slots consumed by block and structure members are 257determined by applying the rules above in a depth-first traversal of the 258instantiated members as though the structure or block member were declared 259as an input or output variable of the same type. 260 261Any two inputs listed as operands on the same code:OpEntryPoint must: not be 262assigned the same code:Location slot and code:Component word, either 263explicitly or implicitly. 264Any two outputs listed as operands on the same code:OpEntryPoint must: not 265be assigned the same code:Location slot and code:Component word, either 266explicitly or implicitly. 267 268The number of input and output code:Location slots available for a shader 269input or output interface is limited, and dependent on the shader stage as 270described in <<interfaces-iointerfaces-limits>>. 271All variables in both the <<interfaces-builtin-variables,built-in interface 272block>> and the <<interfaces-iointerfaces-user,user-defined variable 273interface>> count against these limits. 274Each effective code:Location must: have a value less than the number of 275code:Location slots available for the given interface, as specified in the 276"`Locations Available`" column in <<interfaces-iointerfaces-limits>>. 277 278 279[[interfaces-iointerfaces-limits]] 280.Shader Input and Output Locations 281[width="90%",cols="<6,<13",options="header"] 282|==== 283| Shader Interface | Locations Available 284| vertex input | pname:maxVertexInputAttributes 285| vertex output | pname:maxVertexOutputComponents / 4 286| tessellation control input | pname:maxTessellationControlPerVertexInputComponents / 4 287| tessellation control output | pname:maxTessellationControlPerVertexOutputComponents / 4 288| tessellation evaluation input | pname:maxTessellationEvaluationInputComponents / 4 289| tessellation evaluation output| pname:maxTessellationEvaluationOutputComponents / 4 290| geometry input | pname:maxGeometryInputComponents / 4 291| geometry output | pname:maxGeometryOutputComponents / 4 292| fragment input | pname:maxFragmentInputComponents / 4 293| fragment output | pname:maxFragmentOutputAttachments 294ifdef::VK_EXT_mesh_shader[] 295| mesh output | pname:maxMeshOutputComponents / 4 296endif::VK_EXT_mesh_shader[] 297ifndef::VK_EXT_mesh_shader[] 298ifdef::VK_NV_mesh_shader[] 299// we forgot to add maxMeshOutputComponents 300| mesh output | pname:maxFragmentInputComponents / 4 301endif::VK_NV_mesh_shader[] 302endif::VK_EXT_mesh_shader[] 303ifdef::VK_HUAWEI_cluster_culling_shader[] 304| cluster culling output | pname:maxOutputClusterCount 305endif::VK_HUAWEI_cluster_culling_shader[] 306|==== 307 308 309[[interfaces-iointerfaces-components]] 310=== Component Assignment 311 312The code:Component decoration allows the code:Location to be more finely 313specified for scalars and vectors, down to the individual code:Component 314word within a code:Location slot that are consumed. 315The code:Component word within a code:Location are 0, 1, 2, and 3. 316A variable or block member starting at code:Component N will consume 317code:Component words N, N+1, N+2, ... 318up through its size. 319ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 320For 16-, and 32-bit types, 321endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 322ifndef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 323For single precision types, 324endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 325it is invalid if this sequence of code:Component words gets larger than 3. 326A scalar 64-bit type will consume two of these code:Component words in 327sequence, and a two-component 64-bit vector type will consume all four 328code:Component words available within a code:Location. 329A three- or four-component 64-bit vector type must: not specify a non-zero 330code:Component decoration. 331A three-component 64-bit vector type will consume all four code:Component 332words of the first code:Location and code:Component 0 and 1 of the second 333code:Location. 334This leaves code:Component 2 and 3 available for other component-qualified 335declarations. 336 337A scalar or two-component 64-bit data type must: not specify a 338code:Component decoration of 1 or 3. 339A code:Component decoration must: not be specified for any type that is not 340a scalar or vector. 341 342A four-component 64-bit data type will consume all four code:Component words 343of the first code:Location and all four code:Component words of the second 344code:Location. 345 346[[interfaces-vertexinput]] 347== Vertex Input Interface 348 349When the vertex stage is present in a pipeline, the vertex shader input 350variables form an interface with the vertex input attributes. 351The vertex shader input variables are matched by the code:Location and 352code:Component decorations to the vertex input attributes specified in the 353pname:pVertexInputState member of the slink:VkGraphicsPipelineCreateInfo 354structure. 355 356The vertex shader input variables listed by code:OpEntryPoint with the 357code:Input storage class form the _vertex input interface_. 358These variables must: be identified with a code:Location decoration and can: 359also be identified with a code:Component decoration. 360 361For the purposes of interface matching: variables declared without a 362code:Component decoration are considered to have a code:Component decoration 363of zero. 364The number of available vertex input code:Location slots is given by the 365pname:maxVertexInputAttributes member of the sname:VkPhysicalDeviceLimits 366structure. 367 368See <<fxvertex-attrib-location>> for details. 369 370All vertex shader inputs declared as above must: have a corresponding 371attribute and binding in the pipeline. 372 373 374[[interfaces-fragmentoutput]] 375== Fragment Output Interface 376 377When the fragment stage is present in a pipeline, the fragment shader 378outputs form an interface with the output attachments defined by a 379<<renderpass, render pass instance>>. 380The fragment shader output variables are matched by the code:Location and 381code:Component decorations to specified color attachments. 382 383The fragment shader output variables listed by code:OpEntryPoint with the 384code:Output storage class form the _fragment output interface_. 385These variables must: be identified with a code:Location decoration. 386They can: also be identified with a code:Component decoration and/or an 387code:Index decoration. 388For the purposes of interface matching: variables declared without a 389code:Component decoration are considered to have a code:Component decoration 390of zero, and variables declared without an code:Index decoration are 391considered to have an code:Index decoration of zero. 392 393A fragment shader output variable identified with a code:Location decoration 394of _i_ is associated with 395ifdef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 396the color attachment indicated by 397slink:VkRenderingInfo::pname:pColorAttachments[_i_]. 398When using render pass objects, it is associated with 399endif::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 400the color attachment indicated by 401slink:VkSubpassDescription::pname:pColorAttachments[_i_]. 402Values are written to those attachments after passing through the blending 403unit as described in <<framebuffer-blending>>, if enabled. 404Locations are consumed as described in 405<<interfaces-iointerfaces-locations,Location Assignment>>. 406The number of available fragment output code:Location slots is given by the 407pname:maxFragmentOutputAttachments member of the 408sname:VkPhysicalDeviceLimits structure. 409 410When an active fragment shader invocation finishes, the values of all 411fragment shader outputs are copied out and used as blend inputs or color 412attachments writes. 413If the invocation does not set a value for them, the input values to those 414blending or color attachment writes are undefined:. 415 416Components of the output variables are assigned as described in 417<<interfaces-iointerfaces-components,Component Assignment>>. 418Output code:Component words identified as 0, 1, 2, and 3 will be directed to 419the R, G, B, and A inputs to the blending unit, respectively, or to the 420output attachment if blending is disabled. 421If two variables are placed within the same code:Location, they must: have 422the same underlying type (floating-point or integer). 423code:Component words which do not correspond to any fragment shader output 424will also result in undefined: values for blending or color attachment 425writes. 426 427Fragment outputs identified with an code:Index of zero are directed to the 428first input of the blending unit associated with the corresponding 429code:Location. 430Outputs identified with an code:Index of one are directed to the second 431input of the corresponding blending unit. 432 433There must: be no output variable which has the same code:Location, 434code:Component, and code:Index as any other, either explicitly declared or 435implied. 436 437Output values written by a fragment shader must: be declared with either 438code:OpTypeFloat or code:OpTypeInt, and a code:Width of 32. 439ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 440If pname:storageInputOutput16 is supported, output values written by a 441fragment shader can: be also declared with either code:OpTypeFloat or 442code:OpTypeInt and a code:Width of 16. 443endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 444Composites of these types are also permitted. 445If the color attachment has a signed or unsigned normalized fixed-point 446format, color values are assumed to be floating-point and are converted to 447fixed-point as described in <<fundamentals-fpfixedconv>>; If the color 448attachment has an integer format, color values are assumed to be integers 449and converted to the bit-depth of the target. 450Any value that cannot be represented in the attachment's format is 451undefined:. 452For any other attachment format no conversion is performed. 453If the type of the values written by the fragment shader do not match the 454format of the corresponding color attachment, the resulting values are 455undefined: for those components. 456 457ifdef::VK_EXT_legacy_dithering[] 458[[interfaces-legacy-dithering]] 459== Legacy Dithering 460 461The application can: enable dithering to be applied to the color output of a 462subpass, by using the 463ename:VK_SUBPASS_DESCRIPTION_ENABLE_LEGACY_DITHERING_BIT_EXT 464ifndef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 465flag. 466endif::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 467ifdef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 468or the ename:VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT flags. 469endif::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] 470 471When dithering is enabled, the implementation may: modify the output color 472value [eq]#c# by one ULP. 473This modification must: only depend on the framebuffer coordinates 474[eq]#(x~f~,y~f~)# of the sample, as well as on the value of [eq]#c#. 475 476The exact details of the dithering algorithm are unspecified, including the 477algorithm itself, the formats dithering is applied to, and the stage in 478which it is applied. 479 480[NOTE] 481.Note 482==== 483This extension is intended only for use by OpenGL emulation layers, and as 484such the dithering algorithm applied to the subpass should: be equivalent to 485the vendor's OpenGL implementation, if any. 486==== 487endif::VK_EXT_legacy_dithering[] 488 489ifdef::VK_EXT_shader_tile_image[] 490[[interfaces-fragmenttileimage]] 491== Fragment Tile Image Interface 492 493When a fragment stage is present in a pipeline, the fragment shader tile 494image variables decorated with code:Location form an interface with the 495color attachments defined by the render pass instance. 496The fragment shader tile image variables are matched by code:Location 497decorations to the color attachments specified in the 498pname:pColorAttachments array of the slink:VkRenderingInfoKHR structure 499describing the render pass instance the fragment shader is executed in. 500 501The fragment shader variables listed by code:OpEntryPoint with the 502code:TileImageEXT storage class and a decoration of code:Location form the 503_fragment tile image interface_. 504These variables must: be declared with a type of code:OpTypeImage, and a 505code:Dim operand of code:TileImageDataEXT. 506The code:Component decoration is not supported for these variables. 507 508Reading from a tile image variable with a code:Location decoration of _i_ 509reads from the color attachment identified by the element of 510slink:VkRenderingInfoKHR::pname:pColorAttachments with a pname:location 511equal to _i_. 512If the tile image variable is declared as an array of size N, it consumes N 513consecutive tile image locations, starting with the index specified. 514There must: not be more than one tile image variable with the same 515code:Location whether explicitly declared or implied by an array 516declaration. 517The number of available tile image locations is the same as the number of 518available fragment output locations as given by the 519pname:maxFragmentOutputAttachments member of the 520sname:VkPhysicalDeviceLimits structure. 521 522The basic data type (floating-point, integer, unsigned integer) of the tile 523image variable must: match the basic format of the corresponding color 524attachment, or the values read from the tile image variables are undefined:. 525endif::VK_EXT_shader_tile_image[] 526 527[[interfaces-inputattachment]] 528== Fragment Input Attachment Interface 529 530When a fragment stage is present in a pipeline, the fragment shader subpass 531inputs form an interface with the input attachments of the current subpass. 532The fragment shader subpass input variables are matched by 533code:InputAttachmentIndex decorations to the input attachments specified in 534the pname:pInputAttachments array of the slink:VkSubpassDescription 535structure describing the subpass that the fragment shader is executed in. 536 537The fragment shader subpass input variables with the code:UniformConstant 538storage class and a decoration of code:InputAttachmentIndex that are 539statically used by code:OpEntryPoint form the _fragment input attachment 540interface_. 541These variables must: be declared with a type of code:OpTypeImage, a 542code:Dim operand of code:SubpassData, an code:Arrayed operand of 0, and a 543code:Sampled operand of 2. 544The code:MS operand of the code:OpTypeImage must: be 0 if the pname:samples 545field of the corresponding slink:VkAttachmentDescription is 546ename:VK_SAMPLE_COUNT_1_BIT and 547ifdef::VK_EXT_multisampled_render_to_single_sampled[] 548<<subpass-multisampledrendertosinglesampled,multisampled-render-to-single-sampled>> 549is not enabled, and 550endif::VK_EXT_multisampled_render_to_single_sampled[] 5511 otherwise. 552 553A subpass input variable identified with an code:InputAttachmentIndex 554decoration of _i_ reads from the input attachment indicated by 555pname:pInputAttachments[_i_] member of sname:VkSubpassDescription. 556If the subpass input variable is declared as an array of size N, it consumes 557N consecutive input attachments, starting with the index specified. 558There must: not be more than one input variable with the same 559code:InputAttachmentIndex whether explicitly declared or implied by an array 560declaration per image aspect. 561A multi-aspect image (e.g. a depth/stencil format) can: use the same input 562variable. 563The number of available input attachment indices is given by the 564pname:maxPerStageDescriptorInputAttachments member of the 565sname:VkPhysicalDeviceLimits structure. 566 567Variables identified with the code:InputAttachmentIndex must: only be used 568by a fragment stage. 569The <<formats-numericformat, numeric format>> of the subpass input must: 570match the format of the corresponding input attachment, or the values of 571subpass loads from these variables are undefined:. 572If the framebuffer attachment contains both depth and stencil aspects, the 573numeric format of the subpass input determines if depth or stencil aspect is 574accessed by the shader. 575 576See <<descriptorsets-inputattachment>> for more details. 577 578 579[[compatibility-inputattachment]] 580=== Fragment Input Attachment Compatibility 581An input attachment that is statically accessed by a fragment shader must: 582be backed by a descriptor that is equivalent to the slink:VkImageView in the 583slink:VkFramebuffer, except for pname:subresourceRange.aspectMask. 584The pname:aspectMask must: be equal to the aspect accessed by the shader. 585 586ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 587[[interfaces-raypipeline]] 588== Ray Tracing Pipeline Interface 589 590Ray tracing pipelines may: have more stages than other pipelines with 591multiple instances of each stage and more dynamic interactions between the 592stages, but still have interface structures that obey the same general rules 593as interfaces between shader stages in other pipelines. 594The three types of inter-stage interface variables for ray tracing pipelines 595are: 596 597 * Ray payloads containing data tracked for the entire lifetime of the ray. 598 * Hit attributes containing data about a specific hit for the duration of 599 its processing. 600 * Callable data for passing data into and out of a callable shader. 601 602Ray payloads and callable data are used in explicit shader call 603instructions, so they have an incoming variant to distinguish the parameter 604passed to the invocation from any other payloads or data being used by 605subsequent shader call instructions. 606 607An interface structure used between stages must: match between the stages 608using it. 609Specifically: 610 611 * The hit attribute structure read in an any-hit or closest hit shader 612 must: be the same structure as the hit attribute structure written in 613 the corresponding intersection shader in the same hit group. 614 * The incoming callable data for a callable shader must: be the same 615 structure as the callable data referenced by the execute callable 616 instruction in the calling shader. 617 * The ray payload for a shader invoked by a ray tracing command must: be 618 the same structure for all shader stages using the payload for that ray. 619 620Any shader with an incoming ray payload, incoming callable data, or hit 621attribute must: only declare one variable of that type. 622 623.Ray Pipeline Shader Interface 624[width="90%",options="header"] 625|==== 626| Shader Stage | Ray Payload | Incoming Ray Payload | Hit Attribute | Callable Data | Incoming Callable Data 627| Ray Generation | r/w | | | r/w | 628| Intersection | | | r/w | | 629| Any-Hit | | r/w | r | | 630| Closest Hit | r/w | r/w | r | r/w | 631| Miss | r/w | r/w | | r/w | 632| Callable | | | | r/w | r/w 633|==== 634endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 635 636 637[[interfaces-resources]] 638== Shader Resource Interface 639 640When a shader stage accesses buffer or image resources, as described in the 641<<descriptorsets,Resource Descriptors>> section, the shader resource 642variables must: be matched with the <<descriptorsets-pipelinelayout,pipeline 643layout>> that is provided at pipeline creation time. 644 645The set of shader variables that form the _shader resource interface_ for a 646stage are the variables statically used by that stage's code:OpEntryPoint 647with a storage class of code:Uniform, code:UniformConstant, 648ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 649code:StorageBuffer, 650endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 651or code:PushConstant. 652For the fragment shader, this includes the <<interfaces-inputattachment, 653fragment input attachment interface>>. 654 655The shader resource interface consists of two sub-interfaces: the push 656constant interface and the descriptor set interface. 657 658 659[[interfaces-resources-pushconst]] 660=== Push Constant Interface 661 662The shader variables defined with a storage class of code:PushConstant that 663are statically used by the shader entry points for the pipeline define the 664_push constant interface_. 665They must: be: 666 667 * typed as code:OpTypeStruct, 668 * identified with a code:Block decoration, and 669 * laid out explicitly using the code:Offset, code:ArrayStride, and 670 code:MatrixStride decorations as specified in 671 <<interfaces-resources-layout,Offset and Stride Assignment>>. 672 673There must: be no more than one push constant block statically used per 674shader entry point. 675 676Each statically used member of a push constant block must: be placed at an 677code:Offset such that the entire member is entirely contained within the 678slink:VkPushConstantRange for each code:OpEntryPoint that uses it, and the 679pname:stageFlags for that range must: specify the appropriate 680elink:VkShaderStageFlagBits for that stage. 681The code:Offset decoration for any member of a push constant block must: not 682cause the space required for that member to extend outside the range 683[eq]#[0, pname:maxPushConstantsSize)#. 684 685Any member of a push constant block that is declared as an array must: only 686be accessed with _dynamically uniform_ indices. 687 688 689[[interfaces-resources-descset]] 690=== Descriptor Set Interface 691 692The _descriptor set interface_ is comprised of the shader variables with the 693storage class of 694ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 695code:StorageBuffer, 696endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 697code:Uniform or code:UniformConstant (including the variables in the 698<<interfaces-inputattachment,fragment input attachment interface>>) that are 699statically used by the shader entry points for the pipeline. 700 701These variables must: have code:DescriptorSet and code:Binding decorations 702specified, which are assigned and matched with the 703sname:VkDescriptorSetLayout objects in the pipeline layout as described in 704<<interfaces-resources-setandbinding,DescriptorSet and Binding Assignment>>. 705 706The code:Image code:Format of an code:OpTypeImage declaration must: not be 707*Unknown*, for variables which are used for code:OpImageRead, 708code:OpImageSparseRead, or code:OpImageWrite operations, except under the 709following conditions: 710 711 * For code:OpImageWrite, if the image format is listed in the 712 <<formats-without-shader-storage-format,storage without format>> list 713 and if the pname:shaderStorageImageWriteWithoutFormat feature is enabled 714 and the shader module declares the code:StorageImageWriteWithoutFormat 715 capability. 716ifdef::VK_VERSION_1_3,VK_KHR_format_feature_flags2[] 717 * For code:OpImageWrite, if the image format supports 718 ename:VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT and the 719 shader module declares the code:StorageImageWriteWithoutFormat 720 capability. 721endif::VK_VERSION_1_3,VK_KHR_format_feature_flags2[] 722 * For code:OpImageRead or code:OpImageSparseRead, if the image format is 723 listed in the <<formats-without-shader-storage-format,storage without 724 format>> list and if the pname:shaderStorageImageReadWithoutFormat 725 feature is enabled and the shader module declares the 726 code:StorageImageReadWithoutFormat capability. 727ifdef::VK_VERSION_1_3,VK_KHR_format_feature_flags2[] 728 * For code:OpImageRead or code:OpImageSparseRead, if the image format 729 supports ename:VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT and 730 the shader module declares the code:StorageImageReadWithoutFormat 731 capability. 732endif::VK_VERSION_1_3,VK_KHR_format_feature_flags2[] 733 * For code:OpImageRead, if code:Dim is code:SubpassData (indicating a read 734 from an input attachment). 735 736The code:Image code:Format of an code:OpTypeImage declaration must: not be 737*Unknown*, for variables which are used for code:OpAtomic* operations. 738 739Variables identified with the code:Uniform storage class are used to access 740transparent buffer backed resources. 741Such variables must: be: 742 743 * typed as code:OpTypeStruct, or an array of this type, 744 * identified with a code:Block or code:BufferBlock decoration, and 745 * laid out explicitly using the code:Offset, code:ArrayStride, and 746 code:MatrixStride decorations as specified in 747 <<interfaces-resources-layout,Offset and Stride Assignment>>. 748 749ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 750Variables identified with the code:StorageBuffer storage class are used to 751access transparent buffer backed resources. 752Such variables must: be: 753 754 * typed as code:OpTypeStruct, or an array of this type, 755 * identified with a code:Block decoration, and 756 * laid out explicitly using the code:Offset, code:ArrayStride, and 757 code:MatrixStride decorations as specified in 758 <<interfaces-resources-layout,Offset and Stride Assignment>>. 759endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 760 761ifndef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 762The code:Offset decoration for any variable in a code:Block must: not cause 763the space required for that variable to extend outside the range [eq]#[0, 764pname:maxUniformBufferRange)#. 765The code:Offset decoration for any variable in a code:BufferBlock must: not 766cause the space required for that variable to extend outside the range 767[eq]#[0, pname:maxStorageBufferRange)#. 768endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 769 770ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 771The code:Offset decoration for any member of a code:Block-decorated variable 772in the code:Uniform storage class must: not cause the space required for 773that variable to extend outside the range [eq]#[0, 774pname:maxUniformBufferRange)#. 775The code:Offset decoration for any member of a code:Block-decorated variable 776in the code:StorageBuffer storage class must: not cause the space required 777for that variable to extend outside the range [eq]#[0, 778pname:maxStorageBufferRange)#. 779endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 780 781ifdef::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 782Variables identified with the code:Uniform storage class can: also be used 783to access transparent descriptor set backed resources when the variable is 784assigned to a descriptor set layout binding with a pname:descriptorType of 785ename:VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK. 786In this case the variable must: be typed as code:OpTypeStruct and cannot: be 787aggregated into arrays of that type. 788Further, the code:Offset decoration for any member of such a variable must: 789not cause the space required for that variable to extend outside the range 790[eq]#[0,pname:maxInlineUniformBlockSize)#. 791endif::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 792 793Variables identified with a storage class of code:UniformConstant and a 794decoration of code:InputAttachmentIndex must: be declared as described in 795<<interfaces-inputattachment,Fragment Input Attachment Interface>>. 796 797SPIR-V variables decorated with a descriptor set and binding that identify a 798<<descriptorsets-combinedimagesampler, combined image sampler descriptor>> 799can: have a type of code:OpTypeImage, code:OpTypeSampler (code:Sampled=1), 800or code:OpTypeSampledImage. 801 802Arrays of any of these types can: be indexed with _constant integral 803expressions_. 804The following features must: be enabled and capabilities must: be declared 805in order to index such arrays with dynamically uniform or non-uniform 806indices: 807 808 * Storage images (except storage texel buffers and input attachments): 809 ** Dynamically uniform: pname:shaderStorageImageArrayDynamicIndexing and 810 code:StorageImageArrayDynamicIndexing 811ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 812 ** Non-uniform: pname:shaderStorageImageArrayNonUniformIndexing and 813 code:StorageImageArrayNonUniformIndexing 814 * Storage texel buffers: 815 ** Dynamically uniform: pname:shaderStorageTexelBufferArrayDynamicIndexing 816 and code:StorageTexelBufferArrayDynamicIndexing 817 ** Non-uniform: pname:shaderStorageTexelBufferArrayNonUniformIndexing and 818 code:StorageTexelBufferArrayNonUniformIndexing 819 * Input attachments: 820 ** Dynamically uniform: pname:shaderInputAttachmentArrayDynamicIndexing 821 and code:InputAttachmentArrayDynamicIndexing 822 ** Non-uniform: pname:shaderInputAttachmentArrayNonUniformIndexing and 823 code:InputAttachmentArrayNonUniformIndexing 824endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 825 * Sampled images (except uniform texel buffers), samplers and combined 826 image samplers: 827 ** Dynamically uniform: pname:shaderSampledImageArrayDynamicIndexing and 828 code:SampledImageArrayDynamicIndexing 829ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 830 ** Non-uniform: pname:shaderSampledImageArrayNonUniformIndexing and 831 code:SampledImageArrayNonUniformIndexing 832 * Uniform texel buffers: 833 ** Dynamically uniform: pname:shaderUniformTexelBufferArrayDynamicIndexing 834 and code:UniformTexelBufferArrayDynamicIndexing 835 ** Non-uniform: pname:shaderUniformTexelBufferArrayNonUniformIndexing and 836 code:UniformTexelBufferArrayNonUniformIndexing 837endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 838 * Uniform buffers: 839 ** Dynamically uniform: pname:shaderUniformBufferArrayDynamicIndexing and 840 code:UniformBufferArrayDynamicIndexing 841ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 842 ** Non-uniform: pname:shaderUniformBufferArrayNonUniformIndexing and 843 code:UniformBufferArrayNonUniformIndexing 844endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 845 * Storage buffers: 846 ** Dynamically uniform: pname:shaderStorageBufferArrayDynamicIndexing and 847 code:StorageBufferArrayDynamicIndexing 848ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 849 ** Non-uniform: pname:shaderStorageBufferArrayNonUniformIndexing and 850 code:StorageBufferArrayNonUniformIndexing 851endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 852ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 853 * Acceleration structures: 854 ** Dynamically uniform: Always supported. 855 ** Non-uniform: Always supported. 856endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 857ifdef::VK_QCOM_image_processing[] 858 * <<descriptorsets-weightimage,weight image>>: 859 ** Dynamically uniform: Always supported. 860 ** Non-uniform: Never supported. 861 * <<descriptorsets-blockmatch, Block matching image>>: 862 ** Dynamically uniform: Always supported. 863 ** Non-uniform: Never supported. 864endif::VK_QCOM_image_processing[] 865 866ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 867If an instruction loads from or stores to a resource (including atomics and 868image instructions) and the resource descriptor being accessed is not 869dynamically uniform, then the corresponding non-uniform indexing feature 870must: be enabled and the capability must: be declared. 871endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 872If an instruction loads from or stores to a resource (including atomics and 873image instructions) and the resource descriptor being accessed is loaded 874from an array element with a non-constant index, then the corresponding 875dynamic 876ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 877or non-uniform 878endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 879indexing feature must: be enabled and the capability must: be declared. 880 881ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 882If the combined image sampler enables sampler {YCbCr} 883ifndef::VK_EXT_fragment_density_map[] 884conversion, 885endif::VK_EXT_fragment_density_map[] 886ifdef::VK_EXT_fragment_density_map[] 887conversion or samples a <<samplers-subsamplesampler,subsampled image>>, 888endif::VK_EXT_fragment_density_map[] 889it must: be indexed only by constant integral expressions when aggregated 890into arrays in shader code, irrespective of the 891pname:shaderSampledImageArrayDynamicIndexing feature. 892endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 893ifndef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 894ifdef::VK_EXT_fragment_density_map[] 895If the combined image sampler samples a 896<<samplers-subsamplesampler,subsampled image>>, it must: be indexed only by 897constant integral expressions when aggregated into arrays in shader code, 898irrespective of the pname:shaderSampledImageArrayDynamicIndexing feature. 899endif::VK_EXT_fragment_density_map[] 900endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[] 901 902[[interfaces-resources-correspondence]] 903.Shader Resource and Descriptor Type Correspondence 904[width="90%",cols="<1,<2",options="header"] 905|==== 906| Resource type | Descriptor Type 907| sampler | ename:VK_DESCRIPTOR_TYPE_SAMPLER or 908 ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER 909| sampled image | ename:VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE or 910 ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER 911| storage image | ename:VK_DESCRIPTOR_TYPE_STORAGE_IMAGE 912| combined image sampler | ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER 913| uniform texel buffer | ename:VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER 914| storage texel buffer | ename:VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER 915| uniform buffer | ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or 916 ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC 917| storage buffer | ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or 918 ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC 919| input attachment | ename:VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT 920ifdef::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 921| inline uniform block | ename:VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK 922endif::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 923ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 924| acceleration structure | 925ifdef::VK_KHR_acceleration_structure[ename:VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR] 926ifdef::VK_NV_ray_tracing+VK_KHR_acceleration_structure[or] 927ifdef::VK_NV_ray_tracing[ename:VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV] 928endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 929ifdef::VK_QCOM_image_processing[] 930| weight image | ename:VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM 931| block matching image | ename:VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM 932endif::VK_QCOM_image_processing[] 933|==== 934 935[[interfaces-resources-storage-class-correspondence]] 936.Shader Resource and Storage Class Correspondence 937[width="100%",cols="<21%,<22%,<27%,<30%",options="header"] 938|==== 939| Resource type | Storage Class | Type^1^ | Decoration(s)^2^ 940| sampler 941 | code:UniformConstant | code:OpTypeSampler | 942| sampled image 943 | code:UniformConstant | code:OpTypeImage (code:Sampled=1)| 944| storage image 945 | code:UniformConstant | code:OpTypeImage (code:Sampled=2) | 946| combined image sampler 947 | code:UniformConstant | code:OpTypeSampledImage + 948 code:OpTypeImage (code:Sampled=1) + 949 code:OpTypeSampler | 950| uniform texel buffer 951 | code:UniformConstant | code:OpTypeImage (code:Dim=code:Buffer, code:Sampled=1) | 952| storage texel buffer 953 | code:UniformConstant | code:OpTypeImage (code:Dim=code:Buffer, code:Sampled=2) | 954| uniform buffer 955 | code:Uniform | code:OpTypeStruct 956 | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride) 957ifndef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 958| storage buffer 959 | code:Uniform | code:OpTypeStruct 960 | code:BufferBlock, code:Offset, (code:ArrayStride), (code:MatrixStride) 961endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 962ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 963.2+<.^| storage buffer 964 | code:Uniform .2+<.^| code:OpTypeStruct 965 | code:BufferBlock, code:Offset, (code:ArrayStride), (code:MatrixStride) 966 | code:StorageBuffer | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride) 967endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[] 968| input attachment 969 | code:UniformConstant | code:OpTypeImage (code:Dim=code:SubpassData, code:Sampled=2) 970 | code:InputAttachmentIndex 971ifdef::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 972| inline uniform block 973 | code:Uniform | code:OpTypeStruct 974 | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride) 975endif::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 976ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 977| acceleration structure 978 | code:UniformConstant | code:OpTypeAccelerationStructureKHR | 979endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 980ifdef::VK_QCOM_image_processing[] 981| sample weight image 982 | code:UniformConstant | code:OpTypeImage (code:Depth=0, code:Dim=code:2D, + 983 code:Arrayed=1, code:MS=0, code:Sampled=1) 984 | code:WeightTextureQCOM 985| block matching image 986 | code:UniformConstant | code:OpTypeImage (code:Depth=0, code:Dim=code:2D, + 987 code:Arrayed=0, code:MS=0, code:Sampled=1) 988 | code:BlockMatchTextureQCOM 989endif::VK_QCOM_image_processing[] 990|==== 991 9921:: 993 Where code:OpTypeImage is referenced, the code:Dim values code:Buffer 994 and code:Subpassdata are only accepted where they are specifically 995 referenced. 996 They do not correspond to resource types where a generic 997 code:OpTypeImage is specified. 9982:: 999 In addition to code:DescriptorSet and code:Binding. 1000 1001 1002[[interfaces-resources-setandbinding]] 1003=== DescriptorSet and Binding Assignment 1004 1005A variable decorated with a code:DescriptorSet decoration of [eq]#s# and a 1006code:Binding decoration of [eq]#b# indicates that this variable is 1007associated with the slink:VkDescriptorSetLayoutBinding that has a 1008pname:binding equal to [eq]#b# in pname:pSetLayouts[_s_] that was specified 1009in slink:VkPipelineLayoutCreateInfo. 1010 1011code:DescriptorSet decoration values must: be between zero and 1012pname:maxBoundDescriptorSets minus one, inclusive. 1013code:Binding decoration values can: be any 32-bit unsigned integer value, as 1014described in <<descriptorsets-setlayout>>. 1015Each descriptor set has its own binding name space. 1016 1017If the code:Binding decoration is used with an array, the entire array is 1018assigned that binding value. 1019The array must: be a single-dimensional array and size of the array must: be 1020no larger than the number of descriptors in the binding. 1021ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1022If the array is runtime-sized, then array elements greater than or equal to 1023the size of that binding in the bound descriptor set must: not be used. 1024If the array is runtime-sized, the pname:runtimeDescriptorArray feature 1025must: be enabled and the code:RuntimeDescriptorArray capability must: be 1026declared. 1027endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1028ifndef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1029The array must: not be runtime-sized. 1030endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1031The index of each element of the array is referred to as the _arrayElement_. 1032For the purposes of interface matching and descriptor set 1033<<descriptorsets-updates,operations>>, if a resource variable is not an 1034array, it is treated as if it has an arrayElement of zero. 1035 1036There is a limit on the number of resources of each type that can: be 1037accessed by a pipeline stage as shown in 1038<<interfaces-resources-limits,Shader Resource Limits>>. 1039The "`Resources Per Stage`" column gives the limit on the number each type 1040of resource that can: be statically used for an entry point in any given 1041stage in a pipeline. 1042The "`Resource Types`" column lists which resource types are counted against 1043the limit. 1044Some resource types count against multiple limits. 1045ifdef::VK_EXT_mutable_descriptor_type,VK_VALVE_mutable_descriptor_type[] 1046The ename:VK_DESCRIPTOR_TYPE_MUTABLE_EXT descriptor type counts as one 1047individual resource and one for every unique resource limit per descriptor 1048set type that is present in the associated binding's 1049slink:VkMutableDescriptorTypeListEXT. 1050If multiple descriptor types in slink:VkMutableDescriptorTypeListEXT map to 1051the same resource limit, only one descriptor is consumed for purposes of 1052computing resource limits. 1053endif::VK_EXT_mutable_descriptor_type,VK_VALVE_mutable_descriptor_type[] 1054 1055The pipeline layout may: include descriptor sets and bindings which are not 1056referenced by any variables statically used by the entry points for the 1057shader stages in the binding's pname:stageFlags. 1058 1059However, if a variable assigned to a given code:DescriptorSet and 1060code:Binding is statically used by the entry point for a shader stage, the 1061pipeline layout must: contain a descriptor set layout binding in that 1062descriptor set layout and for that binding number, and that binding's 1063pname:stageFlags must: include the appropriate elink:VkShaderStageFlagBits 1064for that stage. 1065The variable must: be of a valid resource type determined by its SPIR-V type 1066and storage class, as defined in 1067<<interfaces-resources-storage-class-correspondence,Shader Resource and 1068Storage Class Correspondence>>. 1069The descriptor set layout binding must: be of a corresponding descriptor 1070type, as defined in <<interfaces-resources-correspondence,Shader Resource 1071and Descriptor Type Correspondence>>. 1072 1073[NOTE] 1074.Note 1075==== 1076There are no limits on the number of shader variables that can have 1077overlapping set and binding values in a shader; but which resources are 1078<<shaders-staticuse,statically used>> has an impact. 1079If any shader variable identifying a resource is 1080<<shaders-staticuse,statically used>> in a shader, then the underlying 1081descriptor bound at the declared set and binding must 1082<<interfaces-resources-correspondence,support the declared type in the 1083shader>> when the shader executes. 1084 1085If multiple shader variables are declared with the same set and binding 1086values, and with the same underlying descriptor type, they can all be 1087statically used within the same shader. 1088However, accesses are not automatically synchronized, and code:Aliased 1089decorations should be used to avoid data hazards (see 1090https://registry.khronos.org/spir-v/specs/unified1/SPIRV.html#_a_id_aliasingsection_a_aliasing[section 10912.18.2 Aliasing in the SPIR-V specification]). 1092 1093If multiple shader variables with the same set and binding values are 1094declared in a single shader, but with different declared types, where any of 1095those are not supported by the relevant bound descriptor, that shader can 1096only be executed if the variables with the unsupported type are not 1097statically used. 1098 1099A noteworthy example of using multiple statically-used shader variables 1100sharing the same descriptor set and binding values is a descriptor of type 1101ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER that has multiple 1102corresponding shader variables in the code:UniformConstant storage class, 1103where some could be code:OpTypeImage (code:Sampled=1), some could be 1104code:OpTypeSampler, and some could be code:OpTypeSampledImage. 1105==== 1106 1107[[interfaces-resources-limits]] 1108.Shader Resource Limits 1109[width="80%",cols="<35,<23",options="header"] 1110|==== 1111| Resources per Stage | Resource Types 1112.2+<.^| pname:maxPerStageDescriptorSamplers 1113ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1114or pname:maxPerStageDescriptorUpdateAfterBindSamplers 1115endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1116 | sampler | combined image sampler 1117ifndef::VK_QCOM_image_processing[] 1118.3+<.^| pname:maxPerStageDescriptorSampledImages 1119ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1120or pname:maxPerStageDescriptorUpdateAfterBindSampledImages 1121endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1122 | sampled image | combined image sampler | uniform texel buffer 1123endif::VK_QCOM_image_processing[] 1124ifdef::VK_QCOM_image_processing[] 1125.5+<.^| pname:maxPerStageDescriptorSampledImages 1126ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1127or pname:maxPerStageDescriptorUpdateAfterBindSampledImages 1128endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1129 | sampled image | combined image sampler | uniform texel buffer + 1130 | sample weight image | block matching image 1131endif::VK_QCOM_image_processing[] 1132.2+<.^| pname:maxPerStageDescriptorStorageImages 1133ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1134or pname:maxPerStageDescriptorUpdateAfterBindStorageImages 1135endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1136 | storage image | storage texel buffer 1137.2+<.^| pname:maxPerStageDescriptorUniformBuffers 1138ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1139or pname:maxPerStageDescriptorUpdateAfterBindUniformBuffers 1140endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1141 | uniform buffer | uniform buffer dynamic 1142.2+<.^| pname:maxPerStageDescriptorStorageBuffers 1143ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1144or pname:maxPerStageDescriptorUpdateAfterBindStorageBuffers 1145endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1146 | storage buffer | storage buffer dynamic 1147| pname:maxPerStageDescriptorInputAttachments 1148ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1149or pname:maxPerStageDescriptorUpdateAfterBindInputAttachments 1150endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1151 | input attachment^1^ 1152ifdef::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 1153| pname:maxPerStageDescriptorInlineUniformBlocks 1154ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1155or pname:maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks 1156endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] 1157 | inline uniform block 1158endif::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] 1159ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 1160| 1161ifdef::VK_NV_ray_tracing[sname:VkPhysicalDeviceRayTracingPropertiesNV::pname:maxDescriptorSetAccelerationStructures] 1162ifdef::VK_NV_ray_tracing+VK_KHR_acceleration_structure[or] 1163ifdef::VK_KHR_acceleration_structure[] 1164pname:maxPerStageDescriptorAccelerationStructures or 1165pname:maxPerStageDescriptorUpdateAfterBindAccelerationStructures 1166endif::VK_KHR_acceleration_structure[] 1167 | acceleration structure 1168endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 1169|==== 1170 11711:: 1172 Input attachments can: only be used in the fragment shader stage 1173 1174 1175[[interfaces-resources-layout]] 1176=== Offset and Stride Assignment 1177 1178Certain objects must: be explicitly laid out using the code:Offset, 1179code:ArrayStride, and code:MatrixStride, as described in 1180https://registry.khronos.org/spir-v/specs/unified1/SPIRV.html#ShaderValidation[SPIR-V 1181explicit layout validation rules]. 1182All such layouts also must: conform to the following requirements. 1183 1184[NOTE] 1185.Note 1186==== 1187The numeric order of code:Offset decorations does not need to follow member 1188declaration order. 1189==== 1190 1191 1192[[interfaces-alignment-requirements]] 1193*Alignment Requirements* 1194 1195There are different alignment requirements depending on the specific 1196resources and on the features enabled on the device. 1197 1198Matrix types are defined in terms of arrays as follows: 1199 1200 * A column-major matrix with [eq]#C# columns and [eq]#R# rows is 1201 equivalent to a [eq]#C# element array of vectors with [eq]#R# 1202 components. 1203 * A row-major matrix with [eq]#C# columns and [eq]#R# rows is equivalent 1204 to an [eq]#R# element array of vectors with [eq]#C# components. 1205 1206The _scalar alignment_ of the type of an code:OpTypeStruct member is defined 1207recursively as follows: 1208 1209 * A scalar of size [eq]#N# has a scalar alignment of [eq]#N#. 1210 * A vector type has a scalar alignment equal to that of its component 1211 type. 1212 * An array type has a scalar alignment equal to that of its element type. 1213 * A structure has a scalar alignment equal to the largest scalar alignment 1214 of any of its members. 1215 * A matrix type inherits _scalar alignment_ from the equivalent array 1216 declaration. 1217 1218The _base alignment_ of the type of an code:OpTypeStruct member is defined 1219recursively as follows: 1220 1221 * A scalar has a base alignment equal to its scalar alignment. 1222 * A two-component vector has a base alignment equal to twice its scalar 1223 alignment. 1224 * A three- or four-component vector has a base alignment equal to four 1225 times its scalar alignment. 1226 * An array has a base alignment equal to the base alignment of its element 1227 type. 1228 * A structure has a base alignment equal to the largest base alignment of 1229 any of its members. 1230 An empty structure has a base alignment equal to the size of the 1231 smallest scalar type permitted by the capabilities declared in the 1232 SPIR-V module. 1233 (e.g., for a 1 byte aligned empty struct in the code:StorageBuffer 1234 storage class, code:StorageBuffer8BitAccess or 1235 code:UniformAndStorageBuffer8BitAccess must: be declared in the SPIR-V 1236 module.) 1237 * A matrix type inherits _base alignment_ from the equivalent array 1238 declaration. 1239 1240The _extended alignment_ of the type of an code:OpTypeStruct member is 1241similarly defined as follows: 1242 1243 * A scalar or vector type has an extended alignment equal to its base 1244 alignment. 1245 * An array or structure type has an extended alignment equal to the 1246 largest extended alignment of any of its members, rounded up to a 1247 multiple of 16. 1248 * A matrix type inherits extended alignment from the equivalent array 1249 declaration. 1250 1251ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1252 1253A member is defined to _improperly straddle_ if either of the following are 1254true: 1255 1256 * It is a vector with total size less than or equal to 16 bytes, and has 1257 code:Offset decorations placing its first byte at [eq]#F# and its last 1258 byte at [eq]#L#, where [eq]#floor(F / 16) != floor(L / 16)#. 1259 * It is a vector with total size greater than 16 bytes and has its 1260 code:Offset decorations placing its first byte at a non-integer multiple 1261 of 16. 1262 1263endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1264 1265[[interfaces-resources-standard-layout]] 1266*Standard Buffer Layout* 1267 1268Every member of an code:OpTypeStruct that is required to be explicitly laid 1269out must: be aligned according to the first matching rule as follows. 1270If the struct is contained in pointer types of multiple storage classes, it 1271must: satisfy the requirements for every storage class used to reference it. 1272 1273ifdef::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1274 . If the code:scalarBlockLayout feature is enabled on the device and the 1275 storage class is code:Uniform, code:StorageBuffer, 1276ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1277 code:PhysicalStorageBuffer, 1278endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1279ifdef::VK_KHR_ray_tracing_pipeline[] 1280 code:ShaderRecordBufferKHR, 1281endif::VK_KHR_ray_tracing_pipeline[] 1282 or code:PushConstant then every member must: be aligned according to its 1283 scalar alignment. 1284endif::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1285ifdef::VK_KHR_workgroup_memory_explicit_layout[] 1286 . If the code:workgroupMemoryExplicitLayoutScalarBlockLayout feature is 1287 enabled on the device and the storage class is code:Workgroup then every 1288 member must: be aligned according to its scalar alignment. 1289endif::VK_KHR_workgroup_memory_explicit_layout[] 1290ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1291 . All vectors must: be aligned according to their scalar alignment. 1292endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1293ifdef::VK_VERSION_1_2,VK_KHR_uniform_buffer_standard_layout[] 1294 . If the pname:uniformBufferStandardLayout feature is not enabled on the 1295 device, then any 1296endif::VK_VERSION_1_2,VK_KHR_uniform_buffer_standard_layout[] 1297ifndef::VK_VERSION_1_2,VK_KHR_uniform_buffer_standard_layout[] 1298 . Any 1299endif::VK_VERSION_1_2,VK_KHR_uniform_buffer_standard_layout[] 1300 member of an code:OpTypeStruct with a storage class of code:Uniform and 1301 a decoration of code:Block must: be aligned according to its extended 1302 alignment. 1303 . Every other member must: be aligned according to its base alignment. 1304 1305ifdef::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1306[NOTE] 1307.Note 1308==== 1309Even if scalar alignment is supported, it is generally more performant to 1310use the _base alignment_. 1311==== 1312endif::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1313 1314The memory layout must: obey the following rules: 1315 1316 * The code:Offset decoration of any member must: be a multiple of its 1317 alignment. 1318 * Any code:ArrayStride or code:MatrixStride decoration must: be a multiple 1319 of the alignment of the array or matrix as defined above. 1320 1321ifdef::VK_VERSION_1_2,VK_EXT_scalar_block_layout,VK_KHR_workgroup_memory_explicit_layout[] 1322If one of the conditions below applies 1323 1324ifdef::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1325 * The storage class is code:Uniform, code:StorageBuffer, 1326ifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1327 code:PhysicalStorageBuffer, 1328endif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[] 1329ifdef::VK_KHR_ray_tracing_pipeline[] 1330 code:ShaderRecordBufferKHR, 1331endif::VK_KHR_ray_tracing_pipeline[] 1332 or code:PushConstant, and the code:scalarBlockLayout feature is not 1333 enabled on the device. 1334endif::VK_VERSION_1_2,VK_EXT_scalar_block_layout[] 1335ifdef::VK_KHR_workgroup_memory_explicit_layout[] 1336 * The storage class is code:Workgroup, and either the struct member is not 1337 part of a code:Block or the 1338 code:workgroupMemoryExplicitLayoutScalarBlockLayout feature is not 1339 enabled on the device. 1340endif::VK_KHR_workgroup_memory_explicit_layout[] 1341 * The storage class is any other storage class. 1342 1343the memory layout must: also obey the following rules: 1344endif::VK_VERSION_1_2,VK_EXT_scalar_block_layout,VK_KHR_workgroup_memory_explicit_layout[] 1345 1346ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1347 * Vectors must: not improperly straddle, as defined above. 1348endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[] 1349 * The code:Offset decoration of a member must: not place it between the 1350 end of a structure, an array or a matrix and the next multiple of the 1351 alignment of that structure, array or matrix. 1352 1353[NOTE] 1354.Note 1355==== 1356The *std430 layout* in GLSL satisfies these rules for types using the base 1357alignment. 1358The *std140 layout* satisfies the rules for types using the extended 1359alignment. 1360==== 1361 1362 1363[[interfaces-builtin-variables]] 1364== Built-In Variables 1365 1366Built-in variables are accessed in shaders by declaring a variable decorated 1367with a code:BuiltIn SPIR-V decoration. 1368The meaning of each code:BuiltIn decoration is as follows. 1369In the remainder of this section, the name of a built-in is used 1370interchangeably with a term equivalent to a variable decorated with that 1371particular built-in. 1372Built-ins that represent integer values can: be declared as either signed or 1373unsigned 32-bit integers. 1374 1375<<interfaces-iointerfaces-matching, As mentioned above>>, some inputs and 1376outputs have an additional level of arrayness relative to other shader 1377inputs and outputs. 1378This level of arrayness is not included in the type descriptions below, but 1379must be included when declaring the built-in. 1380 1381ifdef::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 1382[[interfaces-builtin-variables-barycoordkhr]] 1383[open,refpage='BaryCoordKHR',desc='Barycentric coordinates of a fragment',type='builtins'] 1384-- 1385:refpage: BaryCoordKHR 1386 1387code:BaryCoordKHR:: 1388 1389The code:BaryCoordKHR decoration can: be used to decorate a fragment shader 1390input variable. 1391This variable will contain a three-component floating-point vector with 1392barycentric weights that indicate the location of the fragment relative to 1393the screen-space locations of vertices of its primitive, obtained using 1394perspective interpolation. 1395 1396.Valid Usage 1397**** 1398 * [[VUID-{refpage}-BaryCoordKHR-04154]] 1399 The code:BaryCoordKHR decoration must: be used only within the 1400 code:Fragment {ExecutionModel} 1401 * [[VUID-{refpage}-BaryCoordKHR-04155]] 1402 The variable decorated with code:BaryCoordKHR must: be declared using 1403 the code:Input {StorageClass} 1404 * [[VUID-{refpage}-BaryCoordKHR-04156]] 1405 The variable decorated with code:BaryCoordKHR must: be declared as a 1406 three-component vector of 32-bit floating-point values 1407**** 1408-- 1409endif::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 1410 1411ifdef::VK_AMD_shader_explicit_vertex_parameter[] 1412[open,refpage='BaryCoordNoPerspAMD',desc='Barycentric coordinates of a fragment center in screen-space',type='builtins'] 1413-- 1414:refpage: BaryCoordNoPerspAMD 1415 1416code:BaryCoordNoPerspAMD:: 1417 1418The code:BaryCoordNoPerspAMD decoration can: be used to decorate a fragment 1419shader input variable. 1420This variable will contain the (I,J) pair of the barycentric coordinates 1421corresponding to the fragment evaluated using linear interpolation at the 1422fragment's center. 1423The K coordinate of the barycentric coordinates can: be derived given the 1424identity I {plus} J {plus} K = 1.0. 1425 1426.Valid Usage 1427**** 1428 * [[VUID-{refpage}-BaryCoordNoPerspAMD-04157]] 1429 The code:BaryCoordNoPerspAMD decoration must: be used only within the 1430 code:Fragment {ExecutionModel} 1431 * [[VUID-{refpage}-BaryCoordNoPerspAMD-04158]] 1432 The variable decorated with code:BaryCoordNoPerspAMD must: be declared 1433 using the code:Input {StorageClass} 1434 * [[VUID-{refpage}-BaryCoordNoPerspAMD-04159]] 1435 The variable decorated with code:BaryCoordNoPerspAMD must: be declared 1436 as a two-component vector of 32-bit floating-point values 1437**** 1438-- 1439endif::VK_AMD_shader_explicit_vertex_parameter[] 1440 1441ifdef::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 1442[[interfaces-builtin-variables-barycoordnoperspkhr]] 1443[open,refpage='BaryCoordNoPerspKHR',desc='Barycentric coordinates of a fragment in screen-space',type='builtins'] 1444-- 1445:refpage: BaryCoordNoPerspKHR 1446 1447code:BaryCoordNoPerspKHR:: 1448 1449The code:BaryCoordNoPerspKHR decoration can: be used to decorate a fragment 1450shader input variable. 1451This variable will contain a three-component floating-point vector with 1452barycentric weights that indicate the location of the fragment relative to 1453the screen-space locations of vertices of its primitive, obtained using 1454linear interpolation. 1455 1456.Valid Usage 1457**** 1458 * [[VUID-{refpage}-BaryCoordNoPerspKHR-04160]] 1459 The code:BaryCoordNoPerspKHR decoration must: be used only within the 1460 code:Fragment {ExecutionModel} 1461 * [[VUID-{refpage}-BaryCoordNoPerspKHR-04161]] 1462 The variable decorated with code:BaryCoordNoPerspKHR must: be declared 1463 using the code:Input {StorageClass} 1464 * [[VUID-{refpage}-BaryCoordNoPerspKHR-04162]] 1465 The variable decorated with code:BaryCoordNoPerspKHR must: be declared 1466 as a three-component vector of 32-bit floating-point values 1467**** 1468-- 1469endif::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 1470 1471ifdef::VK_AMD_shader_explicit_vertex_parameter[] 1472[open,refpage='BaryCoordNoPerspCentroidAMD',desc='Barycentric coordinates of a fragment centroid in screen-space',type='builtins'] 1473-- 1474:refpage: BaryCoordNoPerspCentroidAMD 1475 1476code:BaryCoordNoPerspCentroidAMD:: 1477 1478The code:BaryCoordNoPerspCentroidAMD decoration can: be used to decorate a 1479fragment shader input variable. 1480This variable will contain the (I,J) pair of the barycentric coordinates 1481corresponding to the fragment evaluated using linear interpolation at the 1482centroid. 1483The K coordinate of the barycentric coordinates can: be derived given the 1484identity I {plus} J {plus} K = 1.0. 1485 1486.Valid Usage 1487**** 1488 * [[VUID-{refpage}-BaryCoordNoPerspCentroidAMD-04163]] 1489 The code:BaryCoordNoPerspCentroidAMD decoration must: be used only 1490 within the code:Fragment {ExecutionModel} 1491 * [[VUID-{refpage}-BaryCoordNoPerspCentroidAMD-04164]] 1492 The variable decorated with code:BaryCoordNoPerspCentroidAMD must: be 1493 declared using the code:Input {StorageClass} 1494 * [[VUID-{refpage}-BaryCoordNoPerspCentroidAMD-04165]] 1495 The variable decorated with code:BaryCoordNoPerspCentroidAMD must: be 1496 declared as a three-component vector of 32-bit floating-point values 1497**** 1498-- 1499 1500[open,refpage='BaryCoordNoPerspSampleAMD',desc='Barycentric coordinates of a sample center in screen-space',type='builtins'] 1501-- 1502:refpage: BaryCoordNoPerspSampleAMD 1503 1504code:BaryCoordNoPerspSampleAMD:: 1505 1506The code:BaryCoordNoPerspSampleAMD decoration can: be used to decorate a 1507fragment shader input variable. 1508This variable will contain the (I,J) pair of the barycentric coordinates 1509corresponding to the fragment evaluated using linear interpolation at each 1510covered sample. 1511The K coordinate of the barycentric coordinates can: be derived given the 1512identity I {plus} J {plus} K = 1.0. 1513 1514.Valid Usage 1515**** 1516 * [[VUID-{refpage}-BaryCoordNoPerspSampleAMD-04166]] 1517 The code:BaryCoordNoPerspSampleAMD decoration must: be used only within 1518 the code:Fragment {ExecutionModel} 1519 * [[VUID-{refpage}-BaryCoordNoPerspSampleAMD-04167]] 1520 The variable decorated with code:BaryCoordNoPerspSampleAMD must: be 1521 declared using the code:Input {StorageClass} 1522 * [[VUID-{refpage}-BaryCoordNoPerspSampleAMD-04168]] 1523 The variable decorated with code:BaryCoordNoPerspSampleAMD must: be 1524 declared as a two-component vector of 32-bit floating-point values 1525**** 1526-- 1527 1528[open,refpage='BaryCoordPullModelAMD',desc='Inverse barycentric coordinates of a fragment center',type='builtins'] 1529-- 1530:refpage: BaryCoordPullModelAMD 1531 1532code:BaryCoordPullModelAMD:: 1533 1534The code:BaryCoordPullModelAMD decoration can: be used to decorate a 1535fragment shader input variable. 1536This variable will contain (1/W, 1/I, 1/J) evaluated at the fragment center 1537and can: be used to calculate gradients and then interpolate I, J, and W at 1538any desired sample location. 1539 1540.Valid Usage 1541**** 1542 * [[VUID-{refpage}-BaryCoordPullModelAMD-04169]] 1543 The code:BaryCoordPullModelAMD decoration must: be used only within the 1544 code:Fragment {ExecutionModel} 1545 * [[VUID-{refpage}-BaryCoordPullModelAMD-04170]] 1546 The variable decorated with code:BaryCoordPullModelAMD must: be declared 1547 using the code:Input {StorageClass} 1548 * [[VUID-{refpage}-BaryCoordPullModelAMD-04171]] 1549 The variable decorated with code:BaryCoordPullModelAMD must: be declared 1550 as a three-component vector of 32-bit floating-point values 1551**** 1552-- 1553 1554[open,refpage='BaryCoordSmoothAMD',desc='Barycentric coordinates of a fragment center',type='builtins'] 1555-- 1556:refpage: BaryCoordSmoothAMD 1557 1558code:BaryCoordSmoothAMD:: 1559 1560The code:BaryCoordSmoothAMD decoration can: be used to decorate a fragment 1561shader input variable. 1562This variable will contain the (I,J) pair of the barycentric coordinates 1563corresponding to the fragment evaluated using perspective interpolation at 1564the fragment's center. 1565The K coordinate of the barycentric coordinates can: be derived given the 1566identity I {plus} J {plus} K = 1.0. 1567 1568.Valid Usage 1569**** 1570 * [[VUID-{refpage}-BaryCoordSmoothAMD-04172]] 1571 The code:BaryCoordSmoothAMD decoration must: be used only within the 1572 code:Fragment {ExecutionModel} 1573 * [[VUID-{refpage}-BaryCoordSmoothAMD-04173]] 1574 The variable decorated with code:BaryCoordSmoothAMD must: be declared 1575 using the code:Input {StorageClass} 1576 * [[VUID-{refpage}-BaryCoordSmoothAMD-04174]] 1577 The variable decorated with code:BaryCoordSmoothAMD must: be declared as 1578 a two-component vector of 32-bit floating-point values 1579**** 1580-- 1581 1582[open,refpage='BaryCoordSmoothCentroidAMD',desc='Barycentric coordinates of a fragment centroid',type='builtins'] 1583-- 1584:refpage: BaryCoordSmoothCentroidAMD 1585 1586code:BaryCoordSmoothCentroidAMD:: 1587 1588The code:BaryCoordSmoothCentroidAMD decoration can: be used to decorate a 1589fragment shader input variable. 1590This variable will contain the (I,J) pair of the barycentric coordinates 1591corresponding to the fragment evaluated using perspective interpolation at 1592the centroid. 1593The K coordinate of the barycentric coordinates can: be derived given the 1594identity I {plus} J {plus} K = 1.0. 1595 1596.Valid Usage 1597**** 1598 * [[VUID-{refpage}-BaryCoordSmoothCentroidAMD-04175]] 1599 The code:BaryCoordSmoothCentroidAMD decoration must: be used only within 1600 the code:Fragment {ExecutionModel} 1601 * [[VUID-{refpage}-BaryCoordSmoothCentroidAMD-04176]] 1602 The variable decorated with code:BaryCoordSmoothCentroidAMD must: be 1603 declared using the code:Input {StorageClass} 1604 * [[VUID-{refpage}-BaryCoordSmoothCentroidAMD-04177]] 1605 The variable decorated with code:BaryCoordSmoothCentroidAMD must: be 1606 declared as a two-component vector of 32-bit floating-point values 1607**** 1608-- 1609 1610[open,refpage='BaryCoordSmoothSampleAMD',desc='Barycentric coordinates of a sample center',type='builtins'] 1611-- 1612:refpage: BaryCoordSmoothSampleAMD 1613 1614code:BaryCoordSmoothSampleAMD:: 1615 1616The code:BaryCoordSmoothSampleAMD decoration can: be used to decorate a 1617fragment shader input variable. 1618This variable will contain the (I,J) pair of the barycentric coordinates 1619corresponding to the fragment evaluated using perspective interpolation at 1620each covered sample. 1621The K coordinate of the barycentric coordinates can: be derived given the 1622identity I {plus} J {plus} K = 1.0. 1623 1624.Valid Usage 1625**** 1626 * [[VUID-{refpage}-BaryCoordSmoothSampleAMD-04178]] 1627 The code:BaryCoordSmoothSampleAMD decoration must: be used only within 1628 the code:Fragment {ExecutionModel} 1629 * [[VUID-{refpage}-BaryCoordSmoothSampleAMD-04179]] 1630 The variable decorated with code:BaryCoordSmoothSampleAMD must: be 1631 declared using the code:Input {StorageClass} 1632 * [[VUID-{refpage}-BaryCoordSmoothSampleAMD-04180]] 1633 The variable decorated with code:BaryCoordSmoothSampleAMD must: be 1634 declared as a two-component vector of 32-bit floating-point values 1635**** 1636-- 1637endif::VK_AMD_shader_explicit_vertex_parameter[] 1638 1639 1640ifdef::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[] 1641[[interfaces-builtin-variables-baseinstance]] 1642[open,refpage='BaseInstance',desc='First instance being rendered',type='builtins'] 1643-- 1644:refpage: BaseInstance 1645 1646code:BaseInstance:: 1647 1648Decorating a variable with the code:BaseInstance built-in will make that 1649variable contain the integer value corresponding to the first instance that 1650was passed to the command that invoked the current vertex shader invocation. 1651code:BaseInstance is the pname:firstInstance parameter to a _direct drawing 1652command_ or the pname:firstInstance member of a structure consumed by an 1653_indirect drawing command_. 1654 1655.Valid Usage 1656**** 1657 * [[VUID-{refpage}-BaseInstance-04181]] 1658 The code:BaseInstance decoration must: be used only within the 1659 code:Vertex {ExecutionModel} 1660 * [[VUID-{refpage}-BaseInstance-04182]] 1661 The variable decorated with code:BaseInstance must: be declared using 1662 the code:Input {StorageClass} 1663 * [[VUID-{refpage}-BaseInstance-04183]] 1664 The variable decorated with code:BaseInstance must: be declared as a 1665 scalar 32-bit integer value 1666**** 1667-- 1668 1669[[interfaces-builtin-variables-basevertex]] 1670[open,refpage='BaseVertex',desc='First vertex being rendered',type='builtins'] 1671-- 1672:refpage: BaseVertex 1673 1674code:BaseVertex:: 1675 1676Decorating a variable with the code:BaseVertex built-in will make that 1677variable contain the integer value corresponding to the first vertex or 1678vertex offset that was passed to the command that invoked the current vertex 1679shader invocation. 1680For _non-indexed drawing commands_, this variable is the pname:firstVertex 1681parameter to a _direct drawing command_ or the pname:firstVertex member of 1682the structure consumed by an _indirect drawing command_. 1683For _indexed drawing commands_, this variable is the pname:vertexOffset 1684parameter to a _direct drawing command_ or the pname:vertexOffset member of 1685the structure consumed by an _indirect drawing command_. 1686 1687.Valid Usage 1688**** 1689 * [[VUID-{refpage}-BaseVertex-04184]] 1690 The code:BaseVertex decoration must: be used only within the code:Vertex 1691 {ExecutionModel} 1692 * [[VUID-{refpage}-BaseVertex-04185]] 1693 The variable decorated with code:BaseVertex must: be declared using the 1694 code:Input {StorageClass} 1695 * [[VUID-{refpage}-BaseVertex-04186]] 1696 The variable decorated with code:BaseVertex must: be declared as a 1697 scalar 32-bit integer value 1698**** 1699-- 1700endif::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[] 1701 1702[[interfaces-builtin-variables-clipdistance]] 1703[open,refpage='ClipDistance',desc='Application-specified clip distances',type='builtins'] 1704-- 1705:refpage: ClipDistance 1706 1707code:ClipDistance:: 1708 1709Decorating a variable with the code:ClipDistance built-in decoration will 1710make that variable contain the mechanism for controlling user clipping. 1711code:ClipDistance is an array such that the i^th^ element of the array 1712specifies the clip distance for plane i. 1713A clip distance of 0 means the vertex is on the plane, a positive distance 1714means the vertex is inside the clip half-space, and a negative distance 1715means the vertex is outside the clip half-space. 1716 1717[NOTE] 1718.Note 1719==== 1720The array variable decorated with code:ClipDistance is explicitly sized by 1721the shader. 1722==== 1723 1724[NOTE] 1725.Note 1726==== 1727In the last <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization 1728shader stage>>, these values will be linearly interpolated across the 1729primitive and the portion of the primitive with interpolated distances less 1730than 0 will be considered outside the clip volume. 1731If code:ClipDistance is then used by a fragment shader, code:ClipDistance 1732contains these linearly interpolated values. 1733==== 1734 1735.Valid Usage 1736**** 1737 * [[VUID-{refpage}-ClipDistance-04187]] 1738 The code:ClipDistance decoration must: be used only within the 1739 code:MeshEXT, code:MeshNV, code:Vertex, code:Fragment, 1740 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 1741 {ExecutionModel} 1742 * [[VUID-{refpage}-ClipDistance-04188]] 1743 The variable decorated with code:ClipDistance within the code:MeshEXT, 1744 code:MeshNV, or code:Vertex {ExecutionModel} must: be declared using the 1745 code:Output {StorageClass} 1746 * [[VUID-{refpage}-ClipDistance-04189]] 1747 The variable decorated with code:ClipDistance within the code:Fragment 1748 {ExecutionModel} must: be declared using the code:Input {StorageClass} 1749 * [[VUID-{refpage}-ClipDistance-04190]] 1750 The variable decorated with code:ClipDistance within the 1751 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 1752 {ExecutionModel} must: not be declared in a {StorageClass} other than 1753 code:Input or code:Output 1754 * [[VUID-{refpage}-ClipDistance-04191]] 1755 The variable decorated with code:ClipDistance must: be declared as an 1756 array of 32-bit floating-point values 1757**** 1758-- 1759 1760ifdef::VK_NV_mesh_shader[] 1761[[interfaces-builtin-variables-clipdistancepv]] 1762[open,refpage='ClipDistancePerViewNV',desc='Application-specified clip distances per view',type='builtins'] 1763-- 1764:refpage: ClipDistancePerViewNV 1765 1766code:ClipDistancePerViewNV:: 1767 1768Decorating a variable with the code:ClipDistancePerViewNV built-in 1769decoration will make that variable contain the per-view clip distances. 1770The per-view clip distances have the same semantics as code:ClipDistance. 1771 1772.Valid Usage 1773**** 1774 * [[VUID-{refpage}-ClipDistancePerViewNV-04192]] 1775 The code:ClipDistancePerViewNV decoration must: be used only within the 1776 code:MeshNV {ExecutionModel} 1777 * [[VUID-{refpage}-ClipDistancePerViewNV-04193]] 1778 The variable decorated with code:ClipDistancePerViewNV must: be declared 1779 using the code:Output {StorageClass} 1780 * [[VUID-{refpage}-ClipDistancePerViewNV-04194]] 1781 The variable decorated with code:ClipDistancePerViewNV must: also be 1782 decorated with the code:PerViewNV decoration 1783 * [[VUID-{refpage}-ClipDistancePerViewNV-04195]] 1784 The variable decorated with code:ClipDistancePerViewNV must: be declared 1785 as a two-dimensional array of 32-bit floating-point values 1786**** 1787-- 1788endif::VK_NV_mesh_shader[] 1789 1790 1791ifdef::VK_HUAWEI_cluster_culling_shader[] 1792[[interfaces-builtin-variables-clusteridhuawei]] 1793[open,refpage='ClusterIDHUAWEI',desc='cluster culling shader output variable',type='builtins'] 1794-- 1795:refpage: ClusterIDHUAWEI 1796 1797code:ClusterIDHUAWEI:: 1798 1799The code:ClusterIDHUAWEI decoration can be used to decorate a cluster 1800culling shader output variable,this variable will contain an integer value 1801that specifies the id of cluster being rendered by this drawing command. 1802When Cluster Culling Shader enable, code:ClusterIDHUAWEI will replace 1803gl_DrawID pass to vertex shader for cluster-related information fetching. 1804 1805 1806.Valid Usage 1807**** 1808 * [[VUID-{refpage}-ClusterIDHUAWEI-07797]] 1809 The code:ClusterIDHUAWEI decoration must: be used only within the 1810 code:ClusterCullingHUAWEI {ExecutionModel} 1811 * [[VUID-{refpage}-ClusterIDHUAWEI-07798]] 1812 The variable decorated with code:ClusterIDHUAWEI must: be declared as a 1813 scalar 32-bit integer value 1814**** 1815-- 1816endif::VK_HUAWEI_cluster_culling_shader[] 1817 1818ifdef::VK_HUAWEI_cluster_culling_shader[] 1819[[interfaces-builtin-variables-clustershadingratehuawei]] 1820[open,refpage='ClusterShadingRateHUAWEI',desc='cluster culling shader output variable',type='builtins'] 1821-- 1822:refpage: ClusterShadingRateHUAWEI 1823 1824code:ClusterShadingRateHUAWEI:: 1825 1826The code:ClusterShadingRateHUAWEI decoration can be used to decorate a 1827cluster culling shader output variable. 1828This variable will contain an integer value specifying the shading rate of a 1829rendering cluster. 1830 1831.Valid Usage 1832**** 1833 * [[VUID-{refpage}-ClusterShadingRateHUAWEI-09448]] 1834 The code:ClusterShadingRateHUAWEI decoration must: be used only within 1835 the code:ClusterCullingHUAWEI {ExecutionModel} 1836 * [[VUID-{refpage}-ClusterShadingRateHUAWEI-09449]] 1837 The variable decorated with code:ClusterShadingRateHUAWEI must: be 1838 declared as a scalar 32-bit integer value 1839**** 1840-- 1841endif::VK_HUAWEI_cluster_culling_shader[] 1842 1843 1844 1845[[interfaces-builtin-variables-culldistance]] 1846[open,refpage='CullDistance',desc='Application-specified cull distances',type='builtins'] 1847-- 1848:refpage: CullDistance 1849 1850code:CullDistance:: 1851 1852Decorating a variable with the code:CullDistance built-in decoration will 1853make that variable contain the mechanism for controlling user culling. 1854If any member of this array is assigned a negative value for all vertices 1855belonging to a primitive, then the primitive is discarded before 1856rasterization. 1857 1858[NOTE] 1859.Note 1860==== 1861In fragment shaders, the values of the code:CullDistance array are linearly 1862interpolated across each primitive. 1863==== 1864 1865[NOTE] 1866.Note 1867==== 1868If code:CullDistance decorates an input variable, that variable will contain 1869the corresponding value from the code:CullDistance decorated output variable 1870from the previous shader stage. 1871==== 1872 1873.Valid Usage 1874**** 1875 * [[VUID-{refpage}-CullDistance-04196]] 1876 The code:CullDistance decoration must: be used only within the 1877 code:MeshEXT, code:MeshNV, code:Vertex, code:Fragment, 1878 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 1879 {ExecutionModel} 1880 * [[VUID-{refpage}-CullDistance-04197]] 1881 The variable decorated with code:CullDistance within the code:MeshEXT, 1882 code:MeshNV or code:Vertex {ExecutionModel} must: be declared using the 1883 code:Output {StorageClass} 1884 * [[VUID-{refpage}-CullDistance-04198]] 1885 The variable decorated with code:CullDistance within the code:Fragment 1886 {ExecutionModel} must: be declared using the code:Input {StorageClass} 1887 * [[VUID-{refpage}-CullDistance-04199]] 1888 The variable decorated with code:CullDistance within the 1889 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 1890 {ExecutionModel} must: not be declared using a {StorageClass} other than 1891 code:Input or code:Output 1892 * [[VUID-{refpage}-CullDistance-04200]] 1893 The variable decorated with code:CullDistance must: be declared as an 1894 array of 32-bit floating-point values 1895**** 1896-- 1897 1898ifdef::VK_NV_mesh_shader[] 1899[[interfaces-builtin-variables-culldistancepv]] 1900[open,refpage='CullDistancePerViewNV',desc='Application-specified cull distances per view',type='builtins'] 1901-- 1902:refpage: CullDistancePerViewNV 1903 1904code:CullDistancePerViewNV:: 1905 1906Decorating a variable with the code:CullDistancePerViewNV built-in 1907decoration will make that variable contain the per-view cull distances. 1908The per-view cull distances have the same semantics as code:CullDistance. 1909 1910.Valid Usage 1911**** 1912 * [[VUID-{refpage}-CullDistancePerViewNV-04201]] 1913 The code:CullDistancePerViewNV decoration must: be used only within the 1914 code:MeshNV {ExecutionModel} 1915 * [[VUID-{refpage}-CullDistancePerViewNV-04202]] 1916 The variable decorated with code:CullDistancePerViewNV must: be declared 1917 using the code:Output {StorageClass} 1918 * [[VUID-{refpage}-CullDistancePerViewNV-04203]] 1919 The variable decorated with code:CullDistancePerViewNV must: also be 1920 decorated with the code:PerViewNV decoration 1921 * [[VUID-{refpage}-CullDistancePerViewNV-04204]] 1922 The variable decorated with code:CullDistancePerViewNV must: be declared 1923 as a two-dimensional array of 32-bit floating-point values 1924**** 1925-- 1926endif::VK_NV_mesh_shader[] 1927 1928ifdef::VK_EXT_mesh_shader[] 1929[[interfaces-builtin-variables-cullprimitive]] 1930[open,refpage='CullPrimitiveEXT',desc='Application-specified culling state per primitive',type='builtins'] 1931-- 1932:refpage: CullPrimitiveEXT 1933 1934code:CullPrimitiveEXT:: 1935 1936Decorating a variable with the code:CullPrimitiveEXT built-in decoration 1937will make that variable contain the culling state of output primitives. 1938If the per-primitive boolean value is code:true, the primitive will be 1939culled, if it is code:false it will not be culled. 1940 1941.Valid Usage 1942**** 1943 * [[VUID-{refpage}-CullPrimitiveEXT-07034]] 1944 The code:CullPrimitiveEXT decoration must: be used only within the 1945 code:MeshEXT {ExecutionModel} 1946 * [[VUID-{refpage}-CullPrimitiveEXT-07035]] 1947 The variable decorated with code:CullPrimitiveEXT must: be declared 1948 using the code:Output {StorageClass} 1949 * [[VUID-{refpage}-CullPrimitiveEXT-07036]] 1950 The variable decorated with code:CullPrimitiveEXT must: be declared as 1951 an array of boolean values 1952 * [[VUID-{refpage}-CullPrimitiveEXT-07037]] 1953 The size of the array decorated with code:CullPrimitiveEXT must: match 1954 the value specified by code:OutputPrimitivesEXT 1955 * [[VUID-{refpage}-CullPrimitiveEXT-07038]] 1956 The variable decorated with code:CullPrimitiveEXT within the 1957 code:MeshEXT {ExecutionModel} must: also be decorated with the 1958 code:PerPrimitiveEXT decoration 1959**** 1960-- 1961endif::VK_EXT_mesh_shader[] 1962 1963ifdef::VK_KHR_ray_tracing_pipeline,VK_KHR_ray_tracing_maintenance1[] 1964[[interfaces-builtin-variables-cullmask]] 1965[open,refpage='CullMaskKHR',desc='OpTrace specified ray cull mask',type='builtins'] 1966-- 1967:refpage: CullMaskKHR 1968 1969code:CullMaskKHR:: 1970 1971A variable decorated with the code:CullMaskKHR decoration will specify the 1972cull mask of the ray being processed. 1973The value is given by the `Cull Mask` parameter passed into one of the 1974code:OpTrace* instructions. 1975 1976.Valid Usage 1977**** 1978 * [[VUID-{refpage}-CullMaskKHR-06735]] 1979 The code:CullMaskKHR decoration must: be used only within the 1980 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 1981 code:MissKHR {ExecutionModel} 1982 * [[VUID-{refpage}-CullMaskKHR-06736]] 1983 The variable decorated with code:CullMaskKHR must: be declared using the 1984 code:Input {StorageClass} 1985 * [[VUID-{refpage}-CullMaskKHR-06737]] 1986 The variable decorated with code:CullMaskKHR must: be declared as a 1987 scalar 32-bit integer value 1988**** 1989-- 1990endif::VK_KHR_ray_tracing_pipeline,VK_KHR_ray_tracing_maintenance1[] 1991 1992ifdef::VK_NV_ray_tracing_motion_blur[] 1993[[interfaces-builtin-variables-currentraytime]] 1994[open,refpage='CurrentRayTimeNV',desc='Time value of a ray intersection',type='builtins'] 1995-- 1996:refpage: CurrentRayTimeNV 1997 1998code:CurrentRayTimeNV:: 1999 2000A variable decorated with the code:CurrentRayTimeNV decoration contains the 2001time value passed in to code:OpTraceRayMotionNV which called this shader. 2002 2003.Valid Usage 2004**** 2005 * [[VUID-{refpage}-CurrentRayTimeNV-04942]] 2006 The code:CurrentRayTimeNV decoration must: be used only within the 2007 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 2008 code:MissKHR {ExecutionModel} 2009 * [[VUID-{refpage}-CurrentRayTimeNV-04943]] 2010 The variable decorated with code:CurrentRayTimeNV must: be declared 2011 using the code:Input {StorageClass} 2012 * [[VUID-{refpage}-CurrentRayTimeNV-04944]] 2013 The variable decorated with code:CurrentRayTimeNV must: be declared as a 2014 scalar 32-bit floating-point value 2015**** 2016-- 2017endif::VK_NV_ray_tracing_motion_blur[] 2018 2019 2020ifdef::VK_VERSION_1_1,VK_KHR_device_group[] 2021[[interfaces-builtin-variables-deviceindex]] 2022[open,refpage='DeviceIndex',desc='Index of the device executing the shader',type='builtins'] 2023-- 2024:refpage: DeviceIndex 2025 2026code:DeviceIndex:: 2027 2028The code:DeviceIndex decoration can: be applied to a shader input which will 2029be filled with the device index of the physical device that is executing the 2030current shader invocation. 2031This value will be in the range latexmath:[[0,max(1,physicalDeviceCount))], 2032where physicalDeviceCount is the pname:physicalDeviceCount member of 2033slink:VkDeviceGroupDeviceCreateInfo. 2034 2035.Valid Usage 2036**** 2037 * [[VUID-{refpage}-DeviceIndex-04205]] 2038 The variable decorated with code:DeviceIndex must: be declared using the 2039 code:Input {StorageClass} 2040 * [[VUID-{refpage}-DeviceIndex-04206]] 2041 The variable decorated with code:DeviceIndex must: be declared as a 2042 scalar 32-bit integer value 2043**** 2044-- 2045endif::VK_VERSION_1_1,VK_KHR_device_group[] 2046 2047ifdef::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[] 2048[[interfaces-builtin-variables-drawindex]] 2049[open,refpage='DrawIndex',desc='Index of the current draw',type='builtins'] 2050-- 2051:refpage: DrawIndex 2052 2053code:DrawIndex:: 2054 2055Decorating a variable with the code:DrawIndex built-in will make that 2056variable contain the integer value corresponding to the zero-based index of 2057the draw that invoked the current 2058ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[task, mesh, or] 2059vertex shader invocation. 2060For _indirect drawing commands_, code:DrawIndex begins at zero and 2061increments by one for each draw executed. 2062The number of draws is given by the pname:drawCount parameter. 2063For _direct drawing commands_, 2064ifdef::VK_EXT_multi_draw[] 2065if flink:vkCmdDrawMultiEXT or flink:vkCmdDrawMultiIndexedEXT is used, this 2066variable contains the integer value corresponding to the zero-based index of 2067the draw. 2068Otherwise 2069endif::VK_EXT_multi_draw[] 2070code:DrawIndex is always zero. 2071code:DrawIndex is dynamically uniform. 2072 2073ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2074When task or mesh shaders are used, only the first active stage will have 2075proper access to the variable. 2076The value read by other stages is undefined:. 2077endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2078 2079.Valid Usage 2080**** 2081 * [[VUID-{refpage}-DrawIndex-04207]] 2082 The code:DrawIndex decoration must: be used only within the code:Vertex, 2083 code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV {ExecutionModel} 2084 * [[VUID-{refpage}-DrawIndex-04208]] 2085 The variable decorated with code:DrawIndex must: be declared using the 2086 code:Input {StorageClass} 2087 * [[VUID-{refpage}-DrawIndex-04209]] 2088 The variable decorated with code:DrawIndex must: be declared as a scalar 2089 32-bit integer value 2090**** 2091-- 2092endif::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[] 2093 2094ifdef::VK_HUAWEI_cluster_culling_shader[] 2095[[interfaces-builtin-variables-firstindexhuawei]] 2096[open,refpage='FirstIndexHUAWEI',desc='cluster culling shader output variable',type='builtins'] 2097-- 2098:refpage: FirstIndexHUAWEI 2099 2100code:FirstIndexHUAWEI:: 2101 2102The code:FirstIndexHUAWEI decoration can be used to decorate a cluster 2103culling shader output variable,this indexed mode specific variable will 2104contain an integer value that specifies the base index within the index 2105buffer corresponding to a cluster. 2106 2107 2108.Valid Usage 2109**** 2110 * [[VUID-{refpage}-FirstIndexHUAWEI-07799]] 2111 The code:FirstIndexHUAWEI decoration must: be used only within the 2112 code:ClusterCullingHUAWEI {ExecutionModel} 2113 * [[VUID-{refpage}-FirstIndexHUAWEI-07800]] 2114 The variable decorated with code:FirstIndexHUAWEI must: be declared as a 2115 scalar 32-bit integer value 2116**** 2117-- 2118endif::VK_HUAWEI_cluster_culling_shader[] 2119 2120 2121[[interfaces-builtin-variables-fragcoord]] 2122[open,refpage='FragCoord',desc='Screen-space coordinate of the fragment center',type='builtins'] 2123-- 2124:refpage: FragCoord 2125 2126code:FragCoord:: 2127 2128Decorating a variable with the code:FragCoord built-in decoration will make 2129that variable contain the framebuffer coordinate 2130latexmath:[(x,y,z,\frac{1}{w})] of the fragment being processed. 2131The [eq]#(x,y)# coordinate [eq]#(0,0)# is the upper left corner of the upper 2132left pixel in the framebuffer. 2133+ 2134When <<primsrast-sampleshading,Sample Shading>> is enabled, the [eq]#x# and 2135[eq]#y# components of code:FragCoord reflect the location of one of the 2136samples corresponding to the shader invocation. 2137+ 2138Otherwise, the [eq]#x# and [eq]#y# components of code:FragCoord reflect the 2139location of the center of the fragment. 2140+ 2141The [eq]#z# component of code:FragCoord is the interpolated depth value of 2142the primitive. 2143+ 2144The [eq]#w# component is the interpolated latexmath:[\frac{1}{w}]. 2145+ 2146The code:Centroid interpolation decoration is ignored, but allowed, on 2147code:FragCoord. 2148 2149.Valid Usage 2150**** 2151 * [[VUID-{refpage}-FragCoord-04210]] 2152 The code:FragCoord decoration must: be used only within the 2153 code:Fragment {ExecutionModel} 2154 * [[VUID-{refpage}-FragCoord-04211]] 2155 The variable decorated with code:FragCoord must: be declared using the 2156 code:Input {StorageClass} 2157 * [[VUID-{refpage}-FragCoord-04212]] 2158 The variable decorated with code:FragCoord must: be declared as a 2159 four-component vector of 32-bit floating-point values 2160**** 2161-- 2162 2163[[interfaces-builtin-variables-fragdepth]] 2164[open,refpage='FragDepth',desc='Application-specified depth for depth testing',type='builtins'] 2165-- 2166:refpage: FragDepth 2167 2168code:FragDepth:: 2169 2170To have a shader supply a fragment-depth value, the shader must: declare the 2171code:DepthReplacing execution mode. 2172Such a shader's fragment-depth value will come from the variable decorated 2173with the code:FragDepth built-in decoration. 2174+ 2175This value will be used for any subsequent depth testing performed by the 2176implementation or writes to the depth attachment. 2177See <<fragops-shader-depthreplacement, fragment shader depth replacement>> 2178for details. 2179 2180.Valid Usage 2181**** 2182 * [[VUID-{refpage}-FragDepth-04213]] 2183 The code:FragDepth decoration must: be used only within the 2184 code:Fragment {ExecutionModel} 2185 * [[VUID-{refpage}-FragDepth-04214]] 2186 The variable decorated with code:FragDepth must: be declared using the 2187 code:Output {StorageClass} 2188 * [[VUID-{refpage}-FragDepth-04215]] 2189 The variable decorated with code:FragDepth must: be declared as a scalar 2190 32-bit floating-point value 2191 * [[VUID-{refpage}-FragDepth-04216]] 2192 If the shader dynamically writes to the variable decorated with 2193 code:FragDepth, the code:DepthReplacing {ExecutionMode} must: be 2194 declared 2195**** 2196-- 2197 2198ifdef::VK_HUAWEI_cluster_culling_shader[] 2199[[interfaces-builtin-variables-firstinstancehuawei]] 2200[open,refpage='FirstInstanceHUAWEI',desc='cluster culling shader output variable',type='builtins'] 2201-- 2202:refpage: FirstInstanceHUAWEI 2203 2204code:FirstInstanceHUAWEI:: 2205 2206The code:FirstInstanceHUAWEI decoration can be used to decorate a cluster 2207culling shader output variable,this variable will contain an integer value 2208that specifies the instance ID of the first instance to draw. 2209 2210.Valid Usage 2211**** 2212 * [[VUID-{refpage}-FirstInstanceHUAWEI-07801]] 2213 The code:FirstInstanceHUAWEI decoration must: be used only within the 2214 code:ClusterCullingHUAWEI {ExecutionModel} 2215 * [[VUID-{refpage}-FirstInstanceHUAWEI-07802]] 2216 The variable decorated with code:FirstInstanceHUAWEI must: be declared 2217 as a scalar 32-bit integer value 2218**** 2219-- 2220endif::VK_HUAWEI_cluster_culling_shader[] 2221 2222 2223ifdef::VK_HUAWEI_cluster_culling_shader[] 2224[[interfaces-builtin-variables-firstvertexhuawei]] 2225[open,refpage='FirstVertexHUAWEI',desc='cluster culling shader output variable',type='builtins'] 2226-- 2227:refpage: FirstVertexHUAWEI 2228 2229code:FirstVertexHUAWEI:: 2230 2231The code:FirstVertexHUAWEI decoration can be used to decorate a cluster 2232culling shader output variable,this non-indexed mode specific variable will 2233contain an integer value that specifies the index of the first vertex in a 2234cluster to draw. 2235 2236.Valid Usage 2237**** 2238 * [[VUID-{refpage}-FirstVertexHUAWEI-07803]] 2239 The code:FirstVertexHUAWEI decoration must: be used only within the 2240 code:FirstVertexHUAWEI {ExecutionModel} 2241 * [[VUID-{refpage}-FirstVertexHUAWEI-07804]] 2242 The variable decorated with code:FirstVertexHUAWEI must: be declared as 2243 a scalar 32-bit integer value 2244**** 2245-- 2246endif::VK_HUAWEI_cluster_culling_shader[] 2247 2248 2249ifdef::VK_EXT_fragment_density_map[] 2250[[interfaces-builtin-variables-fraginvocationcount]] 2251[open,refpage='FragInvocationCountEXT',desc='Number of fragment shader invocations for a fragment',type='builtins'] 2252-- 2253:refpage: FragInvocationCountEXT 2254 2255code:FragInvocationCountEXT:: 2256 2257Decorating a variable with the code:FragInvocationCountEXT built-in 2258decoration will make that variable contain the maximum number of fragment 2259shader invocations for the fragment, as determined by 2260pname:minSampleShading. 2261+ 2262If <<primsrast-sampleshading,Sample Shading>> is not enabled, 2263code:FragInvocationCountEXT will be filled with a value of 1. 2264 2265.Valid Usage 2266**** 2267 * [[VUID-{refpage}-FragInvocationCountEXT-04217]] 2268 The code:FragInvocationCountEXT decoration must: be used only within the 2269 code:Fragment {ExecutionModel} 2270 * [[VUID-{refpage}-FragInvocationCountEXT-04218]] 2271 The variable decorated with code:FragInvocationCountEXT must: be 2272 declared using the code:Input {StorageClass} 2273 * [[VUID-{refpage}-FragInvocationCountEXT-04219]] 2274 The variable decorated with code:FragInvocationCountEXT must: be 2275 declared as a scalar 32-bit integer value 2276**** 2277-- 2278endif::VK_EXT_fragment_density_map[] 2279 2280ifdef::VK_EXT_fragment_density_map[] 2281[[interfaces-builtin-variables-fragsize]] 2282[open,refpage='FragSizeEXT',desc='Size of the screen-space area covered by the fragment',type='builtins'] 2283-- 2284:refpage: FragSizeEXT 2285 2286code:FragSizeEXT:: 2287 2288Decorating a variable with the code:FragSizeEXT built-in decoration will 2289make that variable contain the dimensions in pixels of the 2290<<glossary-fragment-area,area>> that the fragment covers for that 2291invocation. 2292+ 2293If fragment density map is not enabled, code:FragSizeEXT will be filled with 2294a value of [eq]#(1,1)#. 2295 2296.Valid Usage 2297**** 2298 * [[VUID-{refpage}-FragSizeEXT-04220]] 2299 The code:FragSizeEXT decoration must: be used only within the 2300 code:Fragment {ExecutionModel} 2301 * [[VUID-{refpage}-FragSizeEXT-04221]] 2302 The variable decorated with code:FragSizeEXT must: be declared using the 2303 code:Input {StorageClass} 2304 * [[VUID-{refpage}-FragSizeEXT-04222]] 2305 The variable decorated with code:FragSizeEXT must: be declared as a 2306 two-component vector of 32-bit integer values 2307**** 2308-- 2309endif::VK_EXT_fragment_density_map[] 2310 2311ifdef::VK_EXT_shader_stencil_export[] 2312[[interfaces-builtin-variables-fragstencilref]] 2313[open,refpage='FragStencilRefEXT',desc='Application-specified stencil reference value used in stencil tests',type='builtins'] 2314-- 2315:refpage: FragStencilRefEXT 2316 2317code:FragStencilRefEXT:: 2318 2319Decorating a variable with the code:FragStencilRefEXT built-in decoration 2320will make that variable contain the new stencil reference value for all 2321samples covered by the fragment. 2322This value will be used as the stencil reference value used in stencil 2323testing. 2324+ 2325To write to code:FragStencilRefEXT, a shader must: declare the 2326code:StencilRefReplacingEXT execution mode. 2327If a shader declares the code:StencilRefReplacingEXT execution mode and 2328there is an execution path through the shader that does not set 2329code:FragStencilRefEXT, then the fragment's stencil reference value is 2330undefined: for executions of the shader that take that path. 2331+ 2332Only the least significant *s* bits of the integer value of the variable 2333decorated with code:FragStencilRefEXT are considered for stencil testing, 2334where *s* is the number of bits in the stencil framebuffer attachment, and 2335higher order bits are discarded. 2336+ 2337See <<fragops-shader-stencilrefreplacement, fragment shader stencil 2338reference replacement>> for more details. 2339 2340.Valid Usage 2341**** 2342 * [[VUID-{refpage}-FragStencilRefEXT-04223]] 2343 The code:FragStencilRefEXT decoration must: be used only within the 2344 code:Fragment {ExecutionModel} 2345 * [[VUID-{refpage}-FragStencilRefEXT-04224]] 2346 The variable decorated with code:FragStencilRefEXT must: be declared 2347 using the code:Output {StorageClass} 2348 * [[VUID-{refpage}-FragStencilRefEXT-04225]] 2349 The variable decorated with code:FragStencilRefEXT must: be declared as 2350 a scalar integer value 2351**** 2352-- 2353endif::VK_EXT_shader_stencil_export[] 2354 2355ifdef::VK_NV_shading_rate_image[] 2356[open,refpage='FragmentSizeNV',desc='Size of the screen-space area covered by the fragment',type='builtins'] 2357-- 2358:refpage: FragmentSizeNV 2359 2360code:FragmentSizeNV:: 2361 2362Decorating a variable with the code:FragmentSizeNV built-in decoration will 2363make that variable contain the width and height of the fragment. 2364 2365.Valid Usage 2366**** 2367 * [[VUID-{refpage}-FragmentSizeNV-04226]] 2368 The code:FragmentSizeNV decoration must: be used only within the 2369 code:Fragment {ExecutionModel} 2370 * [[VUID-{refpage}-FragmentSizeNV-04227]] 2371 The variable decorated with code:FragmentSizeNV must: be declared using 2372 the code:Input {StorageClass} 2373 * [[VUID-{refpage}-FragmentSizeNV-04228]] 2374 The variable decorated with code:FragmentSizeNV must: be declared as a 2375 two-component vector of 32-bit integer values 2376**** 2377-- 2378endif::VK_NV_shading_rate_image[] 2379 2380 2381[[interfaces-builtin-variables-frontfacing]] 2382[open,refpage='FrontFacing',desc='Front face determination of a fragment',type='builtins'] 2383-- 2384:refpage: FrontFacing 2385 2386code:FrontFacing:: 2387 2388Decorating a variable with the code:FrontFacing built-in decoration will 2389make that variable contain whether the fragment is front or back facing. 2390This variable is non-zero if the current fragment is considered to be part 2391of a <<primsrast-polygons-basic,front-facing>> polygon primitive or of a 2392non-polygon primitive and is zero if the fragment is considered to be part 2393of a back-facing polygon primitive. 2394 2395.Valid Usage 2396**** 2397 * [[VUID-{refpage}-FrontFacing-04229]] 2398 The code:FrontFacing decoration must: be used only within the 2399 code:Fragment {ExecutionModel} 2400 * [[VUID-{refpage}-FrontFacing-04230]] 2401 The variable decorated with code:FrontFacing must: be declared using the 2402 code:Input {StorageClass} 2403 * [[VUID-{refpage}-FrontFacing-04231]] 2404 The variable decorated with code:FrontFacing must: be declared as a 2405 boolean value 2406**** 2407-- 2408 2409ifdef::VK_EXT_conservative_rasterization[] 2410[[interfaces-builtin-variables-fullycoveredext]] 2411[open,refpage='FullyCoveredEXT',desc='Indication of whether a fragment is fully covered',type='builtins'] 2412-- 2413:refpage: FullyCoveredEXT 2414 2415code:FullyCoveredEXT:: 2416 2417Decorating a variable with the code:FullyCoveredEXT built-in decoration will 2418make that variable indicate whether the <<glossary-fragment-area,fragment 2419area>> is fully covered by the generating primitive. 2420This variable is non-zero if conservative rasterization is enabled and the 2421current fragment area is fully covered by the generating primitive, and is 2422zero if the fragment is not covered or partially covered, or conservative 2423rasterization is disabled. 2424 2425.Valid Usage 2426**** 2427 * [[VUID-{refpage}-FullyCoveredEXT-04232]] 2428 The code:FullyCoveredEXT decoration must: be used only within the 2429 code:Fragment {ExecutionModel} 2430 * [[VUID-{refpage}-FullyCoveredEXT-04233]] 2431 The variable decorated with code:FullyCoveredEXT must: be declared using 2432 the code:Input {StorageClass} 2433 * [[VUID-{refpage}-FullyCoveredEXT-04234]] 2434 The variable decorated with code:FullyCoveredEXT must: be declared as a 2435 boolean value 2436ifdef::VK_EXT_post_depth_coverage[] 2437 * [[VUID-{refpage}-conservativeRasterizationPostDepthCoverage-04235]] 2438 If 2439 sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:conservativeRasterizationPostDepthCoverage 2440 is not supported the code:PostDepthCoverage {ExecutionMode} must: not be 2441 declared, when a variable with the code:FullyCoveredEXT decoration is 2442 declared 2443endif::VK_EXT_post_depth_coverage[] 2444**** 2445-- 2446endif::VK_EXT_conservative_rasterization[] 2447 2448[[interfaces-builtin-variables-globalinvocationid]] 2449[open,refpage='GlobalInvocationId',desc='Global invocation ID',type='builtins'] 2450-- 2451:refpage: GlobalInvocationId 2452 2453code:GlobalInvocationId:: 2454 2455Decorating a variable with the code:GlobalInvocationId built-in decoration 2456will make that variable contain the location of the current invocation 2457within the global workgroup. 2458Each component is equal to the index of the local workgroup multiplied by 2459the size of the local workgroup plus code:LocalInvocationId. 2460 2461.Valid Usage 2462**** 2463 * [[VUID-{refpage}-GlobalInvocationId-04236]] 2464 The code:GlobalInvocationId decoration must: be used only within the 2465 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 2466 {ExecutionModel} 2467 * [[VUID-{refpage}-GlobalInvocationId-04237]] 2468 The variable decorated with code:GlobalInvocationId must: be declared 2469 using the code:Input {StorageClass} 2470 * [[VUID-{refpage}-GlobalInvocationId-04238]] 2471 The variable decorated with code:GlobalInvocationId must: be declared as 2472 a three-component vector of 32-bit integer values 2473**** 2474-- 2475 2476[[interfaces-builtin-variables-helperinvocation]] 2477[open,refpage='HelperInvocation',desc='Indication of whether a fragment shader is a helper invocation',type='builtins'] 2478-- 2479:refpage: HelperInvocation 2480 2481code:HelperInvocation:: 2482 2483Decorating a variable with the code:HelperInvocation built-in decoration 2484will make that variable contain whether the current invocation is a helper 2485invocation. 2486This variable is non-zero if the current fragment being shaded is a helper 2487invocation and zero otherwise. 2488A helper invocation is an invocation of the shader that is produced to 2489satisfy internal requirements such as the generation of derivatives. 2490 2491[NOTE] 2492.Note 2493==== 2494It is very likely that a helper invocation will have a value of 2495code:SampleMask fragment shader input value that is zero. 2496==== 2497 2498.Valid Usage 2499**** 2500 * [[VUID-{refpage}-HelperInvocation-04239]] 2501 The code:HelperInvocation decoration must: be used only within the 2502 code:Fragment {ExecutionModel} 2503 * [[VUID-{refpage}-HelperInvocation-04240]] 2504 The variable decorated with code:HelperInvocation must: be declared 2505 using the code:Input {StorageClass} 2506 * [[VUID-{refpage}-HelperInvocation-04241]] 2507 The variable decorated with code:HelperInvocation must: be declared as a 2508 boolean value 2509**** 2510-- 2511 2512ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 2513[[interfaces-builtin-variables-hitkind]] 2514[open,refpage='HitKindKHR',desc='Kind of hit that triggered an any-hit or closest hit ray shader',type='builtins'] 2515-- 2516:refpage: HitKindKHR 2517 2518code:HitKindKHR:: 2519 2520A variable decorated with the code:HitKindKHR decoration will describe the 2521intersection that triggered the execution of the current shader. 2522The values are determined by the intersection shader. 2523For user-defined intersection shaders this is the value that was passed to 2524the "`Hit Kind`" operand of code:OpReportIntersectionKHR. 2525For triangle intersection candidates, this will be one of 2526code:HitKindFrontFacingTriangleKHR or code:HitKindBackFacingTriangleKHR. 2527 2528.Valid Usage 2529**** 2530 * [[VUID-{refpage}-HitKindKHR-04242]] 2531 The code:HitKindKHR decoration must: be used only within the 2532 code:AnyHitKHR or code:ClosestHitKHR {ExecutionModel} 2533 * [[VUID-{refpage}-HitKindKHR-04243]] 2534 The variable decorated with code:HitKindKHR must: be declared using the 2535 code:Input {StorageClass} 2536 * [[VUID-{refpage}-HitKindKHR-04244]] 2537 The variable decorated with code:HitKindKHR must: be declared as a 2538 scalar 32-bit integer value 2539**** 2540-- 2541 2542ifdef::VK_NV_ray_tracing[] 2543[[interfaces-builtin-variables-hitt]] 2544[open,refpage='HitTNV',desc='T value of a ray intersection',type='builtins'] 2545-- 2546:refpage: HitTNV 2547 2548code:HitTNV:: 2549 2550A variable decorated with the code:HitTNV decoration is equivalent to a 2551variable decorated with the code:RayTmaxKHR decoration. 2552 2553.Valid Usage 2554**** 2555 * [[VUID-{refpage}-HitTNV-04245]] 2556 The code:HitTNV decoration must: be used only within the code:AnyHitNV 2557 or code:ClosestHitNV {ExecutionModel} 2558 * [[VUID-{refpage}-HitTNV-04246]] 2559 The variable decorated with code:HitTNV must: be declared using the 2560 code:Input {StorageClass} 2561 * [[VUID-{refpage}-HitTNV-04247]] 2562 The variable decorated with code:HitTNV must: be declared as a scalar 2563 32-bit floating-point value 2564**** 2565-- 2566endif::VK_NV_ray_tracing[] 2567 2568ifdef::VK_KHR_ray_tracing_position_fetch[] 2569[[interfaces-builtin-variables-hittrianglevertexpositions]] 2570[open,refpage='HitTriangleVertexPositionsKHR',desc='Vertices of an intersected triangle',type='builtins'] 2571-- 2572:refpage: HitTriangleVertexPositionsKHR 2573 2574code:HitTriangleVertexPositionsKHR:: 2575 2576A variable decorated with the code:HitTriangleVertexPositionsKHR decoration 2577will specify the object space vertices of the triangle at the current 2578intersection in application-provided order. 2579The positions returned are transformed by the geometry transform, which is 2580performed at standard <<fundamentals-floatingpoint, floating point>> 2581precision, but without a specifically defined order of floating point 2582operations to perform the matrix multiplication. 2583 2584.Valid Usage 2585**** 2586 * [[VUID-{refpage}-HitTriangleVertexPositionsKHR-08747]] 2587 The code:HitTriangleVertexPositionsKHR decoration must: be used only 2588 within the code:AnyHitKHR or code:ClosestHitKHR {ExecutionModel} 2589 * [[VUID-{refpage}-HitTriangleVertexPositionsKHR-08748]] 2590 The variable decorated with code:HitTriangleVertexPositionsKHR must: be 2591 declared using the code:Input {StorageClass} 2592 * [[VUID-{refpage}-HitTriangleVertexPositionsKHR-08749]] 2593 The variable decorated with code:HitTriangleVertexPositionsKHR must: be 2594 declared as an array of three vectors of three 32-bit float values 2595 * [[VUID-{refpage}-HitTriangleVertexPositionsKHR-08750]] 2596 The variable decorated with code:HitTriangleVertexPositionsKHR must: be 2597 used only if the value of code:HitKindKHR is 2598 code:HitKindFrontFacingTriangleKHR or code:HitKindBackFacingTriangleKHR 2599 * [[VUID-{refpage}-None-08751]] 2600 The acceleration structure corresponding to the current intersection 2601 must: have been built with 2602 ename:VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR 2603**** 2604-- 2605endif::VK_KHR_ray_tracing_position_fetch[] 2606 2607[[interfaces-builtin-variables-incomingrayflags]] 2608[open,refpage='IncomingRayFlagsKHR',desc='Flags used to trace a ray',type='builtins'] 2609-- 2610:refpage: IncomingRayFlagsKHR 2611 2612code:IncomingRayFlagsKHR:: 2613 2614A variable with the code:IncomingRayFlagsKHR decoration will contain the ray 2615flags passed in to the trace call that invoked this particular shader. 2616Setting pipeline flags on the raytracing pipeline must: not cause any 2617corresponding flags to be set in variables with this decoration. 2618 2619.Valid Usage 2620**** 2621 * [[VUID-{refpage}-IncomingRayFlagsKHR-04248]] 2622 The code:IncomingRayFlagsKHR decoration must: be used only within the 2623 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 2624 code:MissKHR {ExecutionModel} 2625 * [[VUID-{refpage}-IncomingRayFlagsKHR-04249]] 2626 The variable decorated with code:IncomingRayFlagsKHR must: be declared 2627 using the code:Input {StorageClass} 2628 * [[VUID-{refpage}-IncomingRayFlagsKHR-04250]] 2629 The variable decorated with code:IncomingRayFlagsKHR must: be declared 2630 as a scalar 32-bit integer value 2631**** 2632-- 2633 2634ifdef::VK_HUAWEI_cluster_culling_shader[] 2635[[interfaces-builtin-variables-indexcounthuawei]] 2636[open,refpage='IndexCountHUAWEI',desc='cluster culling shader output variable',type='builtins'] 2637-- 2638:refpage: IndexCountHUAWEI 2639 2640code:IndexCountHUAWEI:: 2641 2642The code:IndexCountHUAWEI decoration can be used to decorate a cluster 2643culling shader output variable,this indexed mode specific variable will 2644contain an integer value that specifies the number of indexed vertices in a 2645cluster to draw. 2646 2647.Valid Usage 2648**** 2649 * [[VUID-{refpage}-IndexCountHUAWEI-07805]] 2650 The code:IndexCountHUAWEI decoration must: be used only within the 2651 code:ClusterCullingHUAWEI {ExecutionModel} 2652 * [[VUID-{refpage}-IndexCountHUAWEI-07806]] 2653 The variable decorated with code:IndexCountHUAWEI must: be declared as a 2654 scalar 32-bit integer value 2655**** 2656-- 2657endif::VK_HUAWEI_cluster_culling_shader[] 2658 2659ifdef::VK_HUAWEI_cluster_culling_shader[] 2660[[interfaces-builtin-variables-instancecounthuawei]] 2661[open,refpage='InstanceCountHUAWEI',desc='cluster culling shader output variable',type='builtins'] 2662-- 2663:refpage: InstanceCountHUAWEI 2664 2665code:InstanceCountHUAWEI:: 2666 2667The code:InstanceCountHUAWEI decoration can be used to decorate a cluster 2668culling shader output variable,this variable will contain an integer value 2669that specifies the number of instance to draw in a cluster. 2670 2671.Valid Usage 2672**** 2673 * [[VUID-{refpage}-InstanceCountHUAWEI-07807]] 2674 The code:InstanceCountHUAWEI decoration must: be used only within the 2675 code:ClusterCullingHUAWEI {ExecutionModel} 2676 * [[VUID-{refpage}-InstanceCountHUAWEI-07808]] 2677 The variable decorated with code:InstanceCountHUAWEI must: be declared 2678 as a scalar 32-bit integer value 2679**** 2680-- 2681endif::VK_HUAWEI_cluster_culling_shader[] 2682 2683[[interfaces-builtin-variables-instancecustomindex]] 2684[open,refpage='InstanceCustomIndexKHR',desc='Custom index associated with an intersected instance',type='builtins'] 2685-- 2686:refpage: InstanceCustomIndexKHR 2687 2688code:InstanceCustomIndexKHR:: 2689 2690A variable decorated with the code:InstanceCustomIndexKHR decoration will 2691contain the application-defined value of the instance that intersects the 2692current ray. 2693This variable contains the value that was specified in 2694slink:VkAccelerationStructureInstanceKHR::pname:instanceCustomIndex for the 2695current acceleration structure instance in the lower 24 bits and the upper 8 2696bits will be zero. 2697 2698.Valid Usage 2699**** 2700 * [[VUID-{refpage}-InstanceCustomIndexKHR-04251]] 2701 The code:InstanceCustomIndexKHR decoration must: be used only within the 2702 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 2703 {ExecutionModel} 2704 * [[VUID-{refpage}-InstanceCustomIndexKHR-04252]] 2705 The variable decorated with code:InstanceCustomIndexKHR must: be 2706 declared using the code:Input {StorageClass} 2707 * [[VUID-{refpage}-InstanceCustomIndexKHR-04253]] 2708 The variable decorated with code:InstanceCustomIndexKHR must: be 2709 declared as a scalar 32-bit integer value 2710**** 2711-- 2712 2713[[interfaces-builtin-variables-instanceid]] 2714[open,refpage='InstanceId',desc='Id associated with an intersected instance',type='builtins'] 2715-- 2716:refpage: InstanceId 2717 2718code:InstanceId:: 2719 2720Decorating a variable in an intersection, any-hit, or closest hit shader 2721with the code:InstanceId decoration will make that variable contain the 2722index of the instance that intersects the current ray. 2723 2724.Valid Usage 2725**** 2726 * [[VUID-{refpage}-InstanceId-04254]] 2727 The code:InstanceId decoration must: be used only within the 2728 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 2729 {ExecutionModel} 2730 * [[VUID-{refpage}-InstanceId-04255]] 2731 The variable decorated with code:InstanceId must: be declared using the 2732 code:Input {StorageClass} 2733 * [[VUID-{refpage}-InstanceId-04256]] 2734 The variable decorated with code:InstanceId must: be declared as a 2735 scalar 32-bit integer value 2736**** 2737-- 2738endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 2739 2740[[interfaces-builtin-variables-invocationid]] 2741[open,refpage='InvocationId',desc='Invocation ID in a geometry or tessellation control shader',type='builtins'] 2742-- 2743:refpage: InvocationId 2744 2745code:InvocationId:: 2746 2747Decorating a variable with the code:InvocationId built-in decoration will 2748make that variable contain the index of the current shader invocation in a 2749geometry shader, or the index of the output patch vertex in a tessellation 2750control shader. 2751+ 2752In a geometry shader, the index of the current shader invocation ranges from 2753zero to the number of <<geometry-invocations,instances>> declared in the 2754shader minus one. 2755If the instance count of the geometry shader is one or is not specified, 2756then code:InvocationId will be zero. 2757 2758.Valid Usage 2759**** 2760 * [[VUID-{refpage}-InvocationId-04257]] 2761 The code:InvocationId decoration must: be used only within the 2762 code:TessellationControl or code:Geometry {ExecutionModel} 2763 * [[VUID-{refpage}-InvocationId-04258]] 2764 The variable decorated with code:InvocationId must: be declared using 2765 the code:Input {StorageClass} 2766 * [[VUID-{refpage}-InvocationId-04259]] 2767 The variable decorated with code:InvocationId must: be declared as a 2768 scalar 32-bit integer value 2769**** 2770-- 2771 2772ifdef::VK_NV_shading_rate_image[] 2773[open,refpage='InvocationsPerPixelNV',desc='Number of fragment shader invocations for the current pixel',type='builtins'] 2774-- 2775:refpage: InvocationsPerPixelNV 2776 2777code:InvocationsPerPixelNV:: 2778 2779Decorating a variable with the code:InvocationsPerPixelNV built-in 2780decoration will make that variable contain the maximum number of fragment 2781shader invocations per pixel, as derived from the effective shading rate for 2782the fragment. 2783If a primitive does not fully cover a pixel, the number of fragment shader 2784invocations for that pixel may: be less than the value of 2785code:InvocationsPerPixelNV. 2786If the shading rate indicates a fragment covering multiple pixels, then 2787code:InvocationsPerPixelNV will be one. 2788 2789.Valid Usage 2790**** 2791 * [[VUID-{refpage}-InvocationsPerPixelNV-04260]] 2792 The code:InvocationsPerPixelNV decoration must: be used only within the 2793 code:Fragment {ExecutionModel} 2794 * [[VUID-{refpage}-InvocationsPerPixelNV-04261]] 2795 The variable decorated with code:InvocationsPerPixelNV must: be declared 2796 using the code:Input {StorageClass} 2797 * [[VUID-{refpage}-InvocationsPerPixelNV-04262]] 2798 The variable decorated with code:InvocationsPerPixelNV must: be declared 2799 as a scalar 32-bit integer value 2800**** 2801-- 2802endif::VK_NV_shading_rate_image[] 2803 2804[[interfaces-builtin-variables-instanceindex]] 2805[open,refpage='InstanceIndex',desc='Index of an instance',type='builtins'] 2806-- 2807:refpage: InstanceIndex 2808 2809code:InstanceIndex:: 2810 2811Decorating a variable in a vertex shader with the code:InstanceIndex 2812built-in decoration will make that variable contain the index of the 2813instance that is being processed by the current vertex shader invocation. 2814code:InstanceIndex begins at the pname:firstInstance parameter to 2815flink:vkCmdDraw or flink:vkCmdDrawIndexed or at the pname:firstInstance 2816member of a structure consumed by flink:vkCmdDrawIndirect or 2817flink:vkCmdDrawIndexedIndirect. 2818 2819.Valid Usage 2820**** 2821 * [[VUID-{refpage}-InstanceIndex-04263]] 2822 The code:InstanceIndex decoration must: be used only within the 2823 code:Vertex {ExecutionModel} 2824 * [[VUID-{refpage}-InstanceIndex-04264]] 2825 The variable decorated with code:InstanceIndex must: be declared using 2826 the code:Input {StorageClass} 2827 * [[VUID-{refpage}-InstanceIndex-04265]] 2828 The variable decorated with code:InstanceIndex must: be declared as a 2829 scalar 32-bit integer value 2830**** 2831-- 2832 2833ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 2834[[interfaces-builtin-variables-launchid]] 2835[open,refpage='LaunchIdKHR',desc='Launch Id for ray shaders',type='builtins'] 2836-- 2837:refpage: LaunchIdKHR 2838 2839code:LaunchIdKHR:: 2840 2841A variable decorated with the code:LaunchIdKHR decoration will specify the 2842index of the work item being processed. 2843One work item is generated for each of the pname:width {times} pname:height 2844{times} pname:depth items dispatched by a flink:vkCmdTraceRaysKHR command. 2845All shader invocations inherit the same value for variables decorated with 2846code:LaunchIdKHR. 2847 2848.Valid Usage 2849**** 2850 * [[VUID-{refpage}-LaunchIdKHR-04266]] 2851 The code:LaunchIdKHR decoration must: be used only within the 2852 code:RayGenerationKHR, code:IntersectionKHR, code:AnyHitKHR, 2853 code:ClosestHitKHR, code:MissKHR, or code:CallableKHR {ExecutionModel} 2854 * [[VUID-{refpage}-LaunchIdKHR-04267]] 2855 The variable decorated with code:LaunchIdKHR must: be declared using the 2856 code:Input {StorageClass} 2857 * [[VUID-{refpage}-LaunchIdKHR-04268]] 2858 The variable decorated with code:LaunchIdKHR must: be declared as a 2859 three-component vector of 32-bit integer values 2860**** 2861-- 2862 2863[[interfaces-builtin-variables-launchsize]] 2864[open,refpage='LaunchSizeKHR',desc='Launch dimensions for ray shaders',type='builtins'] 2865-- 2866:refpage: LaunchSizeKHR 2867 2868code:LaunchSizeKHR:: 2869 2870A variable decorated with the code:LaunchSizeKHR decoration will contain the 2871pname:width, pname:height, and pname:depth dimensions passed to the 2872flink:vkCmdTraceRaysKHR command that initiated this shader execution. 2873The pname:width is in the first component, the pname:height is in the second 2874component, and the pname:depth is in the third component. 2875 2876.Valid Usage 2877**** 2878 * [[VUID-{refpage}-LaunchSizeKHR-04269]] 2879 The code:LaunchSizeKHR decoration must: be used only within the 2880 code:RayGenerationKHR, code:IntersectionKHR, code:AnyHitKHR, 2881 code:ClosestHitKHR, code:MissKHR, or code:CallableKHR {ExecutionModel} 2882 * [[VUID-{refpage}-LaunchSizeKHR-04270]] 2883 The variable decorated with code:LaunchSizeKHR must: be declared using 2884 the code:Input {StorageClass} 2885 * [[VUID-{refpage}-LaunchSizeKHR-04271]] 2886 The variable decorated with code:LaunchSizeKHR must: be declared as a 2887 three-component vector of 32-bit integer values 2888**** 2889-- 2890endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 2891 2892[[interfaces-builtin-variables-layer]] 2893[open,refpage='Layer',desc='Layer index for layered rendering',type='builtins'] 2894-- 2895:refpage: Layer 2896 2897code:Layer:: 2898+ 2899[open] 2900---- 2901Decorating a variable with the code:Layer built-in decoration will make that 2902variable contain the select layer of a multi-layer framebuffer attachment. 2903 2904In a 2905ifdef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 2906ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[mesh,] 2907vertex, tessellation evaluation, or 2908endif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 2909geometry shader, any variable decorated with code:Layer can be written with 2910the framebuffer layer index to which the primitive produced by that shader 2911will be directed. 2912 2913ifdef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 2914The last active 2915<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 2916stage>> (in pipeline order) controls the code:Layer that is used. 2917Outputs in previous shader stages are not used, even if the last stage fails 2918to write the code:Layer. 2919endif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 2920 2921If the last active 2922<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 2923stage>> shader entry point's interface does not include a variable decorated 2924with code:Layer, then the first layer is used. 2925If a <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 2926stage>> shader entry point's interface includes a variable decorated with 2927code:Layer, it must: write the same value to code:Layer for all output 2928vertices of a given primitive. 2929If the code:Layer value is less than 0 or greater than or equal to the 2930number of layers in the framebuffer, then primitives may: still be 2931rasterized, fragment shaders may: be executed, and the framebuffer values 2932for all layers are undefined:. 2933ifdef::VK_EXT_mesh_shader[] 2934In a mesh shader this also applies when the code:Layer value is greater than 2935or equal to the pname:maxMeshOutputLayers limit. 2936endif::VK_EXT_mesh_shader[] 2937 2938ifdef::VK_NV_viewport_array2[] 2939If a variable with the code:Layer decoration is also decorated with 2940code:ViewportRelativeNV, then the code:ViewportIndex is added to the layer 2941that is used for rendering and that is made available in the fragment 2942shader. 2943 2944If the shader writes to a variable decorated code:ViewportMaskNV, then the 2945layer selected has a different value for each viewport a primitive is 2946rendered to. 2947endif::VK_NV_viewport_array2[] 2948 2949In a fragment shader, a variable decorated with code:Layer contains the 2950layer index of the primitive that the fragment invocation belongs to. 2951---- 2952 2953.Valid Usage 2954**** 2955 * [[VUID-{refpage}-Layer-04272]] 2956 The code:Layer decoration must: be used only within the code:MeshEXT, 2957 code:MeshNV, code:Vertex, code:TessellationEvaluation, code:Geometry, or 2958 code:Fragment {ExecutionModel} 2959ifdef::VK_VERSION_1_2[] 2960 * [[VUID-{refpage}-Layer-04273]] 2961 If the <<features-shaderOutputLayer, pname:shaderOutputLayer>> feature 2962 is not enabled then the code:Layer decoration must: be used only within 2963 the code:Geometry or code:Fragment {ExecutionModel} 2964endif::VK_VERSION_1_2[] 2965 * [[VUID-{refpage}-Layer-04274]] 2966 The variable decorated with code:Layer within the code:MeshEXT, 2967 code:MeshNV, code:Vertex, code:TessellationEvaluation, or code:Geometry 2968 {ExecutionModel} must: be declared using the code:Output {StorageClass} 2969 * [[VUID-{refpage}-Layer-04275]] 2970 The variable decorated with code:Layer within the code:Fragment 2971 {ExecutionModel} must: be declared using the code:Input {StorageClass} 2972 * [[VUID-{refpage}-Layer-04276]] 2973 The variable decorated with code:Layer must: be declared as a scalar 2974 32-bit integer value 2975 * [[VUID-{refpage}-Layer-07039]] 2976 The variable decorated with code:Layer within the code:MeshEXT 2977 {ExecutionModel} must: also be decorated with the code:PerPrimitiveEXT 2978 decoration 2979**** 2980-- 2981 2982ifdef::VK_NV_mesh_shader[] 2983[[interfaces-builtin-variables-layerpv]] 2984[open,refpage='LayerPerViewNV',desc='Layer index per view for layered rendering',type='builtins'] 2985-- 2986:refpage: LayerPerViewNV 2987 2988code:LayerPerViewNV:: 2989 2990Decorating a variable with the code:LayerPerViewNV built-in decoration will 2991make that variable contain the per-view layer information. 2992The per-view layer has the same semantics as code:Layer, for each view. 2993 2994.Valid Usage 2995**** 2996 * [[VUID-{refpage}-LayerPerViewNV-04277]] 2997 The code:LayerPerViewNV decoration must: be used only within the 2998 code:MeshNV {ExecutionModel} 2999 * [[VUID-{refpage}-LayerPerViewNV-04278]] 3000 The variable decorated with code:LayerPerViewNV must: be declared using 3001 the code:Output {StorageClass} 3002 * [[VUID-{refpage}-LayerPerViewNV-04279]] 3003 The variable decorated with code:LayerPerViewNV must: also be decorated 3004 with the code:PerViewNV decoration 3005 * [[VUID-{refpage}-LayerPerViewNV-04280]] 3006 The variable decorated with code:LayerPerViewNV must: be declared as an 3007 array of scalar 32-bit integer values 3008**** 3009-- 3010endif::VK_NV_mesh_shader[] 3011 3012[[interfaces-builtin-variables-localinvocationid]] 3013[open,refpage='LocalInvocationId',desc='Local invocation ID',type='builtins'] 3014-- 3015:refpage: LocalInvocationId 3016 3017code:LocalInvocationId:: 3018 3019Decorating a variable with the code:LocalInvocationId built-in decoration 3020will make that variable contain the location of the current 3021ifdef::VK_HUAWEI_cluster_culling_shader[cluster culling, ] 3022ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[task, mesh, or] 3023compute shader invocation within the local workgroup. 3024Each component ranges from zero through to the size of the workgroup in that 3025dimension minus one. 3026 3027[NOTE] 3028.Note 3029==== 3030If the size of the workgroup in a particular dimension is one, then the 3031code:LocalInvocationId in that dimension will be zero. 3032If the workgroup is effectively two-dimensional, then 3033code:LocalInvocationId.z will be zero. 3034If the workgroup is effectively one-dimensional, then both 3035code:LocalInvocationId.y and code:LocalInvocationId.z will be zero. 3036==== 3037 3038.Valid Usage 3039**** 3040 * [[VUID-{refpage}-LocalInvocationId-04281]] 3041 The code:LocalInvocationId decoration must: be used only within the 3042 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 3043 {ExecutionModel} 3044 * [[VUID-{refpage}-LocalInvocationId-04282]] 3045 The variable decorated with code:LocalInvocationId must: be declared 3046 using the code:Input {StorageClass} 3047 * [[VUID-{refpage}-LocalInvocationId-04283]] 3048 The variable decorated with code:LocalInvocationId must: be declared as 3049 a three-component vector of 32-bit integer values 3050**** 3051-- 3052 3053[[interfaces-builtin-variables-localinvocationindex]] 3054[open,refpage='LocalInvocationIndex',desc='Linear local invocation index',type='builtins'] 3055-- 3056:refpage: LocalInvocationIndex 3057 3058code:LocalInvocationIndex:: 3059 3060Decorating a variable with the code:LocalInvocationIndex built-in decoration 3061will make that variable contain a one-dimensional representation of 3062code:LocalInvocationId. 3063This is computed as: 3064+ 3065[source,c++] 3066---- 3067LocalInvocationIndex = 3068 LocalInvocationId.z * WorkgroupSize.x * WorkgroupSize.y + 3069 LocalInvocationId.y * WorkgroupSize.x + 3070 LocalInvocationId.x; 3071---- 3072 3073.Valid Usage 3074**** 3075 * [[VUID-{refpage}-LocalInvocationIndex-04284]] 3076 The code:LocalInvocationIndex decoration must: be used only within the 3077 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 3078 {ExecutionModel} 3079 * [[VUID-{refpage}-LocalInvocationIndex-04285]] 3080 The variable decorated with code:LocalInvocationIndex must: be declared 3081 using the code:Input {StorageClass} 3082 * [[VUID-{refpage}-LocalInvocationIndex-04286]] 3083 The variable decorated with code:LocalInvocationIndex must: be declared 3084 as a scalar 32-bit integer value 3085**** 3086-- 3087 3088ifdef::VK_NV_mesh_shader[] 3089[[interfaces-builtin-variables-meshviewcount]] 3090[open,refpage='MeshViewCountNV',desc='Number of views processed by a mesh or task shader',type='builtins'] 3091-- 3092:refpage: MeshViewCountNV 3093 3094code:MeshViewCountNV:: 3095 3096Decorating a variable with the code:MeshViewCountNV built-in decoration will 3097make that variable contain the number of views processed by the current mesh 3098or task shader invocations. 3099 3100.Valid Usage 3101**** 3102 * [[VUID-{refpage}-MeshViewCountNV-04287]] 3103 The code:MeshViewCountNV decoration must: be used only within the 3104 code:MeshNV or code:TaskNV {ExecutionModel} 3105 * [[VUID-{refpage}-MeshViewCountNV-04288]] 3106 The variable decorated with code:MeshViewCountNV must: be declared using 3107 the code:Input {StorageClass} 3108 * [[VUID-{refpage}-MeshViewCountNV-04289]] 3109 The variable decorated with code:MeshViewCountNV must: be declared as a 3110 scalar 32-bit integer value 3111**** 3112-- 3113 3114[[interfaces-builtin-variables-meshviewindices]] 3115[open,refpage='MeshViewIndicesNV',desc='Indices of views processed by a mesh or task shader',type='builtins'] 3116-- 3117:refpage: MeshViewIndicesNV 3118 3119code:MeshViewIndicesNV:: 3120 3121Decorating a variable with the code:MeshViewIndicesNV built-in decoration 3122will make that variable contain the mesh view indices. 3123The mesh view indices is an array of values where each element holds the 3124view number of one of the views being processed by the current mesh or task 3125shader invocations. 3126The values of array elements with indices greater than or equal to 3127code:MeshViewCountNV are undefined:. 3128If the value of code:MeshViewIndicesNV[i] is [eq]#j#, then any outputs 3129decorated with code:PerViewNV will take on the value of array element 3130[eq]#i# when processing primitives for view index [eq]#j#. 3131 3132.Valid Usage 3133**** 3134 * [[VUID-{refpage}-MeshViewIndicesNV-04290]] 3135 The code:MeshViewIndicesNV decoration must: be used only within the 3136 code:MeshNV or code:TaskNV {ExecutionModel} 3137 * [[VUID-{refpage}-MeshViewIndicesNV-04291]] 3138 The variable decorated with code:MeshViewIndicesNV must: be declared 3139 using the code:Input {StorageClass} 3140 * [[VUID-{refpage}-MeshViewIndicesNV-04292]] 3141 The variable decorated with code:MeshViewIndicesNV must: be declared as 3142 an array of scalar 32-bit integer values 3143**** 3144-- 3145endif::VK_NV_mesh_shader[] 3146 3147ifdef::VK_VERSION_1_1[] 3148[[interfaces-builtin-variables-numsubgroups]] 3149[open,refpage='NumSubgroups',desc='Number of subgroups in a workgroup',type='builtins'] 3150-- 3151:refpage: NumSubgroups 3152 3153code:NumSubgroups:: 3154 3155Decorating a variable with the code:NumSubgroups built-in decoration will 3156make that variable contain the number of subgroups in the local workgroup. 3157 3158.Valid Usage 3159**** 3160 * [[VUID-{refpage}-NumSubgroups-04293]] 3161 The code:NumSubgroups decoration must: be used only within the 3162 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 3163 {ExecutionModel} 3164 * [[VUID-{refpage}-NumSubgroups-04294]] 3165 The variable decorated with code:NumSubgroups must: be declared using 3166 the code:Input {StorageClass} 3167 * [[VUID-{refpage}-NumSubgroups-04295]] 3168 The variable decorated with code:NumSubgroups must: be declared as a 3169 scalar 32-bit integer value 3170**** 3171-- 3172endif::VK_VERSION_1_1[] 3173 3174[[interfaces-builtin-variables-numworkgroups]] 3175[open,refpage='NumWorkgroups',desc='Number of workgroups in a dispatch',type='builtins'] 3176-- 3177:refpage: NumWorkgroups 3178 3179code:NumWorkgroups:: 3180 3181Decorating a variable with the code:NumWorkgroups built-in decoration will 3182make that variable contain the number of local workgroups that are part of 3183the dispatch that the invocation belongs to. 3184Each component is equal to the values of the workgroup count parameters 3185passed into the dispatching commands. 3186 3187.Valid Usage 3188**** 3189 * [[VUID-{refpage}-NumWorkgroups-04296]] 3190 The code:NumWorkgroups decoration must: be used only within the 3191 code:GLCompute, code:MeshEXT, or code:TaskEXT {ExecutionModel} 3192 * [[VUID-{refpage}-NumWorkgroups-04297]] 3193 The variable decorated with code:NumWorkgroups must: be declared using 3194 the code:Input {StorageClass} 3195 * [[VUID-{refpage}-NumWorkgroups-04298]] 3196 The variable decorated with code:NumWorkgroups must: be declared as a 3197 three-component vector of 32-bit integer values 3198**** 3199-- 3200 3201ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3202[[interfaces-builtin-variables-objectraydirection]] 3203[open,refpage='ObjectRayDirectionKHR',desc='Ray direction in object space',type='builtins'] 3204-- 3205:refpage: ObjectRayDirectionKHR 3206 3207code:ObjectRayDirectionKHR:: 3208 3209A variable decorated with the code:ObjectRayDirectionKHR decoration will 3210specify the direction of the ray being processed, in object space. 3211 3212.Valid Usage 3213**** 3214 * [[VUID-{refpage}-ObjectRayDirectionKHR-04299]] 3215 The code:ObjectRayDirectionKHR decoration must: be used only within the 3216 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 3217 {ExecutionModel} 3218 * [[VUID-{refpage}-ObjectRayDirectionKHR-04300]] 3219 The variable decorated with code:ObjectRayDirectionKHR must: be declared 3220 using the code:Input {StorageClass} 3221 * [[VUID-{refpage}-ObjectRayDirectionKHR-04301]] 3222 The variable decorated with code:ObjectRayDirectionKHR must: be declared 3223 as a three-component vector of 32-bit floating-point values 3224**** 3225-- 3226 3227[[interfaces-builtin-variables-objectrayorigin]] 3228[open,refpage='ObjectRayOriginKHR',desc='Ray origin in object space',type='builtins'] 3229-- 3230:refpage: ObjectRayOriginKHR 3231 3232code:ObjectRayOriginKHR:: 3233 3234A variable decorated with the code:ObjectRayOriginKHR decoration will 3235specify the origin of the ray being processed, in object space. 3236 3237.Valid Usage 3238**** 3239 * [[VUID-{refpage}-ObjectRayOriginKHR-04302]] 3240 The code:ObjectRayOriginKHR decoration must: be used only within the 3241 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 3242 {ExecutionModel} 3243 * [[VUID-{refpage}-ObjectRayOriginKHR-04303]] 3244 The variable decorated with code:ObjectRayOriginKHR must: be declared 3245 using the code:Input {StorageClass} 3246 * [[VUID-{refpage}-ObjectRayOriginKHR-04304]] 3247 The variable decorated with code:ObjectRayOriginKHR must: be declared as 3248 a three-component vector of 32-bit floating-point values 3249**** 3250-- 3251 3252[[interfaces-builtin-variables-objecttoworld]] 3253[open,refpage='ObjectToWorldKHR',desc='Transformation matrix from object to world space',type='builtins'] 3254-- 3255:refpage: ObjectToWorldKHR 3256 3257code:ObjectToWorldKHR:: 3258 3259A variable decorated with the code:ObjectToWorldKHR decoration will contain 3260the current object-to-world transformation matrix, which is determined by 3261the instance of the current intersection. 3262 3263.Valid Usage 3264**** 3265 * [[VUID-{refpage}-ObjectToWorldKHR-04305]] 3266 The code:ObjectToWorldKHR decoration must: be used only within the 3267 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 3268 {ExecutionModel} 3269 * [[VUID-{refpage}-ObjectToWorldKHR-04306]] 3270 The variable decorated with code:ObjectToWorldKHR must: be declared 3271 using the code:Input {StorageClass} 3272 * [[VUID-{refpage}-ObjectToWorldKHR-04307]] 3273 The variable decorated with code:ObjectToWorldKHR must: be declared as a 3274 matrix with four columns of three-component vectors of 32-bit 3275 floating-point values 3276**** 3277-- 3278endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3279 3280[[interfaces-builtin-variables-patchvertices]] 3281[open,refpage='PatchVertices',desc='Number of vertices in an input patch',type='builtins'] 3282-- 3283:refpage: PatchVertices 3284 3285code:PatchVertices:: 3286 3287Decorating a variable with the code:PatchVertices built-in decoration will 3288make that variable contain the number of vertices in the input patch being 3289processed by the shader. 3290In a Tessellation Control Shader, this is the same as the 3291name:patchControlPoints member of 3292slink:VkPipelineTessellationStateCreateInfo. 3293In a Tessellation Evaluation Shader, code:PatchVertices is equal to the 3294tessellation control output patch size. 3295When the same shader is used in different pipelines where the patch sizes 3296are configured differently, the value of the code:PatchVertices variable 3297will also differ. 3298 3299.Valid Usage 3300**** 3301 * [[VUID-{refpage}-PatchVertices-04308]] 3302 The code:PatchVertices decoration must: be used only within the 3303 code:TessellationControl or code:TessellationEvaluation {ExecutionModel} 3304 * [[VUID-{refpage}-PatchVertices-04309]] 3305 The variable decorated with code:PatchVertices must: be declared using 3306 the code:Input {StorageClass} 3307 * [[VUID-{refpage}-PatchVertices-04310]] 3308 The variable decorated with code:PatchVertices must: be declared as a 3309 scalar 32-bit integer value 3310**** 3311-- 3312 3313[[interfaces-builtin-variables-pointcoord]] 3314[open,refpage='PointCoord',desc='Fragment coordinates in screen-space within a point primitive',type='builtins'] 3315-- 3316:refpage: PointCoord 3317 3318code:PointCoord:: 3319 3320Decorating a variable with the code:PointCoord built-in decoration will make 3321that variable contain the coordinate of the current fragment within the 3322point being rasterized, normalized to the size of the point with origin in 3323the upper left corner of the point, as described in 3324<<primsrast-points-basic,Basic Point Rasterization>>. 3325If the primitive the fragment shader invocation belongs to is not a point, 3326then the variable decorated with code:PointCoord contains an undefined: 3327value. 3328 3329[NOTE] 3330.Note 3331==== 3332Depending on how the point is rasterized, code:PointCoord may: never reach 3333[eq]#(0,0)# or [eq]#(1,1)#. 3334==== 3335 3336.Valid Usage 3337**** 3338 * [[VUID-{refpage}-PointCoord-04311]] 3339 The code:PointCoord decoration must: be used only within the 3340 code:Fragment {ExecutionModel} 3341 * [[VUID-{refpage}-PointCoord-04312]] 3342 The variable decorated with code:PointCoord must: be declared using the 3343 code:Input {StorageClass} 3344 * [[VUID-{refpage}-PointCoord-04313]] 3345 The variable decorated with code:PointCoord must: be declared as a 3346 two-component vector of 32-bit floating-point values 3347**** 3348-- 3349 3350[[interfaces-builtin-variables-pointsize]] 3351[open,refpage='PointSize',desc='Size of a point primitive',type='builtins'] 3352-- 3353:refpage: PointSize 3354 3355code:PointSize:: 3356 3357Decorating a variable with the code:PointSize built-in decoration will make 3358that variable contain the size of point primitives 3359ifdef::VK_KHR_maintenance5[] 3360or the final rasterization of polygons if <<primsrast-polygonmode, polygon 3361mode>> is ename:VK_POLYGON_MODE_POINT when 3362sname:VkPhysicalDeviceMaintenance5PropertiesKHR::pname:polygonModePointSize 3363is set to ename:VK_TRUE 3364endif::VK_KHR_maintenance5[] 3365. 3366The value written to the variable decorated with code:PointSize by the last 3367<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3368stage>> in the pipeline is used as the framebuffer-space size of points 3369produced by rasterization. 3370ifdef::VK_KHR_maintenance5[] 3371If <<features-maintenance5, pname:maintenance5>> is enabled and a value is 3372not written to a variable decorated with code:PointSize, a value of 1.0 is 3373used as the size of points. 3374endif::VK_KHR_maintenance5[] 3375 3376[NOTE] 3377.Note 3378==== 3379When code:PointSize decorates a variable in the code:Input {StorageClass}, 3380it contains the data written to the output variable decorated with 3381code:PointSize from the previous shader stage. 3382==== 3383 3384.Valid Usage 3385**** 3386 * [[VUID-{refpage}-PointSize-04314]] 3387 The code:PointSize decoration must: be used only within the 3388 code:MeshEXT, code:MeshNV, code:Vertex, code:TessellationControl, 3389 code:TessellationEvaluation, or code:Geometry {ExecutionModel} 3390 * [[VUID-{refpage}-PointSize-04315]] 3391 The variable decorated with code:PointSize within the code:MeshEXT, 3392 code:MeshNV, or code:Vertex {ExecutionModel} must: be declared using the 3393 code:Output {StorageClass} 3394 * [[VUID-{refpage}-PointSize-04316]] 3395 The variable decorated with code:PointSize within the 3396 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 3397 {ExecutionModel} must: not be declared using a {StorageClass} other than 3398 code:Input or code:Output 3399 * [[VUID-{refpage}-PointSize-04317]] 3400 The variable decorated with code:PointSize must: be declared as a scalar 3401 32-bit floating-point value 3402**** 3403-- 3404 3405[[interfaces-builtin-variables-position]] 3406[open,refpage='Position',desc='Vertex position',type='builtins'] 3407-- 3408:refpage: Position 3409 3410code:Position:: 3411 3412Decorating a variable with the code:Position built-in decoration will make 3413that variable contain the position of the current vertex. 3414In the last <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization 3415shader stage>>, the value of the variable decorated with code:Position is 3416used in subsequent primitive assembly, clipping, and rasterization 3417operations. 3418 3419[NOTE] 3420.Note 3421==== 3422When code:Position decorates a variable in the code:Input {StorageClass}, it 3423contains the data written to the output variable decorated with 3424code:Position from the previous shader stage. 3425==== 3426 3427.Valid Usage 3428**** 3429 * [[VUID-{refpage}-Position-04318]] 3430 The code:Position decoration must: be used only within the code:MeshEXT, 3431 code:MeshNV, code:Vertex, code:TessellationControl, 3432 code:TessellationEvaluation, or code:Geometry {ExecutionModel} 3433 * [[VUID-{refpage}-Position-04319]] 3434 The variable decorated with code:Position within the code:MeshEXT, 3435 code:MeshNV, or code:Vertex {ExecutionModel} must: be declared using the 3436 code:Output {StorageClass} 3437 * [[VUID-{refpage}-Position-04320]] 3438 The variable decorated with code:Position within the 3439 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 3440 {ExecutionModel} must: not be declared using a {StorageClass} other than 3441 code:Input or code:Output 3442 * [[VUID-{refpage}-Position-04321]] 3443 The variable decorated with code:Position must: be declared as a 3444 four-component vector of 32-bit floating-point values 3445**** 3446-- 3447 3448ifdef::VK_NVX_multiview_per_view_attributes[] 3449[[interfaces-builtin-variables-positionperview]] 3450[open,refpage='PositionPerViewNV',desc='Vertex position per view',type='builtins'] 3451-- 3452:refpage: PositionPerViewNV 3453 3454code:PositionPerViewNV:: 3455 3456Decorating a variable with the code:PositionPerViewNV built-in decoration 3457will make that variable contain the position of the current vertex, for each 3458view. 3459+ 3460Elements of the array correspond to views in a multiview subpass, and those 3461elements corresponding to views in the view mask of the subpass the shader 3462is compiled against will be used as the position value for those views. 3463For the final 3464<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3465stage>> in the pipeline, values written to an output variable decorated with 3466code:PositionPerViewNV are used in subsequent primitive assembly, clipping, 3467and rasterization operations, as with code:Position. 3468code:PositionPerViewNV output in an earlier 3469<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3470stage>> is available as an input in the subsequent 3471<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3472stage>>. 3473+ 3474If a shader is compiled against a subpass that has the 3475ename:VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX bit set, then 3476the position values for each view must: not differ in any component other 3477than the X component. 3478If the values do differ, one will be chosen in an implementation-dependent 3479manner. 3480 3481.Valid Usage 3482**** 3483 * [[VUID-{refpage}-PositionPerViewNV-04322]] 3484 The code:PositionPerViewNV decoration must: be used only within the 3485 code:MeshNV, code:Vertex, code:TessellationControl, 3486 code:TessellationEvaluation, or code:Geometry {ExecutionModel} 3487 * [[VUID-{refpage}-PositionPerViewNV-04323]] 3488 The variable decorated with code:PositionPerViewNV within the 3489 code:Vertex, or code:MeshNV {ExecutionModel} must: be declared using the 3490 code:Output {StorageClass} 3491 * [[VUID-{refpage}-PositionPerViewNV-04324]] 3492 The variable decorated with code:PositionPerViewNV within the 3493 code:TessellationControl, code:TessellationEvaluation, or code:Geometry 3494 {ExecutionModel} must: not be declared using a {StorageClass} other than 3495 code:Input or code:Output 3496 * [[VUID-{refpage}-PositionPerViewNV-04325]] 3497 The variable decorated with code:PositionPerViewNV must: be declared as 3498 an array of four-component vector of 32-bit floating-point values with 3499 at least as many elements as the maximum view in the subpass's view mask 3500 plus one 3501 * [[VUID-{refpage}-PositionPerViewNV-04326]] 3502 The array variable decorated with code:PositionPerViewNV must: only be 3503 indexed by a constant or specialization constant 3504**** 3505-- 3506endif::VK_NVX_multiview_per_view_attributes[] 3507 3508ifdef::VK_NV_mesh_shader[] 3509[[interfaces-builtin-variables-primitivecount]] 3510[open,refpage='PrimitiveCountNV',desc='Number of primitives output by a mesh shader',type='builtins'] 3511-- 3512:refpage: PrimitiveCountNV 3513 3514code:PrimitiveCountNV:: 3515+ 3516Decorating a variable with the code:PrimitiveCountNV decoration will make 3517that variable contain the primitive count. 3518The primitive count specifies the number of primitives in the output mesh 3519produced by the mesh shader that will be processed by subsequent pipeline 3520stages. 3521 3522.Valid Usage 3523**** 3524 * [[VUID-{refpage}-PrimitiveCountNV-04327]] 3525 The code:PrimitiveCountNV decoration must: be used only within the 3526 code:MeshNV {ExecutionModel} 3527 * [[VUID-{refpage}-PrimitiveCountNV-04328]] 3528 The variable decorated with code:PrimitiveCountNV must: be declared 3529 using the code:Output {StorageClass} 3530 * [[VUID-{refpage}-PrimitiveCountNV-04329]] 3531 The variable decorated with code:PrimitiveCountNV must: be declared as a 3532 scalar 32-bit integer value 3533**** 3534-- 3535endif::VK_NV_mesh_shader[] 3536 3537[[interfaces-builtin-variables-primitiveid]] 3538[open,refpage='PrimitiveId',desc='Primitive ID',type='builtins'] 3539-- 3540:refpage: PrimitiveId 3541 3542code:PrimitiveId:: 3543 3544Decorating a variable with the code:PrimitiveId built-in decoration will 3545make that variable contain the index of the current primitive. 3546+ 3547The index of the first primitive generated by a drawing command is zero, and 3548the index is incremented after every individual point, line, or triangle 3549primitive is processed. 3550+ 3551For triangles drawn as points or line segments (see <<primsrast-polygonmode, 3552Polygon Mode>>), the primitive index is incremented only once, even if 3553multiple points or lines are eventually drawn. 3554+ 3555Variables decorated with code:PrimitiveId are reset to zero between each 3556instance drawn. 3557+ 3558Restarting a primitive topology using primitive restart has no effect on the 3559value of variables decorated with code:PrimitiveId. 3560+ 3561In tessellation control and tessellation evaluation shaders, it will contain 3562the index of the patch within the current set of rendering primitives that 3563corresponds to the shader invocation. 3564+ 3565In a geometry shader, it will contain the number of primitives presented as 3566input to the shader since the current set of rendering primitives was 3567started. 3568+ 3569In a fragment shader, it will contain the primitive index written by the 3570ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 3571mesh shader if a mesh shader is present, or the primitive index written by 3572the 3573endif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 3574geometry shader if a geometry shader is present, or with the value that 3575would have been presented as input to the geometry shader had it been 3576present. 3577ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3578+ 3579In an intersection, any-hit, or closest hit shader, it will contain the 3580index within the geometry of the triangle or bounding box being processed. 3581endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3582 3583[NOTE] 3584.Note 3585==== 3586When the code:PrimitiveId decoration is applied to an output variable in the 3587ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[mesh shader or] 3588geometry shader, the resulting value is seen through the code:PrimitiveId 3589decorated input variable in the fragment shader. 3590 3591The fragment shader using code:PrimitiveId will need to declare either the 3592ifdef::VK_NV_mesh_shader[code:MeshShadingNV,] 3593ifdef::VK_EXT_mesh_shader[code:MeshShadingEXT,] 3594code:Geometry or code:Tessellation capability to satisfy the requirement 3595SPIR-V has to use code:PrimitiveId. 3596==== 3597 3598.Valid Usage 3599**** 3600 * [[VUID-{refpage}-PrimitiveId-04330]] 3601 The code:PrimitiveId decoration must: be used only within the 3602 code:MeshEXT, code:MeshNV, code:IntersectionKHR, code:AnyHitKHR, 3603 code:ClosestHitKHR, code:TessellationControl, 3604 code:TessellationEvaluation, code:Geometry, or code:Fragment 3605 {ExecutionModel} 3606 * [[VUID-{refpage}-Fragment-04331]] 3607 If pipeline contains both the code:Fragment and code:Geometry 3608 {ExecutionModel} and a variable decorated with code:PrimitiveId is read 3609 from code:Fragment shader, then the code:Geometry shader must: write to 3610 the output variables decorated with code:PrimitiveId in all execution 3611 paths 3612 * [[VUID-{refpage}-Fragment-04332]] 3613 If pipeline contains both the code:Fragment and code:MeshEXT or 3614 code:MeshNV {ExecutionModel} and a variable decorated with 3615 code:PrimitiveId is read from code:Fragment shader, then the 3616 code:MeshEXT or code:MeshNV shader must: write to the output variables 3617 decorated with code:PrimitiveId in all execution paths 3618 * [[VUID-{refpage}-Fragment-04333]] 3619 If code:Fragment {ExecutionModel} contains a variable decorated with 3620 code:PrimitiveId, then either the code:MeshShadingEXT, 3621 code:MeshShadingNV, code:Geometry or code:Tessellation capability must: 3622 also be declared 3623 * [[VUID-{refpage}-PrimitiveId-04334]] 3624 The variable decorated with code:PrimitiveId within the 3625 code:TessellationControl, code:TessellationEvaluation, code:Fragment, 3626 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 3627 {ExecutionModel} must: be declared using the code:Input {StorageClass} 3628 * [[VUID-{refpage}-PrimitiveId-04335]] 3629 The variable decorated with code:PrimitiveId within the code:Geometry 3630 {ExecutionModel} must: be declared using the code:Input or code:Output 3631 {StorageClass} 3632 * [[VUID-{refpage}-PrimitiveId-04336]] 3633 The variable decorated with code:PrimitiveId within the code:MeshEXT or 3634 code:MeshNV {ExecutionModel} must: be declared using the code:Output 3635 {StorageClass} 3636 * [[VUID-{refpage}-PrimitiveId-04337]] 3637 The variable decorated with code:PrimitiveId must: be declared as a 3638 scalar 32-bit integer value 3639 * [[VUID-{refpage}-PrimitiveId-07040]] 3640 The variable decorated with code:PrimitiveId within the code:MeshEXT 3641 {ExecutionModel} must: also be decorated with the code:PerPrimitiveEXT 3642 decoration 3643**** 3644-- 3645 3646ifdef::VK_NV_mesh_shader[] 3647[[interfaces-builtin-variables-primitiveindices]] 3648[open,refpage='PrimitiveIndicesNV',desc='Indices of primitives in a mesh shader',type='builtins'] 3649-- 3650:refpage: PrimitiveIndicesNV 3651 3652code:PrimitiveIndicesNV:: 3653+ 3654Decorating a variable with the code:PrimitiveIndicesNV decoration will make 3655that variable contain the output array of vertex index values. 3656Depending on the output primitive type declared using the execution mode, 3657the indices are split into groups of one (code:OutputPoints), two 3658(code:OutputLinesNV), or three (code:OutputTrianglesNV) indices and each 3659group generates a primitive. 3660 3661.Valid Usage 3662**** 3663 * [[VUID-{refpage}-PrimitiveIndicesNV-04338]] 3664 The code:PrimitiveIndicesNV decoration must: be used only within the 3665 code:MeshNV {ExecutionModel} 3666 * [[VUID-{refpage}-PrimitiveIndicesNV-04339]] 3667 The variable decorated with code:PrimitiveIndicesNV must: be declared 3668 using the code:Output {StorageClass} 3669 * [[VUID-{refpage}-PrimitiveIndicesNV-04340]] 3670 The variable decorated with code:PrimitiveIndicesNV must: be declared as 3671 an array of scalar 32-bit integer values 3672 * [[VUID-{refpage}-PrimitiveIndicesNV-04341]] 3673 All index values of the array decorated with code:PrimitiveIndicesNV 3674 must: be in the range [eq]#[0, N-1]#, where [eq]#N# is the value 3675 specified by the code:OutputVertices {ExecutionMode} 3676 * [[VUID-{refpage}-OutputPoints-04342]] 3677 If the {ExecutionMode} is code:OutputPoints, then the array decorated 3678 with code:PrimitiveIndicesNV must: be the size of the value specified by 3679 code:OutputPrimitivesNV 3680 * [[VUID-{refpage}-OutputLinesNV-04343]] 3681 If the {ExecutionMode} is code:OutputLinesNV, then the array decorated 3682 with code:PrimitiveIndicesNV must: be the size of two times the value 3683 specified by code:OutputPrimitivesNV 3684 * [[VUID-{refpage}-OutputTrianglesNV-04344]] 3685 If the {ExecutionMode} is code:OutputTrianglesNV, then the array 3686 decorated with code:PrimitiveIndicesNV must: be the size of three times 3687 the value specified by code:OutputPrimitivesNV 3688**** 3689-- 3690endif::VK_NV_mesh_shader[] 3691 3692ifdef::VK_EXT_mesh_shader[] 3693[[interfaces-builtin-variables-primitivepointindices]] 3694[open,refpage='PrimitivePointIndicesEXT',desc='Indices of point primitives in a mesh shader',type='builtins'] 3695-- 3696:refpage: PrimitivePointIndicesEXT 3697 3698code:PrimitivePointIndicesEXT:: 3699+ 3700Decorating a variable with the code:PrimitivePointIndicesEXT decoration will 3701make that variable contain the output array of vertex index values for point 3702primitives. 3703 3704.Valid Usage 3705**** 3706 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07041]] 3707 The code:PrimitivePointIndicesEXT decoration must: be used only within 3708 the code:MeshEXT {ExecutionModel} 3709 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07042]] 3710 The code:PrimitivePointIndicesEXT decoration must: be used with the 3711 code:OutputPoints {ExecutionMode} 3712 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07043]] 3713 The variable decorated with code:PrimitivePointIndicesEXT must: be 3714 declared using the code:Output {StorageClass} 3715 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07044]] 3716 The variable decorated with code:PrimitivePointIndicesEXT must: be 3717 declared as an array of scalar 32-bit integer values 3718 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07045]] 3719 All index values of the array decorated with 3720 code:PrimitivePointIndicesEXT must: be in the range [eq]#[0, N-1]#, 3721 where [eq]#N# is the value specified by the code:OutputVertices 3722 {ExecutionMode} 3723 * [[VUID-{refpage}-PrimitivePointIndicesEXT-07046]] 3724 The size of the array decorated with code:PrimitivePointIndicesEXT must: 3725 match the value specified by code:OutputPrimitivesEXT 3726**** 3727-- 3728 3729[[interfaces-builtin-variables-primitivelineindices]] 3730[open,refpage='PrimitiveLineIndicesEXT',desc='Indices of line primitives in a mesh shader',type='builtins'] 3731-- 3732:refpage: PrimitiveLineIndicesEXT 3733 3734code:PrimitiveLineIndicesEXT:: 3735+ 3736Decorating a variable with the code:PrimitiveLineIndicesEXT decoration will 3737make that variable contain the output array of vertex index values for line 3738primitives. 3739 3740.Valid Usage 3741**** 3742 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07047]] 3743 The code:PrimitiveLineIndicesEXT decoration must: be used only within 3744 the code:MeshEXT {ExecutionModel} 3745 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07048]] 3746 The code:PrimitiveLineIndicesEXT decoration must: be used with the 3747 code:OutputLinesEXT {ExecutionMode} 3748 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07049]] 3749 The variable decorated with code:PrimitiveLineIndicesEXT must: be 3750 declared using the code:Output {StorageClass} 3751 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07050]] 3752 The variable decorated with code:PrimitiveLineIndicesEXT must: be 3753 declared as an array of two component vector 32-bit integer values 3754 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07051]] 3755 All index values of the array decorated with 3756 code:PrimitiveLineIndicesEXT must: be in the range [eq]#[0, N-1]#, where 3757 [eq]#N# is the value specified by the code:OutputVertices 3758 {ExecutionMode} 3759 * [[VUID-{refpage}-PrimitiveLineIndicesEXT-07052]] 3760 The size of the array decorated with code:PrimitiveLineIndicesEXT must: 3761 match the value specified by code:OutputPrimitivesEXT 3762**** 3763-- 3764 3765[[interfaces-builtin-variables-primitivetriangleindices]] 3766[open,refpage='PrimitiveTriangleIndicesEXT',desc='Indices of triangle primitives in a mesh shader',type='builtins'] 3767-- 3768:refpage: PrimitiveTriangleIndicesEXT 3769 3770code:PrimitiveTriangleIndicesEXT:: 3771+ 3772Decorating a variable with the code:PrimitiveTriangleIndicesEXT decoration 3773will make that variable contain the output array of vertex index values for 3774triangle primitives. 3775 3776.Valid Usage 3777**** 3778 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07053]] 3779 The code:PrimitiveTriangleIndicesEXT decoration must: be used only 3780 within the code:MeshEXT {ExecutionModel} 3781 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07054]] 3782 The code:PrimitiveTriangleIndicesEXT decoration must: be used with the 3783 code:OutputTrianglesEXT {ExecutionMode} 3784 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07055]] 3785 The variable decorated with code:PrimitiveTriangleIndicesEXT must: be 3786 declared using the code:Output {StorageClass} 3787 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07056]] 3788 The variable decorated with code:PrimitiveTriangleIndicesEXT must: be 3789 declared as an array of three component vector 32-bit integer values 3790 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07057]] 3791 All index values of the array decorated with 3792 code:PrimitiveTriangleIndicesEXT must: be in the range [eq]#[0, N-1]#, 3793 where [eq]#N# is the value specified by the code:OutputVertices 3794 {ExecutionMode} 3795 * [[VUID-{refpage}-PrimitiveTriangleIndicesEXT-07058]] 3796 The size of the array decorated with code:PrimitiveTriangleIndicesEXT 3797 must: match the value specified by code:OutputPrimitivesEXT 3798**** 3799-- 3800endif::VK_EXT_mesh_shader[] 3801 3802ifdef::VK_KHR_fragment_shading_rate[] 3803[[interfaces-builtin-variables-primitiveshadingrate]] 3804[open,refpage='PrimitiveShadingRateKHR',desc='Primitive contribution to fragment shading rate',type='builtins'] 3805-- 3806:refpage: PrimitiveShadingRateKHR 3807 3808code:PrimitiveShadingRateKHR:: 3809 3810Decorating a variable with the code:PrimitiveShadingRateKHR built-in 3811decoration will make that variable contain the 3812<<primsrast-fragment-shading-rate-primitive, primitive fragment shading 3813rate>>. 3814+ 3815The value written to the variable decorated with 3816code:PrimitiveShadingRateKHR by the last 3817<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3818stage>> in the pipeline is used as the 3819<<primsrast-fragment-shading-rate-primitive, primitive fragment shading 3820rate>>. 3821Outputs in previous shader stages are ignored. 3822+ 3823If the last active 3824<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 3825stage>> shader entry point's interface does not include a variable decorated 3826with code:PrimitiveShadingRateKHR, then it is as if the shader specified a 3827fragment shading rate value of 0, indicating a horizontal and vertical rate 3828of 1 pixel. 3829+ 3830If a shader has code:PrimitiveShadingRateKHR in the output interface and 3831there is an execution path through the shader that does not write to it, its 3832value is undefined: for executions of the shader that take that path. 3833 3834.Valid Usage 3835**** 3836 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04484]] 3837 The code:PrimitiveShadingRateKHR decoration must: be used only within 3838 the code:MeshEXT, code:MeshNV, code:Vertex, or code:Geometry 3839 {ExecutionModel} 3840 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04485]] 3841 The variable decorated with code:PrimitiveShadingRateKHR must: be 3842 declared using the code:Output {StorageClass} 3843 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04486]] 3844 The variable decorated with code:PrimitiveShadingRateKHR must: be 3845 declared as a scalar 32-bit integer value 3846 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04487]] 3847 The value written to code:PrimitiveShadingRateKHR must: include no more 3848 than one of code:Vertical2Pixels and code:Vertical4Pixels 3849 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04488]] 3850 The value written to code:PrimitiveShadingRateKHR must: include no more 3851 than one of code:Horizontal2Pixels and code:Horizontal4Pixels 3852 * [[VUID-{refpage}-PrimitiveShadingRateKHR-04489]] 3853 The value written to code:PrimitiveShadingRateKHR must: not have any 3854 bits set other than those defined by *Fragment Shading Rate Flags* 3855 enumerants in the SPIR-V specification 3856 * [[VUID-{refpage}-PrimitiveShadingRateKHR-07059]] 3857 The variable decorated with code:PrimitiveShadingRateKHR within the 3858 code:MeshEXT {ExecutionModel} must: also be decorated with the 3859 code:PerPrimitiveEXT decoration 3860**** 3861-- 3862endif::VK_KHR_fragment_shading_rate[] 3863 3864ifdef::VK_KHR_ray_tracing_pipeline[] 3865[[interfaces-builtin-variables-raygeometryindex]] 3866[open,refpage='RayGeometryIndexKHR',desc='Geometry index in a ray shader',type='builtins'] 3867-- 3868:refpage: RayGeometryIndexKHR 3869 3870code:RayGeometryIndexKHR:: 3871 3872A variable decorated with the code:RayGeometryIndexKHR decoration will 3873contain the <<acceleration-structure-geometry-index, geometry index>> for 3874the acceleration structure geometry currently being shaded. 3875 3876.Valid Usage 3877**** 3878 * [[VUID-{refpage}-RayGeometryIndexKHR-04345]] 3879 The code:RayGeometryIndexKHR decoration must: be used only within the 3880 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 3881 {ExecutionModel} 3882 * [[VUID-{refpage}-RayGeometryIndexKHR-04346]] 3883 The variable decorated with code:RayGeometryIndexKHR must: be declared 3884 using the code:Input {StorageClass} 3885 * [[VUID-{refpage}-RayGeometryIndexKHR-04347]] 3886 The variable decorated with code:RayGeometryIndexKHR must: be declared 3887 as a scalar 32-bit integer value 3888**** 3889-- 3890endif::VK_KHR_ray_tracing_pipeline[] 3891 3892ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3893[[interfaces-builtin-variables-raytmax]] 3894[open,refpage='RayTmaxKHR',desc='Maximum T value of a ray',type='builtins'] 3895-- 3896:refpage: RayTmaxKHR 3897 3898code:RayTmaxKHR:: 3899 3900A variable decorated with the code:RayTmaxKHR decoration will contain the 3901parametric [eq]#t~max~# value of the ray being processed. 3902The value is independent of the space in which the ray origin and direction 3903exist. 3904The value is initialized to the parameter passed into the 3905<<glossary-pipeline-trace-ray, pipeline trace ray>> instruction. 3906+ 3907The [eq]#t~max~# value changes throughout the lifetime of the ray that 3908produced the intersection. 3909In the closest hit shader, the value reflects the closest distance to the 3910intersected primitive. 3911In the any-hit shader, it reflects the distance to the primitive currently 3912being intersected. 3913In the intersection shader, it reflects the distance to the closest 3914primitive intersected so far or the initial value. 3915The value can change in the intersection shader after calling 3916code:OpReportIntersectionKHR if the corresponding any-hit shader does not 3917ignore the intersection. 3918In a miss shader, the value is identical to the parameter passed into the 3919<<glossary-pipeline-trace-ray, pipeline trace ray>> instruction. 3920 3921.Valid Usage 3922**** 3923 * [[VUID-{refpage}-RayTmaxKHR-04348]] 3924 The code:RayTmaxKHR decoration must: be used only within the 3925 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 3926 code:MissKHR {ExecutionModel} 3927 * [[VUID-{refpage}-RayTmaxKHR-04349]] 3928 The variable decorated with code:RayTmaxKHR must: be declared using the 3929 code:Input {StorageClass} 3930 * [[VUID-{refpage}-RayTmaxKHR-04350]] 3931 The variable decorated with code:RayTmaxKHR must: be declared as a 3932 scalar 32-bit floating-point value 3933**** 3934-- 3935 3936[[interfaces-builtin-variables-raytmin]] 3937[open,refpage='RayTminKHR',desc='Minimum T value of a ray',type='builtins'] 3938-- 3939:refpage: RayTminKHR 3940 3941code:RayTminKHR:: 3942 3943A variable decorated with the code:RayTminKHR decoration will contain the 3944parametric [eq]#t~min~# value of the ray being processed. 3945The value is independent of the space in which the ray origin and direction 3946exist. 3947The value is the parameter passed into the <<glossary-pipeline-trace-ray, 3948pipeline trace ray>> instruction. 3949+ 3950The [eq]#t~min~# value remains constant for the duration of the ray query. 3951 3952.Valid Usage 3953**** 3954 * [[VUID-{refpage}-RayTminKHR-04351]] 3955 The code:RayTminKHR decoration must: be used only within the 3956 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 3957 code:MissKHR {ExecutionModel} 3958 * [[VUID-{refpage}-RayTminKHR-04352]] 3959 The variable decorated with code:RayTminKHR must: be declared using the 3960 code:Input {StorageClass} 3961 * [[VUID-{refpage}-RayTminKHR-04353]] 3962 The variable decorated with code:RayTminKHR must: be declared as a 3963 scalar 32-bit floating-point value 3964**** 3965-- 3966endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 3967 3968[[interfaces-builtin-variables-sampleid]] 3969[open,refpage='SampleId',desc='Sample ID within a fragment',type='builtins'] 3970-- 3971:refpage: SampleId 3972 3973code:SampleId:: 3974 3975Decorating a variable with the code:SampleId built-in decoration will make 3976that variable contain the <<primsrast-multisampling-coverage-mask, coverage 3977index>> for the current fragment shader invocation. 3978code:SampleId ranges from zero to the number of samples in the framebuffer 3979minus one. 3980If a fragment shader entry point's interface includes an input variable 3981decorated with code:SampleId, <<primsrast-sampleshading,Sample Shading>> is 3982considered enabled with a pname:minSampleShading value of 1.0. 3983 3984.Valid Usage 3985**** 3986 * [[VUID-{refpage}-SampleId-04354]] 3987 The code:SampleId decoration must: be used only within the code:Fragment 3988 {ExecutionModel} 3989 * [[VUID-{refpage}-SampleId-04355]] 3990 The variable decorated with code:SampleId must: be declared using the 3991 code:Input {StorageClass} 3992 * [[VUID-{refpage}-SampleId-04356]] 3993 The variable decorated with code:SampleId must: be declared as a scalar 3994 32-bit integer value 3995**** 3996-- 3997 3998[[interfaces-builtin-variables-samplemask]] 3999[open,refpage='SampleMask',desc='Coverage mask for a fragment shader invocation',type='builtins'] 4000-- 4001:refpage: SampleMask 4002 4003code:SampleMask:: 4004 4005Decorating a variable with the code:SampleMask built-in decoration will make 4006any variable contain the <<fragops-shader-samplemask, sample mask>> for the 4007current fragment shader invocation. 4008+ 4009A variable in the code:Input storage class decorated with code:SampleMask 4010will contain a bitmask of the set of samples covered by the primitive 4011generating the fragment during rasterization. 4012It has a sample bit set if and only if the sample is considered covered for 4013this fragment shader invocation. 4014code:SampleMask[] is an array of integers. 4015Bits are mapped to samples in a manner where bit B of mask M 4016(`SampleMask[M]`) corresponds to sample [eq]#32 {times} M {plus} B#. 4017+ 4018A variable in the code:Output storage class decorated with code:SampleMask 4019is an array of integers forming a bit array in a manner similar to an input 4020variable decorated with code:SampleMask, but where each bit represents 4021coverage as computed by the shader. 4022This computed code:SampleMask is combined with the generated coverage mask 4023in the <<fragops-covg, multisample coverage>> operation. 4024+ 4025Variables decorated with code:SampleMask must: be either an unsized array, 4026or explicitly sized to be no larger than the implementation-dependent 4027maximum sample-mask (as an array of 32-bit elements), determined by the 4028maximum number of samples. 4029+ 4030If a fragment shader entry point's interface includes an output variable 4031decorated with code:SampleMask, the sample mask will be undefined: for any 4032array elements of any fragment shader invocations that fail to assign a 4033value. 4034If a fragment shader entry point's interface does not include an output 4035variable decorated with code:SampleMask, the sample mask has no effect on 4036the processing of a fragment. 4037 4038.Valid Usage 4039**** 4040 * [[VUID-{refpage}-SampleMask-04357]] 4041 The code:SampleMask decoration must: be used only within the 4042 code:Fragment {ExecutionModel} 4043 * [[VUID-{refpage}-SampleMask-04358]] 4044 The variable decorated with code:SampleMask must: be declared using the 4045 code:Input or code:Output {StorageClass} 4046 * [[VUID-{refpage}-SampleMask-04359]] 4047 The variable decorated with code:SampleMask must: be declared as an 4048 array of 32-bit integer values 4049**** 4050-- 4051 4052[[interfaces-builtin-variables-sampleposition]] 4053[open,refpage='SamplePosition',desc='Position of a shaded sample',type='builtins'] 4054-- 4055:refpage: SamplePosition 4056 4057code:SamplePosition:: 4058 4059Decorating a variable with the code:SamplePosition built-in decoration will 4060make that variable contain the sub-pixel position of the sample being 4061shaded. 4062The top left of the pixel is considered to be at coordinate [eq]#(0,0)# and 4063the bottom right of the pixel is considered to be at coordinate [eq]#(1,1)#. 4064ifdef::VK_EXT_fragment_density_map[] 4065// Markup here is weird. To get all these paragraphs indented properly for 4066// the keyword, the '+' connector must be *inside* ifdefs w/o blank lines. 4067+ 4068If the render pass has a fragment density map attachment, the variable will 4069instead contain the sub-fragment position of the sample being shaded. 4070The top left of the fragment is considered to be at coordinate [eq]#(0,0)# 4071and the bottom right of the fragment is considered to be at coordinate 4072[eq]#(1,1)# for any fragment area. 4073endif::VK_EXT_fragment_density_map[] 4074+ 4075If a fragment shader entry point's interface includes an input variable 4076decorated with code:SamplePosition, <<primsrast-sampleshading,Sample 4077Shading>> is considered enabled with a pname:minSampleShading value of 1.0. 4078ifdef::VK_EXT_sample_locations[] 4079+ 4080If the current pipeline uses <<primsrast-samplelocations, custom sample 4081locations>> the value of any variable decorated with the code:SamplePosition 4082built-in decoration is undefined:. 4083endif::VK_EXT_sample_locations[] 4084 4085.Valid Usage 4086**** 4087 * [[VUID-{refpage}-SamplePosition-04360]] 4088 The code:SamplePosition decoration must: be used only within the 4089 code:Fragment {ExecutionModel} 4090 * [[VUID-{refpage}-SamplePosition-04361]] 4091 The variable decorated with code:SamplePosition must: be declared using 4092 the code:Input {StorageClass} 4093 * [[VUID-{refpage}-SamplePosition-04362]] 4094 The variable decorated with code:SamplePosition must: be declared as a 4095 two-component vector of 32-bit floating-point values 4096**** 4097-- 4098 4099ifdef::VK_KHR_fragment_shading_rate[] 4100[[interfaces-builtin-variables-shadingratekhr]] 4101[open,refpage='ShadingRateKHR',desc='Shading rate of a fragment',type='builtins'] 4102-- 4103:refpage: ShadingRateKHR 4104 4105code:ShadingRateKHR:: 4106 4107Decorating a variable with the code:ShadingRateKHR built-in decoration will 4108make that variable contain the <<primsrast-fragment-shading-rate, fragment 4109shading rate>> for the current fragment invocation. 4110 4111.Valid Usage 4112**** 4113 * [[VUID-{refpage}-ShadingRateKHR-04490]] 4114 The code:ShadingRateKHR decoration must: be used only within the 4115 code:Fragment {ExecutionModel} 4116 * [[VUID-{refpage}-ShadingRateKHR-04491]] 4117 The variable decorated with code:ShadingRateKHR must: be declared using 4118 the code:Input {StorageClass} 4119 * [[VUID-{refpage}-ShadingRateKHR-04492]] 4120 The variable decorated with code:ShadingRateKHR must: be declared as a 4121 scalar 32-bit integer value 4122**** 4123-- 4124endif::VK_KHR_fragment_shading_rate[] 4125 4126ifdef::VK_NV_shader_sm_builtins[] 4127[[interfaces-builtin-variables-smcountnv]] 4128[open,refpage='SMCountNV',desc='Number of SMs on the device',type='builtins'] 4129-- 4130:refpage: SMCountNV 4131 4132code:SMCountNV:: 4133 4134Decorating a variable with the code:SMCountNV built-in decoration will make 4135that variable contain the number of SMs on the device. 4136 4137.Valid Usage 4138**** 4139 * [[VUID-{refpage}-SMCountNV-04363]] 4140 The variable decorated with code:SMCountNV must: be declared using the 4141 code:Input {StorageClass} 4142 * [[VUID-{refpage}-SMCountNV-04364]] 4143 The variable decorated with code:SMCountNV must: be declared as a scalar 4144 32-bit integer value 4145**** 4146-- 4147 4148[[interfaces-builtin-variables-smidnv]] 4149[open,refpage='SMIDNV',desc='SM ID on which a shader invocation is running',type='builtins'] 4150-- 4151:refpage: SMIDNV 4152 4153code:SMIDNV:: 4154 4155Decorating a variable with the code:SMIDNV built-in decoration will make 4156that variable contain the ID of the SM on which the current shader 4157invocation is running. 4158This variable is in the range [eq]#[0, code:SMCountNV-1]#. 4159 4160.Valid Usage 4161**** 4162 * [[VUID-{refpage}-SMIDNV-04365]] 4163 The variable decorated with code:SMIDNV must: be declared using the 4164 code:Input {StorageClass} 4165 * [[VUID-{refpage}-SMIDNV-04366]] 4166 The variable decorated with code:SMIDNV must: be declared as a scalar 4167 32-bit integer value 4168**** 4169-- 4170endif::VK_NV_shader_sm_builtins[] 4171 4172ifdef::VK_VERSION_1_1[] 4173[[interfaces-builtin-variables-subgroupid]] 4174[open,refpage='SubgroupId',desc='Subgroup ID ',type='builtins'] 4175-- 4176:refpage: SubgroupId 4177 4178code:SubgroupId:: 4179+ 4180Decorating a variable with the code:SubgroupId built-in decoration will make 4181that variable contain the index of the subgroup within the local workgroup. 4182This variable is in range [0, code:NumSubgroups-1]. 4183 4184.Valid Usage 4185**** 4186 * [[VUID-{refpage}-SubgroupId-04367]] 4187 The code:SubgroupId decoration must: be used only within the 4188 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 4189 {ExecutionModel} 4190 * [[VUID-{refpage}-SubgroupId-04368]] 4191 The variable decorated with code:SubgroupId must: be declared using the 4192 code:Input {StorageClass} 4193 * [[VUID-{refpage}-SubgroupId-04369]] 4194 The variable decorated with code:SubgroupId must: be declared as a 4195 scalar 32-bit integer value 4196**** 4197-- 4198endif::VK_VERSION_1_1[] 4199 4200ifdef::VK_VERSION_1_1,VK_EXT_shader_subgroup_ballot[] 4201[[interfaces-builtin-variables-sgeq]] 4202[open,refpage='SubgroupEqMask',desc='Mask of shader invocations in a subgroup with the same subgroup local invocation ID',type='builtins'] 4203-- 4204:refpage: SubgroupEqMask 4205 4206code:SubgroupEqMask:: 4207+ 4208Decorating a variable with the code:SubgroupEqMask builtin decoration will 4209make that variable contain the _subgroup mask_ of the current subgroup 4210invocation. 4211The bit corresponding to the code:SubgroupLocalInvocationId is set in the 4212variable decorated with code:SubgroupEqMask. 4213All other bits are set to zero. 4214+ 4215code:SubgroupEqMaskKHR is an alias of code:SubgroupEqMask. 4216 4217.Valid Usage 4218**** 4219 * [[VUID-{refpage}-SubgroupEqMask-04370]] 4220 The variable decorated with code:SubgroupEqMask must: be declared using 4221 the code:Input {StorageClass} 4222 * [[VUID-{refpage}-SubgroupEqMask-04371]] 4223 The variable decorated with code:SubgroupEqMask must: be declared as a 4224 four-component vector of 32-bit integer values 4225**** 4226-- 4227 4228[[interfaces-builtin-variables-sgge]] 4229[open,refpage='SubgroupGeMask',desc='Mask of shader invocations in a subgroup with the same or higher subgroup local invocation ID',type='builtins'] 4230-- 4231:refpage: SubgroupGeMask 4232 4233code:SubgroupGeMask:: 4234+ 4235Decorating a variable with the code:SubgroupGeMask builtin decoration will 4236make that variable contain the _subgroup mask_ of the current subgroup 4237invocation. 4238The bits corresponding to the invocations greater than or equal to 4239code:SubgroupLocalInvocationId through code:SubgroupSize-1 are set in the 4240variable decorated with code:SubgroupGeMask. 4241All other bits are set to zero. 4242+ 4243code:SubgroupGeMaskKHR is an alias of code:SubgroupGeMask. 4244 4245.Valid Usage 4246**** 4247 * [[VUID-{refpage}-SubgroupGeMask-04372]] 4248 The variable decorated with code:SubgroupGeMask must: be declared using 4249 the code:Input {StorageClass} 4250 * [[VUID-{refpage}-SubgroupGeMask-04373]] 4251 The variable decorated with code:SubgroupGeMask must: be declared as a 4252 four-component vector of 32-bit integer values 4253**** 4254-- 4255 4256[[interfaces-builtin-variables-sggt]] 4257[open,refpage='SubgroupGtMask',desc='Mask of shader invocations in a subgroup with a higher subgroup local invocation ID',type='builtins'] 4258-- 4259:refpage: SubgroupGtMask 4260 4261code:SubgroupGtMask:: 4262+ 4263Decorating a variable with the code:SubgroupGtMask builtin decoration will 4264make that variable contain the _subgroup mask_ of the current subgroup 4265invocation. 4266The bits corresponding to the invocations greater than 4267code:SubgroupLocalInvocationId through code:SubgroupSize-1 are set in the 4268variable decorated with code:SubgroupGtMask. 4269All other bits are set to zero. 4270+ 4271code:SubgroupGtMaskKHR is an alias of code:SubgroupGtMask. 4272 4273.Valid Usage 4274**** 4275 * [[VUID-{refpage}-SubgroupGtMask-04374]] 4276 The variable decorated with code:SubgroupGtMask must: be declared using 4277 the code:Input {StorageClass} 4278 * [[VUID-{refpage}-SubgroupGtMask-04375]] 4279 The variable decorated with code:SubgroupGtMask must: be declared as a 4280 four-component vector of 32-bit integer values 4281**** 4282-- 4283 4284[[interfaces-builtin-variables-sgle]] 4285[open,refpage='SubgroupLeMask',desc='Mask of shader invocations in a subgroup with the same or lower subgroup local invocation ID',type='builtins'] 4286-- 4287:refpage: SubgroupLeMask 4288 4289code:SubgroupLeMask:: 4290+ 4291Decorating a variable with the code:SubgroupLeMask builtin decoration will 4292make that variable contain the _subgroup mask_ of the current subgroup 4293invocation. 4294The bits corresponding to the invocations less than or equal to 4295code:SubgroupLocalInvocationId are set in the variable decorated with 4296code:SubgroupLeMask. 4297All other bits are set to zero. 4298+ 4299code:SubgroupLeMaskKHR is an alias of code:SubgroupLeMask. 4300 4301.Valid Usage 4302**** 4303 * [[VUID-{refpage}-SubgroupLeMask-04376]] 4304 The variable decorated with code:SubgroupLeMask must: be declared using 4305 the code:Input {StorageClass} 4306 * [[VUID-{refpage}-SubgroupLeMask-04377]] 4307 The variable decorated with code:SubgroupLeMask must: be declared as a 4308 four-component vector of 32-bit integer values 4309**** 4310-- 4311 4312[[interfaces-builtin-variables-sglt]] 4313[open,refpage='SubgroupLtMask',desc='Mask of shader invocations in a subgroup with a lower subgroup local invocation ID',type='builtins'] 4314-- 4315:refpage: SubgroupLtMask 4316 4317code:SubgroupLtMask:: 4318+ 4319Decorating a variable with the code:SubgroupLtMask builtin decoration will 4320make that variable contain the _subgroup mask_ of the current subgroup 4321invocation. 4322The bits corresponding to the invocations less than 4323code:SubgroupLocalInvocationId are set in the variable decorated with 4324code:SubgroupLtMask. 4325All other bits are set to zero. 4326+ 4327code:SubgroupLtMaskKHR is an alias of code:SubgroupLtMask. 4328 4329.Valid Usage 4330**** 4331 * [[VUID-{refpage}-SubgroupLtMask-04378]] 4332 The variable decorated with code:SubgroupLtMask must: be declared using 4333 the code:Input {StorageClass} 4334 * [[VUID-{refpage}-SubgroupLtMask-04379]] 4335 The variable decorated with code:SubgroupLtMask must: be declared as a 4336 four-component vector of 32-bit integer values 4337**** 4338-- 4339 4340[[interfaces-builtin-variables-sgli]] 4341[open,refpage='SubgroupLocalInvocationId',desc='ID of the invocation within a subgroup',type='builtins'] 4342-- 4343:refpage: SubgroupLocalInvocationId 4344 4345code:SubgroupLocalInvocationId:: 4346+ 4347Decorating a variable with the code:SubgroupLocalInvocationId builtin 4348decoration will make that variable contain the index of the invocation 4349within the subgroup. 4350This variable is in range [0,code:SubgroupSize-1]. 4351ifdef::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4352+ 4353If ename:VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT is 4354specified, 4355ifdef::VK_VERSION_1_3[] 4356or if pname:module declares SPIR-V version 1.6 or higher, and the local 4357workgroup size in the X dimension of the pname:stage is a multiple of 4358<<interfaces-builtin-variables-sgs,code:SubgroupSize>>, 4359endif::VK_VERSION_1_3[] 4360full subgroups are enabled for that pipeline stage. 4361When full subgroups are enabled, subgroups must: be launched with all 4362invocations active, i.e., there is an active invocation with 4363code:SubgroupLocalInvocationId for each value in range 4364[0,code:SubgroupSize-1]. 4365endif::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4366 4367[NOTE] 4368.Note 4369==== 4370There is no direct relationship between code:SubgroupLocalInvocationId and 4371code:LocalInvocationId or code:LocalInvocationIndex. 4372ifdef::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4373If the pipeline 4374ifdef::VK_EXT_shader_object[] 4375or shader object 4376endif::VK_EXT_shader_object[] 4377was created with full subgroups applications can compute their own local 4378invocation index to serve the same purpose: 4379 4380[eq]#index = code:SubgroupLocalInvocationId + code:SubgroupId {times} 4381code:SubgroupSize# 4382 4383If full subgroups are not enabled, some subgroups may be dispatched with 4384inactive invocations that do not correspond to a local workgroup invocation, 4385making the value of [eq]#index# unreliable. 4386endif::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4387==== 4388 4389ifdef::VK_VERSION_1_3[] 4390[NOTE] 4391.Note 4392==== 4393ename:VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT 4394ifndef::VK_EXT_shader_object[] 4395is 4396endif::VK_EXT_shader_object[] 4397ifdef::VK_EXT_shader_object[] 4398and ename:VK_SHADER_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT are 4399endif::VK_EXT_shader_object[] 4400effectively deprecated when compiling SPIR-V 1.6 shaders, as this behavior 4401is the default for Vulkan with SPIR-V 1.6. 4402This is more aligned with developer expectations, and avoids applications 4403unexpectedly breaking in the future. 4404==== 4405endif::VK_VERSION_1_3[] 4406 4407.Valid Usage 4408**** 4409 * [[VUID-{refpage}-SubgroupLocalInvocationId-04380]] 4410 The variable decorated with code:SubgroupLocalInvocationId must: be 4411 declared using the code:Input {StorageClass} 4412 * [[VUID-{refpage}-SubgroupLocalInvocationId-04381]] 4413 The variable decorated with code:SubgroupLocalInvocationId must: be 4414 declared as a scalar 32-bit integer value 4415**** 4416-- 4417 4418[[interfaces-builtin-variables-sgs]] 4419[open,refpage='SubgroupSize',desc='Size of a subgroup',type='builtins'] 4420-- 4421:refpage: SubgroupSize 4422 4423code:SubgroupSize:: 4424+ 4425Decorating a variable with the code:SubgroupSize builtin decoration will 4426make that variable contain the implementation-dependent 4427<<limits-subgroup-size, number of invocations in a subgroup>>. 4428This value must: be a power-of-two integer. 4429+ 4430ifdef::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4431If the pipeline was created with the 4432ename:VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT flag 4433set, 4434ifdef::VK_EXT_shader_object[] 4435or the shader object was created with the 4436ename:VK_SHADER_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT flag set, 4437endif::VK_EXT_shader_object[] 4438ifdef::VK_VERSION_1_3[] 4439or the SPIR-V pname:module is at least version 1.6, 4440endif::VK_VERSION_1_3[] 4441the code:SubgroupSize decorated variable will contain the subgroup size for 4442each subgroup that gets dispatched. 4443This value must: be between <<limits-minSubgroupSize, 4444pname:minSubgroupSize>> and <<limits-maxSubgroupSize, 4445pname:maxSubgroupSize>> and must: be uniform with <<shaders-scope-subgroup, 4446subgroup scope>>. 4447The value may: vary across a single draw call, and for fragment shaders may: 4448vary across a single primitive. 4449In compute dispatches, code:SubgroupSize must: be uniform with 4450<<shaders-scope-command, command scope>>. 4451+ 4452If the pipeline was created with a chained 4453slink:VkPipelineShaderStageRequiredSubgroupSizeCreateInfo structure, 4454ifdef::VK_EXT_shader_object[] 4455or the shader object was created with a chained 4456slink:VkShaderRequiredSubgroupSizeCreateInfoEXT structure, 4457endif::VK_EXT_shader_object[] 4458the code:SubgroupSize decorated variable will match 4459<<pipelines-required-subgroup-size, pname:requiredSubgroupSize>>. 4460+ 4461If 4462ifdef::VK_VERSION_1_3[] 4463SPIR-V pname:module is less than version 1.6 and 4464endif::VK_VERSION_1_3[] 4465the pipeline was not created with the 4466ename:VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT flag 4467set and no slink:VkPipelineShaderStageRequiredSubgroupSizeCreateInfo 4468structure was chained, 4469ifdef::VK_EXT_shader_object[] 4470and the shader was not created with the 4471ename:VK_SHADER_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT flag set and no 4472slink:VkShaderRequiredSubgroupSizeCreateInfoEXT structure was chained, 4473endif::VK_EXT_shader_object[] 4474the 4475endif::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4476ifndef::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4477The 4478endif::VK_VERSION_1_3,VK_EXT_subgroup_size_control[] 4479variable decorated with code:SubgroupSize will match <<limits-subgroup-size, 4480pname:subgroupSize>>. 4481+ 4482The maximum number of invocations that an implementation can support per 4483subgroup is 128. 4484 4485ifdef::VK_VERSION_1_3[] 4486[NOTE] 4487.Note 4488==== 4489The old behavior for code:SubgroupSize is considered deprecated as certain 4490compute algorithms cannot be easily implemented without the guarantees of 4491ename:VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT and 4492ename:VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT. 4493==== 4494endif::VK_VERSION_1_3[] 4495 4496.Valid Usage 4497**** 4498 * [[VUID-{refpage}-SubgroupSize-04382]] 4499 The variable decorated with code:SubgroupSize must: be declared using 4500 the code:Input {StorageClass} 4501 * [[VUID-{refpage}-SubgroupSize-04383]] 4502 The variable decorated with code:SubgroupSize must: be declared as a 4503 scalar 32-bit integer value 4504**** 4505-- 4506endif::VK_VERSION_1_1,VK_EXT_shader_subgroup_ballot[] 4507 4508ifdef::VK_NV_mesh_shader[] 4509[[interfaces-builtin-variables-taskcount]] 4510[open,refpage='TaskCountNV',desc='Number of mesh shader workgroups that will be generated',type='builtins'] 4511-- 4512:refpage: TaskCountNV 4513 4514code:TaskCountNV:: 4515+ 4516Decorating a variable with the code:TaskCountNV decoration will make that 4517variable contain the task count. 4518The task count specifies the number of subsequent mesh shader workgroups 4519that get generated upon completion of the task shader. 4520 4521.Valid Usage 4522**** 4523 * [[VUID-{refpage}-TaskCountNV-04384]] 4524 The code:TaskCountNV decoration must: be used only within the 4525 code:TaskNV {ExecutionModel} 4526 * [[VUID-{refpage}-TaskCountNV-04385]] 4527 The variable decorated with code:TaskCountNV must: be declared using the 4528 code:Output {StorageClass} 4529 * [[VUID-{refpage}-TaskCountNV-04386]] 4530 The variable decorated with code:TaskCountNV must: be declared as a 4531 scalar 32-bit integer value 4532**** 4533-- 4534endif::VK_NV_mesh_shader[] 4535 4536[[interfaces-builtin-variables-tesscoord]] 4537[open,refpage='TessCoord',desc='Barycentric coordinate of a tessellated vertex within a patch',type='builtins'] 4538-- 4539:refpage: TessCoord 4540 4541code:TessCoord:: 4542 4543Decorating a variable with the code:TessCoord built-in decoration will make 4544that variable contain the three-dimensional [eq]#(u,v,w)# barycentric 4545coordinate of the tessellated vertex within the patch. 4546[eq]#u#, [eq]#v#, and [eq]#w# are in the range [eq]#[0,1]# and vary linearly 4547across the primitive being subdivided. 4548For the tessellation modes of code:Quads or code:IsoLines, the third 4549component is always zero. 4550 4551.Valid Usage 4552**** 4553 * [[VUID-{refpage}-TessCoord-04387]] 4554 The code:TessCoord decoration must: be used only within the 4555 code:TessellationEvaluation {ExecutionModel} 4556 * [[VUID-{refpage}-TessCoord-04388]] 4557 The variable decorated with code:TessCoord must: be declared using the 4558 code:Input {StorageClass} 4559 * [[VUID-{refpage}-TessCoord-04389]] 4560 The variable decorated with code:TessCoord must: be declared as a 4561 three-component vector of 32-bit floating-point values 4562**** 4563-- 4564 4565[[interfaces-builtin-variables-tesslevelouter]] 4566[open,refpage='TessLevelOuter',desc='Outer tessellation levels',type='builtins'] 4567-- 4568:refpage: TessLevelOuter 4569 4570code:TessLevelOuter:: 4571 4572Decorating a variable with the code:TessLevelOuter built-in decoration will 4573make that variable contain the outer tessellation levels for the current 4574patch. 4575+ 4576In tessellation control shaders, the variable decorated with 4577code:TessLevelOuter can: be written to, controlling the tessellation factors 4578for the resulting patch. 4579These values are used by the tessellator to control primitive tessellation 4580and can: be read by tessellation evaluation shaders. 4581+ 4582In tessellation evaluation shaders, the variable decorated with 4583code:TessLevelOuter can: read the values written by the tessellation control 4584shader. 4585 4586.Valid Usage 4587**** 4588 * [[VUID-{refpage}-TessLevelOuter-04390]] 4589 The code:TessLevelOuter decoration must: be used only within the 4590 code:TessellationControl or code:TessellationEvaluation {ExecutionModel} 4591 * [[VUID-{refpage}-TessLevelOuter-04391]] 4592 The variable decorated with code:TessLevelOuter within the 4593 code:TessellationControl {ExecutionModel} must: be declared using the 4594 code:Output {StorageClass} 4595 * [[VUID-{refpage}-TessLevelOuter-04392]] 4596 The variable decorated with code:TessLevelOuter within the 4597 code:TessellationEvaluation {ExecutionModel} must: be declared using the 4598 code:Input {StorageClass} 4599 * [[VUID-{refpage}-TessLevelOuter-04393]] 4600 The variable decorated with code:TessLevelOuter must: be declared as an 4601 array of size four, containing 32-bit floating-point values 4602**** 4603-- 4604 4605[[interfaces-builtin-variables-tesslevelinner]] 4606[open,refpage='TessLevelInner',desc='Inner tessellation levels',type='builtins'] 4607-- 4608:refpage: TessLevelInner 4609 4610code:TessLevelInner:: 4611 4612Decorating a variable with the code:TessLevelInner built-in decoration will 4613make that variable contain the inner tessellation levels for the current 4614patch. 4615+ 4616In tessellation control shaders, the variable decorated with 4617code:TessLevelInner can: be written to, controlling the tessellation factors 4618for the resulting patch. 4619These values are used by the tessellator to control primitive tessellation 4620and can: be read by tessellation evaluation shaders. 4621+ 4622In tessellation evaluation shaders, the variable decorated with 4623code:TessLevelInner can: read the values written by the tessellation control 4624shader. 4625 4626.Valid Usage 4627**** 4628 * [[VUID-{refpage}-TessLevelInner-04394]] 4629 The code:TessLevelInner decoration must: be used only within the 4630 code:TessellationControl or code:TessellationEvaluation {ExecutionModel} 4631 * [[VUID-{refpage}-TessLevelInner-04395]] 4632 The variable decorated with code:TessLevelInner within the 4633 code:TessellationControl {ExecutionModel} must: be declared using the 4634 code:Output {StorageClass} 4635 * [[VUID-{refpage}-TessLevelInner-04396]] 4636 The variable decorated with code:TessLevelInner within the 4637 code:TessellationEvaluation {ExecutionModel} must: be declared using the 4638 code:Input {StorageClass} 4639 * [[VUID-{refpage}-TessLevelInner-04397]] 4640 The variable decorated with code:TessLevelInner must: be declared as an 4641 array of size two, containing 32-bit floating-point values 4642**** 4643-- 4644 4645ifdef::VK_HUAWEI_cluster_culling_shader[] 4646[[interfaces-builtin-variables-vertexcounthuawei]] 4647[open,refpage='VertexCountHUAWEI',desc='cluster culling shader output variable',type='builtins'] 4648-- 4649:refpage: VertexCountHUAWEI 4650 4651code:VertexCountHUAWEI:: 4652 4653The code:VertexCountHUAWEI decoration can be used to decorate a cluster 4654culling shader output variable,this non-indexed mode specific variable will 4655contain an integer value that specifies the number of vertices in a cluster 4656to draw. 4657 4658.Valid Usage 4659**** 4660 * [[VUID-{refpage}-VertexCountHUAWEI-07809]] 4661 The code:VertexCountHUAWEI decoration must: be used only within the 4662 code:ClusterCullingHUAWEI {ExecutionModel} 4663 * [[VUID-{refpage}-VertexCountHUAWEI-07810]] 4664 The variable decorated with code:VertexCountHUAWEI must: be declared as 4665 a scalar 32-bit integer value 4666**** 4667-- 4668endif::VK_HUAWEI_cluster_culling_shader[] 4669 4670[[interfaces-builtin-variables-vertexindex]] 4671[open,refpage='VertexIndex',desc='Vertex index of a shader invocation',type='builtins'] 4672-- 4673:refpage: VertexIndex 4674 4675code:VertexIndex:: 4676 4677Decorating a variable with the code:VertexIndex built-in decoration will 4678make that variable contain the index of the vertex that is being processed 4679by the current vertex shader invocation. 4680For non-indexed draws, this variable begins at the pname:firstVertex 4681parameter to flink:vkCmdDraw or the pname:firstVertex member of a structure 4682consumed by flink:vkCmdDrawIndirect and increments by one for each vertex in 4683the draw. 4684For indexed draws, its value is the content of the index buffer for the 4685vertex plus the pname:vertexOffset parameter to flink:vkCmdDrawIndexed or 4686the pname:vertexOffset member of the structure consumed by 4687flink:vkCmdDrawIndexedIndirect. 4688 4689[NOTE] 4690.Note 4691==== 4692code:VertexIndex starts at the same starting value for each instance. 4693==== 4694 4695.Valid Usage 4696**** 4697 * [[VUID-{refpage}-VertexIndex-04398]] 4698 The code:VertexIndex decoration must: be used only within the 4699 code:Vertex {ExecutionModel} 4700 * [[VUID-{refpage}-VertexIndex-04399]] 4701 The variable decorated with code:VertexIndex must: be declared using the 4702 code:Input {StorageClass} 4703 * [[VUID-{refpage}-VertexIndex-04400]] 4704 The variable decorated with code:VertexIndex must: be declared as a 4705 scalar 32-bit integer value 4706**** 4707-- 4708 4709ifdef::VK_HUAWEI_cluster_culling_shader[] 4710[[interfaces-builtin-variables-vertexoffsethuawei]] 4711[open,refpage='VertexOffsetHUAWEI',desc='cluster culling shader output variable',type='builtins'] 4712-- 4713:refpage: VertexOffsetHUAWEI 4714 4715code:VertexOffsetHUAWEI:: 4716 4717The code:VertexOffsetHUAWEI decoration can be used to decorate a cluster 4718culling shader output variable,this indexed mode specific variable will 4719contain an integer value that specifies a offset value added to the vertex 4720index of a cluster before indexing into the vertex buffer. 4721 4722.Valid Usage 4723**** 4724 * [[VUID-{refpage}-VertexOffsetHUAWEI-07811]] 4725 The code:VertexOffsetHUAWEI decoration must: be used only within the 4726 code:ClusterCullingHUAWEI {ExecutionModel} 4727 * [[VUID-{refpage}-VertexOffsetHUAWEI-07812]] 4728 The variable decorated with code:VertexOffsetHUAWEI must: be declared as 4729 a scalar 32-bit integer value 4730**** 4731-- 4732endif::VK_HUAWEI_cluster_culling_shader[] 4733 4734ifdef::VK_VERSION_1_1,VK_KHR_multiview[] 4735[[interfaces-builtin-variables-viewindex]] 4736[open,refpage='ViewIndex',desc='View index of a shader invocation',type='builtins'] 4737-- 4738:refpage: ViewIndex 4739 4740code:ViewIndex:: 4741 4742The code:ViewIndex decoration can: be applied to a shader input which will 4743be filled with the index of the view that is being processed by the current 4744shader invocation. 4745+ 4746If multiview is enabled in the render pass, this value will be one of the 4747bits set in the view mask of the subpass the pipeline is compiled against. 4748If multiview is not enabled in the render pass, this value will be zero. 4749 4750.Valid Usage 4751**** 4752 * [[VUID-{refpage}-ViewIndex-04401]] 4753 The code:ViewIndex decoration must: be used only within the 4754 code:MeshEXT, code:Vertex, code:Geometry, code:TessellationControl, 4755 code:TessellationEvaluation or code:Fragment {ExecutionModel} 4756 * [[VUID-{refpage}-ViewIndex-04402]] 4757 The variable decorated with code:ViewIndex must: be declared using the 4758 code:Input {StorageClass} 4759 * [[VUID-{refpage}-ViewIndex-04403]] 4760 The variable decorated with code:ViewIndex must: be declared as a scalar 4761 32-bit integer value 4762**** 4763-- 4764endif::VK_VERSION_1_1,VK_KHR_multiview[] 4765 4766[[interfaces-builtin-variables-viewportindex]] 4767[open,refpage='ViewportIndex',desc='Viewport index used',type='builtins'] 4768-- 4769:refpage: ViewportIndex 4770 4771code:ViewportIndex:: 4772 4773Decorating a variable with the code:ViewportIndex built-in decoration will 4774make that variable contain the index of the viewport. 4775+ 4776In a 4777ifdef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 4778ifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[mesh,] 4779vertex, tessellation evaluation, or 4780endif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 4781geometry shader, the variable decorated with code:ViewportIndex can be 4782written to with the viewport index to which the primitive produced by that 4783shader will be directed. 4784+ 4785The selected viewport index is used to select the 4786ifndef::VK_NV_scissor_exclusive[] 4787viewport transform and 4788endif::VK_NV_scissor_exclusive[] 4789ifdef::VK_NV_scissor_exclusive[] 4790viewport transform, scissor rectangle, and exclusive 4791endif::VK_NV_scissor_exclusive[] 4792scissor rectangle. 4793ifdef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 4794+ 4795The last active 4796_<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4797stage>>_ (in pipeline order) controls the code:ViewportIndex that is used. 4798Outputs in previous shader stages are not used, even if the last stage fails 4799to write the code:ViewportIndex. 4800endif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[] 4801+ 4802If the last active 4803<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4804stage>> shader entry point's interface does not include a variable decorated 4805with code:ViewportIndex 4806ifdef::VK_QCOM_multiview_per_view_viewports[] 4807, and if <<features-multiview-per-view-viewports, 4808multiviewPerViewViewports>> is not enabled, 4809endif::VK_QCOM_multiview_per_view_viewports[] 4810then the first viewport is used. 4811If a <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4812stage>> shader entry point's interface includes a variable decorated with 4813code:ViewportIndex, it must: write the same value to code:ViewportIndex for 4814all output vertices of a given primitive. 4815+ 4816In a fragment shader, the variable decorated with code:ViewportIndex 4817contains the viewport index of the primitive that the fragment invocation 4818belongs to. 4819ifdef::VK_QCOM_multiview_per_view_viewports[] 4820+ 4821If <<features-multiview-per-view-viewports, 4822pname:multiviewPerViewViewports>> is enabled, and if the last active 4823<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4824stage>> shader entry point's interface does not include a variable decorated 4825with code:ViewportIndex, then the value of code:ViewIndex is used as an 4826index to select the viewport transform and scissor rectangle, and the value 4827of code:ViewportIndex in the fragment shader is undefined::. 4828endif::VK_QCOM_multiview_per_view_viewports[] 4829 4830.Valid Usage 4831**** 4832 * [[VUID-{refpage}-ViewportIndex-04404]] 4833 The code:ViewportIndex decoration must: be used only within the 4834 code:MeshEXT, code:MeshNV, code:Vertex, code:TessellationEvaluation, 4835 code:Geometry, or code:Fragment {ExecutionModel} 4836ifdef::VK_VERSION_1_2[] 4837 * [[VUID-{refpage}-ViewportIndex-04405]] 4838 If the <<features-shaderOutputViewportIndex, 4839 pname:shaderOutputViewportIndex>> feature is not enabled then the 4840 code:ViewportIndex decoration must: be used only within the 4841 code:Geometry or code:Fragment {ExecutionModel} 4842endif::VK_VERSION_1_2[] 4843 * [[VUID-{refpage}-ViewportIndex-04406]] 4844 The variable decorated with code:ViewportIndex within the code:MeshEXT, 4845 code:MeshNV, code:Vertex, code:TessellationEvaluation, or code:Geometry 4846 {ExecutionModel} must: be declared using the code:Output {StorageClass} 4847 * [[VUID-{refpage}-ViewportIndex-04407]] 4848 The variable decorated with code:ViewportIndex within the code:Fragment 4849 {ExecutionModel} must: be declared using the code:Input {StorageClass} 4850 * [[VUID-{refpage}-ViewportIndex-04408]] 4851 The variable decorated with code:ViewportIndex must: be declared as a 4852 scalar 32-bit integer value 4853 * [[VUID-{refpage}-ViewportIndex-07060]] 4854 The variable decorated with code:ViewportIndex within the code:MeshEXT 4855 {ExecutionModel} must: also be decorated with the code:PerPrimitiveEXT 4856 decoration 4857**** 4858-- 4859 4860ifdef::VK_NV_viewport_array2[] 4861[[interfaces-builtin-variables-viewportmask]] 4862[open,refpage='ViewportMaskNV',desc='Mask of the viewports used',type='builtins'] 4863-- 4864:refpage: ViewportMaskNV 4865 4866code:ViewportMaskNV:: 4867 4868Decorating a variable with the code:ViewportMaskNV built-in decoration will 4869make that variable contain the viewport mask. 4870+ 4871In a 4872ifdef::VK_NV_mesh_shader[] 4873mesh, 4874endif::VK_NV_mesh_shader[] 4875vertex, tessellation evaluation, or geometry shader, the variable decorated 4876with code:ViewportMaskNV can be written to with the mask of which viewports 4877the primitive produced by that shader will directed. 4878+ 4879The code:ViewportMaskNV variable must: be an array that has 4880[eq]#{lceil}(sname:VkPhysicalDeviceLimits::pname:maxViewports / 32){rceil}# 4881elements. 4882When a shader writes to this variable, bit B of element M controls whether a 4883primitive is emitted to viewport [eq]#32 {times} M {plus} B#. 4884The viewports indicated by the mask are used to select the 4885ifndef::VK_NV_scissor_exclusive[] 4886viewport transform and 4887endif::VK_NV_scissor_exclusive[] 4888ifdef::VK_NV_scissor_exclusive[] 4889viewport transform, scissor rectangle, and exclusive 4890endif::VK_NV_scissor_exclusive[] 4891scissor rectangle that a primitive will be transformed by. 4892+ 4893The last active 4894_<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4895stage>>_ (in pipeline order) controls the code:ViewportMaskNV that is used. 4896Outputs in previous shader stages are not used, even if the last stage fails 4897to write the code:ViewportMaskNV. 4898When code:ViewportMaskNV is written by the final 4899<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4900stage>>, any variable decorated with code:ViewportIndex in the fragment 4901shader will have the index of the viewport that was used in generating that 4902fragment. 4903+ 4904If a <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4905stage>> shader entry point's interface includes a variable decorated with 4906code:ViewportMaskNV, it must: write the same value to code:ViewportMaskNV 4907for all output vertices of a given primitive. 4908 4909.Valid Usage 4910**** 4911 * [[VUID-{refpage}-ViewportMaskNV-04409]] 4912 The code:ViewportMaskNV decoration must: be used only within the 4913 code:Vertex, code:MeshNV, code:TessellationEvaluation, or code:Geometry 4914 {ExecutionModel} 4915 * [[VUID-{refpage}-ViewportMaskNV-04410]] 4916 The variable decorated with code:ViewportMaskNV must: be declared using 4917 the code:Output {StorageClass} 4918 * [[VUID-{refpage}-ViewportMaskNV-04411]] 4919 The variable decorated with code:ViewportMaskNV must: be declared as an 4920 array of 32-bit integer values 4921**** 4922-- 4923endif::VK_NV_viewport_array2[] 4924 4925ifdef::VK_NVX_multiview_per_view_attributes+VK_NV_viewport_array2[] 4926[[interfaces-builtin-variables-viewportmaskperview]] 4927[open,refpage='ViewportMaskPerViewNV',desc='Mask of viewports broadcast to per view',type='builtins'] 4928-- 4929:refpage: ViewportMaskPerViewNV 4930 4931code:ViewportMaskPerViewNV:: 4932 4933Decorating a variable with the code:ViewportMaskPerViewNV built-in 4934decoration will make that variable contain the mask of viewports primitives 4935are broadcast to, for each view. 4936+ 4937The value written to an element of code:ViewportMaskPerViewNV in the last 4938<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4939stage>> is a bitmask indicating which viewports the primitive will be 4940directed to. 4941The primitive will be broadcast to the viewport corresponding to each 4942non-zero bit of the bitmask, and that viewport index is used to select the 4943ifndef::VK_NV_scissor_exclusive[] 4944viewport transform and 4945endif::VK_NV_scissor_exclusive[] 4946ifdef::VK_NV_scissor_exclusive[] 4947viewport transform, scissor rectangle, and exclusive 4948endif::VK_NV_scissor_exclusive[] 4949scissor rectangle, for each view. 4950The same values must: be written to all vertices in a given primitive, or 4951else the set of viewports used for that primitive is undefined:. 4952+ 4953Elements of the array correspond to views in a multiview subpass, and those 4954elements corresponding to views in the view mask of the subpass the shader 4955is compiled against will be used as the viewport mask value for those views. 4956code:ViewportMaskPerViewNV output in an earlier 4957<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4958stage>> is not available as an input in the subsequent 4959<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 4960stage>>. 4961+ 4962Although code:ViewportMaskNV is an array, code:ViewportMaskPerViewNV is not 4963a two-dimensional array. 4964Instead, code:ViewportMaskPerViewNV is limited to 32 viewports. 4965 4966.Valid Usage 4967**** 4968 * [[VUID-{refpage}-ViewportMaskPerViewNV-04412]] 4969 The code:ViewportMaskPerViewNV decoration must: be used only within the 4970 code:Vertex, code:MeshNV, code:TessellationControl, 4971 code:TessellationEvaluation, or code:Geometry {ExecutionModel} 4972 * [[VUID-{refpage}-ViewportMaskPerViewNV-04413]] 4973 The variable decorated with code:ViewportMaskPerViewNV must: be declared 4974 using the code:Output {StorageClass} 4975 * [[VUID-{refpage}-ViewportMaskPerViewNV-04414]] 4976 The variable decorated with code:ViewportMaskPerViewNV must: be declared 4977 as an array of 32-bit integer values 4978 * [[VUID-{refpage}-ViewportMaskPerViewNV-04415]] 4979 The array decorated with code:ViewportMaskPerViewNV must: be a size less 4980 than or equal to 32 4981 * [[VUID-{refpage}-ViewportMaskPerViewNV-04416]] 4982 The array decorated with code:ViewportMaskPerViewNV must: be a size 4983 greater than the maximum view in the subpass's view mask 4984 * [[VUID-{refpage}-ViewportMaskPerViewNV-04417]] 4985 The array variable decorated with code:ViewportMaskPerViewNV must: only 4986 be indexed by a constant or specialization constant 4987**** 4988-- 4989endif::VK_NVX_multiview_per_view_attributes+VK_NV_viewport_array2[] 4990 4991ifdef::VK_NV_shader_sm_builtins[] 4992[[interfaces-builtin-variables-warpspersmnv]] 4993[open,refpage='WarpsPerSMNV',desc='Number of warps per SM',type='builtins'] 4994-- 4995:refpage: WarpsPerSMNV 4996 4997code:WarpsPerSMNV:: 4998 4999Decorating a variable with the code:WarpsPerSMNV built-in decoration will 5000make that variable contain the maximum number of warps executing on a SM. 5001 5002.Valid Usage 5003**** 5004 * [[VUID-{refpage}-WarpsPerSMNV-04418]] 5005 The variable decorated with code:WarpsPerSMNV must: be declared using 5006 the code:Input {StorageClass} 5007 * [[VUID-{refpage}-WarpsPerSMNV-04419]] 5008 The variable decorated with code:WarpsPerSMNV must: be declared as a 5009 scalar 32-bit integer value 5010**** 5011-- 5012 5013[[interfaces-builtin-variables-warpidnv]] 5014[open,refpage='WarpIDNV',desc='Warp ID within an SM of a shader invocation',type='builtins'] 5015-- 5016:refpage: WarpIDNV 5017 5018code:WarpIDNV:: 5019 5020Decorating a variable with the code:WarpIDNV built-in decoration will make 5021that variable contain the ID of the warp on a SM on which the current shader 5022invocation is running. 5023This variable is in the range [eq]#[0, code:WarpsPerSMNV-1]#. 5024 5025.Valid Usage 5026**** 5027 * [[VUID-{refpage}-WarpIDNV-04420]] 5028 The variable decorated with code:WarpIDNV must: be declared using the 5029 code:Input {StorageClass} 5030 * [[VUID-{refpage}-WarpIDNV-04421]] 5031 The variable decorated with code:WarpIDNV must: be declared as a scalar 5032 32-bit integer value 5033**** 5034-- 5035endif::VK_NV_shader_sm_builtins[] 5036 5037[[interfaces-builtin-variables-workgroupid]] 5038[open,refpage='WorkgroupId',desc='Workgroup ID of a shader',type='builtins'] 5039-- 5040:refpage: WorkgroupId 5041 5042code:WorkgroupId:: 5043 5044Decorating a variable with the code:WorkgroupId built-in decoration will 5045make that variable contain the global workgroup that the current invocation 5046is a member of. 5047Each component ranges from a base value to a [eq]#base {plus} count# value, 5048based on the parameters passed into the dispatching commands. 5049 5050.Valid Usage 5051**** 5052 * [[VUID-{refpage}-WorkgroupId-04422]] 5053 The code:WorkgroupId decoration must: be used only within the 5054 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 5055 {ExecutionModel} 5056 * [[VUID-{refpage}-WorkgroupId-04423]] 5057 The variable decorated with code:WorkgroupId must: be declared using the 5058 code:Input {StorageClass} 5059 * [[VUID-{refpage}-WorkgroupId-04424]] 5060 The variable decorated with code:WorkgroupId must: be declared as a 5061 three-component vector of 32-bit integer values 5062**** 5063-- 5064 5065[[interfaces-builtin-variables-workgroupsize]] 5066[open,refpage='WorkgroupSize',desc='Size of a workgroup',type='builtins'] 5067-- 5068:refpage: WorkgroupSize 5069 5070code:WorkgroupSize:: 5071 5072ifdef::VK_VERSION_1_3[] 5073[NOTE] 5074.Note 5075==== 5076SPIR-V 1.6 deprecated code:WorkgroupSize in favor of using the 5077code:LocalSizeId Execution Mode instead. 5078Support for code:LocalSizeId was added with `apiext:VK_KHR_maintenance4` and 5079promoted to core in Version 1.3. 5080==== 5081endif::VK_VERSION_1_3[] 5082 5083Decorating an object with the code:WorkgroupSize built-in decoration will 5084make that object contain the dimensions of a local workgroup. 5085If an object is decorated with the code:WorkgroupSize decoration, this takes 5086precedence over any code:LocalSize 5087ifdef::VK_VERSION_1_3,VK_KHR_maintenance4[or code:LocalSizeId] 5088execution mode. 5089 5090.Valid Usage 5091**** 5092 * [[VUID-{refpage}-WorkgroupSize-04425]] 5093 The code:WorkgroupSize decoration must: be used only within the 5094 code:GLCompute, code:MeshEXT, code:TaskEXT, code:MeshNV, or code:TaskNV 5095 {ExecutionModel} 5096 * [[VUID-{refpage}-WorkgroupSize-04426]] 5097 The variable decorated with code:WorkgroupSize must: be a specialization 5098 constant or a constant 5099 * [[VUID-{refpage}-WorkgroupSize-04427]] 5100 The variable decorated with code:WorkgroupSize must: be declared as a 5101 three-component vector of 32-bit integer values 5102**** 5103-- 5104 5105ifdef::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 5106[[interfaces-builtin-variables-worldraydirection]] 5107[open,refpage='WorldRayDirectionKHR',desc='Ray direction in world space',type='builtins'] 5108-- 5109:refpage: WorldRayDirectionKHR 5110 5111code:WorldRayDirectionKHR:: 5112 5113A variable decorated with the code:WorldRayDirectionKHR decoration will 5114specify the direction of the ray being processed, in world space. 5115The value is the parameter passed into the <<glossary-pipeline-trace-ray, 5116pipeline trace ray>> instruction. 5117 5118.Valid Usage 5119**** 5120 * [[VUID-{refpage}-WorldRayDirectionKHR-04428]] 5121 The code:WorldRayDirectionKHR decoration must: be used only within the 5122 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 5123 code:MissKHR {ExecutionModel} 5124 * [[VUID-{refpage}-WorldRayDirectionKHR-04429]] 5125 The variable decorated with code:WorldRayDirectionKHR must: be declared 5126 using the code:Input {StorageClass} 5127 * [[VUID-{refpage}-WorldRayDirectionKHR-04430]] 5128 The variable decorated with code:WorldRayDirectionKHR must: be declared 5129 as a three-component vector of 32-bit floating-point values 5130**** 5131-- 5132 5133[[interfaces-builtin-variables-worldrayorigin]] 5134[open,refpage='WorldRayOriginKHR',desc='Ray origin in world space',type='builtins'] 5135-- 5136:refpage: WorldRayOriginKHR 5137 5138code:WorldRayOriginKHR:: 5139 5140A variable decorated with the code:WorldRayOriginKHR decoration will specify 5141the origin of the ray being processed, in world space. 5142The value is the parameter passed into the <<glossary-pipeline-trace-ray, 5143pipeline trace ray>> instruction. 5144 5145.Valid Usage 5146**** 5147 * [[VUID-{refpage}-WorldRayOriginKHR-04431]] 5148 The code:WorldRayOriginKHR decoration must: be used only within the 5149 code:IntersectionKHR, code:AnyHitKHR, code:ClosestHitKHR, or 5150 code:MissKHR {ExecutionModel} 5151 * [[VUID-{refpage}-WorldRayOriginKHR-04432]] 5152 The variable decorated with code:WorldRayOriginKHR must: be declared 5153 using the code:Input {StorageClass} 5154 * [[VUID-{refpage}-WorldRayOriginKHR-04433]] 5155 The variable decorated with code:WorldRayOriginKHR must: be declared as 5156 a three-component vector of 32-bit floating-point values 5157**** 5158-- 5159 5160[[interfaces-builtin-variables-worldtoobject]] 5161[open,refpage='WorldToObjectKHR',desc='Transformation matrix from world to object space',type='builtins'] 5162-- 5163:refpage: WorldToObjectKHR 5164 5165code:WorldToObjectKHR:: 5166 5167A variable decorated with the code:WorldToObjectKHR decoration will contain 5168the current world-to-object transformation matrix, which is determined by 5169the instance of the current intersection. 5170 5171.Valid Usage 5172**** 5173 * [[VUID-{refpage}-WorldToObjectKHR-04434]] 5174 The code:WorldToObjectKHR decoration must: be used only within the 5175 code:IntersectionKHR, code:AnyHitKHR, or code:ClosestHitKHR 5176 {ExecutionModel} 5177 * [[VUID-{refpage}-WorldToObjectKHR-04435]] 5178 The variable decorated with code:WorldToObjectKHR must: be declared 5179 using the code:Input {StorageClass} 5180 * [[VUID-{refpage}-WorldToObjectKHR-04436]] 5181 The variable decorated with code:WorldToObjectKHR must: be declared as a 5182 matrix with four columns of three-component vectors of 32-bit 5183 floating-point values 5184**** 5185-- 5186endif::VK_NV_ray_tracing,VK_KHR_ray_tracing_pipeline[] 5187 5188ifdef::VK_ARM_shader_core_builtins[] 5189[[interfaces-builtin-variables-corecountarm]] 5190[open,refpage='CoreCountARM',desc='Number of cores on the device',type='builtins'] 5191-- 5192:refpage: CoreCountARM 5193 5194code:CoreCountARM:: 5195 5196Decorating a variable with the code:CoreCountARM built-in decoration will 5197make that variable contain the number of cores on the device. 5198 5199.Valid Usage 5200**** 5201 * [[VUID-{refpage}-CoreCountARM-07595]] 5202 The variable decorated with code:CoreCountARM must: be declared using 5203 the code:Input {StorageClass} 5204 * [[VUID-{refpage}-CoreCountARM-07596]] 5205 The variable decorated with code:CoreCountARM must: be declared as a 5206 scalar 32-bit integer value 5207**** 5208-- 5209 5210[[interfaces-builtin-variables-coremaxidarm]] 5211[open,refpage='CoreMaxIDARM',desc='Max core ID that can be observed on the device running the invovation reading CoreMaxIDARM',type='builtins'] 5212-- 5213:refpage: CoreMaxIDARM 5214 5215code:CoreMaxIDARM:: 5216 5217Decorating a variable with the code:CoreMaxIDARM built-in decoration will 5218make that variable contain the max ID of any shader core on the device on 5219which the current shader invocation is running. 5220 5221.Valid Usage 5222**** 5223 * [[VUID-{refpage}-CoreMaxIDARM-07597]] 5224 The variable decorated with code:CoreMaxIDARM must: be declared using 5225 the code:Input {StorageClass} 5226 * [[VUID-{refpage}-CoreMaxIDARM-07598]] 5227 The variable decorated with code:CoreMaxIDARM must: be declared as a 5228 scalar 32-bit integer value 5229**** 5230-- 5231 5232[[interfaces-builtin-variables-coreidarm]] 5233[open,refpage='CoreIDARM',desc='Core ID on which a shader invocation is running',type='builtins'] 5234-- 5235:refpage: CoreIDARM 5236 5237code:CoreIDARM:: 5238 5239Decorating a variable with the code:CoreIDARM built-in decoration will make 5240that variable contain the ID of the core on which the current shader 5241invocation is running. 5242This variable is in the range [eq]#[0, code:CoreMaxIDARM]#. 5243 5244.Valid Usage 5245**** 5246 * [[VUID-{refpage}-CoreIDARM-07599]] 5247 The variable decorated with code:CoreIDARM must: be declared using the 5248 code:Input {StorageClass} 5249 * [[VUID-{refpage}-CoreIDARM-07600]] 5250 The variable decorated with code:CoreIDARM must: be declared as a scalar 5251 32-bit integer value 5252**** 5253-- 5254 5255[[interfaces-builtin-variables-warpmaxidarm]] 5256[open,refpage='WarpMaxIDARM',desc='Max ID for a warp on the core running a shader invovation',type='builtins'] 5257-- 5258:refpage: WarpMaxIDARM 5259 5260code:WarpMaxIDARM:: 5261 5262Decorating a variable with the code:WarpMaxIDARM built-in decoration will 5263make that variable contain the maximum warp ID for the core on which the 5264current invocation is running. 5265 5266.Valid Usage 5267**** 5268 * [[VUID-{refpage}-WarpMaxIDARM-07601]] 5269 The variable decorated with code:WarpMaxIDARM must: be declared using 5270 the code:Input {StorageClass} 5271 * [[VUID-{refpage}-WarpMaxIDARM-07602]] 5272 The variable decorated with code:WarpMaxIDARM must: be declared as a 5273 scalar 32-bit integer value 5274**** 5275-- 5276 5277[[interfaces-builtin-variables-warpidarm]] 5278[open,refpage='WarpIDARM',desc='Warp ID within a core of a shader invocation',type='builtins'] 5279-- 5280:refpage: WarpIDARM 5281 5282code:WarpIDARM:: 5283 5284Decorating a variable with the code:WarpIDARM built-in decoration will make 5285that variable contain the ID of the warp on a core on which the current 5286shader invocation is running. 5287This variable is in the range [eq]#[0, code:WarpMaxIDARM]#. 5288 5289.Valid Usage 5290**** 5291 * [[VUID-{refpage}-WarpIDARM-07603]] 5292 The variable decorated with code:WarpIDARM must: be declared using the 5293 code:Input {StorageClass} 5294 * [[VUID-{refpage}-WarpIDARM-07604]] 5295 The variable decorated with code:WarpIDARM must: be declared as a scalar 5296 32-bit integer value 5297**** 5298-- 5299endif::VK_ARM_shader_core_builtins[] 5300 5301ifdef::VK_AMDX_shader_enqueue[] 5302[[interfaces-builtin-variables-coalescedinputcountamd]] 5303[open,refpage='CoalescedInputCountAMDX',desc='Number of inputs coalesced for a coalescing node in a work graph',type='builtins'] 5304-- 5305:refpage: CoalescedInputCountAMDX 5306 5307code:CoalescedInputCountAMDX:: 5308 5309Decorating a variable with the code:CoalescedInputCountAMDX built-in 5310decoration will make that variable contain the number of node dispatches 5311that the implementation coalesced into the input for the current shader. 5312This variable will take a value in the range [eq]#[1, arraySize)#, where 5313[eq]#arraySize# is the maximum size of the input payload array for the 5314shader. 5315 5316.Valid Usage 5317**** 5318 * [[VUID-{refpage}-CoalescedInputCountAMDX-09172]] 5319 The variable decorated with code:CoalescedInputCountAMDX must: be 5320 declared using the code:Input {StorageClass} 5321 * [[VUID-{refpage}-CoalescedInputCountAMDX-09173]] 5322 If a variable is decorated with code:CoalescedInputCountAMDX, the 5323 code:CoalescingAMDX execution mode must: be declared 5324 * [[VUID-{refpage}-CoalescedInputCountAMDX-09174]] 5325 The variable decorated with code:CoalescedInputCountAMDX must: be 5326 declared as a scalar 32-bit integer value 5327**** 5328-- 5329 5330[open,refpage='ShaderIndexAMDX',desc='Index assigned to the shader within the workgraph',type='builtins'] 5331-- 5332:refpage: ShaderIndexAMDX 5333 5334code:ShaderIndexAMDX:: 5335 5336Decorating a variable with the code:ShaderIndexAMDX built-in decoration will 5337make that variable contain the index of the shader specified when it was 5338compiled, either via 5339slink:VkPipelineShaderStageNodeCreateInfoAMDX::pname:index or by the 5340code:ShaderIndexAMDX execution mode. 5341 5342.Valid Usage 5343**** 5344 * [[VUID-{refpage}-ShaderIndexAMDX-09175]] 5345 The variable decorated with code:ShaderIndexAMDX must: be declared using 5346 the code:Input {StorageClass} 5347 * [[VUID-{refpage}-ShaderIndexAMDX-09176]] 5348 The variable decorated with code:ShaderIndexAMDX must: be declared as a 5349 scalar 32-bit integer value 5350**** 5351-- 5352endif::VK_AMDX_shader_enqueue[] 5353