1 module metal.vertexdescriptor;
2 import objc.runtime;
3 
4 version(D_ObjectiveC):
5 extern(Objective-C):
6 
7 
8 enum MTLVertexFormat : uint
9 {
10     ///An invalid vertex format.
11     invalid,
12     ///One unsigned 8-bit value.
13     uchar = 45,
14     ///Two unsigned 8-bit values.
15     uchar2 = 1,
16     ///Three unsigned 8-bit values.
17     uchar3 = 2,
18     ///Four unsigned 8-bit values.
19     uchar4 = 3,
20     ///One signed 8-bit two's complement value.
21     char1 = 46,
22     ///Two signed 8-bit two's complement values.
23     char2 = 4,
24     ///Three signed 8-bit two's complement values.
25     char3 = 5,
26     ///Four signed 8-bit two's complement values.
27     char4 = 6,
28     ///One unsigned normalized 8-bit value.
29     ucharNormalized = 47,
30     ///Two unsigned normalized 8-bit values.
31     uchar2Normalized = 7,
32     ///Three unsigned normalized 8-bit values.
33     uchar3Normalized = 8,
34     ///Four unsigned normalized 8-bit values.
35     uchar4Normalized = 9,
36     ///One signed normalized 8-bit two's complement value.
37     charNormalized = 48,
38     ///Two signed normalized 8-bit two's complement values.
39     char2Normalized = 10,
40     ///Three signed normalized 8-bit two's complement values.
41     char3Normalized = 11,
42     ///Four signed normalized 8-bit two's complement values.
43     char4Normalized = 12,
44     ///One unsigned 16-bit value.
45     ushort1 = 49,
46     ///Two unsigned 16-bit values.
47     ushort2 = 13,
48     ///Three unsigned 16-bit values.
49     ushort3 = 14,
50     ///Four unsigned 16-bit values.
51     ushort4 = 15,
52     ///One signed 16-bit two's complement value.
53     short1 = 50,
54     ///Two signed 16-bit two's complement values.
55     short2 = 16,
56     ///Three signed 16-bit two's complement values.
57     short3 = 17,
58     ///Four signed 16-bit two's complement values.
59     short4 = 18,
60     ///One unsigned normalized 16-bit value.
61     ushortNormalized = 51,
62     ///Two unsigned normalized 16-bit values.
63     ushort2Normalized = 19,
64     ///Three unsigned normalized 16-bit values.
65     ushort3Normalized = 20,
66     ///Four unsigned normalized 16-bit values.
67     ushort4Normalized = 21,
68     ///One signed normalized 16-bit two's complement value.
69     shortNormalized = 52,
70     ///Two signed normalized 16-bit two's complement values.
71     short2Normalized = 22,
72     ///Three signed normalized 16-bit two's complement values.
73     short3Normalized = 23,
74     ///Four signed normalized 16-bit two's complement values.
75     short4Normalized = 24,
76     ///One half-precision floating-point value.
77     half1 = 53,
78     ///Two half-precision floating-point values.
79     half2 = 25,
80     ///Three half-precision floating-point values.
81     half3 = 26,
82     ///Four half-precision floating-point values.
83     half4 = 27,
84     ///One single-precision floating-point value.
85     float1 = 28,
86     ///Two single-precision floating-point values.
87     float2 = 29,
88     ///Three single-precision floating-point values.
89     float3 = 30,
90     ///Four single-precision floating-point values.
91     float4 = 31,
92     ///One unsigned 32-bit value.
93     uint1 = 36,
94     ///Two unsigned 32-bit values.
95     uint2 = 37,
96     ///Three unsigned 32-bit values.
97     uint3 = 38,
98     ///Four unsigned 32-bit values.
99     uint4 = 39,
100     ///One signed 32-bit two's complement value.
101     int1 = 32,
102     ///Two signed 32-bit two's complement values.
103     int2 = 33,
104     ///Three signed 32-bit two's complement values.
105     int3 = 34,
106     ///Four signed 32-bit two's complement values.
107     int4 = 35,
108     ///One packed 32-bit value with four normalized signed two's complement integer values, arranged as 10 bits, 10 bits, 10 bits, and 2 bits.
109     int1010102Normalized = 40,
110     ///One packed 32-bit value with four normalized unsigned integer values, arranged as 10 bits, 10 bits, 10 bits, and 2 bits.
111     uint1010102Normalized = 41,
112     ///Four unsigned normalized 8-bit values, arranged as blue, green, red, and alpha components.
113     uchar4Normalized_bgra = 42,
114 }
115 
116 
117 ///An object that determines how to store attribute data in memory and map it to the arguments of a vertex function.
118 extern class MTLVertexAttributeDescriptor : NSObject
119 {
120     ///The format of the vertex attribute.
121     @selector("format")
122     MTLVertexFormat format();
123 
124     @selector("setFormat:")
125     MTLVertexFormat format(MTLVertexFormat);
126 
127     ///The location of an attribute in vertex data, determined by the byte offset from the start of the vertex data.
128     @selector("offset")
129     NSUInteger offset();
130     @selector("setOffset:")
131     NSUInteger offset(NSUInteger);
132 
133     ///The index in the argument table for the associated vertex buffer.
134     @selector("bufferIndex")
135     NSUInteger bufferIndex();
136     @selector("setBufferIndex:")
137     NSUInteger bufferIndex(NSUInteger);
138 }
139 
140 extern class MTLVertexAttributeDescriptorArray : NSObject
141 {
142     ///Returns the state of the specified vertex attribute.
143     @selector("objectAtIndexedSubscript:")
144     MTLVertexAttributeDescriptor objectAtIndexedSubscript(NSUInteger index);
145 
146     ///Sets state for the specified vertex attribute.
147     @selector("setObject:atIndexedSubscript:")
148     void setObjectAtIndexedSubscript(MTLVertexAttributeDescriptor descriptor, NSUInteger index);
149 
150     extern(D) final MTLVertexAttributeDescriptor opIndex(NSUInteger index)
151     {
152         return objectAtIndexedSubscript(index);
153     }
154     extern(D) final void opIndexAssign(MTLVertexAttributeDescriptor v, NSUInteger index)
155     {
156         setObjectAtIndexedSubscript(v, index);
157     }
158 }
159 
160 ///The frequency with which the vertex function or post-tessellation vertex function fetches attribute data.
161 enum MTLVertexStepFunction : NSUInteger
162 {
163     ///The vertex function fetches attribute data once and uses that data for every vertex.
164     Constant = 0,
165     ///The vertex function fetches and uses new attribute data for every vertex.
166     PerVertex = 1,
167     ///The vertex function regularly fetches new attribute data for a number of instances that is determined by stepRate.
168     PerInstance = 2,
169     ///The post-tessellation vertex function fetches data based on the patch index of the patch.
170     PerPatch = 3,
171     ///The post-tessellation vertex function fetches data based on the control-point indices associated with the patch.
172     PerPatchControlPoint = 4
173 }
174 
175 ///An object that configures how a render pipeline fetches data to send to the vertex function.
176 extern class MTLVertexBufferLayoutDescriptor : NSObject
177 {
178     ///The circumstances under which the vertex and its attributes are presented to the vertex function.
179     @selector("stepFunction")
180     MTLVertexStepFunction stepFunction();
181     @selector("setStepFunction:")
182     MTLVertexStepFunction stepFunction(MTLVertexStepFunction);
183 
184     ///The interval at which the vertex and its attributes are presented to the vertex function.
185     @selector("stepRate")
186     NSUInteger stepRate();
187     @selector("setStepRate:")
188     NSUInteger stepRate(NSUInteger);
189 
190     ///The distance, in bytes, between the attribute data of two vertices in the buffer.
191     @selector("stride")
192     NSUInteger stride();
193     @selector("setStride:")
194     NSUInteger stride(NSUInteger);
195 }
196 
197 extern class MTLVertexBufferLayoutDescriptorArray : NSObject
198 {
199     ///Returns the state of the specified vertex buffer layout.
200     @selector("objectAtIndexedSubscript:")
201     MTLVertexBufferLayoutDescriptor objectAtIndexedSubscript(NSUInteger index);
202 
203     ///Sets the state of the specified vertex buffer layout.
204     @selector("setObject:atIndexedSubscript:")
205     void setObjectAtIndexedSubscript(MTLVertexBufferLayoutDescriptor bufferDesc, NSUInteger index);
206 
207     extern(D) final MTLVertexBufferLayoutDescriptor opIndex(NSUInteger index)
208     {
209         return objectAtIndexedSubscript(index);       
210     }
211     extern(D) final void opIndexAssign(MTLVertexBufferLayoutDescriptor value, NSUInteger index)
212     {
213         setObjectAtIndexedSubscript(value, index);
214     }
215 }
216 
217 extern class MTLVertexDescriptor : NSObject
218 {
219     ///Creates and returns a new vertex descriptor.
220     static MTLVertexDescriptor vertexDescriptor() @selector("vertexDescriptor");
221     ///Resets the default state for the vertex descriptor.
222     void reset() @selector("reset");
223 
224     ///An array of state data that describes how vertex attribute data is stored in memory and is mapped to arguments for a vertex shader function.
225     MTLVertexAttributeDescriptorArray attributes() @selector("attributes");
226 
227     ///An array of state data that describes how data are fetched by a vertex shader function when rendering primitives.
228     MTLVertexBufferLayoutDescriptorArray layouts() @selector("layouts");
229 }