/ chapters / interfaces.txt
interfaces.txt
   1  // Copyright (c) 2015-2019 Khronos Group. This work is licensed under a
   2  // Creative Commons Attribution 4.0 International License; see
   3  // http://creativecommons.org/licenses/by/4.0/
   4  
   5  [[interfaces]]
   6  = Shader Interfaces
   7  
   8  When a pipeline is created, the set of shaders specified in the
   9  corresponding stext:Vk*PipelineCreateInfo structure are implicitly linked at
  10  a 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>>
  16    * <<interfaces-resources,Shader Resource Interface>>
  17  
  18  Interface definitions make use of the following SPIR-V decorations:
  19  
  20    * code:DescriptorSet and code:Binding
  21    * code:Location, code:Component, and code:Index
  22    * code:Flat, code:NoPerspective, code:Centroid, and code:Sample
  23    * code:Block and code:BufferBlock
  24    * code:InputAttachmentIndex
  25    * code:Offset, code:ArrayStride, and code:MatrixStride
  26    * code:BuiltIn
  27  ifdef::VK_NV_geometry_shader_passthrough[]
  28    * <<geometry-passthrough-passthrough,code:PassthroughNV>>
  29  endif::VK_NV_geometry_shader_passthrough[]
  30  
  31  
  32  This specification describes valid uses for Vulkan of these decorations.
  33  Any other use of one of these decorations is invalid.
  34  
  35  [[interfaces-iointerfaces]]
  36  == Shader Input and Output Interfaces
  37  
  38  When multiple stages are present in a pipeline, the outputs of one stage
  39  form an interface with the inputs of the next stage.
  40  When such an interface involves a shader, shader outputs are matched against
  41  the inputs of the next stage, and shader inputs are matched against the
  42  outputs of the previous stage.
  43  
  44  There are two classes of variables that can: be matched between shader
  45  stages, built-in variables and user-defined variables.
  46  Each class has a different set of matching criteria.
  47  Generally, when non-shader stages are between shader stages, the
  48  user-defined variables, and most built-in variables, form an interface
  49  between the shader stages.
  50  
  51  The variables forming the input or output _interfaces_ are listed as
  52  operands to the code:OpEntryPoint instruction and are declared with the
  53  code:Input or code:Output storage classes, respectively, in the SPIR-V
  54  module.
  55  
  56  code:Output variables of a shader stage have undefined: values until the
  57  shader writes to them or uses the code:Initializer operand when declaring
  58  the variable.
  59  
  60  
  61  [[interfaces-iointerfaces-builtin]]
  62  === Built-in Interface Block
  63  
  64  Shader <<interfaces-builtin-variables,built-in>> variables meeting the
  65  following requirements define the _built-in interface block_.
  66  They must:
  67  
  68    * be explicitly declared (there are no implicit built-ins),
  69    * be identified with a code:BuiltIn decoration,
  70    * form object types as described in the
  71      <<interfaces-builtin-variables,Built-in Variables>> section, and
  72    * be declared in a block whose top-level members are the built-ins.
  73  
  74  Built-ins only participate in interface matching if they are declared in
  75  such a block.
  76  They must: not have any code:Location or code:Component decorations.
  77  
  78  There must: be no more than one built-in interface block per shader per
  79  interface.
  80  
  81  
  82  [[interfaces-iointerfaces-user]]
  83  === User-defined Variable Interface
  84  
  85  The remaining variables listed by code:OpEntryPoint with the code:Input or
  86  code:Output storage class form the _user-defined variable interface_.
  87  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
  88  By default such variables have a type with a width of 32 or 64.
  89  If an implementation supports
  90  <<features-storageInputOutput16,storageInputOutput16>>, user-defined
  91  variables in the code:Input and code:Output storage classes can: also have
  92  types with a width of 16.
  93  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
  94  These variables must: be identified with a code:Location decoration and can:
  95  also be identified with a code:Component decoration.
  96  
  97  
  98  [[interfaces-iointerfaces-matching]]
  99  === Interface Matching
 100  
 101  A user-defined output variable is considered to match an input variable in
 102  the subsequent stage if the two variables are declared with the same
 103  code:Location and code:Component decoration and match in type and
 104  decoration, except that <<shaders-interpolation-decorations,interpolation
 105  decorations>> are not required: to match.
 106  ifdef::VK_EXT_transform_feedback[]
 107  code:XfbBuffer, code:XfbStride, code:Offset, and code:Stream are also not
 108  required to match for the purposes of interface matching.
 109  endif::VK_EXT_transform_feedback[]
 110  For the purposes of interface matching, variables declared without a
 111  code:Component decoration are considered to have a code:Component decoration
 112  of zero.
 113  
 114  ifdef::VK_NV_geometry_shader_passthrough[]
 115  [NOTE]
 116  .Note
 117  ====
 118  Matching rules for _passthrough geometry shaders_ are slightly different and
 119  are described in the <<geometry-passthrough-interface,Passthrough Interface
 120  Matching>> section.
 121  ====
 122  
 123  endif::VK_NV_geometry_shader_passthrough[]
 124  Variables or block members declared as structures are considered to match in
 125  type if and only if the structure members match in type, decoration, number,
 126  and declaration order.
 127  Variables or block members declared as arrays are considered to match in
 128  type only if both declarations specify the same element type and size.
 129  
 130  
 131  Tessellation control
 132  ifdef::VK_NV_mesh_shader[]
 133  and mesh
 134  endif::VK_NV_mesh_shader[]
 135  shader per-vertex output variables and blocks, and tessellation control,
 136  tessellation evaluation, and geometry shader per-vertex input variables and
 137  blocks are required to be declared as arrays, with each element representing
 138  input or output values for a single vertex of a multi-vertex primitive.
 139  For the purposes of interface matching, the outermost array dimension of
 140  such variables and blocks is ignored.
 141  
 142  At an interface between two non-fragment shader stages, the built-in
 143  interface block must: match exactly, as described
 144  ifdef::VK_NV_mesh_shader[]
 145  above, except for per-view outputs as described in
 146  <<mesh-output-perview,Mesh Shader Per-View Outputs>>.
 147  endif::VK_NV_mesh_shader[]
 148  ifndef::VK_NV_mesh_shader[]
 149  above.
 150  endif::VK_NV_mesh_shader[]
 151  At an interface involving the fragment shader inputs, the presence or
 152  absence of any built-in output does not affect the interface matching.
 153  
 154  At an interface between two shader stages, the user-defined variable
 155  interface must: match exactly, as described above.
 156  
 157  Any input value to a shader stage is well-defined as long as the preceding
 158  stages writes to a matching output, as described above.
 159  
 160  Additionally, scalar and vector inputs are well-defined if there is a
 161  corresponding output satisfying all of the following conditions:
 162  
 163    * the input and output match exactly in decoration,
 164    * the output is a vector with the same basic type and has at least as many
 165      components as the input, and
 166    * the common component type of the input and output is
 167  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 168      16-bit integer or floating-point, or
 169  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 170      32-bit integer or floating-point (64-bit component types are excluded).
 171  
 172  In this case, the components of the input will be taken from the first
 173  components of the output, and any extra components of the output will be
 174  ignored.
 175  
 176  
 177  [[interfaces-iointerfaces-locations]]
 178  === Location Assignment
 179  
 180  This section describes how many locations are consumed by a given type.
 181  As mentioned above, geometry shader inputs, tessellation control shader
 182  inputs and outputs, and tessellation evaluation inputs all have an
 183  additional level of arrayness relative to other shader inputs and outputs.
 184  This outer array level is removed from the type before considering how many
 185  locations the type consumes.
 186  
 187  The code:Location value specifies an interface slot comprised of a 32-bit
 188  four-component vector conveyed between stages.
 189  The code:Component specifies
 190  <<interfaces-iointerfaces-components,components>> within these vector
 191  locations.
 192  Only types with widths of
 193  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 194  16,
 195  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 196  32 or 64 are supported in shader interfaces.
 197  
 198  Inputs and outputs of the following types consume a single interface
 199  location:
 200  
 201  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 202    * 16-bit scalar and vector types, and
 203  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 204    * 32-bit scalar and vector types, and
 205    * 64-bit scalar and 2-component vector types.
 206  
 207  64-bit three- and four-component vectors consume two consecutive locations.
 208  
 209  If a declared input or output is an array of size _n_ and each element takes
 210  _m_ locations, it will be assigned _m_ {times} _n_ consecutive locations
 211  starting with the location specified.
 212  
 213  If the declared input or output is an _n_ {times} _m_
 214  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 215  16-,
 216  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 217  32- or 64-bit matrix, it will be assigned multiple locations starting with
 218  the location specified.
 219  The number of locations assigned for each matrix will be the same as for an
 220  _n_-element array of _m_-component vectors.
 221  
 222  The layout of a structure type used as an code:Input or code:Output depends
 223  on whether it is also a code:Block (i.e. has a code:Block decoration).
 224  
 225  If it is a not a code:Block, then the structure type must: have a
 226  code:Location decoration.
 227  Its members are assigned consecutive locations in their declaration order,
 228  with the first member assigned to the location specified for the structure
 229  type.
 230  The members, and their nested types, must: not themselves have code:Location
 231  decorations.
 232  
 233  If the structure type is a code:Block but without a code:Location, then each
 234  of its members must: have a code:Location decoration.
 235  If it is a code:Block with a code:Location decoration, then its members are
 236  assigned consecutive locations in declaration order, starting from the first
 237  member which is initially assigned the location specified for the
 238  code:Block.
 239  Any member with its own code:Location decoration is assigned that location.
 240  Each remaining member is assigned the location after the immediately
 241  preceding member in declaration order.
 242  
 243  The locations consumed by block and structure members are determined by
 244  applying the rules above in a depth-first traversal of the instantiated
 245  members as though the structure or block member were declared as an input or
 246  output variable of the same type.
 247  
 248  Any two inputs listed as operands on the same code:OpEntryPoint must: not be
 249  assigned the same location, either explicitly or implicitly.
 250  Any two outputs listed as operands on the same code:OpEntryPoint must: not
 251  be assigned the same location, either explicitly or implicitly.
 252  
 253  The number of input and output locations available for a shader input or
 254  output interface are limited, and dependent on the shader stage as described
 255  in <<interfaces-iointerfaces-limits>>.
 256  All variables in both the <<interfaces-builtin-variables,built-in interface
 257  block>> and the <<interfaces-iointerfaces-user,user-defined variable
 258  interface>> count against these 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
 276  |====
 277  
 278  
 279  [[interfaces-iointerfaces-components]]
 280  === Component Assignment
 281  
 282  The code:Component decoration allows the code:Location to be more finely
 283  specified for scalars and vectors, down to the individual components within
 284  a location that are consumed.
 285  The components within a location are 0, 1, 2, and 3.
 286  A variable or block member starting at component N will consume components
 287  N, N+1, N+2, ...
 288  up through its size.
 289  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 290  For 16-, and 32-bit types,
 291  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 292  ifndef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 293  For single precision types,
 294  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 295  it is invalid if this sequence of components gets larger than 3.
 296  A scalar 64-bit type will consume two of these components in sequence, and a
 297  two-component 64-bit vector type will consume all four components available
 298  within a location.
 299  A three- or four-component 64-bit vector type must: not specify a
 300  code:Component decoration.
 301  A three-component 64-bit vector type will consume all four components of the
 302  first location and components 0 and 1 of the second location.
 303  This leaves components 2 and 3 available for other component-qualified
 304  declarations.
 305  
 306  A scalar or two-component 64-bit data type must: not specify a
 307  code:Component decoration of 1 or 3.
 308  A code:Component decoration must: not be specified for any type that is not
 309  a scalar or vector.
 310  
 311  
 312  [[interfaces-vertexinput]]
 313  == Vertex Input Interface
 314  
 315  When the vertex stage is present in a pipeline, the vertex shader input
 316  variables form an interface with the vertex input attributes.
 317  The vertex shader input variables are matched by the code:Location and
 318  code:Component decorations to the vertex input attributes specified in the
 319  pname:pVertexInputState member of the slink:VkGraphicsPipelineCreateInfo
 320  structure.
 321  
 322  The vertex shader input variables listed by code:OpEntryPoint with the
 323  code:Input storage class form the _vertex input interface_.
 324  These variables must: be identified with a code:Location decoration and can:
 325  also be identified with a code:Component decoration.
 326  
 327  For the purposes of interface matching: variables declared without a
 328  code:Component decoration are considered to have a code:Component decoration
 329  of zero.
 330  The number of available vertex input locations is given by the
 331  pname:maxVertexInputAttributes member of the sname:VkPhysicalDeviceLimits
 332  structure.
 333  
 334  See <<fxvertex-attrib-location>> for details.
 335  
 336  All vertex shader inputs declared as above must: have a corresponding
 337  attribute and binding in the pipeline.
 338  
 339  
 340  [[interfaces-fragmentoutput]]
 341  == Fragment Output Interface
 342  
 343  When the fragment stage is present in a pipeline, the fragment shader
 344  outputs form an interface with the output attachments of the current
 345  subpass.
 346  The fragment shader output variables are matched by the code:Location and
 347  code:Component decorations to the color attachments specified in the
 348  pname:pColorAttachments array of the slink:VkSubpassDescription structure
 349  that describes the subpass that the fragment shader is executed in.
 350  
 351  The fragment shader output variables listed by code:OpEntryPoint with the
 352  code:Output storage class form the _fragment output interface_.
 353  These variables must: be identified with a code:Location decoration.
 354  They can: also be identified with a code:Component decoration and/or an
 355  code:Index decoration.
 356  For the purposes of interface matching: variables declared without a
 357  code:Component decoration are considered to have a code:Component decoration
 358  of zero, and variables declared without an code:Index decoration are
 359  considered to have an code:Index decoration of zero.
 360  
 361  A fragment shader output variable identified with a code:Location decoration
 362  of _i_ is directed to the color attachment indicated by
 363  pname:pColorAttachments[_i_], after passing through the blending unit as
 364  described in <<framebuffer-blending>>, if enabled.
 365  Locations are consumed as described in
 366  <<interfaces-iointerfaces-locations,Location Assignment>>.
 367  The number of available fragment output locations is given by the
 368  pname:maxFragmentOutputAttachments member of the
 369  sname:VkPhysicalDeviceLimits structure.
 370  
 371  Components of the output variables are assigned as described in
 372  <<interfaces-iointerfaces-components,Component Assignment>>.
 373  Output components identified as 0, 1, 2, and 3 will be directed to the R, G,
 374  B, and A inputs to the blending unit, respectively, or to the output
 375  attachment if blending is disabled.
 376  If two variables are placed within the same location, they must: have the
 377  same underlying type (floating-point or integer).
 378  The input values to blending or color attachment writes are undefined: for
 379  components which do not correspond to a fragment shader output.
 380  
 381  Fragment outputs identified with an code:Index of zero are directed to the
 382  first input of the blending unit associated with the corresponding
 383  code:Location.
 384  Outputs identified with an code:Index of one are directed to the second
 385  input of the corresponding blending unit.
 386  
 387  No _component aliasing_ of output variables is allowed, that is there must:
 388  not be two output variables which have the same location, component, and
 389  index, either explicitly declared or implied.
 390  
 391  Output values written by a fragment shader must: be declared with either
 392  code:OpTypeFloat or code:OpTypeInt, and a code:Width of 32.
 393  ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 394  If pname:storageInputOutput16 is supported, output values written by a
 395  fragment shader can: be also declared with either code:OpTypeFloat or
 396  code:OpTypeInt and a code:Width of 16.
 397  endif::VK_VERSION_1_1,VK_KHR_16bit_storage[]
 398  Composites of these types are also permitted.
 399  If the color attachment has a signed or unsigned normalized fixed-point
 400  format, color values are assumed to be floating-point and are converted to
 401  fixed-point as described in <<fundamentals-fpfixedconv>>; If the color
 402  attachment has an integer format, color values are assumed to be integers
 403  and converted to the bit-depth of the target.
 404  Any value that cannot be represented in the attachment's format is
 405  undefined:.
 406  For any other attachment format no conversion is performed.
 407  If the type of the values written by the fragment shader do not match the
 408  format of the corresponding color attachment, the resulting values are
 409  undefined: for those components.
 410  
 411  
 412  [[interfaces-inputattachment]]
 413  == Fragment Input Attachment Interface
 414  
 415  When a fragment stage is present in a pipeline, the fragment shader subpass
 416  inputs form an interface with the input attachments of the current subpass.
 417  The fragment shader subpass input variables are matched by
 418  code:InputAttachmentIndex decorations to the input attachments specified in
 419  the pname:pInputAttachments array of the slink:VkSubpassDescription
 420  structure that describes the subpass that the fragment shader is executed
 421  in.
 422  
 423  The fragment shader subpass input variables with the code:UniformConstant
 424  storage class and a decoration of code:InputAttachmentIndex that are
 425  statically used by code:OpEntryPoint form the _fragment input attachment
 426  interface_.
 427  These variables must: be declared with a type of code:OpTypeImage, a
 428  code:Dim operand of code:SubpassData, and a code:Sampled operand of 2.
 429  
 430  A subpass input variable identified with an code:InputAttachmentIndex
 431  decoration of _i_ reads from the input attachment indicated by
 432  pname:pInputAttachments[_i_] member of sname:VkSubpassDescription.
 433  If the subpass input variable is declared as an array of size N, it consumes
 434  N consecutive input attachments, starting with the index specified.
 435  There must: not be more than one input variable with the same
 436  code:InputAttachmentIndex whether explicitly declared or implied by an array
 437  declaration.
 438  The number of available input attachment indices is given by the
 439  pname:maxPerStageDescriptorInputAttachments member of the
 440  sname:VkPhysicalDeviceLimits structure.
 441  
 442  Variables identified with the code:InputAttachmentIndex must: only be used
 443  by a fragment stage.
 444  The basic data type (floating-point, integer, unsigned integer) of the
 445  subpass input must: match the basic format of the corresponding input
 446  attachment, or the values of subpass loads from these variables are
 447  undefined:.
 448  
 449  See <<descriptorsets-inputattachment>> for more details.
 450  
 451  
 452  [[interfaces-resources]]
 453  == Shader Resource Interface
 454  
 455  When a shader stage accesses buffer or image resources, as described in the
 456  <<descriptorsets,Resource Descriptors>> section, the shader resource
 457  variables must: be matched with the <<descriptorsets-pipelinelayout,pipeline
 458  layout>> that is provided at pipeline creation time.
 459  
 460  The set of shader resources that form the _shader resource interface_ for a
 461  stage are the variables statically used by code:OpEntryPoint with the
 462  storage class of code:Uniform, code:UniformConstant, or code:PushConstant.
 463  For the fragment shader, this includes the <<interfaces-inputattachment,
 464  fragment input attachment interface>>.
 465  
 466  The shader resource interface consists of two sub-interfaces: the push
 467  constant interface and the descriptor set interface.
 468  
 469  
 470  [[interfaces-resources-pushconst]]
 471  === Push Constant Interface
 472  
 473  The shader variables defined with a storage class of code:PushConstant that
 474  are statically used by the shader entry points for the pipeline define the
 475  _push constant interface_.
 476  They must: be:
 477  
 478    * typed as code:OpTypeStruct,
 479    * identified with a code:Block decoration, and
 480    * laid out explicitly using the code:Offset, code:ArrayStride, and
 481      code:MatrixStride decorations as specified in
 482      <<interfaces-resources-layout,Offset and Stride Assignment>>.
 483  
 484  There must: be no more than one push constant block statically used per
 485  shader entry point.
 486  
 487  Each statically used member of a push constant block must: be placed at an
 488  code:Offset such that the entire member is entirely contained within the
 489  slink:VkPushConstantRange for each code:OpEntryPoint that uses it, and the
 490  pname:stageFlags for that range must: specify the appropriate
 491  elink:VkShaderStageFlagBits for that stage.
 492  The code:Offset decoration for any member of a push constant block must: not
 493  cause the space required for that member to extend outside the range
 494  [eq]#[0, pname:maxPushConstantsSize)#.
 495  
 496  Any member of a push constant block that is declared as an array must: only
 497  be accessed with _dynamically uniform_ indices.
 498  
 499  
 500  [[interfaces-resources-descset]]
 501  === Descriptor Set Interface
 502  
 503  The _descriptor set interface_ is comprised of the shader variables with the
 504  storage class of
 505  ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 506  code:StorageBuffer,
 507  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 508  code:Uniform or code:UniformConstant (including the variables in the
 509  <<interfaces-inputattachment,fragment input attachment interface>>) that are
 510  statically used by the shader entry points for the pipeline.
 511  
 512  These variables must: have code:DescriptorSet and code:Binding decorations
 513  specified, which are assigned and matched with the
 514  sname:VkDescriptorSetLayout objects in the pipeline layout as described in
 515  <<interfaces-resources-setandbinding,DescriptorSet and Binding Assignment>>.
 516  
 517  Variables identified with the code:UniformConstant storage class are used
 518  only as handles to refer to opaque resources.
 519  Such variables must: be typed as code:OpTypeImage, code:OpTypeSampler,
 520  code:OpTypeSampledImage, or an array of one of these types.
 521  
 522  The code:Sampled code:Type of an code:OpTypeImage declaration must: match
 523  the numeric format of the corresponding resource in type and signedness, as
 524  shown in the _SPIR-V Sampled Type_ column of the <<formats-numericformat>>
 525  table, or the values obtained by reading or sampling from this image are
 526  undefined:.
 527  
 528  The code:Image code:Format of an code:OpTypeImage declaration must: not be
 529  *Unknown*, for variables which are used for code:OpImageRead,
 530  code:OpImageSparseRead, or code:OpImageWrite operations, except under the
 531  following conditions:
 532  
 533    * For code:OpImageWrite, if the pname:shaderStorageImageWriteWithoutFormat
 534      feature is enabled and the shader module declares the
 535      code:StorageImageWriteWithoutFormat capability.
 536    * For code:OpImageRead or code:OpImageSparseRead, if the
 537      pname:shaderStorageImageReadWithoutFormat feature is enabled and the
 538      shader module declares the code:StorageImageReadWithoutFormat
 539      capability.
 540    * For code:OpImageRead, if code:Dim is code:SubpassData (indicating a read
 541      from an input attachment).
 542  
 543  The code:Image code:Format of an code:OpTypeImage declaration must: not be
 544  *Unknown*, for variables which are used for code:OpAtomic* operations.
 545  
 546  Variables identified with the code:Uniform storage class are used to access
 547  transparent buffer backed resources.
 548  Such variables must: be:
 549  
 550    * typed as code:OpTypeStruct, or an array of this type,
 551    * identified with a code:Block or code:BufferBlock decoration, and
 552    * laid out explicitly using the code:Offset, code:ArrayStride, and
 553      code:MatrixStride decorations as specified in
 554      <<interfaces-resources-layout,Offset and Stride Assignment>>.
 555  
 556  ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 557  Variables identified with the code:StorageBuffer storage class are used to
 558  access transparent buffer backed resources.
 559  Such variables must: be:
 560  
 561    * typed as code:OpTypeStruct, or an array of this type,
 562    * identified with a code:Block decoration, and
 563    * laid out explicitly using the code:Offset, code:ArrayStride, and
 564      code:MatrixStride decorations as specified in
 565      <<interfaces-resources-layout,Offset and Stride Assignment>>.
 566  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 567  
 568  ifndef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 569  The code:Offset decoration for any variable in a code:Block must: not cause
 570  the space required for that variable to extend outside the range [eq]#[0,
 571  pname:maxUniformBufferRange)#.
 572  The code:Offset decoration for any variable in a code:BufferBlock must: not
 573  cause the space required for that variable to extend outside the range
 574  [eq]#[0, pname:maxStorageBufferRange)#.
 575  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 576  
 577  ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 578  The code:Offset decoration for any member of a code:Block-decorated variable
 579  in the code:Uniform storage class must: not cause the space required for
 580  that variable to extend outside the range [eq]#[0,
 581  pname:maxUniformBufferRange)#.
 582  The code:Offset decoration for any member of a code:Block-decorated variable
 583  in the code:StorageBuffer storage class must: not cause the space required
 584  for that variable to extend outside the range [eq]#[0,
 585  pname:maxStorageBufferRange)#.
 586  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 587  
 588  ifdef::VK_EXT_inline_uniform_block[]
 589  Variables identified with the code:Uniform storage class can: also be used
 590  to access transparent descriptor set backed resources when the variable is
 591  assigned to a descriptor set layout binding with a pname:descriptorType of
 592  ename:VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.
 593  In this case the variable must: be typed as code:OpTypeStruct and cannot: be
 594  aggregated into arrays of that type.
 595  Further, the code:Offset decoration for any member of such a variable must:
 596  not cause the space required for that variable to extend outside the range
 597  [eq]#[0,pname:maxInlineUniformBlockSize)#.
 598  endif::VK_EXT_inline_uniform_block[]
 599  
 600  Variables identified with a storage class of code:UniformConstant and a
 601  decoration of code:InputAttachmentIndex must: be declared as described in
 602  <<interfaces-inputattachment,Fragment Input Attachment Interface>>.
 603  
 604  SPIR-V variables decorated with a descriptor set and binding that identify a
 605  <<descriptorsets-combinedimagesampler, combined image sampler descriptor>>
 606  can: have a type of code:OpTypeImage, code:OpTypeSampler (code:Sampled=1),
 607  or code:OpTypeSampledImage.
 608  
 609  Arrays of any of these types can: be indexed with constant integral
 610  expressions.
 611  The following features must: be enabled and capabilities must: be declared
 612  in order to index such arrays with dynamically uniform or non-uniform
 613  indices:
 614  
 615    * Storage images (except storage texel buffers and input attachments):
 616    ** Dynamically uniform: pname:shaderStorageImageArrayDynamicIndexing and
 617       code:StorageImageArrayDynamicIndexing
 618  ifdef::VK_EXT_descriptor_indexing[]
 619    ** Non-uniform: pname:shaderStorageImageArrayNonUniformIndexing and
 620       code:StorageImageArrayNonUniformIndexingEXT
 621    * Storage texel buffers:
 622    ** Dynamically uniform: pname:shaderStorageTexelBufferArrayDynamicIndexing
 623       and code:StorageTexelBufferArrayDynamicIndexingEXT
 624    ** Non-uniform: pname:shaderStorageTexelBufferArrayNonUniformIndexing and
 625       code:StorageTexelBufferArrayNonUniformIndexingEXT
 626    * Input attachments:
 627    ** Dynamically uniform: pname:shaderInputAttachmentArrayDynamicIndexing
 628       and code:InputAttachmentArrayDynamicIndexingEXT
 629    ** Non-uniform: pname:shaderInputAttachmentArrayNonUniformIndexing and
 630       code:InputAttachmentArrayNonUniformIndexingEXT
 631  endif::VK_EXT_descriptor_indexing[]
 632    * Sampled images (except uniform texel buffers):
 633    ** Dynamically uniform: pname:shaderSampledImageArrayDynamicIndexing and
 634       code:SampledImageArrayDynamicIndexing
 635  ifdef::VK_EXT_descriptor_indexing[]
 636    ** Non-uniform: pname:shaderSampledImageArrayNonUniformIndexing and
 637       code:SampledImageArrayNonUniformIndexingEXT
 638    * Uniform texel buffers:
 639    ** Dynamically uniform: pname:shaderUniformTexelBufferArrayDynamicIndexing
 640       and code:UniformTexelBufferArrayDynamicIndexingEXT
 641    ** Non-uniform: pname:shaderUniformTexelBufferArrayNonUniformIndexing and
 642       code:UniformTexelBufferArrayNonUniformIndexingEXT
 643  endif::VK_EXT_descriptor_indexing[]
 644    * Uniform buffers:
 645    ** Dynamically uniform: pname:shaderUniformBufferArrayDynamicIndexing and
 646       code:UniformBufferArrayDynamicIndexing
 647  ifdef::VK_EXT_descriptor_indexing[]
 648    ** Non-uniform: pname:shaderUniformBufferArrayNonUniformIndexing and
 649       code:UniformBufferArrayNonUniformIndexingEXT
 650  endif::VK_EXT_descriptor_indexing[]
 651    * Storage buffers:
 652    ** Dynamically uniform: pname:shaderStorageBufferArrayDynamicIndexing and
 653       code:StorageBufferArrayDynamicIndexing
 654  ifdef::VK_EXT_descriptor_indexing[]
 655    ** Non-uniform: pname:shaderStorageBufferArrayNonUniformIndexing and
 656       code:StorageBufferArrayNonUniformIndexingEXT
 657  endif::VK_EXT_descriptor_indexing[]
 658  ifdef::VK_NV_ray_tracing[]
 659    * Acceleration structures:
 660    ** No additional capabilities needed.
 661  endif::VK_NV_ray_tracing[]
 662  
 663  
 664  ifdef::VK_EXT_descriptor_indexing[]
 665  If an instruction loads from or stores to a resource (including atomics and
 666  image instructions) and the resource descriptor being accessed is not
 667  dynamically uniform, then the corresponding non-uniform indexing feature
 668  must: be enabled and the capability must: be declared.
 669  endif::VK_EXT_descriptor_indexing[]
 670  If an instruction loads from or stores to a resource (including atomics and
 671  image instructions) and the resource descriptor being accessed is not
 672  uniform, then the corresponding dynamic indexing
 673  ifdef::VK_EXT_descriptor_indexing[]
 674  or non-uniform
 675  endif::VK_EXT_descriptor_indexing[]
 676  feature must: be enabled and the capability must: be declared.
 677  
 678  ifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
 679  If the combined image sampler enables sampler Y'C~B~C~R~
 680  ifndef::VK_EXT_fragment_density_map[]
 681  conversion,
 682  endif::VK_EXT_fragment_density_map[]
 683  ifdef::VK_EXT_fragment_density_map[]
 684  conversion or samples a <<samplers-subsamplesampler,subsampled image>>,
 685  endif::VK_EXT_fragment_density_map[]
 686  it must: be indexed only by constant integral expressions when aggregated
 687  into arrays in shader code, irrespective of the
 688  pname:shaderSampledImageArrayDynamicIndexing feature.
 689  endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
 690  ifndef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
 691  ifdef::VK_EXT_fragment_density_map[]
 692  If the combined image sampler samples a
 693  <<samplers-subsamplesampler,subsampled image>>, it must: be indexed only by
 694  constant integral expressions when aggregated into arrays in shader code,
 695  irrespective of the pname:shaderSampledImageArrayDynamicIndexing feature.
 696  endif::VK_EXT_fragment_density_map[]
 697  endif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
 698  
 699  [[interfaces-resources-correspondence]]
 700  .Shader Resource and Descriptor Type Correspondence
 701  [width="90%",cols="<1,<2",options="header"]
 702  |====
 703  | Resource type          | Descriptor Type
 704  | sampler                | ename:VK_DESCRIPTOR_TYPE_SAMPLER or
 705                             ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
 706  | sampled image          | ename:VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE or
 707                             ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
 708  | storage image          | ename:VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
 709  | combined image sampler | ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
 710  | uniform texel buffer   | ename:VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
 711  | storage texel buffer   | ename:VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
 712  | uniform buffer         | ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or
 713                             ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
 714  | storage buffer         | ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or
 715                             ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
 716  | input attachment       | ename:VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
 717  ifdef::VK_EXT_inline_uniform_block[]
 718  | inline uniform block   | ename:VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT
 719  endif::VK_EXT_inline_uniform_block[]
 720  ifdef::VK_NV_ray_tracing[]
 721  | acceleration structure | ename:VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV
 722  endif::VK_NV_ray_tracing[]
 723  |====
 724  
 725  [[interfaces-resources-storage-class-correspondence]]
 726  .Shader Resource and Storage Class Correspondence
 727  [width="100%",cols="<21%,<22%,<27%,<30%",options="header"]
 728  |====
 729  | Resource type   | Storage Class | Type | Decoration(s)^1^
 730  | sampler
 731          | code:UniformConstant | code:OpTypeSampler |
 732  | sampled image
 733          | code:UniformConstant | code:OpTypeImage (code:Sampled=1)|
 734  | storage image
 735          | code:UniformConstant | code:OpTypeImage (code:Sampled=2) |
 736  | combined image sampler
 737          | code:UniformConstant | code:OpTypeSampledImage +
 738                                   code:OpTypeImage (code:Sampled=1) +
 739                                   code:OpTypeSampler |
 740  | uniform texel buffer
 741          | code:UniformConstant | code:OpTypeImage (code:Dim=code:Buffer, code:Sampled=1) |
 742  | storage texel buffer
 743          | code:UniformConstant | code:OpTypeImage (code:Dim=code:Buffer, code:Sampled=2) |
 744  | uniform buffer
 745          | code:Uniform         | code:OpTypeStruct
 746          | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride)
 747  ifndef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 748  | storage buffer
 749          | code:Uniform         | code:OpTypeStruct
 750          | code:BufferBlock, code:Offset, (code:ArrayStride), (code:MatrixStride)
 751  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 752  ifdef::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 753  .2+<.^| storage buffer
 754          | code:Uniform         .2+<.^| code:OpTypeStruct
 755          | code:BufferBlock, code:Offset, (code:ArrayStride), (code:MatrixStride)
 756          | code:StorageBuffer | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride)
 757  endif::VK_VERSION_1_1,VK_KHR_storage_buffer_storage_class[]
 758  | input attachment
 759          | code:UniformConstant | code:OpTypeImage (code:Dim=code:SubpassData, code:Sampled=2)
 760          | code:InputAttachmentIndex
 761  ifdef::VK_EXT_inline_uniform_block[]
 762  | inline uniform block
 763          | code:Uniform | code:OpTypeStruct
 764          | code:Block, code:Offset, (code:ArrayStride), (code:MatrixStride)
 765  endif::VK_EXT_inline_uniform_block[]
 766  ifdef::VK_NV_ray_tracing[]
 767  | acceleration structure
 768          | code:UniformConstant | code:OpTypeAccelerationStructureNV
 769  endif::VK_NV_ray_tracing[]
 770  |====
 771  1:: in addition to code:DescriptorSet and code:Binding
 772  
 773  
 774  [[interfaces-resources-setandbinding]]
 775  === DescriptorSet and Binding Assignment
 776  
 777  A variable decorated with a code:DescriptorSet decoration of [eq]#s# and a
 778  code:Binding decoration of [eq]#b# indicates that this variable is
 779  associated with the slink:VkDescriptorSetLayoutBinding that has a
 780  pname:binding equal to [eq]#b# in pname:pSetLayouts[_s_] that was specified
 781  in slink:VkPipelineLayoutCreateInfo.
 782  
 783  code:DescriptorSet decoration values must: be between zero and
 784  pname:maxBoundDescriptorSets minus one, inclusive.
 785  code:Binding decoration values can: be any 32-bit unsigned integer value, as
 786  described in <<descriptorsets-setlayout>>.
 787  Each descriptor set has its own binding name space.
 788  
 789  If the code:Binding decoration is used with an array, the entire array is
 790  assigned that binding value.
 791  The array must: be a single-dimensional array and size of the array must: be
 792  no larger than the number of descriptors in the binding.
 793  ifdef::VK_EXT_descriptor_indexing[]
 794  If the array is runtime-sized, then array elements greater than or equal to
 795  the size of that binding in the bound descriptor set must: not be used.
 796  If the array is runtime-sized, the pname:runtimeDescriptorArray feature
 797  must: be enabled and the code:RuntimeDescriptorArrayEXT capability must: be
 798  declared.
 799  endif::VK_EXT_descriptor_indexing[]
 800  ifndef::VK_EXT_descriptor_indexing[]
 801  The array must: not be runtime-sized.
 802  endif::VK_EXT_descriptor_indexing[]
 803  The index of each element of the array is referred to as the _arrayElement_.
 804  For the purposes of interface matching and descriptor set
 805  <<descriptorsets-updates,operations>>, if a resource variable is not an
 806  array, it is treated as if it has an arrayElement of zero.
 807  
 808  There is a limit on the number of resources of each type that can: be
 809  accessed by a pipeline stage as shown in
 810  <<interfaces-resources-limits,Shader Resource Limits>>.
 811  The "`Resources Per Stage`" column gives the limit on the number each type
 812  of resource that can: be statically used for an entry point in any given
 813  stage in a pipeline.
 814  The "`Resource Types`" column lists which resource types are counted against
 815  the limit.
 816  Some resource types count against multiple limits.
 817  
 818  The pipeline layout may: include descriptor sets and bindings which are not
 819  referenced by any variables statically used by the entry points for the
 820  shader stages in the binding's pname:stageFlags.
 821  
 822  However, if a variable assigned to a given code:DescriptorSet and
 823  code:Binding is statically used by the entry point for a shader stage, the
 824  pipeline layout must: contain a descriptor set layout binding in that
 825  descriptor set layout and for that binding number, and that binding's
 826  pname:stageFlags must: include the appropriate elink:VkShaderStageFlagBits
 827  for that stage.
 828  The variable must: be of a valid resource type determined by its SPIR-V type
 829  and storage class, as defined in
 830  <<interfaces-resources-storage-class-correspondence,Shader Resource and
 831  Storage Class Correspondence>>.
 832  The descriptor set layout binding must: be of a corresponding descriptor
 833  type, as defined in <<interfaces-resources-correspondence,Shader Resource
 834  and Descriptor Type Correspondence>>.
 835  
 836  [NOTE]
 837  .Note
 838  ====
 839  There are no limits on the number of shader variables that can have
 840  overlapping set and binding values in a shader; but which resources are
 841  <<shaders-staticuse,statically used>> has an impact.
 842  If any shader variable identifying a resource is
 843  <<shaders-staticuse,statically used>> in a shader, then the underlying
 844  descriptor bound at the declared set and binding must
 845  <<interfaces-resources-correspondence,support the declared type in the
 846  shader>> when the shader executes.
 847  
 848  If multiple shader variables are declared with the same set and binding
 849  values, and with the same underlying descriptor type, they can all be
 850  statically used within the same shader.
 851  However, accesses are not automatically synchronized, and code:Aliased
 852  decorations should be used to avoid data hazards (see
 853  https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#_a_id_aliasingsection_a_aliasing[section
 854  2.18.2 Aliasing in the SPIR-V specification]).
 855  
 856  If multiple shader variables with the same set and binding values are
 857  declared in a single shader, but with different declared types, where any of
 858  those are not supported by the relevant bound descriptor, that shader can
 859  only be executed if the variables with the unsupported type are not
 860  statically used.
 861  
 862  A noteworthy example of using multiple statically-used shader variables
 863  sharing the same descriptor set and binding values is a descriptor of type
 864  ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER that has multiple
 865  corresponding shader variables in the code:UniformConstant storage class,
 866  where some could be code:OpTypeImage, some could be code:OpTypeSampler
 867  (code:Sampled=1), and some could be code:OpTypeSampledImage.
 868  ====
 869  
 870  [[interfaces-resources-limits]]
 871  .Shader Resource Limits
 872  [width="80%",cols="<35,<23",options="header"]
 873  |====
 874  | Resources per Stage                   | Resource Types
 875  .2+<.^| pname:maxPerStageDescriptorSamplers
 876  ifdef::VK_EXT_descriptor_indexing[]
 877  or pname:maxPerStageDescriptorUpdateAfterBindSamplers
 878  endif::VK_EXT_descriptor_indexing[]
 879              | sampler           | combined image sampler
 880  .3+<.^| pname:maxPerStageDescriptorSampledImages
 881  ifdef::VK_EXT_descriptor_indexing[]
 882  or pname:maxPerStageDescriptorUpdateAfterBindSampledImages
 883  endif::VK_EXT_descriptor_indexing[]
 884              | sampled image     | combined image sampler | uniform texel buffer
 885  .2+<.^| pname:maxPerStageDescriptorStorageImages
 886  ifdef::VK_EXT_descriptor_indexing[]
 887  or pname:maxPerStageDescriptorUpdateAfterBindStorageImages
 888  endif::VK_EXT_descriptor_indexing[]
 889              | storage image     | storage texel buffer
 890  .2+<.^| pname:maxPerStageDescriptorUniformBuffers
 891  ifdef::VK_EXT_descriptor_indexing[]
 892  or pname:maxPerStageDescriptorUpdateAfterBindUniformBuffers
 893  endif::VK_EXT_descriptor_indexing[]
 894              | uniform buffer    | uniform buffer dynamic
 895  .2+<.^| pname:maxPerStageDescriptorStorageBuffers
 896  ifdef::VK_EXT_descriptor_indexing[]
 897  or pname:maxPerStageDescriptorUpdateAfterBindStorageBuffers
 898  endif::VK_EXT_descriptor_indexing[]
 899              | storage buffer    | storage buffer dynamic
 900  | pname:maxPerStageDescriptorInputAttachments
 901  ifdef::VK_EXT_descriptor_indexing[]
 902  or pname:maxPerStageDescriptorUpdateAfterBindInputAttachments
 903  endif::VK_EXT_descriptor_indexing[]
 904              | input attachment^1^
 905  ifdef::VK_EXT_inline_uniform_block[]
 906  | pname:maxPerStageDescriptorInlineUniformBlocks
 907  ifdef::VK_EXT_descriptor_indexing[]
 908  or pname:maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks
 909  endif::VK_EXT_descriptor_indexing[]
 910              | inline uniform block
 911  endif::VK_EXT_inline_uniform_block[]
 912  |====
 913  
 914  1::
 915      Input attachments can: only be used in the fragment shader stage
 916  
 917  
 918  [[interfaces-resources-layout]]
 919  === Offset and Stride Assignment
 920  
 921  All variables with a storage class of code:Uniform, code:StorageBuffer, or
 922  code:PushConstant must: be explicitly laid out using the code:Offset,
 923  code:ArrayStride, and code:MatrixStride decorations.
 924  
 925  [NOTE]
 926  .Note
 927  ====
 928  The numeric order of code:Offset decorations does not need to follow member
 929  declaration order.
 930  ====
 931  
 932  
 933  [[interfaces-alignment-requirements]]
 934  *Alignment Requirements*
 935  
 936  There are different alignment requirements depending on the specific
 937  resources and on the features enabled on the device.
 938  
 939  The _scalar alignment_ of the type of an code:OpTypeStruct member is defined
 940  recursively as follows:
 941  
 942    * A scalar of size [eq]#N# has a scalar alignment of [eq]#N#.
 943    * A vector or matrix type has a scalar alignment equal to that of its
 944      component type.
 945    * An array type has a scalar alignment equal to that of its element type.
 946    * A structure has a scalar alignment equal to the largest scalar alignment
 947      of any of its members.
 948  
 949  The _base alignment_ of the type of an code:OpTypeStruct member is defined
 950  recursively as follows:
 951  
 952    * A scalar has a base alignment equal to its scalar alignment.
 953    * A two-component vector has a base alignment equal to twice its scalar
 954      alignment.
 955    * A three- or four-component vector has a base alignment equal to four
 956      times its scalar alignment.
 957    * An array has a base alignment equal to the base alignment of its element
 958      type.
 959    * A structure has a base alignment equal to the largest base alignment of
 960      any of its members.
 961    * A row-major matrix of [eq]#C# columns has a base alignment equal to the
 962      base alignment of a vector of [eq]#C# matrix components.
 963    * A column-major matrix has a base alignment equal to the base alignment
 964      of the matrix column type.
 965  
 966  The _extended alignment_ of the type of an code:OpTypeStruct member is
 967  similarly defined as follows:
 968  
 969    * A scalar, vector or matrix type has an extended alignment equal to its
 970      base alignment.
 971    * An array or structure type has an extended alignment equal to the
 972      largest extended alignment of any of its members, rounded up to a
 973      multiple of 16.
 974  
 975  ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
 976  
 977  A member is defined to _improperly straddle_ if either of the following are
 978  true:
 979  
 980    * It is a vector with total size less than or equal to 16 bytes, and has
 981      code:Offset decorations placing its first byte at [eq]#F# and its last
 982      byte at [eq]#L#, where [eq]#floor(F / 16) != floor(L / 16)#.
 983    * It is a vector with total size greater than 16 bytes and has its
 984      code:Offset decorations placing its first byte at a non-integer multiple
 985      of 16.
 986  
 987  endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
 988  
 989  [[interfaces-resources-standard-layout]]
 990  *Standard Buffer Layout*
 991  
 992  Every member of an code:OpTypeStruct with storage class of code:Uniform,
 993  code:StorageBuffer, or code:PushConstant must: be aligned according to the
 994  first matching rule as follows:
 995  
 996  ifdef::VK_EXT_scalar_block_layout[]
 997  . If the code:scalarBlockLayout feature is enabled on the device then every
 998    member must: be aligned according to its scalar alignment.
 999  endif::VK_EXT_scalar_block_layout[]
1000  ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
1001  . All vectors must: be aligned according to their scalar alignment.
1002  endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
1003  ifdef::VK_KHR_uniform_buffer_standard_layout[]
1004  . If the pname:uniformBufferStandardLayout feature is not enabled on the
1005    device, then any
1006  endif::VK_KHR_uniform_buffer_standard_layout[]
1007  ifndef::VK_KHR_uniform_buffer_standard_layout[]
1008  . Any
1009  endif::VK_KHR_uniform_buffer_standard_layout[]
1010    member of an code:OpTypeStruct with a storage class of code:Uniform and a
1011    decoration of code:Block must: be aligned according to its extended
1012    alignment.
1013  . Every other member must: be aligned according to its base alignment.
1014  
1015  ifdef::VK_EXT_scalar_block_layout[]
1016  [NOTE]
1017  .Note
1018  ====
1019  Even if scalar alignment is supported, it is generally more performant to
1020  use the _base alignment_.
1021  ====
1022  endif::VK_EXT_scalar_block_layout[]
1023  
1024  The memory layout must: obey the following rules:
1025  
1026    * The code:Offset decoration of any member must: be a multiple of its
1027      alignment.
1028    * Any code:ArrayStride or code:MatrixStride decoration must: be a multiple
1029      of the alignment of the array or matrix as defined above.
1030  
1031  ifdef::VK_EXT_scalar_block_layout[]
1032  Unless the code:scalarBlockLayout feature is enabled on the device:
1033  endif::VK_EXT_scalar_block_layout[]
1034  
1035  ifdef::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
1036    * Vectors must: not improperly straddle, as defined above.
1037  endif::VK_VERSION_1_1,VK_KHR_relaxed_block_layout[]
1038    * The code:Offset decoration of a member must: not place it between the
1039      end of a structure or an array and the next multiple of the alignment of
1040      that structure or array.
1041  
1042  [NOTE]
1043  .Note
1044  ====
1045  The *std430 layout* in GLSL satisfies these rules for types using the base
1046  alignment.
1047  The *std140 layout* satisfies the rules for types using the extended
1048  alignment.
1049  ====
1050  
1051  
1052  [[interfaces-builtin-variables]]
1053  == Built-In Variables
1054  
1055  Built-in variables are accessed in shaders by declaring a variable decorated
1056  with a code:BuiltIn SPIR-V decoration.
1057  The meaning of each code:BuiltIn decoration is as follows.
1058  In the remainder of this section, the name of a built-in is used
1059  interchangeably with a term equivalent to a variable decorated with that
1060  particular built-in.
1061  Built-ins that represent integer values can: be declared as either signed or
1062  unsigned 32-bit integers.
1063  
1064  ifdef::VK_NV_fragment_shader_barycentric[]
1065  
1066  [[interfaces-builtin-variables-barycoordnv]]
1067  code:BaryCoordNV::
1068  
1069  The code:BaryCoordNV decoration can: be used to decorate a fragment shader
1070  input variable.
1071  This variable will contain a three-component floating-point vector with
1072  barycentric weights that indicate the location of the fragment relative to
1073  the screen-space locations of vertices of its primitive, obtained using
1074  perspective interpolation.
1075  +
1076  The code:BaryCoordNV decoration must: be used only within fragment shaders.
1077  +
1078  The variable decorated with code:BaryCoordNV must: be declared using the
1079  code:Input storage class.
1080  +
1081  The variable decorated with code:BaryCoordNV must: be declared as
1082  three-component vector of 32-bit floating-point values.
1083  
1084  endif::VK_NV_fragment_shader_barycentric[]
1085  
1086  ifdef::VK_AMD_shader_explicit_vertex_parameter[]
1087  code:BaryCoordNoPerspAMD::
1088  
1089  The code:BaryCoordNoPerspAMD decoration can: be used to decorate a fragment
1090  shader input variable.
1091  This variable will contain the (I,J) pair of the barycentric coordinates
1092  corresponding to the fragment evaluated using linear interpolation at the
1093  fragment's center.
1094  The K coordinate of the barycentric coordinates can: be derived given the
1095  identity I + J + K = 1.0.
1096  
1097  endif::VK_AMD_shader_explicit_vertex_parameter[]
1098  
1099  ifdef::VK_NV_fragment_shader_barycentric[]
1100  
1101  [[interfaces-builtin-variables-barycoordnoperspnv]]
1102  code:BaryCoordNoPerspNV::
1103  
1104  The code:BaryCoordNoPerspNV decoration can: be used to decorate a fragment
1105  shader input variable.
1106  This variable will contain a three-component floating-point vector with
1107  barycentric weights that indicate the location of the fragment relative to
1108  the screen-space locations of vertices of its primitive, obtained using
1109  linear interpolation.
1110  +
1111  The code:BaryCoordNoPerspNV decoration must: be used only within fragment
1112  shaders.
1113  +
1114  The variable decorated with code:BaryCoordNoPerspNV must: be declared using
1115  the code:Input storage class.
1116  +
1117  The variable decorated with code:BaryCoordNoPerspNV must: be declared as
1118  three-component vector of 32-bit floating-point values.
1119  
1120  endif::VK_NV_fragment_shader_barycentric[]
1121  
1122  ifdef::VK_AMD_shader_explicit_vertex_parameter[]
1123  
1124  code:BaryCoordNoPerspCentroidAMD::
1125  
1126  The code:BaryCoordNoPerspCentroidAMD decoration can: be used to decorate a
1127  fragment shader input variable.
1128  This variable will contain the (I,J) pair of the barycentric coordinates
1129  corresponding to the fragment evaluated using linear interpolation at the
1130  centroid.
1131  The K coordinate of the barycentric coordinates can: be derived given the
1132  identity I + J + K = 1.0.
1133  
1134  code:BaryCoordNoPerspSampleAMD::
1135  
1136  The code:BaryCoordNoPerspCentroidAMD decoration can: be used to decorate a
1137  fragment shader input variable.
1138  This variable will contain the (I,J) pair of the barycentric coordinates
1139  corresponding to the fragment evaluated using linear interpolation at each
1140  covered sample.
1141  The K coordinate of the barycentric coordinates can: be derived given the
1142  identity I + J + K = 1.0.
1143  
1144  code:BaryCoordPullModelAMD::
1145  
1146  The code:BaryCoordPullModelAMD decoration can: be used to decorate a
1147  fragment shader input variable.
1148  This variable will contain (1/W, 1/I, 1/J) evaluated at the fragment center
1149  and can: be used to calculate gradients and then interpolate I, J, and W at
1150  any desired sample location.
1151  
1152  code:BaryCoordSmoothAMD::
1153  
1154  The code:BaryCoordSmoothAMD decoration can: be used to decorate a fragment
1155  shader input variable.
1156  This variable will contain the (I,J) pair of the barycentric coordinates
1157  corresponding to the fragment evaluated using perspective interpolation at
1158  the fragment's center.
1159  The K coordinate of the barycentric coordinates can: be derived given the
1160  identity I + J + K = 1.0.
1161  
1162  code:BaryCoordSmoothCentroidAMD::
1163  
1164  The code:BaryCoordSmoothCentroidAMD decoration can: be used to decorate a
1165  fragment shader input variable.
1166  This variable will contain the (I,J) pair of the barycentric coordinates
1167  corresponding to the fragment evaluated using perspective interpolation at
1168  the centroid.
1169  The K coordinate of the barycentric coordinates can: be derived given the
1170  identity I + J + K = 1.0.
1171  
1172  code:BaryCoordSmoothSampleAMD::
1173  
1174  The code:BaryCoordSmoothCentroidAMD decoration can: be used to decorate a
1175  fragment shader input variable.
1176  This variable will contain the (I,J) pair of the barycentric coordinates
1177  corresponding to the fragment evaluated using perspective interpolation at
1178  each covered sample.
1179  The K coordinate of the barycentric coordinates can: be derived given the
1180  identity I + J + K = 1.0.
1181  
1182  endif::VK_AMD_shader_explicit_vertex_parameter[]
1183  
1184  ifdef::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[]
1185  
1186  [[interfaces-builtin-variables-baseinstance]]
1187  code:BaseInstance::
1188  
1189  Decorating a variable with the code:BaseInstance built-in will make that
1190  variable contain the integer value corresponding to the first instance that
1191  was passed to the command that invoked the current vertex shader invocation.
1192  code:BaseInstance is the pname:firstInstance parameter to a _direct drawing
1193  command_ or the pname:firstInstance member of a structure consumed by an
1194  _indirect drawing command_.
1195  +
1196  The code:BaseInstance decoration must: be used only within vertex shaders.
1197  +
1198  The variable decorated with BaseInstance must: be declared using the input
1199  storage class.
1200  +
1201  The variable decorated with BaseInstance must: be declared as a scalar
1202  32-bit integer.
1203  
1204  [[interfaces-builtin-variables-basevertex]]
1205  code:BaseVertex::
1206  
1207  Decorating a variable with the code:BaseVertex built-in will make that
1208  variable contain the integer value corresponding to the first vertex or
1209  vertex offset that was passed to the command that invoked the current vertex
1210  shader invocation.
1211  For _non-indexed drawing commands_, this variable is the pname:firstVertex
1212  parameter to a _direct drawing command_ or the pname:firstVertex member of
1213  the structure consumed by an _indirect drawing command_.
1214  For _indexed drawing commands_, this variable is the pname:vertexOffset
1215  parameter to a _direct drawing command_ or the pname:vertexOffset member of
1216  the structure consumed by an _indirect drawing command_.
1217  +
1218  The code:BaseVertex decoration must: be used only within vertex shaders.
1219  +
1220  The variable decorated with code:BaseVertex must: be declared using the
1221  input storage class.
1222  +
1223  The variable decorated with code:BaseVertex must: be declared as a scalar
1224  32-bit integer.
1225  
1226  endif::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[]
1227  
1228  code:ClipDistance::
1229  
1230  Decorating a variable with the code:ClipDistance built-in decoration will
1231  make that variable contain the mechanism for controlling user clipping.
1232  code:ClipDistance is an array such that the i^th^ element of the array
1233  specifies the clip distance for plane i.
1234  A clip distance of 0 means the vertex is on the plane, a positive distance
1235  means the vertex is inside the clip half-space, and a negative distance
1236  means the point is outside the clip half-space.
1237  +
1238  The code:ClipDistance decoration must: be used only within
1239  ifdef::VK_NV_mesh_shader[]
1240  mesh,
1241  endif::VK_NV_mesh_shader[]
1242  vertex, fragment, tessellation control, tessellation evaluation, and
1243  geometry shaders.
1244  +
1245  In
1246  ifdef::VK_NV_mesh_shader[]
1247  mesh or
1248  endif::VK_NV_mesh_shader[]
1249  vertex shaders, any variable decorated with code:ClipDistance must: be
1250  declared using the code:Output storage class.
1251  +
1252  In fragment shaders, any variable decorated with code:ClipDistance must: be
1253  declared using the code:Input storage class.
1254  +
1255  In tessellation control, tessellation evaluation, or geometry shaders, any
1256  variable decorated with code:ClipDistance must: not be in a storage class
1257  other than code:Input or code:Output.
1258  +
1259  Any variable decorated with code:ClipDistance must: be declared as an array
1260  of 32-bit floating-point values.
1261  
1262  [NOTE]
1263  .Note
1264  ====
1265  The array variable decorated with code:ClipDistance is explicitly sized by
1266  the shader.
1267  ====
1268  
1269  [NOTE]
1270  .Note
1271  ====
1272  In the last vertex processing stage, these values will be linearly
1273  interpolated across the primitive and the portion of the primitive with
1274  interpolated distances less than 0 will be considered outside the clip
1275  volume.
1276  If code:ClipDistance is then used by a fragment shader, code:ClipDistance
1277  contains these linearly interpolated values.
1278  ====
1279  
1280  ifdef::VK_NV_mesh_shader[]
1281  [[interfaces-builtin-variables-clipdistancepv]]
1282  code:ClipDistancePerViewNV::
1283  
1284  Decorating a variable with the code:ClipDistancePerViewNV built-in
1285  decoration will make that variable contain the per-view clip distances.
1286  The per-view clip distances have the same semantics as code:ClipDistance.
1287  +
1288  The code:ClipDistancePerViewNV must: be used only within mesh shaders.
1289  +
1290  Any variable decorated with code:ClipDistancePerViewNV must: be declared
1291  using the code:Output storage class, and must: also be decorated with the
1292  code:PerViewNV decoration.
1293  +
1294  Any variable decorated with code:ClipDistancePerViewNV must: be declared as
1295  a two-dimensional array of 32-bit floating-point values.
1296  endif::VK_NV_mesh_shader[]
1297  
1298  code:CullDistance::
1299  
1300  Decorating a variable with the code:CullDistance built-in decoration will
1301  make that variable contain the mechanism for controlling user culling.
1302  If any member of this array is assigned a negative value for all vertices
1303  belonging to a primitive, then the primitive is discarded before
1304  rasterization.
1305  +
1306  The code:CullDistance decoration must: be used only within
1307  ifdef::VK_NV_mesh_shader[]
1308  mesh,
1309  endif::VK_NV_mesh_shader[]
1310  vertex, fragment, tessellation control, tessellation evaluation, and
1311  geometry shaders.
1312  +
1313  In
1314  ifdef::VK_NV_mesh_shader[]
1315  mesh or
1316  endif::VK_NV_mesh_shader[]
1317  vertex shaders, any variable decorated with code:CullDistance must: be
1318  declared using the code:Output storage class.
1319  +
1320  In fragment shaders, any variable decorated with code:CullDistance must: be
1321  declared using the code:Input storage class.
1322  +
1323  In tessellation control, tessellation evaluation, or geometry shaders, any
1324  variable decorated with code:CullDistance must: not be declared in a storage
1325  class other than input or output.
1326  +
1327  Any variable decorated with code:CullDistance must: be declared as an array
1328  of 32-bit floating-point values.
1329  
1330  [NOTE]
1331  .Note
1332  ====
1333  In fragment shaders, the values of the code:CullDistance array are linearly
1334  interpolated across each primitive.
1335  ====
1336  
1337  [NOTE]
1338  .Note
1339  ====
1340  If code:CullDistance decorates an input variable, that variable will contain
1341  the corresponding value from the code:CullDistance decorated output variable
1342  from the previous shader stage.
1343  ====
1344  
1345  ifdef::VK_NV_mesh_shader[]
1346  [[interfaces-builtin-variables-culldistancepv]]
1347  code:CullDistancePerViewNV::
1348  
1349  Decorating a variable with the code:CullDistancePerViewNV built-in
1350  decoration will make that variable contain the per-view cull distances.
1351  The per-view clip distances have the same semantics as code:CullDistance.
1352  +
1353  The code:CullDistancePerViewNV must: be used only within mesh shaders.
1354  +
1355  Any variable decorated with code:CullDistancePerViewNV must: be declared
1356  using the code:Output storage class, and must: also be decorated with the
1357  code:PerViewNV decoration.
1358  +
1359  Any variable decorated with code:CullDistancePerViewNV must: be declared as
1360  a two-dimensional array of 32-bit floating-point values.
1361  endif::VK_NV_mesh_shader[]
1362  
1363  ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
1364  
1365  [[interfaces-builtin-variables-deviceindex]]
1366  code:DeviceIndex::
1367  
1368  The code:DeviceIndex decoration can: be applied to a shader input which will
1369  be filled with the device index of the physical device that is executing the
1370  current shader invocation.
1371  This value will be in the range latexmath:[[0,max(1,physicalDeviceCount))],
1372  where physicalDeviceCount is the pname:physicalDeviceCount member of
1373  slink:VkDeviceGroupDeviceCreateInfo.
1374  +
1375  The code:DeviceIndex decoration can: be used in any shader.
1376  +
1377  The variable decorated with code:DeviceIndex must: be declared using the
1378  code:Input storage class.
1379  +
1380  The variable decorated with code:DeviceIndex must: be declared as a scalar
1381  32-bit integer.
1382  
1383  endif::VK_VERSION_1_1,VK_KHR_device_group[]
1384  
1385  ifdef::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[]
1386  
1387  [[interfaces-builtin-variables-drawindex]]
1388  code:DrawIndex::
1389  
1390  Decorating a variable with the code:DrawIndex built-in will make that
1391  variable contain the integer value corresponding to the zero-based index of
1392  the drawing command that invoked the current
1393  ifdef::VK_NV_mesh_shader[]
1394  task, mesh, or
1395  endif::VK_NV_mesh_shader[]
1396  vertex shader invocation.
1397  For _indirect drawing commands_, code:DrawIndex begins at zero and
1398  increments by one for each draw command executed.
1399  The number of draw commands is given by the pname:drawCount parameter.
1400  For _direct drawing commands_, code:DrawIndex is always zero.
1401  code:DrawIndex is dynamically uniform.
1402  +
1403  The code:DrawIndex decoration must: be used only within
1404  ifdef::VK_NV_mesh_shader[]
1405  task, mesh or
1406  endif::VK_NV_mesh_shader[]
1407  vertex shaders.
1408  +
1409  The variable decorated with code:DrawIndex must: be declared using the input
1410  storage class.
1411  +
1412  The variable decorated with code:DrawIndex must: be declared as a scalar
1413  32-bit integer.
1414  ifdef::VK_NV_mesh_shader[]
1415  +
1416  When task or mesh shaders are used, only the first active stage will have
1417  proper access to the variable, other stages will have undefined values.
1418  endif::VK_NV_mesh_shader[]
1419  
1420  endif::VK_VERSION_1_1,VK_KHR_shader_draw_parameters[]
1421  
1422  code:FragCoord::
1423  
1424  Decorating a variable with the code:FragCoord built-in decoration will make
1425  that variable contain the framebuffer coordinate
1426  latexmath:[(x,y,z,\frac{1}{w})] of the fragment being processed.
1427  The [eq]#(x,y)# coordinate [eq]#(0,0)# is the upper left corner of the upper
1428  left pixel in the framebuffer.
1429  +
1430  When <<primsrast-sampleshading,Sample Shading>> is enabled, the [eq]#x# and
1431  [eq]#y# components of code:FragCoord reflect the location of one of the
1432  samples corresponding to the shader invocation.
1433  +
1434  Otherwise, the [eq]#x# and [eq]#y# components of code:FragCoord reflect the
1435  location of the center of the fragment.
1436  +
1437  The [eq]#z# component of code:FragCoord is the interpolated depth value of
1438  the primitive.
1439  +
1440  The [eq]#w# component is the interpolated latexmath:[\frac{1}{w}].
1441  +
1442  The code:FragCoord decoration must: be used only within fragment shaders.
1443  +
1444  The variable decorated with code:FragCoord must: be declared using the
1445  code:Input storage class.
1446  +
1447  The code:Centroid interpolation decoration is ignored, but allowed, on
1448  code:FragCoord.
1449  +
1450  The variable decorated with code:FragCoord must: be declared as a
1451  four-component vector of 32-bit floating-point values.
1452  
1453  code:FragDepth::
1454  
1455  To have a shader supply a fragment-depth value, the shader must: declare the
1456  code:DepthReplacing execution mode.
1457  Such a shader's fragment-depth value will come from the variable decorated
1458  with the code:FragDepth built-in decoration.
1459  +
1460  This value will be used for any subsequent depth testing performed by the
1461  implementation or writes to the depth attachment.
1462  +
1463  The code:FragDepth decoration must: be used only within fragment shaders.
1464  +
1465  The variable decorated with code:FragDepth must: be declared using the
1466  code:Output storage class.
1467  +
1468  The variable decorated with code:FragDepth must: be declared as a scalar
1469  32-bit floating-point value.
1470  
1471  ifdef::VK_EXT_fragment_density_map[]
1472  [[interfaces-builtin-variables-fraginvocationcount]]
1473  code:FragInvocationCountEXT::
1474  
1475  Decorating a variable with the code:FragInvocationCountEXT built-in
1476  decoration will make that variable contain the maximum number of fragment
1477  shader invocations for the fragment, as determined by
1478  pname:minSampleShading.
1479  +
1480  The code:FragInvocationCountEXT decoration must: be used only within
1481  fragment shaders and the
1482  <<spirvenv-capabilities-table-fragmentdensity,code:FragmentDensityEXT
1483  capability>> must: be declared.
1484  +
1485  If <<primsrast-sampleshading,Sample Shading>> is not enabled,
1486  code:FragInvocationCountEXT will be filled with a value of 1.
1487  +
1488  The variable decorated with code:FragInvocationCountEXT must: be declared
1489  using the code:Input storage class.
1490  +
1491  The variable decorated with code:FragInvocationCountEXT must: be declared as
1492  a scalar 32-bit integer.
1493  endif::VK_EXT_fragment_density_map[]
1494  
1495  ifdef::VK_EXT_fragment_density_map[]
1496  [[interfaces-builtin-variables-fragsize]]
1497  code:FragSizeEXT::
1498  
1499  Decorating a variable with the code:FragSizeEXT built-in decoration will
1500  make that variable contain the dimensions in pixels of the
1501  <<glossary-fragment-area,area>> that the fragment covers for that
1502  invocation.
1503  
1504  +
1505  The code:FragSizeEXT decoration must: be used only within fragment shaders
1506  and the
1507  <<spirvenv-capabilities-table-fragmentdensity,code:FragmentDensityEXT
1508  capability>> must: be declared.
1509  +
1510  If fragment density map is not enabled, code:FragSizeEXT will be filled with
1511  a value of [eq]#(1,1)#.
1512  +
1513  The variable decorated with code:FragSizeEXT must: be declared using the
1514  code:Input storage class.
1515  +
1516  The variable decorated with code:FragSizeEXT must: be declared as a
1517  two-component vector of 32-bit integers.
1518  
1519  endif::VK_EXT_fragment_density_map[]
1520  
1521  ifdef::VK_EXT_shader_stencil_export[]
1522  
1523  code:FragStencilRefEXT::
1524  
1525  Decorating a variable with the code:FragStencilRefEXT built-in decoration
1526  will make that variable contain the new stencil reference value for all
1527  samples covered by the fragment.
1528  This value will be used as the stencil reference value used in stencil
1529  testing.
1530  +
1531  To write to code:FragStencilRefEXT, a shader must: declare the
1532  code:StencilRefReplacingEXT execution mode.
1533  If a shader declares the code:StencilRefReplacingEXT execution mode and
1534  there is an execution path through the shader that does not set
1535  code:FragStencilRefEXT, then the fragment's stencil reference value is
1536  undefined: for executions of the shader that take that path.
1537  +
1538  The code:FragStencilRefEXT decoration must: be used only within fragment
1539  shaders.
1540  +
1541  The variable decorated with code:FragStencilRefEXT must: be declared using
1542  the code:Output storage class.
1543  +
1544  The variable decorated with code:FragStencilRefEXT must: be declared as a
1545  scalar integer value.
1546  Only the least significant *s* bits of the integer value of the variable
1547  decorated with code:FragStencilRefEXT are considered for stencil testing,
1548  where *s* is the number of bits in the stencil framebuffer attachment, and
1549  higher order bits are discarded.
1550  
1551  endif::VK_EXT_shader_stencil_export[]
1552  
1553  ifdef::VK_NV_shading_rate_image[]
1554  
1555  code:FragmentSizeNV::
1556  
1557  Decorating a variable with the code:FragmentSizeNV built-in decoration will
1558  make that variable contain the width and height of the fragment.
1559  +
1560  The code:FragmentSizeNV decoration must: be used only within fragment
1561  shaders.
1562  +
1563  The variable decorated with code:FragmentSizeNV must: be declared using the
1564  code:Input storage class.
1565  +
1566  The variable decorated with code:FragmentSizeNV must: be declared as a
1567  two-component vector of 32-bit integers.
1568  
1569  endif::VK_NV_shading_rate_image[]
1570  
1571  
1572  code:FrontFacing::
1573  
1574  Decorating a variable with the code:FrontFacing built-in decoration will
1575  make that variable contain whether the fragment is front or back facing.
1576  This variable is non-zero if the current fragment is considered to be part
1577  of a <<primsrast-polygons-basic,front-facing>> polygon primitive or of a
1578  non-polygon primitive and is zero if the fragment is considered to be part
1579  of a back-facing polygon primitive.
1580  +
1581  The code:FrontFacing decoration must: be used only within fragment shaders.
1582  +
1583  The variable decorated with code:FrontFacing must: be declared using the
1584  code:Input storage class.
1585  +
1586  The variable decorated with code:FrontFacing must: be declared as a boolean.
1587  
1588  ifdef::VK_EXT_conservative_rasterization[]
1589  
1590  code:FullyCoveredEXT::
1591  
1592  Decorating a variable with the code:FullyCoveredEXT built-in decoration will
1593  make that variable indicate whether the <<glossary-fragment-area,fragment
1594  area>> is fully covered by the generating primitive.
1595  This variable is non-zero if conservative rasterization is enabled and the
1596  current fragment area is fully covered by the generating primitive, and is
1597  zero if the fragment is not covered or partially covered, or conservative
1598  rasterization is disabled.
1599  +
1600  The code:FullyCoveredEXT decoration must: be used only within fragment
1601  shaders and the code:FragmentFullyCoveredEXT capability must: be declared.
1602  +
1603  The variable decorated with code:FullyCoveredEXT must: be declared using the
1604  code:Input storage class.
1605  +
1606  The variable decorated with code:FullyCoveredEXT must: be declared as a
1607  boolean.
1608  +
1609  ifdef::VK_EXT_post_depth_coverage[]
1610  If the implementation supports
1611  sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:conservativeRasterizationPostDepthCoverage
1612  and the
1613  <<shaders-fragment-earlytest-postdepthcoverage,code:PostDepthCoverage>>
1614  execution mode is specified the code:SampleMask built-in input variable will
1615  reflect the coverage after the early per-fragment depth and stencil tests
1616  are applied.
1617  If
1618  sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:conservativeRasterizationPostDepthCoverage
1619  is not supported the
1620  <<shaders-fragment-earlytest-postdepthcoverage,code:PostDepthCoverage>>
1621  execution mode must: not be specified.
1622  endif::VK_EXT_post_depth_coverage[]
1623  
1624  endif::VK_EXT_conservative_rasterization[]
1625  
1626  code:GlobalInvocationId::
1627  
1628  Decorating a variable with the code:GlobalInvocationId built-in decoration
1629  will make that variable contain the location of the current invocation
1630  within the global workgroup.
1631  Each component is equal to the index of the local workgroup multiplied by
1632  the size of the local workgroup plus code:LocalInvocationId.
1633  +
1634  The code:GlobalInvocationId decoration must: be used only within
1635  ifdef::VK_NV_mesh_shader[]
1636  task, mesh, or
1637  endif::VK_NV_mesh_shader[]
1638  compute shaders.
1639  +
1640  The variable decorated with code:GlobalInvocationId must: be declared using
1641  the code:Input storage class.
1642  +
1643  The variable decorated with code:GlobalInvocationId must: be declared as a
1644  three-component vector of 32-bit integers.
1645  
1646  code:HelperInvocation::
1647  
1648  Decorating a variable with the code:HelperInvocation built-in decoration
1649  will make that variable contain whether the current invocation is a helper
1650  invocation.
1651  This variable is non-zero if the current fragment being shaded is a helper
1652  invocation and zero otherwise.
1653  A helper invocation is an invocation of the shader that is produced to
1654  satisfy internal requirements such as the generation of derivatives.
1655  +
1656  The code:HelperInvocation decoration must: be used only within fragment
1657  shaders.
1658  +
1659  The variable decorated with code:HelperInvocation must: be declared using
1660  the code:Input storage class.
1661  +
1662  The variable decorated with code:HelperInvocation must: be declared as a
1663  boolean.
1664  
1665  [NOTE]
1666  .Note
1667  ====
1668  It is very likely that a helper invocation will have a value of
1669  code:SampleMask fragment shader input value that is zero.
1670  ====
1671  
1672  ifdef::VK_NV_ray_tracing[]
1673  [[interfaces-builtin-variables-hitkind]]
1674  code:HitKindNV::
1675  
1676  A variable decorated with the code:HitKindNV decoration will describe the
1677  intersection that triggered the execution of the current shader.
1678  The values are determined by the intersection shader.
1679  +
1680  The code:HitKindNV decoration must: only be used in any-hit and closest hit
1681  shaders.
1682  +
1683  Any variable decorated with code:HitKindNV must: be declared using the
1684  code:Input storage class.
1685  +
1686  Any variable decorated with code:HitKindNV must: be declared as a scalar
1687  32-bit integer.
1688  
1689  [[interfaces-builtin-variables-hitt]]
1690  code:HitTNV::
1691  
1692  A variable decorated with the code:HitTNV decoration is equivalent to a
1693  variable decorated with the code:RayTmaxNV decoration.
1694  +
1695  The code:HitTNV decoration must: only be used in any-hit and closest hit
1696  shaders.
1697  +
1698  Any variable decorated with code:HitTNV must: be declared using the
1699  code:Input storage class.
1700  +
1701  Any variable decorated with code:HitTNV must: be declared as a scalar 32-bit
1702  floating-point value.
1703  
1704  [[interfaces-builtin-variables-incomingrayflags]]
1705  code:IncomingRayFlagsNV::
1706  
1707  A variable with the code:IncomingRayFlagsNV decoration will contain the ray
1708  flags passed in to the trace call that invoked this particular shader.
1709  +
1710  The code:IncomingRayFlagsNV decoration must: only be used in the
1711  intersection, any-hit, closest hit, and miss shaders.
1712  +
1713  Any variable decorated with code:IncomingRayFlagsNV must: be declared using
1714  the code:Input storage class.
1715  +
1716  Any variable decorated with code:IncomingRayFlagsNV must: be declared as a
1717  scalar 32-bit integer.
1718  
1719  [[interfaces-builtin-variables-instancecustomindex]]
1720  code:InstanceCustomIndexNV::
1721  
1722  A variable decorated with the code:InstanceCustomIndexNV decoration will
1723  contain the application-defined value of the instance that intersects the
1724  current ray.
1725  Only the lower 24 bits are valid, the upper 8 bits will be ignored.
1726  +
1727  The code:InstanceCustomIndexNV decoration must: only be used in the
1728  intersection, any-hit, and closest hit shaders.
1729  +
1730  Any variable decorated with code:InstanceCustomIndexNV must: be declared
1731  using the code:Input storage class.
1732  +
1733  Any variable decorated with code:InstanceCustomIndexNV must: be declared as
1734  a scalar 32-bit integer.
1735  
1736  [[interfaces-builtin-variables-instanceid]]
1737  code:InstanceId::
1738  
1739  Decorating a variable in an intersection, any-hit, or closest hit shader
1740  with the code:InstanceId decoration will make that variable contain the
1741  index of the instance that intersects the current ray.
1742  +
1743  The code:InstanceId decoration must: be used only within intersection,
1744  any-hit, or closest hit shaders.
1745  +
1746  The variable decorated with code:InstanceId must: be declared using the
1747  code:Input storage class.
1748  +
1749  The variable decorated with code:InstanceId must: be declared as a scalar
1750  32-bit integer.
1751  
1752  endif::VK_NV_ray_tracing[]
1753  
1754  code:InvocationId::
1755  
1756  Decorating a variable with the code:InvocationId built-in decoration will
1757  make that variable contain the index of the current shader invocation in a
1758  geometry shader, or the index of the output patch vertex in a tessellation
1759  control shader.
1760  +
1761  In a geometry shader, the index of the current shader invocation ranges from
1762  zero to the number of <<geometry-invocations,instances>> declared in the
1763  shader minus one.
1764  If the instance count of the geometry shader is one or is not specified,
1765  then code:InvocationId will be zero.
1766  +
1767  The code:InvocationId decoration must: be used only within tessellation
1768  control and geometry shaders.
1769  +
1770  The variable decorated with code:InvocationId must: be declared using the
1771  code:Input storage class.
1772  +
1773  The variable decorated with code:InvocationId must: be declared as a scalar
1774  32-bit integer.
1775  
1776  ifdef::VK_NV_shading_rate_image[]
1777  
1778  code:InvocationsPerPixelNV::
1779  
1780  Decorating a variable with the code:InvocationsPerPixelNV built-in
1781  decoration will make that variable contain the maximum number of fragment
1782  shader invocations per pixel, as derived from the effective shading rate for
1783  the fragment.
1784  If a primitive does not fully cover a pixel, the number of fragment shader
1785  invocations for that pixel may: be less than the value of
1786  code:InvocationsPerPixelNV.
1787  If the shading rate indicates a fragment covering multiple pixels, then
1788  code:InvocationsPerPixelNV will be one.
1789  +
1790  The code:InvocationsPerPixelNV decoration must: be used only within fragment
1791  shaders.
1792  +
1793  The variable decorated with code:InvocationsPerPixelNV must: be declared
1794  using the code:Input storage class.
1795  +
1796  The variable decorated with code:InvocationsPerPixelNV must: be declared as
1797  a scalar 32-bit integer.
1798  
1799  endif::VK_NV_shading_rate_image[]
1800  
1801  code:InstanceIndex::
1802  
1803  Decorating a variable in a vertex shader with the code:InstanceIndex
1804  built-in decoration will make that variable contain the index of the
1805  instance that is being processed by the current vertex shader invocation.
1806  code:InstanceIndex begins at the pname:firstInstance parameter to
1807  flink:vkCmdDraw or flink:vkCmdDrawIndexed or at the pname:firstInstance
1808  member of a structure consumed by flink:vkCmdDrawIndirect or
1809  flink:vkCmdDrawIndexedIndirect.
1810  +
1811  The code:InstanceIndex decoration must: be used only within vertex shaders.
1812  +
1813  The variable decorated with code:InstanceIndex must: be declared using the
1814  code:Input storage class.
1815  +
1816  The variable decorated with code:InstanceIndex must: be declared as a scalar
1817  32-bit integer.
1818  
1819  ifdef::VK_NV_ray_tracing[]
1820  [[interfaces-builtin-variables-launchid]]
1821  code:LaunchIDNV::
1822  
1823  A variable decorated with the code:LaunchIDNV decoration will specify the
1824  index of the work item being process.
1825  One work item is generated for each of the pname:width {times} pname:height
1826  {times} pname:depth items dispatched by a flink:vkCmdTraceRaysNV command.
1827  All shader invocations inherit the same value for variables decorated with
1828  code:LaunchIDNV.
1829  +
1830  The code:LaunchIDNV decoration must: only be used within the ray generation,
1831  intersection, any-hit, closest hit, and miss shaders.
1832  +
1833  Any variable decorated with code:LaunchIDNV must: be declared using the
1834  code:Input storage class.
1835  +
1836  Any variable decorated with code:LaunchIDNV must: be declared as a
1837  three-component vector of 32-bit integer values.
1838  
1839  [[interfaces-builtin-variables-launchsize]]
1840  code:LaunchSizeNV::
1841  
1842  A variable decorated with the code:LaunchSizeNV decoration will contain the
1843  pname:width, pname:height, and pname:depth dimensions passed to the
1844  flink:vkCmdTraceRaysNV command that initiated this shader execution.
1845  The pname:width is in the first component, the pname:height is in the second
1846  component, and the pname:depth is in the third component.
1847  +
1848  The code:LaunchSizeNV decoration must: only be used within ray generation,
1849  intersection, any-hit, closest hit, and miss shaders.
1850  +
1851  Any variable decorated with code:LaunchSizeNV must: be declared using the
1852  code:Input storage class.
1853  +
1854  Any variable decorated with code:LaunchSizeNV must: be declared as a
1855  three-component vector of 32-bit integer values.
1856  endif::VK_NV_ray_tracing[]
1857  
1858  [[interfaces-builtin-variables-layer]]
1859  code:Layer::
1860  
1861  Decorating a variable with the code:Layer built-in decoration will make that
1862  variable contain the select layer of a multi-layer framebuffer attachment.
1863  +
1864  In a
1865  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1866  ifdef::VK_NV_mesh_shader[]
1867  mesh,
1868  endif::VK_NV_mesh_shader[]
1869  vertex, tessellation evaluation, or
1870  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1871  geometry shader, any variable decorated with code:Layer can be written with
1872  the framebuffer layer index to which the primitive produced by that shader
1873  will be directed.
1874  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1875  +
1876  The last active _vertex processing stage_ (in pipeline order) controls the
1877  code:Layer that is used.
1878  Outputs in previous shader stages are not used, even if the last stage fails
1879  to write the code:Layer.
1880  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1881  +
1882  If the last active vertex processing stage shader entry point's interface
1883  does not include a variable decorated with code:Layer, then the first layer
1884  is used.
1885  If a vertex processing stage shader entry point's interface includes a
1886  variable decorated with code:Layer, it must: write the same value to
1887  code:Layer for all output vertices of a given primitive.
1888  If the code:Layer value is less than 0 or greater than or equal to the
1889  number of layers in the framebuffer, then primitives may: still be
1890  rasterized, fragment shaders may: be executed, and the framebuffer values
1891  for all layers are undefined:.
1892  +
1893  The code:Layer decoration must: be used only within
1894  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1895  ifdef::VK_NV_mesh_shader[]
1896  mesh,
1897  endif::VK_NV_mesh_shader[]
1898  vertex, tessellation evaluation,
1899  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1900  geometry, and fragment shaders.
1901  +
1902  In a
1903  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1904  ifdef::VK_NV_mesh_shader[]
1905  mesh,
1906  endif::VK_NV_mesh_shader[]
1907  vertex, tessellation evaluation, or
1908  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
1909  geometry shader, any variable decorated with code:Layer must: be declared
1910  using the code:Output storage class.
1911  ifdef::VK_NV_viewport_array2[]
1912  If such a variable is also decorated with code:ViewportRelativeNV, then the
1913  code:ViewportIndex is added to the layer that is used for rendering and that
1914  is made available in the fragment shader.
1915  If the shader writes to a variable decorated code:ViewportMaskNV, then the
1916  layer selected has a different value for each viewport a primitive is
1917  rendered to.
1918  endif::VK_NV_viewport_array2[]
1919  +
1920  In a fragment shader, a variable decorated with code:Layer contains the
1921  layer index of the primitive that the fragment invocation belongs to.
1922  +
1923  In a fragment shader, any variable decorated with code:Layer must: be
1924  declared using the code:Input storage class.
1925  +
1926  Any variable decorated with code:Layer must: be declared as a scalar 32-bit
1927  integer.
1928  
1929  ifdef::VK_NV_mesh_shader[]
1930  [[interfaces-builtin-variables-layerpv]]
1931  code:LayerPerViewNV::
1932  
1933  Decorating a variable with the code:LayerPerViewNV built-in decoration will
1934  make that variable contain the per-view layer information.
1935  The per-view layer has the same semantics as code:Layer, for each view.
1936  +
1937  The code:LayerPerViewNV must: only be used within mesh shaders.
1938  +
1939  Any variable decorated with code:LayerPerViewNV must: be declared using the
1940  code:Output storage class, and must: also be decorated with the
1941  code:PerViewNV decoration.
1942  +
1943  Any variable decorated with code:LayerPerViewNV must: be declared as an
1944  array of scalar 32-bit integer values.
1945  endif::VK_NV_mesh_shader[]
1946  
1947  code:LocalInvocationId::
1948  
1949  Decorating a variable with the code:LocalInvocationId built-in decoration
1950  will make that variable contain the location of the current
1951  ifdef::VK_NV_mesh_shader[]
1952  task, mesh, or
1953  endif::VK_NV_mesh_shader[]
1954  compute shader invocation within the local workgroup.
1955  Each component ranges from zero through to the size of the workgroup in that
1956  dimension minus one.
1957  +
1958  The code:LocalInvocationId decoration must: be used only within
1959  ifdef::VK_NV_mesh_shader[]
1960  task, mesh, or
1961  endif::VK_NV_mesh_shader[]
1962  compute shaders.
1963  +
1964  The variable decorated with code:LocalInvocationId must: be declared using
1965  the code:Input storage class.
1966  +
1967  The variable decorated with code:LocalInvocationId must: be declared as a
1968  three-component vector of 32-bit integers.
1969  
1970  [NOTE]
1971  .Note
1972  ====
1973  If the size of the workgroup in a particular dimension is one, then the
1974  code:LocalInvocationId in that dimension will be zero.
1975  If the workgroup is effectively two-dimensional, then
1976  code:LocalInvocationId.z will be zero.
1977  If the workgroup is effectively one-dimensional, then both
1978  code:LocalInvocationId.y and code:LocalInvocationId.z will be zero.
1979  ====
1980  
1981  code:LocalInvocationIndex::
1982  
1983  Decorating a variable with the code:LocalInvocationIndex built-in decoration
1984  will make that variable contain a one-dimensional representation of
1985  code:LocalInvocationId.
1986  This is computed as:
1987  +
1988  [source,c++]
1989  ----
1990  LocalInvocationIndex =
1991      LocalInvocationId.z * WorkgroupSize.x * WorkgroupSize.y +
1992      LocalInvocationId.y * WorkgroupSize.x +
1993      LocalInvocationId.x;
1994  ----
1995  +
1996  The code:LocalInvocationIndex decoration must: be used only within
1997  ifdef::VK_NV_mesh_shader[]
1998  task, mesh, or
1999  endif::VK_NV_mesh_shader[]
2000  compute shaders.
2001  +
2002  The variable decorated with code:LocalInvocationIndex must: be declared
2003  using the code:Input storage class.
2004  +
2005  The variable decorated with code:LocalInvocationIndex must: be declared as a
2006  scalar 32-bit integer.
2007  
2008  ifdef::VK_NV_mesh_shader[]
2009  [[interfaces-builtin-variables-meshviewcount]]
2010  code:MeshViewCountNV::
2011  
2012  Decorating a variable with the code:MeshViewCountNV built-in decoration will
2013  make that variable contain the number of views processed by the current mesh
2014  or task shader invocations.
2015  +
2016  The code:MeshViewCountNV decoration must: only be used in task and mesh
2017  shaders.
2018  +
2019  Any variable decorated with code:MeshViewCountNV must: be declared using the
2020  code:Input storage class.
2021  +
2022  Any variable decorated with code:MeshViewCountNV must: be declared as a
2023  scalar 32-bit integer.
2024  
2025  [[interfaces-builtin-variables-meshviewindices]]
2026  code:MeshViewIndicesNV::
2027  
2028  Decorating a variable with the code:MeshViewIndicesNV built-in decoration
2029  will make that variable contain the mesh view indices.
2030  The mesh view indices is an array of values where each element holds the
2031  view number of one of the views being processed by the current mesh or task
2032  shader invocations.
2033  The array elements with indices great than or equal to code:MeshViewCountNV
2034  are undefined.
2035  If the value of code:MeshViewIndicesNV[i] is [eq]#j#, then any outputs
2036  decorated with code:PerViewNV will take on the value of array element
2037  [eq]#i# when processing primitives for view index [eq]#j#.
2038  +
2039  The code:MeshViewIndicesNV decoration must: only be used in task and mesh
2040  shaders.
2041  +
2042  Any variable decorated with code:MeshViewIndicesNV must: be declared using
2043  the code:Input storage class.
2044  +
2045  Any variable decorated with code:MeshViewIndicesNV must: be declared as an
2046  array of scalar 32-bit integers.
2047  endif::VK_NV_mesh_shader[]
2048  
2049  ifdef::VK_VERSION_1_1[]
2050  
2051  code:NumSubgroups::
2052  
2053  Decorating a variable with the code:NumSubgroups built-in decoration will
2054  make that variable contain the number of subgroups in the local workgroup.
2055  +
2056  The code:NumSubgroups decoration must: be used only within
2057  ifdef::VK_NV_mesh_shader[]
2058  task, mesh, or
2059  endif::VK_NV_mesh_shader[]
2060  compute shaders.
2061  +
2062  The variable decorated with code:NumSubgroups must: be declared using the
2063  code:Input storage class.
2064  +
2065  The object decorated with code:NumSubgroups must: be declared as a scalar
2066  32-bit integer.
2067  
2068  endif::VK_VERSION_1_1[]
2069  
2070  code:NumWorkgroups::
2071  
2072  Decorating a variable with the code:NumWorkgroups built-in decoration will
2073  make that variable contain the number of local workgroups that are part of
2074  the dispatch that the invocation belongs to.
2075  Each component is equal to the values of the workgroup count parameters
2076  passed into the dispatch commands.
2077  +
2078  The code:NumWorkgroups decoration must: be used only within compute shaders.
2079  +
2080  The variable decorated with code:NumWorkgroups must: be declared using the
2081  code:Input storage class.
2082  +
2083  The variable decorated with code:NumWorkgroups must: be declared as a
2084  three-component vector of 32-bit integers.
2085  
2086  ifdef::VK_NV_ray_tracing[]
2087  [[interfaces-builtin-variables-objectraydirection]]
2088  code:ObjectRayDirectionNV::
2089  
2090  A variable decorated with the code:ObjectRayDirectionNV decoration will
2091  specify the direction of the ray being processed, in object space.
2092  +
2093  The code:ObjectRayDirectionNV decoration must: only be used within
2094  intersection, any-hit, closest hit, and miss shaders.
2095  +
2096  Any variable decorated with code:ObjectRayDirectionNV must: be declared
2097  using the code:Input storage class.
2098  +
2099  Any variable decorated with code:ObjectRayDirectionNV must: be declared as a
2100  three-component vector of 32-bit floating-point values.
2101  
2102  [[interfaces-builtin-variables-objectrayorigin]]
2103  code:ObjectRayOriginNV::
2104  
2105  A variable decorated with the code:ObjectRayOriginNV decoration will specify
2106  the origin of the ray being processed, in object space.
2107  +
2108  The code:ObjectRayOriginNV decoration must: only be used within
2109  intersection, any-hit, closest hit, and miss shaders.
2110  +
2111  Any variable decorated with code:ObjectRayOriginNV must: be declared using
2112  the code:Input storage class.
2113  +
2114  Any variable decorated with code:ObjectRayOriginNV must: be declared as a
2115  three-component vector of 32-bit floating-point values.
2116  
2117  [[interfaces-builtin-variables-objecttoworld]]
2118  code:ObjectToWorldNV::
2119  
2120  A variable decorated with the code:ObjectToWorldNV decoration will contain
2121  the current object-to-world transformation matrix, which is determined by
2122  the instance of the current intersection.
2123  +
2124  The code:ObjectToWorldNV decoration must: only be used within intersection,
2125  any-hit, and closest hit shaders.
2126  +
2127  Any variable decorated with code:ObjectToWorldNV must: be declared using the
2128  code:Input storage class.
2129  +
2130  Any variable decorated with code:ObjectToWorldNV must: be declared as a
2131  matrix with four columns of three-component vectors of 32-bit floating-point
2132  values.
2133  endif::VK_NV_ray_tracing[]
2134  
2135  code:PatchVertices::
2136  
2137  Decorating a variable with the code:PatchVertices built-in decoration will
2138  make that variable contain the number of vertices in the input patch being
2139  processed by the shader.
2140  A single tessellation control or tessellation evaluation shader can: read
2141  patches of differing sizes, so the value of the code:PatchVertices variable
2142  may: differ between patches.
2143  +
2144  The code:PatchVertices decoration must: be used only within tessellation
2145  control and tessellation evaluation shaders.
2146  +
2147  The variable decorated with code:PatchVertices must: be declared using the
2148  code:Input storage class.
2149  +
2150  The variable decorated with code:PatchVertices must: be declared as a scalar
2151  32-bit integer.
2152  
2153  code:PointCoord::
2154  
2155  Decorating a variable with the code:PointCoord built-in decoration will make
2156  that variable contain the coordinate of the current fragment within the
2157  point being rasterized, normalized to the size of the point with origin in
2158  the upper left corner of the point, as described in
2159  <<primsrast-points-basic,Basic Point Rasterization>>.
2160  If the primitive the fragment shader invocation belongs to is not a point,
2161  then the variable decorated with code:PointCoord contains an undefined:
2162  value.
2163  +
2164  The code:PointCoord decoration must: be used only within fragment shaders.
2165  +
2166  The variable decorated with code:PointCoord must: be declared using the
2167  code:Input storage class.
2168  +
2169  The variable decorated with code:PointCoord must: be declared as
2170  two-component vector of 32-bit floating-point values.
2171  
2172  [NOTE]
2173  .Note
2174  ====
2175  Depending on how the point is rasterized, code:PointCoord may: never reach
2176  [eq]#(0,0)# or [eq]#(1,1)#.
2177  ====
2178  
2179  code:PointSize::
2180  
2181  Decorating a variable with the code:PointSize built-in decoration will make
2182  that variable contain the size of point primitives.
2183  The value written to the variable decorated with code:PointSize by the last
2184  vertex processing stage in the pipeline is used as the framebuffer-space
2185  size of points produced by rasterization.
2186  +
2187  The code:PointSize decoration must: be used only within
2188  ifdef::VK_NV_mesh_shader[]
2189  mesh,
2190  endif::VK_NV_mesh_shader[]
2191  vertex, tessellation control, tessellation evaluation, and geometry shaders.
2192  +
2193  In a
2194  ifdef::VK_NV_mesh_shader[]
2195  mesh or
2196  endif::VK_NV_mesh_shader[]
2197  vertex shader, any variable decorated with code:PointSize must: be declared
2198  using the code:Output storage class.
2199  +
2200  In a tessellation control, tessellation evaluation, or geometry shader, any
2201  variable decorated with code:PointSize must: be declared using either the
2202  code:Input or code:Output storage class.
2203  +
2204  Any variable decorated with code:PointSize must: be declared as a scalar
2205  32-bit floating-point value.
2206  
2207  [NOTE]
2208  .Note
2209  ====
2210  When code:PointSize decorates a variable in the code:Input storage class, it
2211  contains the data written to the output variable decorated with
2212  code:PointSize from the previous shader stage.
2213  ====
2214  
2215  code:Position::
2216  
2217  Decorating a variable with the code:Position built-in decoration will make
2218  that variable contain the position of the current vertex.
2219  In the last vertex processing stage, the value of the variable decorated
2220  with code:Position is used in subsequent primitive assembly, clipping, and
2221  rasterization operations.
2222  +
2223  The code:Position decoration must: be used only within
2224  ifdef::VK_NV_mesh_shader[]
2225  mesh,
2226  endif::VK_NV_mesh_shader[]
2227  vertex, tessellation control, tessellation evaluation, and geometry shaders.
2228  +
2229  In a
2230  ifdef::VK_NV_mesh_shader[]
2231  mesh or
2232  endif::VK_NV_mesh_shader[]
2233  vertex shader, any variable decorated with code:Position must: be declared
2234  using the code:Output storage class.
2235  +
2236  In a tessellation control, tessellation evaluation, or geometry shader, any
2237  variable decorated with code:Position must: not be declared in a storage
2238  class other than code:Input or code:Output.
2239  +
2240  Any variable decorated with code:Position must: be declared as a
2241  four-component vector of 32-bit floating-point values.
2242  
2243  [NOTE]
2244  .Note
2245  ====
2246  When code:Position decorates a variable in the code:Input storage class, it
2247  contains the data written to the output variable decorated with
2248  code:Position from the previous shader stage.
2249  ====
2250  
2251  ifdef::VK_NVX_multiview_per_view_attributes[]
2252  [[interfaces-builtin-variables-positionperview]]
2253  code:PositionPerViewNV::
2254  
2255  Decorating a variable with the code:PositionPerViewNV built-in decoration
2256  will make that variable contain the position of the current vertex, for each
2257  view.
2258  +
2259  The code:PositionPerViewNV decoration must: be used only within
2260  ifdef::VK_NV_mesh_shader[]
2261  mesh,
2262  endif::VK_NV_mesh_shader[]
2263  vertex, tessellation control, tessellation evaluation, and geometry shaders.
2264  +
2265  In a vertex shader, any variable decorated with code:PositionPerViewNV must:
2266  be declared using the code:Output storage class.
2267  +
2268  In a tessellation control, tessellation evaluation, or geometry shader, any
2269  variable decorated with code:PositionPerViewNV must: not be declared in a
2270  storage class other than input or output.
2271  +
2272  Any variable decorated with code:PositionPerViewNV must: be declared as an
2273  array of four-component vector of 32-bit floating-point values with at least
2274  as many elements as the maximum view in the subpass's view mask plus one.
2275  The array must: be indexed by a constant or specialization constant.
2276  +
2277  Elements of the array correspond to views in a multiview subpass, and those
2278  elements corresponding to views in the view mask of the subpass the shader
2279  is compiled against will be used as the position value for those views.
2280  For the final vertex processing stage in the pipeline, values written to an
2281  output variable decorated with code:PositionPerViewNV are used in subsequent
2282  primitive assembly, clipping, and rasterization operations, as with
2283  code:Position.
2284  code:PositionPerViewNV output in an earlier vertex processing stage is
2285  available as an input in the subsequent vertex processing stage.
2286  +
2287  If a shader is compiled against a subpass that has the
2288  ename:VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX bit set, then
2289  the position values for each view must: not differ in any component other
2290  than the X component.
2291  If the values do differ, one will be chosen in an implementation-dependent
2292  manner.
2293  endif::VK_NVX_multiview_per_view_attributes[]
2294  
2295  ifdef::VK_NV_mesh_shader[]
2296  [[interfaces-builtin-variables-primitivecount]]
2297  code:PrimitiveCountNV::
2298  +
2299  Decorating a variable with the code:PrimitiveCountNV decoration will make
2300  that variable contain the primitive count.
2301  The primitive count specifies the number of primitives in the output mesh
2302  produced by the mesh shader that will be processed by subsequent pipeline
2303  stages.
2304  +
2305  The code:PrimitiveCountNV decoration must: only be used in mesh shaders.
2306  +
2307  Any variable decorated with code:PrimitiveCountNV must: be declared using
2308  the code:Output storage class.
2309  +
2310  Any variable decorated with code:PrimitiveCountNV must: be declared as a
2311  scalar 32-bit integer.
2312  endif::VK_NV_mesh_shader[]
2313  
2314  code:PrimitiveId::
2315  
2316  Decorating a variable with the code:PrimitiveId built-in decoration will
2317  make that variable contain the index of the current primitive.
2318  +
2319  The index of the first primitive generated by a drawing command is zero, and
2320  the index is incremented after every individual point, line, or triangle
2321  primitive is processed.
2322  +
2323  For triangles drawn as points or line segments (see <<primsrast-polygonmode
2324  , Polygon Mode>>), the primitive index is incremented only once, even if
2325  multiple points or lines are eventually drawn.
2326  +
2327  Variables decorated with code:PrimitiveId are reset to zero between each
2328  instance drawn.
2329  +
2330  Restarting a primitive topology using primitive restart has no effect on the
2331  value of variables decorated with code:PrimitiveId.
2332  +
2333  In tessellation control and tessellation evaluation shaders, it will contain
2334  the index of the patch within the current set of rendering primitives that
2335  correspond to the shader invocation.
2336  +
2337  In a geometry shader, it will contain the number of primitives presented as
2338  input to the shader since the current set of rendering primitives was
2339  started.
2340  +
2341  In a fragment shader, it will contain the primitive index written by the
2342  geometry shader if a geometry shader is present, or with the value that
2343  would have been presented as input to the geometry shader had it been
2344  present.
2345  ifdef::VK_NV_ray_tracing[]
2346  +
2347  In an intersection, any-hit, or closest hit shader, it will contain the
2348  index of the triangle or bounding box being processed.
2349  endif::VK_NV_ray_tracing[]
2350  +
2351  If a geometry shader is present and the fragment shader reads from an input
2352  variable decorated with code:PrimitiveId, then the geometry shader must:
2353  write to an output variable decorated with code:PrimitiveId in all execution
2354  paths.
2355  ifdef::VK_NV_mesh_shader[]
2356  +
2357  If a mesh shader is present and the fragment shader reads from an input
2358  variable decorated with code:PrimitiveId, then the mesh shader must: write
2359  to the output variables decorated with code:PrimitiveId in all execution
2360  paths.
2361  endif::VK_NV_mesh_shader[]
2362  +
2363  The code:PrimitiveId decoration must: be used only within
2364  ifdef::VK_NV_mesh_shader[]
2365  mesh,
2366  endif::VK_NV_mesh_shader[]
2367  ifdef::VK_NV_ray_tracing[]
2368  intersection, any-hit, closest hit,
2369  endif::VK_NV_ray_tracing[]
2370  fragment, tessellation control, tessellation evaluation, and geometry
2371  shaders.
2372  +
2373  In
2374  ifdef::VK_NV_ray_tracing[]
2375  an intersection, any-hit, closest hit,
2376  endif::VK_NV_ray_tracing[]
2377  ifndef::VK_NV_ray_tracing[]
2378  a
2379  endif::VK_NV_ray_tracing[]
2380  tessellation control, or tessellation evaluation shader, any variable
2381  decorated with code:PrimitiveId must: be declared using the code:Input
2382  storage class.
2383  +
2384  In a geometry shader, any variable decorated with code:PrimitiveId must: be
2385  declared using either the code:Input or code:Output storage class.
2386  ifdef::VK_NV_mesh_shader[]
2387  +
2388  In a mesh shader, any variable decorated with code:PrimitiveId must: be
2389  declared using the code:Output storage class.
2390  endif::VK_NV_mesh_shader[]
2391  +
2392  In a fragment shader, any variable decorated with code:PrimitiveId must: be
2393  declared using the code:Input storage class, and either the code:Geometry or
2394  code:Tessellation capability must: also be declared.
2395  +
2396  Any variable decorated with code:PrimitiveId must: be declared as a scalar
2397  32-bit integer.
2398  
2399  [NOTE]
2400  .Note
2401  ====
2402  When the code:PrimitiveId decoration is applied to an output variable in the
2403  ifdef::VK_NV_mesh_shader[]
2404  mesh shader or
2405  endif::VK_NV_mesh_shader[]
2406  geometry shader, the resulting value is seen through the code:PrimitiveId
2407  decorated input variable in the fragment shader.
2408  ====
2409  
2410  ifdef::VK_NV_mesh_shader[]
2411  [[interfaces-builtin-variables-primitiveindices]]
2412  code:PrimitiveIndicesNV::
2413  +
2414  Decorating a variable with the code:PrimitiveIndicesNV decoration will make
2415  that variable contain the output array of vertex index values.
2416  Depending on the output primitive type declared using the execution mode,
2417  the indices are split into groups of one (code:OutputPoints), two
2418  (code:OutputLinesNV), or three (code:OutputTriangles) indices and each group
2419  generates a primitive.
2420  +
2421  All index values must: be in the range [eq]#[0, N-1]#, where [eq]#N# is the
2422  value specified by the code:OutputVertices execution mode.
2423  +
2424  The code:PrimitiveIndicesNV decoration must: only be used in mesh shaders.
2425  +
2426  Any variable decorated with code:PrimitiveIndicesNV must: be declared using
2427  the code:Output storage class.
2428  +
2429  Any variable decorated with code:PrimitiveIndicesNV must: be declared as an
2430  array of scalar 32-bit integers.
2431  The array must: be sized according to the primitive type and
2432  code:OutputPrimitivesNV execution modes, where the size is:
2433  
2434    * the value specified by code:OutputPrimitivesNV if the execution mode is
2435      code:OutputPoints,
2436    * two times the value specified by code:OutputPrimitivesNV if the
2437      execution mode is code:OutputLinesNV, or
2438    * three times the value specified by code:OutputPrimitivesNV if the
2439      execution mode is code:OutputTrianglesNV.
2440  endif::VK_NV_mesh_shader[]
2441  
2442  ifdef::VK_NV_ray_tracing[]
2443  [[interfaces-builtin-variables-raytmax]]
2444  code:RayTmaxNV::
2445  
2446  A variable decorated with the code:RayTmaxNV decoration will contain the
2447  parametric pname:tmax values of the ray being processed.
2448  The values are independent of the space in which the ray and origin exist.
2449  +
2450  The pname:tmax value changes throughout the lifetime of the ray query that
2451  produced the intersection.
2452  In the closest hit shader, the value reflects the closest distance to the
2453  intersected primitive.
2454  In the any-hit shader, it reflects the distance to the primitive currently
2455  being intersected.
2456  In the intersection shader, it reflects the distance to the closest
2457  primitive intersected so far.
2458  The value can change in the intersection shader after calling
2459  code:OpReportIntersectionNV if the corresponding any-hit shader does not
2460  ignore the intersection.
2461  In a miss shader, the value is identical to the parameter passed into
2462  code:OpTraceNV.
2463  +
2464  The code:RayTmaxNV decoration must: only be used with the intersection,
2465  any-hit, closest hit, and miss shaders.
2466  +
2467  Any variable decorated with code:RayTmaxNV must: be declared with the
2468  code:Input storage class.
2469  +
2470  Any variable decorated with code:RayTmaxNV must: be declared as a scalar
2471  32-bit floating-point value.
2472  
2473  [[interfaces-builtin-variables-raytmin]]
2474  code:RayTminNV::
2475  
2476  A variable decorated with the code:RayTminNV decoration will contain the
2477  parametric code:tmin values of the ray being processed.
2478  The values are independent of the space in which the ray and origin exist.
2479  +
2480  The code:tmin value remains constant for the duration of the ray query.
2481  +
2482  The code:RayTminNV decoration must: only be used with the intersection,
2483  any-hit, closest hit, and miss shaders.
2484  +
2485  Any variable decorated with code:RayTminNV must: be declared with the
2486  code:Input storage class.
2487  +
2488  Any variable decorated with code:RayTminNV must: be declared as a scalar
2489  32-bit floating-point value.
2490  endif::VK_NV_ray_tracing[]
2491  
2492  code:SampleId::
2493  
2494  Decorating a variable with the code:SampleId built-in decoration will make
2495  that variable contain the zero-based index of the sample the invocation
2496  corresponds to.
2497  code:SampleId ranges from zero to the number of samples in the framebuffer
2498  minus one.
2499  If a fragment shader entry point's interface includes an input variable
2500  decorated with code:SampleId, <<primsrast-sampleshading,Sample Shading>> is
2501  considered enabled with a pname:minSampleShading value of 1.0.
2502  +
2503  The code:SampleId decoration must: be used only within fragment shaders.
2504  +
2505  The variable decorated with code:SampleId must: be declared using the
2506  code:Input storage class.
2507  +
2508  The variable decorated with code:SampleId must: be declared as a scalar
2509  32-bit integer.
2510  
2511  [[interfaces-builtin-variables-samplemask]]
2512  code:SampleMask::
2513  
2514  Decorating a variable with the code:SampleMask built-in decoration will make
2515  any variable contain the sample coverage mask for the current fragment
2516  shader invocation.
2517  +
2518  A variable in the code:Input storage class decorated with code:SampleMask
2519  will contain a bitmask of the set of samples covered by the primitive
2520  generating the fragment during rasterization.
2521  It has a sample bit set if and only if the sample is considered covered for
2522  this fragment shader invocation.
2523  code:SampleMask[] is an array of integers.
2524  Bits are mapped to samples in a manner where bit B of mask M
2525  (`SampleMask[M]`) corresponds to sample [eq]#32 {times} M {plus} B#.
2526  +
2527  When state specifies multiple fragment shader invocations for a given
2528  fragment, the sample mask for any single fragment shader invocation
2529  specifies the subset of the covered samples for the fragment that correspond
2530  to the invocation.
2531  In this case, the bit corresponding to each covered sample will be set in
2532  exactly one fragment shader invocation.
2533  
2534  ifdef::VK_EXT_post_depth_coverage[]
2535  +
2536  If the
2537  <<shaders-fragment-earlytest-postdepthcoverage,code:PostDepthCoverage>>
2538  execution mode is specified, the sample is considered covered if and only if
2539  the sample is covered by the primitive and the sample passes the
2540  <<fragops-early,early per-fragment tests>>.
2541  Otherwise the sample is considered covered if the sample is covered by the
2542  primitive, regardless of the result of the fragment tests.
2543  endif::VK_EXT_post_depth_coverage[]
2544  +
2545  A variable in the code:Output storage class decorated with code:SampleMask
2546  is an array of integers forming a bit array in a manner similar an input
2547  variable decorated with code:SampleMask, but where each bit represents
2548  coverage as computed by the shader.
2549  Modifying the sample mask by writing zero to a bit of code:SampleMask causes
2550  the sample to be considered uncovered.
2551  ifndef::VK_NV_sample_mask_override_coverage[]
2552  However, setting sample mask bits to one will never enable samples not
2553  covered by the original primitive.
2554  endif::VK_NV_sample_mask_override_coverage[]
2555  ifdef::VK_NV_sample_mask_override_coverage[]
2556  If this variable is also decorated with code:OverrideCoverageNV, the
2557  fragment coverage is replaced with the sample mask bits set in the shader
2558  otherwise the fragment coverage is code:ANDed with the bits of the sample
2559  mask.
2560  endif::VK_NV_sample_mask_override_coverage[]
2561  If the fragment shader is being evaluated at any frequency other than
2562  per-fragment, bits of the sample mask not corresponding to the current
2563  fragment shader invocation are ignored.
2564  This array must: be sized in the fragment shader either implicitly or
2565  explicitly, to be no larger than the implementation-dependent maximum
2566  sample-mask (as an array of 32-bit elements), determined by the maximum
2567  number of samples.
2568  If a fragment shader entry point's interface includes an output variable
2569  decorated with code:SampleMask, the sample mask will be undefined: for any
2570  array elements of any fragment shader invocations that fail to assign a
2571  value.
2572  If a fragment shader entry point's interface does not include an output
2573  variable decorated with code:SampleMask, the sample mask has no effect on
2574  the processing of a fragment.
2575  +
2576  The code:SampleMask decoration must: be used only within fragment shaders.
2577  +
2578  Any variable decorated with code:SampleMask must: be declared using either
2579  the code:Input or code:Output storage class.
2580  +
2581  Any variable decorated with code:SampleMask must: be declared as an array of
2582  32-bit integers.
2583  
2584  code:SamplePosition::
2585  
2586  Decorating a variable with the code:SamplePosition built-in decoration will
2587  make that variable contain the sub-pixel position of the sample being
2588  shaded.
2589  The top left of the pixel is considered to be at coordinate [eq]#(0,0)# and
2590  the bottom right of the pixel is considered to be at coordinate [eq]#(1,1)#.
2591  +
2592  ifdef::VK_EXT_fragment_density_map[]
2593  If the render pass has a fragment density map attachment, the variable will
2594  instead contain the sub-fragment position of the sample being shaded.
2595  The top left of the fragment is considered to be at coordinate [eq]#(0,0)#
2596  and the bottom right of the fragment is considered to be at coordinate
2597  [eq]#(1,1)# for any fragment area.
2598  endif::VK_EXT_fragment_density_map[]
2599  +
2600  If a fragment shader entry point's interface includes an input variable
2601  decorated with code:SamplePosition, <<primsrast-sampleshading,Sample
2602  Shading>> is considered enabled with a pname:minSampleShading value of 1.0.
2603  +
2604  The code:SamplePosition decoration must: be used only within fragment
2605  shaders.
2606  +
2607  The variable decorated with code:SamplePosition must: be declared using the
2608  code:Input storage class.
2609  ifdef::VK_EXT_sample_locations[]
2610  If the current pipeline uses <<primrast-samplelocations, custom sample
2611  locations>> the value of any variable decorated with the code:SamplePosition
2612  built-in decoration is undefined:.
2613  endif::VK_EXT_sample_locations[]
2614  +
2615  The variable decorated with code:SamplePosition must: be declared as a
2616  two-component vector of 32-bit floating-point values.
2617  
2618  ifdef::VK_NV_shader_sm_builtins[]
2619  
2620  [[interfaces-builtin-variables-smcountnv]]
2621  code:SMCountNV::
2622  
2623  Decorating a variable with the code:SMCountNV built-in decoration will make
2624  that variable contain the number of SMs on the device.
2625  +
2626  The variable decorated with code:SMCountNV must: be declared using the
2627  code:Input storage class.
2628  +
2629  The variable decorated with code:SMCountNV must: be declared as a scalar
2630  32-bit integer value.
2631  
2632  [[interfaces-builtin-variables-smidnv]]
2633  code:SMIDNV::
2634  
2635  Decorating a variable with the code:SMIDNV built-in decoration will make
2636  that variable contain the ID of the SM on which the current shader
2637  invocation is running.
2638  This variable is in the range [eq]#[0, code:SMCountNV-1]#.
2639  +
2640  The variable decorated with code:SMIDNV must: be declared using the
2641  code:Input storage class.
2642  +
2643  The variable decorated with code:SMIDNV must: be declared as a scalar 32-bit
2644  integer value.
2645  
2646  endif::VK_NV_shader_sm_builtins[]
2647  
2648  ifdef::VK_VERSION_1_1[]
2649  
2650  code:SubgroupId::
2651  +
2652  Decorating a variable with the code:SubgroupId built-in decoration will make
2653  that variable contain the index of the subgroup within the local workgroup.
2654  This variable is in range [0, code:NumSubgroups-1].
2655  +
2656  The code:SubgroupId decoration must: be used only within
2657  ifdef::VK_NV_mesh_shader[]
2658  task, mesh or,
2659  endif::VK_NV_mesh_shader[]
2660  compute shaders.
2661  +
2662  The variable decorated with code:SubgroupId must: be declared using the
2663  code:Input storage class.
2664  +
2665  The variable decorated with code:SubgroupId must: be declared as a scalar
2666  32-bit integer.
2667  
2668  endif::VK_VERSION_1_1[]
2669  
2670  ifdef::VK_VERSION_1_1,VK_EXT_shader_subgroup_ballot[]
2671  
2672  [[interfaces-builtin-variables-sgeq]]
2673  code:SubgroupEqMask::
2674  +
2675  Decorating a variable with the code:SubgroupEqMask builtin decoration will
2676  make that variable contain the _subgroup mask_ of the current subgroup
2677  invocation.
2678  The bit corresponding to the code:SubgroupLocalInvocationId is set in the
2679  variable decorated with code:SubgroupEqMask.
2680  All other bits are set to zero.
2681  +
2682  The variable decorated with code:SubgroupEqMask must: be declared using the
2683  code:Input storage class.
2684  +
2685  The variable decorated with code:SubgroupEqMask must: be declared as a
2686  four-component vector of 32-bit integer values.
2687  +
2688  code:SubgroupEqMaskKHR is an alias of code:SubgroupEqMask.
2689  
2690  [[interfaces-builtin-variables-sgge]]
2691  code:SubgroupGeMask::
2692  +
2693  Decorating a variable with the code:SubgroupGeMask builtin decoration will
2694  make that variable contain the _subgroup mask_ of the current subgroup
2695  invocation.
2696  The bits corresponding to the invocations greater than or equal to
2697  code:SubgroupLocalInvocationId through code:SubgroupSize-1 are set in the
2698  variable decorated with code:SubgroupGeMask.
2699  All other bits are set to zero.
2700  +
2701  The variable decorated with code:SubgroupGeMask must: be declared using the
2702  code:Input storage class.
2703  +
2704  The variable decorated with code:SubgroupGeMask must: be declared as a
2705  four-component vector of 32-bit integer values.
2706  +
2707  code:SubgroupGeMaskKHR is an alias of code:SubgroupGeMask.
2708  
2709  [[interfaces-builtin-variables-sggt]]
2710  code:SubgroupGtMask::
2711  +
2712  Decorating a variable with the code:SubgroupGtMask builtin decoration will
2713  make that variable contain the _subgroup mask_ of the current subgroup
2714  invocation.
2715  The bits corresponding to the invocations greater than
2716  code:SubgroupLocalInvocationId through code:SubgroupSize-1 are set in the
2717  variable decorated with code:SubgroupGtMask.
2718  All other bits are set to zero.
2719  +
2720  The variable decorated with code:SubgroupGtMask must: be declared using the
2721  code:Input storage class.
2722  +
2723  The variable decorated with code:SubgroupGtMask must: be declared as a
2724  four-component vector of 32-bit integer values.
2725  +
2726  code:SubgroupGtMaskKHR is an alias of code:SubgroupGtMask.
2727  
2728  [[interfaces-builtin-variables-sgle]]
2729  code:SubgroupLeMask::
2730  +
2731  Decorating a variable with the code:SubgroupLeMask builtin decoration will
2732  make that variable contain the _subgroup mask_ of the current subgroup
2733  invocation.
2734  The bits corresponding to the invocations less than or equal to
2735  code:SubgroupLocalInvocationId are set in the variable decorated with
2736  code:SubgroupLeMask.
2737  All other bits are set to zero.
2738  +
2739  The variable decorated with code:SubgroupLeMask must: be declared using the
2740  code:Input storage class.
2741  +
2742  The variable decorated with code:SubgroupLeMask must: be declared as a
2743  four-component vector of 32-bit integer values.
2744  +
2745  code:SubgroupLeMaskKHR is an alias of code:SubgroupLeMask.
2746  
2747  [[interfaces-builtin-variables-sglt]]
2748  code:SubgroupLtMask::
2749  +
2750  Decorating a variable with the code:SubgroupLtMask builtin decoration will
2751  make that variable contain the _subgroup mask_ of the current subgroup
2752  invocation.
2753  The bits corresponding to the invocations less than
2754  code:SubgroupLocalInvocationId are set in the variable decorated with
2755  code:SubgroupLtMask.
2756  All other bits are set to zero.
2757  +
2758  The variable decorated with code:SubgroupLtMask must: be declared using the
2759  code:Input storage class.
2760  +
2761  The variable decorated with code:SubgroupLtMask must: be declared as a
2762  four-component vector of 32-bit integer values.
2763  +
2764  code:SubgroupLtMaskKHR is an alias of code:SubgroupLtMask.
2765  
2766  [[interfaces-builtin-variables-sgli]]
2767  code:SubgroupLocalInvocationId::
2768  +
2769  Decorating a variable with the code:SubgroupLocalInvocationId builtin
2770  decoration will make that variable contain the index of the invocation
2771  within the subgroup.
2772  This variable is in range [0,code:SubgroupSize-1].
2773  +
2774  The variable decorated with code:SubgroupLocalInvocationId must: be declared
2775  using the code:Input storage class.
2776  +
2777  The variable decorated with code:SubgroupLocalInvocationId must: be declared
2778  as a scalar 32-bit integer.
2779  
2780  [[interfaces-builtin-variables-sgs]]
2781  code:SubgroupSize::
2782  +
2783  Decorating a variable with the code:SubgroupSize builtin decoration will
2784  make that variable contain the implementation-dependent maximum number of
2785  invocations in a subgroup.
2786  The maximum number of invocations that an implementation can support per
2787  subgroup is 128.
2788  +
2789  The variable decorated with code:SubgroupSize must: be declared using the
2790  code:Input storage class.
2791  +
2792  The variable decorated with code:SubgroupSize must: be declared as a scalar
2793  32-bit integer.
2794  
2795  endif::VK_VERSION_1_1,VK_EXT_shader_subgroup_ballot[]
2796  
2797  ifdef::VK_NV_mesh_shader[]
2798  [[interfaces-builtin-variables-taskcount]]
2799  code:TaskCountNV::
2800  +
2801  Decorating a variable with the code:TaskCountNV decoration will make that
2802  variable contain the task count.
2803  The task count specifies the number of subsequent mesh shader workgroups
2804  that get generated upon completion of the task shader.
2805  +
2806  The code:TaskCountNV decoration must: only be used in task shaders.
2807  +
2808  Any variable decorated with code:TaskCountNV must: be declared using the
2809  code:Output storage class.
2810  +
2811  Any variable decorated with code:TaskCountNV must: be declared as a scalar
2812  32-bit integer.
2813  endif::VK_NV_mesh_shader[]
2814  
2815  code:TessCoord::
2816  
2817  Decorating a variable with the code:TessCoord built-in decoration will make
2818  that variable contain the three-dimensional [eq]#(u,v,w)# barycentric
2819  coordinate of the tessellated vertex within the patch.
2820  [eq]#u#, [eq]#v#, and [eq]#w# are in the range [eq]#[0,1]# and vary linearly
2821  across the primitive being subdivided.
2822  For the tessellation modes of code:Quads or code:IsoLines, the third
2823  component is always zero.
2824  +
2825  The code:TessCoord decoration must: be used only within tessellation
2826  evaluation shaders.
2827  +
2828  The variable decorated with code:TessCoord must: be declared using the
2829  code:Input storage class.
2830  +
2831  The variable decorated with code:TessCoord must: be declared as
2832  three-component vector of 32-bit floating-point values.
2833  
2834  code:TessLevelOuter::
2835  
2836  Decorating a variable with the code:TessLevelOuter built-in decoration will
2837  make that variable contain the outer tessellation levels for the current
2838  patch.
2839  +
2840  In tessellation control shaders, the variable decorated with
2841  code:TessLevelOuter can: be written to which controls the tessellation
2842  factors for the resulting patch.
2843  These values are used by the tessellator to control primitive tessellation
2844  and can: be read by tessellation evaluation shaders.
2845  +
2846  In tessellation evaluation shaders, the variable decorated with
2847  code:TessLevelOuter can: read the values written by the tessellation control
2848  shader.
2849  +
2850  The code:TessLevelOuter decoration must: be used only within tessellation
2851  control and tessellation evaluation shaders.
2852  +
2853  In a tessellation control shader, any variable decorated with
2854  code:TessLevelOuter must: be declared using the code:Output storage class.
2855  +
2856  In a tessellation evaluation shader, any variable decorated with
2857  code:TessLevelOuter must: be declared using the code:Input storage class.
2858  +
2859  Any variable decorated with code:TessLevelOuter must: be declared as an
2860  array of size four, containing 32-bit floating-point values.
2861  
2862  code:TessLevelInner::
2863  
2864  Decorating a variable with the code:TessLevelInner built-in decoration will
2865  make that variable contain the inner tessellation levels for the current
2866  patch.
2867  +
2868  In tessellation control shaders, the variable decorated with
2869  code:TessLevelInner can: be written to, which controls the tessellation
2870  factors for the resulting patch.
2871  These values are used by the tessellator to control primitive tessellation
2872  and can: be read by tessellation evaluation shaders.
2873  +
2874  In tessellation evaluation shaders, the variable decorated with
2875  code:TessLevelInner can: read the values written by the tessellation control
2876  shader.
2877  +
2878  The code:TessLevelInner decoration must: be used only within tessellation
2879  control and tessellation evaluation shaders.
2880  +
2881  In a tessellation control shader, any variable decorated with
2882  code:TessLevelInner must: be declared using the code:Output storage class.
2883  +
2884  In a tessellation evaluation shader, any variable decorated with
2885  code:TessLevelInner must: be declared using the code:Input storage class.
2886  +
2887  Any variable decorated with code:TessLevelInner must: be declared as an
2888  array of size two, containing 32-bit floating-point values.
2889  
2890  code:VertexIndex::
2891  
2892  Decorating a variable with the code:VertexIndex built-in decoration will
2893  make that variable contain the index of the vertex that is being processed
2894  by the current vertex shader invocation.
2895  For non-indexed draws, this variable begins at the pname:firstVertex
2896  parameter to flink:vkCmdDraw or the pname:firstVertex member of a structure
2897  consumed by flink:vkCmdDrawIndirect and increments by one for each vertex in
2898  the draw.
2899  For indexed draws, its value is the content of the index buffer for the
2900  vertex plus the pname:vertexOffset parameter to flink:vkCmdDrawIndexed or
2901  the pname:vertexOffset member of the structure consumed by
2902  flink:vkCmdDrawIndexedIndirect.
2903  +
2904  The code:VertexIndex decoration must: be used only within vertex shaders.
2905  +
2906  The variable decorated with code:VertexIndex must: be declared using the
2907  code:Input storage class.
2908  +
2909  The variable decorated with code:VertexIndex must: be declared as a scalar
2910  32-bit integer.
2911  
2912  [NOTE]
2913  .Note
2914  ====
2915  code:VertexIndex starts at the same starting value for each instance.
2916  ====
2917  
2918  ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
2919  
2920  [[interfaces-builtin-variables-viewindex]]
2921  code:ViewIndex::
2922  
2923  The code:ViewIndex decoration can: be applied to a shader input which will
2924  be filled with the index of the view that is being processed by the current
2925  shader invocation.
2926  +
2927  If multiview is enabled in the render pass, this value will be one of the
2928  bits set in the view mask of the subpass the pipeline is compiled against.
2929  If multiview is not enabled in the render pass, this value will be zero.
2930  +
2931  The code:ViewIndex decoration must: not be used within compute shaders.
2932  +
2933  The variable decorated with code:ViewIndex must: be declared using the
2934  code:Input storage class.
2935  +
2936  The variable decorated with code:ViewIndex must: be declared as a scalar
2937  32-bit integer.
2938  
2939  endif::VK_VERSION_1_1,VK_KHR_multiview[]
2940  
2941  [[interfaces-builtin-variables-viewportindex]]
2942  code:ViewportIndex::
2943  
2944  Decorating a variable with the code:ViewportIndex built-in decoration will
2945  make that variable contain the index of the viewport.
2946  +
2947  In a
2948  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2949  ifdef::VK_NV_mesh_shader[]
2950  mesh,
2951  endif::VK_NV_mesh_shader[]
2952  vertex, tessellation evaluation, or
2953  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2954  geometry shader, the variable decorated with code:ViewportIndex can be
2955  written to with the viewport index to which the primitive produced by that
2956  shader will be directed.
2957  +
2958  The selected viewport index is used to select the
2959  ifndef::VK_NV_scissor_exclusive[]
2960  viewport transform and
2961  endif::VK_NV_scissor_exclusive[]
2962  ifdef::VK_NV_scissor_exclusive[]
2963  viewport transform, scissor rectangle, and exclusive
2964  endif::VK_NV_scissor_exclusive[]
2965  scissor rectangle.
2966  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2967  +
2968  The last active _vertex processing stage_ (in pipeline order) controls the
2969  code:ViewportIndex that is used.
2970  Outputs in previous shader stages are not used, even if the last stage fails
2971  to write the code:ViewportIndex.
2972  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2973  +
2974  If the last active vertex processing stage shader entry point's interface
2975  does not include a variable decorated with code:ViewportIndex, then the
2976  first viewport is used.
2977  If a vertex processing stage shader entry point's interface includes a
2978  variable decorated with code:ViewportIndex, it must: write the same value to
2979  code:ViewportIndex for all output vertices of a given primitive.
2980  +
2981  The code:ViewportIndex decoration must: be used only within
2982  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2983  ifdef::VK_NV_mesh_shader[]
2984  mesh,
2985  endif::VK_NV_mesh_shader[]
2986  vertex, tessellation evaluation,
2987  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2988  geometry, and fragment shaders.
2989  +
2990  In a
2991  ifdef::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2992  ifdef::VK_NV_mesh_shader[]
2993  mesh,
2994  endif::VK_NV_mesh_shader[]
2995  vertex, tessellation evaluation, or
2996  endif::VK_NV_viewport_array2,VK_EXT_shader_viewport_index_layer[]
2997  geometry shader, any variable decorated with code:ViewportIndex must: be
2998  declared using the code:Output storage class.
2999  +
3000  In a fragment shader, the variable decorated with code:ViewportIndex
3001  contains the viewport index of the primitive that the fragment invocation
3002  belongs to.
3003  +
3004  In a fragment shader, any variable decorated with code:ViewportIndex must:
3005  be declared using the code:Input storage class.
3006  +
3007  Any variable decorated with code:ViewportIndex must: be declared as a scalar
3008  32-bit integer.
3009  
3010  ifdef::VK_NV_viewport_array2[]
3011  [[interfaces-builtin-variables-viewportmask]]
3012  code:ViewportMaskNV::
3013  
3014  Decorating a variable with the code:ViewportMaskNV built-in decoration will
3015  make that variable contain the viewport mask.
3016  +
3017  In a
3018  ifdef::VK_NV_mesh_shader[]
3019  mesh,
3020  endif::VK_NV_mesh_shader[]
3021  vertex, tessellation evaluation, or geometry shader, the variable decorated
3022  with code:ViewportMaskNV can be written to with the mask of which viewports
3023  the primitive produced by that shader will directed.
3024  +
3025  The code:ViewportMaskNV variable must: be an array that has
3026  [eq]#{lceil}(sname:VkPhysicalDeviceLimits::pname:maxViewports / 32){rceil}#
3027  elements.
3028  When a shader writes to this variable, bit B of element M controls whether a
3029  primitive is emitted to viewport [eq]#32 {times} M +B#.
3030  The viewports indicated by the mask are used to select the
3031  ifndef::VK_NV_scissor_exclusive[]
3032  viewport transform and
3033  endif::VK_NV_scissor_exclusive[]
3034  ifdef::VK_NV_scissor_exclusive[]
3035  viewport transform, scissor rectangle, and exclusive
3036  endif::VK_NV_scissor_exclusive[]
3037  scissor rectangle that a primitive will be transformed by.
3038  +
3039  The last active _vertex processing stage_ (in pipeline order) controls the
3040  code:ViewportMaskNV that is used.
3041  Outputs in previous shader stages are not used, even if the last stage fails
3042  to write the code:ViewportMaskNV.
3043  When code:ViewportMaskNV is written by the final vertex processing stage,
3044  any variable decorated with code:ViewportIndex in the fragment shader will
3045  have the index of the viewport that was used in generating that fragment.
3046  +
3047  If a vertex processing stage shader entry point's interface includes a
3048  variable decorated with code:ViewportMaskNV, it must: write the same value
3049  to code:ViewportMaskNV for all output vertices of a given primitive.
3050  +
3051  The code:ViewportMaskNV decoration must: be used only within
3052  ifdef::VK_NV_mesh_shader[]
3053  mesh,
3054  endif::VK_NV_mesh_shader[]
3055  vertex, tessellation evaluation, and geometry shaders.
3056  +
3057  Any variable decorated with code:ViewportMaskNV must: be declared using the
3058  code:Output storage class.
3059  +
3060  Any variable decorated with code:ViewportMaskNV must: be declared as an
3061  array of 32-bit integers.
3062  endif::VK_NV_viewport_array2[]
3063  
3064  ifdef::VK_NVX_multiview_per_view_attributes+VK_NV_viewport_array2[]
3065  [[interfaces-builtin-variables-viewportmaskperview]]
3066  code:ViewportMaskPerViewNV::
3067  
3068  Decorating a variable with the code:ViewportMaskPerViewNV built-in
3069  decoration will make that variable contain the mask of viewports primitives
3070  are broadcast to, for each view.
3071  +
3072  The code:ViewportMaskPerViewNV decoration must: be used only within
3073  ifdef::VK_NV_mesh_shader[]
3074  mesh,
3075  endif::VK_NV_mesh_shader[]
3076  vertex, tessellation control, tessellation evaluation, and geometry shaders.
3077  +
3078  Any variable decorated with code:ViewportMaskPerViewNV must: be declared
3079  using the code:Output storage class.
3080  +
3081  The value written to an element of code:ViewportMaskPerViewNV in the last
3082  vertex processing stage is a bitmask indicating which viewports the
3083  primitive will be directed to.
3084  The primitive will be broadcast to the viewport corresponding to each
3085  non-zero bit of the bitmask, and that viewport index is used to select the
3086  ifndef::VK_NV_scissor_exclusive[]
3087  viewport transform and
3088  endif::VK_NV_scissor_exclusive[]
3089  ifdef::VK_NV_scissor_exclusive[]
3090  viewport transform, scissor rectangle, and exclusive
3091  endif::VK_NV_scissor_exclusive[]
3092  scissor rectangle, for each view.
3093  The same values must: be written to all vertices in a given primitive, or
3094  else the set of viewports used for that primitive is undefined:.
3095  +
3096  Any variable decorated with code:ViewportMaskPerViewNV must: be declared as
3097  an array of scalar 32-bit integers with at least as many elements as the
3098  maximum view in the subpass's view mask plus one.
3099  The array must: be indexed by a constant or specialization constant.
3100  +
3101  Elements of the array correspond to views in a multiview subpass, and those
3102  elements corresponding to views in the view mask of the subpass the shader
3103  is compiled against will be used as the viewport mask value for those views.
3104  code:ViewportMaskPerViewNV output in an earlier vertex processing stage is
3105  not available as an input in the subsequent vertex processing stage.
3106  +
3107  Although code:ViewportMaskNV is an array, code:ViewportMaskPerViewNV is not
3108  a two-dimensional array.
3109  Instead, code:ViewportMaskPerViewNV is limited to 32 viewports.
3110  endif::VK_NVX_multiview_per_view_attributes+VK_NV_viewport_array2[]
3111  
3112  ifdef::VK_NV_shader_sm_builtins[]
3113  [[interfaces-builtin-variables-warpspersmnv]]
3114  code:WarpsPerSMNV::
3115  
3116  Decorating a variable with the code:WarpsPerSMNV built-in decoration will
3117  make that variable contain the maximum number of warps executing on a SM.
3118  +
3119  The variable decorated with code:WarpsPerSMNV must: be declared using the
3120  code:Input storage class.
3121  +
3122  The variable decorated with code:WarpsPerSMNV must: be declared as a scalar
3123  32-bit integer value.
3124  
3125  [[interfaces-builtin-variables-warpidnv]]
3126  code:WarpIDNV::
3127  
3128  Decorating a variable with the code:WarpIDNV built-in decoration will make
3129  that variable contain the ID of the warp on a SM on which the current shader
3130  invocation is running.
3131  This variable is in the range [eq]#[0, code:WarpsPerSMNV-1]#.
3132  +
3133  The variable decorated with code:WarpIDNV must: be declared using the
3134  code:Input storage class.
3135  +
3136  The variable decorated with code:WarpIDNV must: be declared as a scalar
3137  32-bit integer value.
3138  
3139  endif::VK_NV_shader_sm_builtins[]
3140  
3141  code:WorkgroupId::
3142  
3143  Decorating a variable with the code:WorkgroupId built-in decoration will
3144  make that variable contain the global workgroup that the current invocation
3145  is a member of.
3146  Each component ranges from a base value to a [eq]#base {plus} count# value,
3147  based on the parameters passed into the dispatch commands.
3148  +
3149  The code:WorkgroupId decoration must: be used only within
3150  ifdef::VK_NV_mesh_shader[]
3151  task, mesh, or
3152  endif::VK_NV_mesh_shader[]
3153  compute shaders.
3154  +
3155  The variable decorated with code:WorkgroupId must: be declared using the
3156  code:Input storage class.
3157  +
3158  The variable decorated with code:WorkgroupId must: be declared as a
3159  three-component vector of 32-bit integers.
3160  
3161  code:WorkgroupSize::
3162  
3163  Decorating an object with the code:WorkgroupSize built-in decoration will
3164  make that object contain the dimensions of a local workgroup.
3165  If an object is decorated with the code:WorkgroupSize decoration, this must:
3166  take precedence over any execution mode set for code:LocalSize.
3167  +
3168  The code:WorkgroupSize decoration must: be used only within
3169  ifdef::VK_NV_mesh_shader[]
3170  task, mesh, or
3171  endif::VK_NV_mesh_shader[]
3172  compute shaders.
3173  +
3174  The object decorated with code:WorkgroupSize must: be a specialization
3175  constant or a constant.
3176  +
3177  The object decorated with code:WorkgroupSize must: be declared as a
3178  three-component vector of 32-bit integers.
3179  
3180  ifdef::VK_NV_ray_tracing[]
3181  [[interfaces-builtin-variables-worldraydirection]]
3182  code:WorldRayDirectionNV::
3183  
3184  A variable decorated with the code:WorldRayDirectionNV decoration will
3185  specify the direction of the ray being processed, in world space.
3186  +
3187  The code:WorldRayDirectionNV decoration must: only be used within
3188  intersection, any-hit, closest hit, and miss shaders.
3189  +
3190  Any variable decorated with code:WorldRayDirectionNV must: be declared using
3191  the code:Input storage class.
3192  +
3193  Any variable decorated with code:WorldRayDirectionNV must: be declared as a
3194  three-component vector of 32-bit floating-point values.
3195  
3196  [[interfaces-builtin-variables-worldrayorigin]]
3197  code:WorldRayOriginNV::
3198  
3199  A variable decorated with the code:WorldRayOriginNV decoration will specify
3200  the origin of the ray being processed, in world space.
3201  +
3202  The code:WorldRayOriginNV decoration must: only be used within intersection,
3203  any-hit, closest hit, and miss shaders.
3204  +
3205  Any variable decorated with code:WorldRayOriginNV must: be declared using
3206  the code:Input storage class.
3207  +
3208  Any variable decorated with code:WorldRayOriginNV must: be declared as a
3209  three-component vector of 32-bit floating-point values.
3210  
3211  [[interfaces-builtin-variables-worldtoobject]]
3212  code:WorldToObjectNV::
3213  
3214  A variable decorated with the code:WorldToObjectNV decoration will contain
3215  the current world-to-object transformation matrix, which is determined by
3216  the instance of the current intersection.
3217  +
3218  The code:WorldToObjectNV decoration must: only be used within intersection,
3219  any-hit, and closest hit shaders.
3220  +
3221  Any variable decorated with code:WorldToObjectNV must: be declared using the
3222  code:Input storage class.
3223  +
3224  Any variable decorated with code:WorldToObjectNV must: be declared as a
3225  matrix with four columns of three-component vectors of 32-bit floating-point
3226  values.
3227  endif::VK_NV_ray_tracing[]