ViewportIndex(3)

# ViewportIndex(3) Manual Page

## Name

ViewportIndex - Viewport index used

Loading… please wait.

## 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 the `ViewportIndex`.

  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 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.

Valid Usage

- VUID-ViewportIndex-ViewportIndex-04404
  The `ViewportIndex` decoration must be used only within the `MeshNV`, `Vertex`, `TessellationEvaluation`, `Geometry`, or `Fragment` `Execution` `Model`

- VUID-ViewportIndex-ViewportIndex-04405
  If the shaderOutputViewportIndex feature is not enabled then the `ViewportIndex` decoration must be used only within the `Geometry` or `Fragment` `Execution` `Model`

- VUID-ViewportIndex-ViewportIndex-04406
  The variable decorated with `ViewportIndex` within the `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

## See Also

No cross-references are available

## 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.

## Copyright

Copyright 2014-2022 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0