objc2_metal/generated/
MTLCounters.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Common counters that, when present, are expected to have similar meanings across
11/// different implementations.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounter?language=objc)
14// NS_TYPED_ENUM
15pub type MTLCommonCounter = NSString;
16
17extern "C" {
18    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertimestamp?language=objc)
19    pub static MTLCommonCounterTimestamp: &'static MTLCommonCounter;
20}
21
22extern "C" {
23    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertessellationinputpatches?language=objc)
24    pub static MTLCommonCounterTessellationInputPatches: &'static MTLCommonCounter;
25}
26
27extern "C" {
28    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountervertexinvocations?language=objc)
29    pub static MTLCommonCounterVertexInvocations: &'static MTLCommonCounter;
30}
31
32extern "C" {
33    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterposttessellationvertexinvocations?language=objc)
34    pub static MTLCommonCounterPostTessellationVertexInvocations: &'static MTLCommonCounter;
35}
36
37extern "C" {
38    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterclipperinvocations?language=objc)
39    pub static MTLCommonCounterClipperInvocations: &'static MTLCommonCounter;
40}
41
42extern "C" {
43    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterclipperprimitivesout?language=objc)
44    pub static MTLCommonCounterClipperPrimitivesOut: &'static MTLCommonCounter;
45}
46
47extern "C" {
48    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentinvocations?language=objc)
49    pub static MTLCommonCounterFragmentInvocations: &'static MTLCommonCounter;
50}
51
52extern "C" {
53    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentspassed?language=objc)
54    pub static MTLCommonCounterFragmentsPassed: &'static MTLCommonCounter;
55}
56
57extern "C" {
58    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountercomputekernelinvocations?language=objc)
59    pub static MTLCommonCounterComputeKernelInvocations: &'static MTLCommonCounter;
60}
61
62extern "C" {
63    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertotalcycles?language=objc)
64    pub static MTLCommonCounterTotalCycles: &'static MTLCommonCounter;
65}
66
67extern "C" {
68    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountervertexcycles?language=objc)
69    pub static MTLCommonCounterVertexCycles: &'static MTLCommonCounter;
70}
71
72extern "C" {
73    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountertessellationcycles?language=objc)
74    pub static MTLCommonCounterTessellationCycles: &'static MTLCommonCounter;
75}
76
77extern "C" {
78    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterposttessellationvertexcycles?language=objc)
79    pub static MTLCommonCounterPostTessellationVertexCycles: &'static MTLCommonCounter;
80}
81
82extern "C" {
83    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterfragmentcycles?language=objc)
84    pub static MTLCommonCounterFragmentCycles: &'static MTLCommonCounter;
85}
86
87extern "C" {
88    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterrendertargetwritecycles?language=objc)
89    pub static MTLCommonCounterRenderTargetWriteCycles: &'static MTLCommonCounter;
90}
91
92/// Common counter set names.
93///
94/// Each of these common counter sets has a defined structure type.  Implementations
95/// may omit some of the counters from these sets.
96///
97/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncounterset?language=objc)
98// NS_TYPED_ENUM
99pub type MTLCommonCounterSet = NSString;
100
101extern "C" {
102    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersettimestamp?language=objc)
103    pub static MTLCommonCounterSetTimestamp: &'static MTLCommonCounterSet;
104}
105
106extern "C" {
107    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersetstageutilization?language=objc)
108    pub static MTLCommonCounterSetStageUtilization: &'static MTLCommonCounterSet;
109}
110
111extern "C" {
112    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommoncountersetstatistic?language=objc)
113    pub static MTLCommonCounterSetStatistic: &'static MTLCommonCounterSet;
114}
115
116/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresulttimestamp?language=objc)
117#[repr(C)]
118#[derive(Clone, Copy, Debug, PartialEq)]
119pub struct MTLCounterResultTimestamp {
120    pub timestamp: u64,
121}
122
123unsafe impl Encode for MTLCounterResultTimestamp {
124    const ENCODING: Encoding = Encoding::Struct("?", &[<u64>::ENCODING]);
125}
126
127unsafe impl RefEncode for MTLCounterResultTimestamp {
128    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
129}
130
131/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresultstageutilization?language=objc)
132#[repr(C)]
133#[derive(Clone, Copy, Debug, PartialEq)]
134pub struct MTLCounterResultStageUtilization {
135    pub totalCycles: u64,
136    pub vertexCycles: u64,
137    pub tessellationCycles: u64,
138    pub postTessellationVertexCycles: u64,
139    pub fragmentCycles: u64,
140    pub renderTargetCycles: u64,
141}
142
143unsafe impl Encode for MTLCounterResultStageUtilization {
144    const ENCODING: Encoding = Encoding::Struct(
145        "?",
146        &[
147            <u64>::ENCODING,
148            <u64>::ENCODING,
149            <u64>::ENCODING,
150            <u64>::ENCODING,
151            <u64>::ENCODING,
152            <u64>::ENCODING,
153        ],
154    );
155}
156
157unsafe impl RefEncode for MTLCounterResultStageUtilization {
158    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
159}
160
161/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterresultstatistic?language=objc)
162#[repr(C)]
163#[derive(Clone, Copy, Debug, PartialEq)]
164pub struct MTLCounterResultStatistic {
165    pub tessellationInputPatches: u64,
166    pub vertexInvocations: u64,
167    pub postTessellationVertexInvocations: u64,
168    pub clipperInvocations: u64,
169    pub clipperPrimitivesOut: u64,
170    pub fragmentInvocations: u64,
171    pub fragmentsPassed: u64,
172    pub computeKernelInvocations: u64,
173}
174
175unsafe impl Encode for MTLCounterResultStatistic {
176    const ENCODING: Encoding = Encoding::Struct(
177        "?",
178        &[
179            <u64>::ENCODING,
180            <u64>::ENCODING,
181            <u64>::ENCODING,
182            <u64>::ENCODING,
183            <u64>::ENCODING,
184            <u64>::ENCODING,
185            <u64>::ENCODING,
186            <u64>::ENCODING,
187        ],
188    );
189}
190
191unsafe impl RefEncode for MTLCounterResultStatistic {
192    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
193}
194
195extern_protocol!(
196    /// A descriptor for a single counter.
197    ///
198    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounter?language=objc)
199    pub unsafe trait MTLCounter: NSObjectProtocol + Send + Sync {
200        #[unsafe(method(name))]
201        #[unsafe(method_family = none)]
202        fn name(&self) -> Retained<NSString>;
203    }
204);
205
206extern_protocol!(
207    /// A collection of MTLCounters that the device can capture in
208    /// a single pass.
209    ///
210    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcounterset?language=objc)
211    pub unsafe trait MTLCounterSet: NSObjectProtocol + Send + Sync {
212        #[unsafe(method(name))]
213        #[unsafe(method_family = none)]
214        fn name(&self) -> Retained<NSString>;
215
216        /// The counters array contains all the counters that will be written
217        /// when a counter sample is collected.  Counters that do not appear in this array
218        /// will not be written to the resolved buffer when the samples are resolved, even if
219        /// they appear in the corresponding resolved counter structure.  Instead
220        /// MTLCounterErrorValue will be written in the resolved buffer.
221        #[unsafe(method(counters))]
222        #[unsafe(method_family = none)]
223        fn counters(&self) -> Retained<NSArray<ProtocolObject<dyn MTLCounter>>>;
224    }
225);
226
227extern_class!(
228    /// Object to represent the counter state.
229    ///
230    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebufferdescriptor?language=objc)
231    #[unsafe(super(NSObject))]
232    #[derive(Debug, PartialEq, Eq, Hash)]
233    pub struct MTLCounterSampleBufferDescriptor;
234);
235
236extern_conformance!(
237    unsafe impl NSCopying for MTLCounterSampleBufferDescriptor {}
238);
239
240unsafe impl CopyingHelper for MTLCounterSampleBufferDescriptor {
241    type Result = Self;
242}
243
244extern_conformance!(
245    unsafe impl NSObjectProtocol for MTLCounterSampleBufferDescriptor {}
246);
247
248impl MTLCounterSampleBufferDescriptor {
249    extern_methods!(
250        #[unsafe(method(counterSet))]
251        #[unsafe(method_family = none)]
252        pub fn counterSet(&self) -> Option<Retained<ProtocolObject<dyn MTLCounterSet>>>;
253
254        /// Setter for [`counterSet`][Self::counterSet].
255        #[unsafe(method(setCounterSet:))]
256        #[unsafe(method_family = none)]
257        pub fn setCounterSet(&self, counter_set: Option<&ProtocolObject<dyn MTLCounterSet>>);
258
259        #[unsafe(method(label))]
260        #[unsafe(method_family = none)]
261        pub fn label(&self) -> Retained<NSString>;
262
263        /// Setter for [`label`][Self::label].
264        ///
265        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
266        #[unsafe(method(setLabel:))]
267        #[unsafe(method_family = none)]
268        pub fn setLabel(&self, label: &NSString);
269
270        #[cfg(feature = "MTLResource")]
271        /// MTLStorageModeShared and MTLStorageModePrivate may be used.
272        #[unsafe(method(storageMode))]
273        #[unsafe(method_family = none)]
274        pub fn storageMode(&self) -> MTLStorageMode;
275
276        #[cfg(feature = "MTLResource")]
277        /// Setter for [`storageMode`][Self::storageMode].
278        #[unsafe(method(setStorageMode:))]
279        #[unsafe(method_family = none)]
280        pub fn setStorageMode(&self, storage_mode: MTLStorageMode);
281
282        /// counter sample buffer.
283        #[unsafe(method(sampleCount))]
284        #[unsafe(method_family = none)]
285        pub fn sampleCount(&self) -> NSUInteger;
286
287        /// Setter for [`sampleCount`][Self::sampleCount].
288        ///
289        /// # Safety
290        ///
291        /// This might not be bounds-checked.
292        #[unsafe(method(setSampleCount:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setSampleCount(&self, sample_count: NSUInteger);
295    );
296}
297
298/// Methods declared on superclass `NSObject`.
299impl MTLCounterSampleBufferDescriptor {
300    extern_methods!(
301        #[unsafe(method(init))]
302        #[unsafe(method_family = init)]
303        pub fn init(this: Allocated<Self>) -> Retained<Self>;
304
305        #[unsafe(method(new))]
306        #[unsafe(method_family = new)]
307        pub fn new() -> Retained<Self>;
308    );
309}
310
311impl DefaultRetained for MTLCounterSampleBufferDescriptor {
312    #[inline]
313    fn default_retained() -> Retained<Self> {
314        Self::new()
315    }
316}
317
318extern_protocol!(
319    /// The Counter Sample Buffer contains opaque counter samples as well
320    /// as state needed to request a sample from the API.
321    ///
322    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebuffer?language=objc)
323    pub unsafe trait MTLCounterSampleBuffer: NSObjectProtocol {
324        #[cfg(feature = "MTLDevice")]
325        /// to use the sample buffer with this device.
326        #[unsafe(method(device))]
327        #[unsafe(method_family = none)]
328        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
329
330        /// property of the descriptor that is used to create the sample buffer.
331        #[unsafe(method(label))]
332        #[unsafe(method_family = none)]
333        fn label(&self) -> Retained<NSString>;
334
335        #[unsafe(method(sampleCount))]
336        #[unsafe(method_family = none)]
337        fn sampleCount(&self) -> NSUInteger;
338
339        /// Resolve the counters from the sample buffer to an NSData containing
340        /// the counter values.  This may only be used with sample buffers that have
341        /// MTLStorageModeShared.
342        ///
343        /// Parameter `range`: The range of indices in the sample buffer to resolve.
344        ///
345        /// Returns: The resolved samples.
346        ///
347        /// Samples that encountered an error during resolve will be set to
348        /// MTLCounterErrorValue.
349        ///
350        /// # Safety
351        ///
352        /// `range` might not be bounds-checked.
353        #[unsafe(method(resolveCounterRange:))]
354        #[unsafe(method_family = none)]
355        unsafe fn resolveCounterRange(&self, range: NSRange) -> Option<Retained<NSData>>;
356    }
357);
358
359extern "C" {
360    /// NSErrors raised when creating a counter sample buffer.
361    ///
362    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountererrordomain?language=objc)
363    pub static MTLCounterErrorDomain: &'static NSErrorDomain;
364}
365
366/// There wasn't enough memory available to allocate the counter sample buffer.
367///
368///
369/// Invalid parameter passed while creating counter sample buffer.
370///
371///
372/// There was some other error in allocating the counter sample buffer.
373///
374/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplebuffererror?language=objc)
375// NS_ENUM
376#[repr(transparent)]
377#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
378pub struct MTLCounterSampleBufferError(pub NSInteger);
379impl MTLCounterSampleBufferError {
380    #[doc(alias = "MTLCounterSampleBufferErrorOutOfMemory")]
381    pub const OutOfMemory: Self = Self(0);
382    #[doc(alias = "MTLCounterSampleBufferErrorInvalid")]
383    pub const Invalid: Self = Self(1);
384    #[doc(alias = "MTLCounterSampleBufferErrorInternal")]
385    pub const Internal: Self = Self(2);
386}
387
388unsafe impl Encode for MTLCounterSampleBufferError {
389    const ENCODING: Encoding = NSInteger::ENCODING;
390}
391
392unsafe impl RefEncode for MTLCounterSampleBufferError {
393    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
394}