objc2-metal 0.3.2

Bindings to the Metal framework
Documentation
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlattributeformat?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLAttributeFormat(pub NSUInteger);
impl MTLAttributeFormat {
    #[doc(alias = "MTLAttributeFormatInvalid")]
    pub const Invalid: Self = Self(0);
    #[doc(alias = "MTLAttributeFormatUChar2")]
    pub const UChar2: Self = Self(1);
    #[doc(alias = "MTLAttributeFormatUChar3")]
    pub const UChar3: Self = Self(2);
    #[doc(alias = "MTLAttributeFormatUChar4")]
    pub const UChar4: Self = Self(3);
    #[doc(alias = "MTLAttributeFormatChar2")]
    pub const Char2: Self = Self(4);
    #[doc(alias = "MTLAttributeFormatChar3")]
    pub const Char3: Self = Self(5);
    #[doc(alias = "MTLAttributeFormatChar4")]
    pub const Char4: Self = Self(6);
    #[doc(alias = "MTLAttributeFormatUChar2Normalized")]
    pub const UChar2Normalized: Self = Self(7);
    #[doc(alias = "MTLAttributeFormatUChar3Normalized")]
    pub const UChar3Normalized: Self = Self(8);
    #[doc(alias = "MTLAttributeFormatUChar4Normalized")]
    pub const UChar4Normalized: Self = Self(9);
    #[doc(alias = "MTLAttributeFormatChar2Normalized")]
    pub const Char2Normalized: Self = Self(10);
    #[doc(alias = "MTLAttributeFormatChar3Normalized")]
    pub const Char3Normalized: Self = Self(11);
    #[doc(alias = "MTLAttributeFormatChar4Normalized")]
    pub const Char4Normalized: Self = Self(12);
    #[doc(alias = "MTLAttributeFormatUShort2")]
    pub const UShort2: Self = Self(13);
    #[doc(alias = "MTLAttributeFormatUShort3")]
    pub const UShort3: Self = Self(14);
    #[doc(alias = "MTLAttributeFormatUShort4")]
    pub const UShort4: Self = Self(15);
    #[doc(alias = "MTLAttributeFormatShort2")]
    pub const Short2: Self = Self(16);
    #[doc(alias = "MTLAttributeFormatShort3")]
    pub const Short3: Self = Self(17);
    #[doc(alias = "MTLAttributeFormatShort4")]
    pub const Short4: Self = Self(18);
    #[doc(alias = "MTLAttributeFormatUShort2Normalized")]
    pub const UShort2Normalized: Self = Self(19);
    #[doc(alias = "MTLAttributeFormatUShort3Normalized")]
    pub const UShort3Normalized: Self = Self(20);
    #[doc(alias = "MTLAttributeFormatUShort4Normalized")]
    pub const UShort4Normalized: Self = Self(21);
    #[doc(alias = "MTLAttributeFormatShort2Normalized")]
    pub const Short2Normalized: Self = Self(22);
    #[doc(alias = "MTLAttributeFormatShort3Normalized")]
    pub const Short3Normalized: Self = Self(23);
    #[doc(alias = "MTLAttributeFormatShort4Normalized")]
    pub const Short4Normalized: Self = Self(24);
    #[doc(alias = "MTLAttributeFormatHalf2")]
    pub const Half2: Self = Self(25);
    #[doc(alias = "MTLAttributeFormatHalf3")]
    pub const Half3: Self = Self(26);
    #[doc(alias = "MTLAttributeFormatHalf4")]
    pub const Half4: Self = Self(27);
    #[doc(alias = "MTLAttributeFormatFloat")]
    pub const Float: Self = Self(28);
    #[doc(alias = "MTLAttributeFormatFloat2")]
    pub const Float2: Self = Self(29);
    #[doc(alias = "MTLAttributeFormatFloat3")]
    pub const Float3: Self = Self(30);
    #[doc(alias = "MTLAttributeFormatFloat4")]
    pub const Float4: Self = Self(31);
    #[doc(alias = "MTLAttributeFormatInt")]
    pub const Int: Self = Self(32);
    #[doc(alias = "MTLAttributeFormatInt2")]
    pub const Int2: Self = Self(33);
    #[doc(alias = "MTLAttributeFormatInt3")]
    pub const Int3: Self = Self(34);
    #[doc(alias = "MTLAttributeFormatInt4")]
    pub const Int4: Self = Self(35);
    #[doc(alias = "MTLAttributeFormatUInt")]
    pub const UInt: Self = Self(36);
    #[doc(alias = "MTLAttributeFormatUInt2")]
    pub const UInt2: Self = Self(37);
    #[doc(alias = "MTLAttributeFormatUInt3")]
    pub const UInt3: Self = Self(38);
    #[doc(alias = "MTLAttributeFormatUInt4")]
    pub const UInt4: Self = Self(39);
    #[doc(alias = "MTLAttributeFormatInt1010102Normalized")]
    pub const Int1010102Normalized: Self = Self(40);
    #[doc(alias = "MTLAttributeFormatUInt1010102Normalized")]
    pub const UInt1010102Normalized: Self = Self(41);
    #[doc(alias = "MTLAttributeFormatUChar4Normalized_BGRA")]
    pub const UChar4Normalized_BGRA: Self = Self(42);
    #[doc(alias = "MTLAttributeFormatUChar")]
    pub const UChar: Self = Self(45);
    #[doc(alias = "MTLAttributeFormatChar")]
    pub const Char: Self = Self(46);
    #[doc(alias = "MTLAttributeFormatUCharNormalized")]
    pub const UCharNormalized: Self = Self(47);
    #[doc(alias = "MTLAttributeFormatCharNormalized")]
    pub const CharNormalized: Self = Self(48);
    #[doc(alias = "MTLAttributeFormatUShort")]
    pub const UShort: Self = Self(49);
    #[doc(alias = "MTLAttributeFormatShort")]
    pub const Short: Self = Self(50);
    #[doc(alias = "MTLAttributeFormatUShortNormalized")]
    pub const UShortNormalized: Self = Self(51);
    #[doc(alias = "MTLAttributeFormatShortNormalized")]
    pub const ShortNormalized: Self = Self(52);
    #[doc(alias = "MTLAttributeFormatHalf")]
    pub const Half: Self = Self(53);
    #[doc(alias = "MTLAttributeFormatFloatRG11B10")]
    pub const FloatRG11B10: Self = Self(54);
    #[doc(alias = "MTLAttributeFormatFloatRGB9E5")]
    pub const FloatRGB9E5: Self = Self(55);
}

unsafe impl Encode for MTLAttributeFormat {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLAttributeFormat {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstepfunction?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLStepFunction(pub NSUInteger);
impl MTLStepFunction {
    #[doc(alias = "MTLStepFunctionConstant")]
    pub const Constant: Self = Self(0);
    #[doc(alias = "MTLStepFunctionPerVertex")]
    pub const PerVertex: Self = Self(1);
    #[doc(alias = "MTLStepFunctionPerInstance")]
    pub const PerInstance: Self = Self(2);
    #[doc(alias = "MTLStepFunctionPerPatch")]
    pub const PerPatch: Self = Self(3);
    #[doc(alias = "MTLStepFunctionPerPatchControlPoint")]
    pub const PerPatchControlPoint: Self = Self(4);
    #[doc(alias = "MTLStepFunctionThreadPositionInGridX")]
    pub const ThreadPositionInGridX: Self = Self(5);
    #[doc(alias = "MTLStepFunctionThreadPositionInGridY")]
    pub const ThreadPositionInGridY: Self = Self(6);
    #[doc(alias = "MTLStepFunctionThreadPositionInGridXIndexed")]
    pub const ThreadPositionInGridXIndexed: Self = Self(7);
    #[doc(alias = "MTLStepFunctionThreadPositionInGridYIndexed")]
    pub const ThreadPositionInGridYIndexed: Self = Self(8);
}

unsafe impl Encode for MTLStepFunction {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLStepFunction {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlbufferlayoutdescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLBufferLayoutDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTLBufferLayoutDescriptor {}
);

unsafe impl CopyingHelper for MTLBufferLayoutDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLBufferLayoutDescriptor {}
);

impl MTLBufferLayoutDescriptor {
    extern_methods!(
        #[unsafe(method(stride))]
        #[unsafe(method_family = none)]
        pub fn stride(&self) -> NSUInteger;

        /// Setter for [`stride`][Self::stride].
        #[unsafe(method(setStride:))]
        #[unsafe(method_family = none)]
        pub fn setStride(&self, stride: NSUInteger);

        #[unsafe(method(stepFunction))]
        #[unsafe(method_family = none)]
        pub fn stepFunction(&self) -> MTLStepFunction;

        /// Setter for [`stepFunction`][Self::stepFunction].
        #[unsafe(method(setStepFunction:))]
        #[unsafe(method_family = none)]
        pub fn setStepFunction(&self, step_function: MTLStepFunction);

        #[unsafe(method(stepRate))]
        #[unsafe(method_family = none)]
        pub fn stepRate(&self) -> NSUInteger;

        /// Setter for [`stepRate`][Self::stepRate].
        #[unsafe(method(setStepRate:))]
        #[unsafe(method_family = none)]
        pub fn setStepRate(&self, step_rate: NSUInteger);
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLBufferLayoutDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLBufferLayoutDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlbufferlayoutdescriptorarray?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLBufferLayoutDescriptorArray;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLBufferLayoutDescriptorArray {}
);

impl MTLBufferLayoutDescriptorArray {
    extern_methods!(
        /// # Safety
        ///
        /// `index` might not be bounds-checked.
        #[unsafe(method(objectAtIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectAtIndexedSubscript(
            &self,
            index: NSUInteger,
        ) -> Retained<MTLBufferLayoutDescriptor>;

        /// # Safety
        ///
        /// `index` might not be bounds-checked.
        #[unsafe(method(setObject:atIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObject_atIndexedSubscript(
            &self,
            buffer_desc: Option<&MTLBufferLayoutDescriptor>,
            index: NSUInteger,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLBufferLayoutDescriptorArray {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLBufferLayoutDescriptorArray {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlattributedescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLAttributeDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTLAttributeDescriptor {}
);

unsafe impl CopyingHelper for MTLAttributeDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLAttributeDescriptor {}
);

impl MTLAttributeDescriptor {
    extern_methods!(
        #[unsafe(method(format))]
        #[unsafe(method_family = none)]
        pub fn format(&self) -> MTLAttributeFormat;

        /// Setter for [`format`][Self::format].
        #[unsafe(method(setFormat:))]
        #[unsafe(method_family = none)]
        pub fn setFormat(&self, format: MTLAttributeFormat);

        #[unsafe(method(offset))]
        #[unsafe(method_family = none)]
        pub fn offset(&self) -> NSUInteger;

        /// Setter for [`offset`][Self::offset].
        #[unsafe(method(setOffset:))]
        #[unsafe(method_family = none)]
        pub fn setOffset(&self, offset: NSUInteger);

        #[unsafe(method(bufferIndex))]
        #[unsafe(method_family = none)]
        pub fn bufferIndex(&self) -> NSUInteger;

        /// Setter for [`bufferIndex`][Self::bufferIndex].
        ///
        /// # Safety
        ///
        /// This might not be bounds-checked.
        #[unsafe(method(setBufferIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBufferIndex(&self, buffer_index: NSUInteger);
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLAttributeDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLAttributeDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlattributedescriptorarray?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLAttributeDescriptorArray;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLAttributeDescriptorArray {}
);

impl MTLAttributeDescriptorArray {
    extern_methods!(
        /// # Safety
        ///
        /// `index` might not be bounds-checked.
        #[unsafe(method(objectAtIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectAtIndexedSubscript(
            &self,
            index: NSUInteger,
        ) -> Retained<MTLAttributeDescriptor>;

        /// # Safety
        ///
        /// `index` might not be bounds-checked.
        #[unsafe(method(setObject:atIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObject_atIndexedSubscript(
            &self,
            attribute_desc: Option<&MTLAttributeDescriptor>,
            index: NSUInteger,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLAttributeDescriptorArray {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLAttributeDescriptorArray {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstageinputoutputdescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLStageInputOutputDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTLStageInputOutputDescriptor {}
);

unsafe impl CopyingHelper for MTLStageInputOutputDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLStageInputOutputDescriptor {}
);

impl MTLStageInputOutputDescriptor {
    extern_methods!(
        #[unsafe(method(stageInputOutputDescriptor))]
        #[unsafe(method_family = none)]
        pub fn stageInputOutputDescriptor() -> Retained<MTLStageInputOutputDescriptor>;

        #[unsafe(method(layouts))]
        #[unsafe(method_family = none)]
        pub fn layouts(&self) -> Retained<MTLBufferLayoutDescriptorArray>;

        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub fn attributes(&self) -> Retained<MTLAttributeDescriptorArray>;

        #[cfg(feature = "MTLArgument")]
        #[unsafe(method(indexType))]
        #[unsafe(method_family = none)]
        pub fn indexType(&self) -> MTLIndexType;

        #[cfg(feature = "MTLArgument")]
        /// Setter for [`indexType`][Self::indexType].
        #[unsafe(method(setIndexType:))]
        #[unsafe(method_family = none)]
        pub fn setIndexType(&self, index_type: MTLIndexType);

        #[unsafe(method(indexBufferIndex))]
        #[unsafe(method_family = none)]
        pub fn indexBufferIndex(&self) -> NSUInteger;

        /// Setter for [`indexBufferIndex`][Self::indexBufferIndex].
        ///
        /// # Safety
        ///
        /// This might not be bounds-checked.
        #[unsafe(method(setIndexBufferIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIndexBufferIndex(&self, index_buffer_index: NSUInteger);

        #[unsafe(method(reset))]
        #[unsafe(method_family = none)]
        pub fn reset(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLStageInputOutputDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLStageInputOutputDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}