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