Description
Layer
-
Decorating a variable with the
Layer
built-in decoration will make that variable contain the select layer of a multi-layer framebuffer attachment.In a mesh, vertex, tessellation evaluation, or geometry shader, any variable decorated with
Layer
can be written with the framebuffer layer index to which the primitive produced by that shader will be directed.The last active pre-rasterization shader stage (in pipeline order) controls the
Layer
that is used. Outputs in previous shader stages are not used, even if the last stage fails to write theLayer
.If the last active pre-rasterization shader stage shader entry point’s interface does not include a variable decorated with
Layer
, then the first layer is used. If a pre-rasterization shader stage shader entry point’s interface includes a variable decorated withLayer
, it must write the same value toLayer
for all output vertices of a given primitive. If theLayer
value is less than 0 or greater than or equal to the number of layers in the framebuffer, then primitives may still be rasterized, fragment shaders may be executed, and the framebuffer values for all layers are undefined. In a mesh shader this also applies when theLayer
value is greater than or equal to themaxMeshOutputLayers
limit.If a variable with the
Layer
decoration is also decorated withViewportRelativeNV
, then theViewportIndex
is added to the layer that is used for rendering and that is made available in the fragment shader.If the shader writes to a variable decorated
ViewportMaskNV
, then the layer selected has a different value for each viewport a primitive is rendered to.In a fragment shader, a variable decorated with
Layer
contains the layer 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.