Description
ViewportIndex
-
Decorating a variable with the
ViewportIndex
built-in decoration will make that variable contain the index of the viewport.In a 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 and 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
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.
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.