Metal Shading Language Specification



Yüklə 4,82 Kb.
Pdf görüntüsü
səhifə22/51
tarix25.05.2018
ölçüsü4,82 Kb.
#45967
1   ...   18   19   20   21   22   23   24   25   ...   51

Table 9 lists the built-in attributes that can be specified for arguments to a vertex function and 
the corresponding data types with which they can be used. 
Table 9 Attributes for Vertex Function Input Arguments 
Notes on vertex function input attributes: 
• If the type used to declare 
[[vertex_id]]
 is 
uint
, the type used to declare 
[[base_vertex]] 
must be 
uint
 or 
ushort

• If the type used to declare 
[[vertex_id]]
 is 
ushort
, the type used to declare 
[[base_vertex]] 
must be 
ushort

• If the type used to declare 
[[instance_id]]
 is 
uint
, the type used to declare 
[[base_instance]] 
must be uint or 
ushort

• If the type used to declare [[instance_id]] is ushort, the type used to declare 
[[base_instance]]must be ushort. 
4.3.4.2  
Post-Tessellation Vertex Function Input Attribute
Table 10 lists the built-in attributes that can be specified for arguments to a post-tessellation 
vertex function and the corresponding data types with which they can be used. 
Table 10 Attributes for Post-Tessellation Vertex Function Input Arguments 
Attribute
Corresponding Data 
Types
Description
[[vertex_id]]
ushort
 or 
uint
The per-vertex identifier. The per-
vertex identifier includes the base 
vertex value if one is specified.
[[instance_id]]
ushort
 or 
uint
The per-instance identifier. The per-
instance identifier includes the base 
instance value if one is specified.
[[base_vertex]]
ushort
 or 
uint
The base vertex value added to each 
vertex identifier before reading per-
vertex data.
[[base_instance]]
ushort
 or 
uint
The base instance value added to 
each instance identifier before 
reading per-instance data.
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page    of  
68
174


Notes on vertex function input attributes: 
• If the type used to declare 
[[instance_id]]
 is 
uint
, the type used to declare 
[[base_instance]] 
must be 
uint
 or 
ushort

• If the type used to declare 
[[instance_id]]
 is 
ushort
, the type used to declare 
[[base_instance]]
 must be 
ushort

4.3.4.3  
Vertex Function Output Attribute
Table 11 lists the built-in attributes that can be specified for a return type of a vertex function or 
the members of a struct that are returned by a vertex function (and the corresponding data 
types with which they can be used). 
Table 11 Attributes for Vertex Function Return Type 
Attribute
Corresponding Data 
Types
Description
[[patch_id]]
ushort
 or 
uint
The patch identifier. 
[[instance_id]]
ushort
 or 
uint
The per-instance identifier. The per-
instance identifier includes the base 
instance value if one is specified.
[[base_instance]]
ushort
 or 
uint
The base instance value added to 
each instance identifier before 
reading per-instance data.
[[position_in_patch]] float2
 or 
float3
Defines the location on the patch 
being evaluated. For quad patches, 
must be 
float2
. For triangle 
patches, must be 
float3
.
Attribute
Corresponding Data Types
[[clip_distance]]
float
 or 
float[n]
 
n
 must be known at compile time
[[point_size]]
float
[[position]]
float4
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page    of  
69
174


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


Yüklə 4,82 Kb.

Dostları ilə paylaş:
1   ...   18   19   20   21   22   23   24   25   ...   51




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə