1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
// Copyright 2016 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use super::NSUInteger;
#[repr(u64)]
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum MTLVertexFormat {
Invalid = 0,
UChar2 = 1,
UChar3 = 2,
UChar4 = 3,
Char2 = 4,
Char3 = 5,
Char4 = 6,
UChar2Normalized = 7,
UChar3Normalized = 8,
UChar4Normalized = 9,
Char2Normalized = 10,
Char3Normalized = 11,
Char4Normalized = 12,
UShort2 = 13,
UShort3 = 14,
UShort4 = 15,
Short2 = 16,
Short3 = 17,
Short4 = 18,
UShort2Normalized = 19,
UShort3Normalized = 20,
UShort4Normalized = 21,
Short2Normalized = 22,
Short3Normalized = 23,
Short4Normalized = 24,
Half2 = 25,
Half3 = 26,
Half4 = 27,
Float = 28,
Float2 = 29,
Float3 = 30,
Float4 = 31,
Int = 32,
Int2 = 33,
Int3 = 34,
Int4 = 35,
UInt = 36,
UInt2 = 37,
UInt3 = 38,
UInt4 = 39,
Int1010102Normalized = 40,
UInt1010102Normalized = 41,
UChar4Normalized_BGRA = 42,
UChar = 45,
Char = 46,
UCharNormalized = 47,
CharNormalized = 48,
UShort = 49,
Short = 50,
UShortNormalized = 51,
ShortNormalized = 52,
Half = 53,
}
#[repr(u64)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum MTLVertexStepFunction {
Constant = 0,
PerVertex = 1,
PerInstance = 2,
PerPatch = 3,
PerPatchControlPoint = 4,
}
pub enum MTLVertexBufferLayoutDescriptor {}
foreign_obj_type! {
type CType = MTLVertexBufferLayoutDescriptor;
pub struct VertexBufferLayoutDescriptor;
pub struct VertexBufferLayoutDescriptorRef;
}
impl VertexBufferLayoutDescriptor {
pub fn new() -> Self {
unsafe {
let class = class!(MTLVertexBufferLayoutDescriptor);
msg_send![class, new]
}
}
}
impl VertexBufferLayoutDescriptorRef {
pub fn stride(&self) -> NSUInteger {
unsafe { msg_send![self, stride] }
}
pub fn set_stride(&self, stride: NSUInteger) {
unsafe { msg_send![self, setStride: stride] }
}
pub fn step_function(&self) -> MTLVertexStepFunction {
unsafe { msg_send![self, stepFunction] }
}
pub fn set_step_function(&self, func: MTLVertexStepFunction) {
unsafe { msg_send![self, setStepFunction: func] }
}
pub fn step_rate(&self) -> NSUInteger {
unsafe { msg_send![self, stepRate] }
}
pub fn set_step_rate(&self, step_rate: NSUInteger) {
unsafe { msg_send![self, setStepRate: step_rate] }
}
}
pub enum MTLVertexBufferLayoutDescriptorArray {}
foreign_obj_type! {
type CType = MTLVertexBufferLayoutDescriptorArray;
pub struct VertexBufferLayoutDescriptorArray;
pub struct VertexBufferLayoutDescriptorArrayRef;
}
impl VertexBufferLayoutDescriptorArrayRef {
pub fn object_at(&self, index: NSUInteger) -> Option<&VertexBufferLayoutDescriptorRef> {
unsafe { msg_send![self, objectAtIndexedSubscript: index] }
}
pub fn set_object_at(
&self,
index: NSUInteger,
layout: Option<&VertexBufferLayoutDescriptorRef>,
) {
unsafe {
msg_send![self, setObject:layout
atIndexedSubscript:index]
}
}
}
pub enum MTLVertexAttributeDescriptor {}
foreign_obj_type! {
type CType = MTLVertexAttributeDescriptor;
pub struct VertexAttributeDescriptor;
pub struct VertexAttributeDescriptorRef;
}
impl VertexAttributeDescriptor {
pub fn new() -> Self {
unsafe {
let class = class!(MTLVertexAttributeDescriptor);
msg_send![class, new]
}
}
}
impl VertexAttributeDescriptorRef {
pub fn format(&self) -> MTLVertexFormat {
unsafe { msg_send![self, format] }
}
pub fn set_format(&self, format: MTLVertexFormat) {
unsafe { msg_send![self, setFormat: format] }
}
pub fn offset(&self) -> NSUInteger {
unsafe { msg_send![self, offset] }
}
pub fn set_offset(&self, offset: NSUInteger) {
unsafe { msg_send![self, setOffset: offset] }
}
pub fn buffer_index(&self) -> NSUInteger {
unsafe { msg_send![self, bufferIndex] }
}
pub fn set_buffer_index(&self, index: NSUInteger) {
unsafe { msg_send![self, setBufferIndex: index] }
}
}
pub enum MTLVertexAttributeDescriptorArray {}
foreign_obj_type! {
type CType = MTLVertexAttributeDescriptorArray;
pub struct VertexAttributeDescriptorArray;
pub struct VertexAttributeDescriptorArrayRef;
}
impl VertexAttributeDescriptorArrayRef {
pub fn object_at(&self, index: NSUInteger) -> Option<&VertexAttributeDescriptorRef> {
unsafe { msg_send![self, objectAtIndexedSubscript: index] }
}
pub fn set_object_at(
&self,
index: NSUInteger,
attribute: Option<&VertexAttributeDescriptorRef>,
) {
unsafe {
msg_send![self, setObject:attribute
atIndexedSubscript:index]
}
}
}
pub enum MTLVertexDescriptor {}
foreign_obj_type! {
type CType = MTLVertexDescriptor;
pub struct VertexDescriptor;
pub struct VertexDescriptorRef;
}
impl VertexDescriptor {
pub fn new<'a>() -> &'a VertexDescriptorRef {
unsafe {
let class = class!(MTLVertexDescriptor);
msg_send![class, vertexDescriptor]
}
}
}
impl VertexDescriptorRef {
pub fn layouts(&self) -> &VertexBufferLayoutDescriptorArrayRef {
unsafe { msg_send![self, layouts] }
}
pub fn attributes(&self) -> &VertexAttributeDescriptorArrayRef {
unsafe { msg_send![self, attributes] }
}
#[cfg(feature = "private")]
pub unsafe fn serialize_descriptor(&self) -> *mut std::ffi::c_void {
msg_send![self, newSerializedDescriptor]
}
pub fn reset(&self) {
unsafe { msg_send![self, reset] }
}
}
|