Description
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 theViewportIndex
.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 withViewportIndex
, it must write the same value toViewportIndex
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 withViewportIndex
, then the value ofViewIndex
is used as an index to select the viewport transform and scissor rectangle, and the value ofViewportIndex
in the fragment shader is undefined:.
Document Notes
For more information, see the Vulkan Specification
This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.