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