[[viewport_array_index]]
enables specifying one viewport or scissor rectangle from
multiple active viewports and scissor rectangles. For details about
[[viewport_array_index]]
, see section 4.11.
[[viewport_array_index]]
and
[[render_target_array_index]]
are only available for
macOS.
If the return type of a vertex function is not
void
, it must include the vertex position. If the
vertex return type is
float4
, then it always refers to the vertex position, and the
[[position]]
attribute must not be specified. If the vertex return type is a struct, it must
include an element declared with the
[[position]]
attribute.
The example below describes a vertex function called
process_vertex
. The function returns a
user-defined struct called
VertexOutput
, which contains a built-in variable that represents the
vertex position, so it requires the
[[position]]
attribute.
struct VertexOutput {
float4 position [[position]];
float4 color;
float2 texcoord;
}
vertex VertexOutput
process_vertex(…)
{
VertexOutput v_out;
//
compute per-vertex output
…
return v_out;
}
[[render_target_array_index]] uchar
,
ushort
or
uint
The render target array index. This refers to the face of
a cubemap, an array slice of a texture array, or an array
slice, face of a cubemap array. For a cubemap the
render target array index is the face index, which is a
value from 0 to 5. For a cubemap array the render
target array index is computed as: array slice index * 6
+ face index.
[[viewport_array_index]]
The viewport (and scissor rectangle) index value of the
primitive.
Attribute
Corresponding Data Types
2017-9-12 | Copyright © 2017 Apple Inc. All Rights Reserved.
Page of
70
174