ViewportIndex
ViewportIndex
Decorating a variable with the ViewportIndex
built-in decoration will
make that variable contain the index of the viewport.
In a
mesh,
vertex, tessellation evaluation, or
geometry shader, the variable decorated with ViewportIndex
can be
written to with the viewport index to which the primitive produced by that
shader will be directed.
The selected viewport index is used to select the viewport transform, scissor rectangle, and exclusive scissor rectangle.
The last active
pre-rasterization shader
stage (in pipeline order) controls the ViewportIndex
that is used.
Outputs in previous shader stages are not used, even if the last stage fails
to write the ViewportIndex
.
If the last active
pre-rasterization shader
stage shader entry point’s interface does not include a variable decorated
with ViewportIndex
, and if multiviewPerViewViewports
is not enabled,
then the first viewport is used.
If a pre-rasterization shader
stage shader entry point’s interface includes a variable decorated with
ViewportIndex
, it must write the same value to ViewportIndex
for
all output vertices of a given primitive.
In a fragment shader, the variable decorated with ViewportIndex
contains the viewport index of the primitive that the fragment invocation
belongs to.
If multiviewPerViewViewports
is enabled, and if the last active
pre-rasterization shader
stage shader entry point’s interface does not include a variable decorated
with ViewportIndex
, then the value of ViewIndex
is used as an
index to select the viewport transform and scissor rectangle, and the value
of ViewportIndex
in the fragment shader is undefined::.
Valid Usage
VUID-ViewportIndex-ViewportIndex-04404
The ViewportIndex
decoration must be used only within the
MeshEXT
, MeshNV
, Vertex
, TessellationEvaluation
,
Geometry
, or Fragment
Execution
Model
VUID-ViewportIndex-ViewportIndex-04406
The variable decorated with ViewportIndex
within the MeshEXT
,
MeshNV
, Vertex
, TessellationEvaluation
, or Geometry
Execution
Model
must be declared using the Output
Storage
Class
VUID-ViewportIndex-ViewportIndex-04407
The variable decorated with ViewportIndex
within the Fragment
Execution
Model
must be declared using the Input
Storage
Class
VUID-ViewportIndex-ViewportIndex-04408
The variable decorated with ViewportIndex
must be declared as a
scalar 32-bit integer value
VUID-ViewportIndex-ViewportIndex-07060
The variable decorated with ViewportIndex
within the MeshEXT
Execution
Model
must also be decorated with the PerPrimitiveEXT
decoration