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