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
//! 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::*;
/// Common counters that, when present, are expected to have similar meanings across
/// different implementations.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounter?language=objc)
// NS_TYPED_ENUM
pub type MTLCommonCounter = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertimestamp?language=objc)
pub static MTLCommonCounterTimestamp: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertessellationinputpatches?language=objc)
pub static MTLCommonCounterTessellationInputPatches: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountervertexinvocations?language=objc)
pub static MTLCommonCounterVertexInvocations: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterposttessellationvertexinvocations?language=objc)
pub static MTLCommonCounterPostTessellationVertexInvocations: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterclipperinvocations?language=objc)
pub static MTLCommonCounterClipperInvocations: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterclipperprimitivesout?language=objc)
pub static MTLCommonCounterClipperPrimitivesOut: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentinvocations?language=objc)
pub static MTLCommonCounterFragmentInvocations: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentspassed?language=objc)
pub static MTLCommonCounterFragmentsPassed: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountercomputekernelinvocations?language=objc)
pub static MTLCommonCounterComputeKernelInvocations: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertotalcycles?language=objc)
pub static MTLCommonCounterTotalCycles: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountervertexcycles?language=objc)
pub static MTLCommonCounterVertexCycles: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertessellationcycles?language=objc)
pub static MTLCommonCounterTessellationCycles: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterposttessellationvertexcycles?language=objc)
pub static MTLCommonCounterPostTessellationVertexCycles: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentcycles?language=objc)
pub static MTLCommonCounterFragmentCycles: &'static MTLCommonCounter;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterrendertargetwritecycles?language=objc)
pub static MTLCommonCounterRenderTargetWriteCycles: &'static MTLCommonCounter;
}
/// Common counter set names.
///
/// Each of these common counter sets has a defined structure type. Implementations
/// may omit some of the counters from these sets.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterset?language=objc)
// NS_TYPED_ENUM
pub type MTLCommonCounterSet = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersettimestamp?language=objc)
pub static MTLCommonCounterSetTimestamp: &'static MTLCommonCounterSet;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersetstageutilization?language=objc)
pub static MTLCommonCounterSetStageUtilization: &'static MTLCommonCounterSet;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersetstatistic?language=objc)
pub static MTLCommonCounterSetStatistic: &'static MTLCommonCounterSet;
}
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresulttimestamp?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MTLCounterResultTimestamp {
pub timestamp: u64,
}
unsafe impl Encode for MTLCounterResultTimestamp {
const ENCODING: Encoding = Encoding::Struct("?", &[<u64>::ENCODING]);
}
unsafe impl RefEncode for MTLCounterResultTimestamp {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresultstageutilization?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MTLCounterResultStageUtilization {
pub totalCycles: u64,
pub vertexCycles: u64,
pub tessellationCycles: u64,
pub postTessellationVertexCycles: u64,
pub fragmentCycles: u64,
pub renderTargetCycles: u64,
}
unsafe impl Encode for MTLCounterResultStageUtilization {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
],
);
}
unsafe impl RefEncode for MTLCounterResultStageUtilization {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresultstatistic?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MTLCounterResultStatistic {
pub tessellationInputPatches: u64,
pub vertexInvocations: u64,
pub postTessellationVertexInvocations: u64,
pub clipperInvocations: u64,
pub clipperPrimitivesOut: u64,
pub fragmentInvocations: u64,
pub fragmentsPassed: u64,
pub computeKernelInvocations: u64,
}
unsafe impl Encode for MTLCounterResultStatistic {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
<u64>::ENCODING,
],
);
}
unsafe impl RefEncode for MTLCounterResultStatistic {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// A descriptor for a single counter.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounter?language=objc)
pub unsafe trait MTLCounter: NSObjectProtocol + Send + Sync {
#[unsafe(method(name))]
#[unsafe(method_family = none)]
fn name(&self) -> Retained<NSString>;
}
);
extern_protocol!(
/// A collection of MTLCounters that the device can capture in
/// a single pass.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterset?language=objc)
pub unsafe trait MTLCounterSet: NSObjectProtocol + Send + Sync {
#[unsafe(method(name))]
#[unsafe(method_family = none)]
fn name(&self) -> Retained<NSString>;
/// The counters array contains all the counters that will be written
/// when a counter sample is collected. Counters that do not appear in this array
/// will not be written to the resolved buffer when the samples are resolved, even if
/// they appear in the corresponding resolved counter structure. Instead
/// MTLCounterErrorValue will be written in the resolved buffer.
#[unsafe(method(counters))]
#[unsafe(method_family = none)]
fn counters(&self) -> Retained<NSArray<ProtocolObject<dyn MTLCounter>>>;
}
);
extern_class!(
/// Object to represent the counter state.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebufferdescriptor?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLCounterSampleBufferDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTLCounterSampleBufferDescriptor {}
);
unsafe impl CopyingHelper for MTLCounterSampleBufferDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTLCounterSampleBufferDescriptor {}
);
impl MTLCounterSampleBufferDescriptor {
extern_methods!(
#[unsafe(method(counterSet))]
#[unsafe(method_family = none)]
pub fn counterSet(&self) -> Option<Retained<ProtocolObject<dyn MTLCounterSet>>>;
/// Setter for [`counterSet`][Self::counterSet].
#[unsafe(method(setCounterSet:))]
#[unsafe(method_family = none)]
pub fn setCounterSet(&self, counter_set: Option<&ProtocolObject<dyn MTLCounterSet>>);
#[unsafe(method(label))]
#[unsafe(method_family = none)]
pub fn label(&self) -> Retained<NSString>;
/// Setter for [`label`][Self::label].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setLabel:))]
#[unsafe(method_family = none)]
pub fn setLabel(&self, label: &NSString);
#[cfg(feature = "MTLResource")]
/// MTLStorageModeShared and MTLStorageModePrivate may be used.
#[unsafe(method(storageMode))]
#[unsafe(method_family = none)]
pub fn storageMode(&self) -> MTLStorageMode;
#[cfg(feature = "MTLResource")]
/// Setter for [`storageMode`][Self::storageMode].
#[unsafe(method(setStorageMode:))]
#[unsafe(method_family = none)]
pub fn setStorageMode(&self, storage_mode: MTLStorageMode);
/// counter sample buffer.
#[unsafe(method(sampleCount))]
#[unsafe(method_family = none)]
pub fn sampleCount(&self) -> NSUInteger;
/// Setter for [`sampleCount`][Self::sampleCount].
///
/// # Safety
///
/// This might not be bounds-checked.
#[unsafe(method(setSampleCount:))]
#[unsafe(method_family = none)]
pub unsafe fn setSampleCount(&self, sample_count: NSUInteger);
);
}
/// Methods declared on superclass `NSObject`.
impl MTLCounterSampleBufferDescriptor {
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 MTLCounterSampleBufferDescriptor {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_protocol!(
/// The Counter Sample Buffer contains opaque counter samples as well
/// as state needed to request a sample from the API.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebuffer?language=objc)
pub unsafe trait MTLCounterSampleBuffer: NSObjectProtocol {
#[cfg(feature = "MTLDevice")]
/// to use the sample buffer with this device.
#[unsafe(method(device))]
#[unsafe(method_family = none)]
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
/// property of the descriptor that is used to create the sample buffer.
#[unsafe(method(label))]
#[unsafe(method_family = none)]
fn label(&self) -> Retained<NSString>;
#[unsafe(method(sampleCount))]
#[unsafe(method_family = none)]
fn sampleCount(&self) -> NSUInteger;
/// Resolve the counters from the sample buffer to an NSData containing
/// the counter values. This may only be used with sample buffers that have
/// MTLStorageModeShared.
///
/// Parameter `range`: The range of indices in the sample buffer to resolve.
///
/// Returns: The resolved samples.
///
/// Samples that encountered an error during resolve will be set to
/// MTLCounterErrorValue.
///
/// # Safety
///
/// `range` might not be bounds-checked.
#[unsafe(method(resolveCounterRange:))]
#[unsafe(method_family = none)]
unsafe fn resolveCounterRange(&self, range: NSRange) -> Option<Retained<NSData>>;
}
);
extern "C" {
/// NSErrors raised when creating a counter sample buffer.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountererrordomain?language=objc)
pub static MTLCounterErrorDomain: &'static NSErrorDomain;
}
/// There wasn't enough memory available to allocate the counter sample buffer.
///
///
/// Invalid parameter passed while creating counter sample buffer.
///
///
/// There was some other error in allocating the counter sample buffer.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebuffererror?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLCounterSampleBufferError(pub NSInteger);
impl MTLCounterSampleBufferError {
#[doc(alias = "MTLCounterSampleBufferErrorOutOfMemory")]
pub const OutOfMemory: Self = Self(0);
#[doc(alias = "MTLCounterSampleBufferErrorInvalid")]
pub const Invalid: Self = Self(1);
#[doc(alias = "MTLCounterSampleBufferErrorInternal")]
pub const Internal: Self = Self(2);
}
unsafe impl Encode for MTLCounterSampleBufferError {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for MTLCounterSampleBufferError {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}