objc2_metal/generated/
MTLDevice.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-io-surface")]
10use objc2_io_surface::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtliocompressionmethod?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct MTLIOCompressionMethod(pub NSInteger);
19impl MTLIOCompressionMethod {
20    #[doc(alias = "MTLIOCompressionMethodZlib")]
21    pub const Zlib: Self = Self(0);
22    #[doc(alias = "MTLIOCompressionMethodLZFSE")]
23    pub const LZFSE: Self = Self(1);
24    #[doc(alias = "MTLIOCompressionMethodLZ4")]
25    pub const LZ4: Self = Self(2);
26    #[doc(alias = "MTLIOCompressionMethodLZMA")]
27    pub const LZMA: Self = Self(3);
28    #[doc(alias = "MTLIOCompressionMethodLZBitmap")]
29    pub const LZBitmap: Self = Self(4);
30}
31
32unsafe impl Encode for MTLIOCompressionMethod {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for MTLIOCompressionMethod {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// Returns a reference to the preferred system default Metal device.
41///
42/// On Mac OS X systems that support automatic graphics switching, calling
43/// this API to get a Metal device will cause the system to switch to the high power
44/// GPU.  On other systems that support more than one GPU it will return the GPU that
45/// is associated with the main display.
46#[inline]
47pub extern "C-unwind" fn MTLCreateSystemDefaultDevice(
48) -> Option<Retained<ProtocolObject<dyn MTLDevice>>> {
49    extern "C-unwind" {
50        fn MTLCreateSystemDefaultDevice() -> *mut ProtocolObject<dyn MTLDevice>;
51    }
52    let ret = unsafe { MTLCreateSystemDefaultDevice() };
53    unsafe { Retained::from_raw(ret) }
54}
55
56/// Type for device notifications
57///
58/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevicenotificationname?language=objc)
59// NS_TYPED_ENUM
60pub type MTLDeviceNotificationName = NSString;
61
62extern "C" {
63    /// This notification is posted when a new Metal device is added to the system
64    ///
65    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevicewasaddednotification?language=objc)
66    pub static MTLDeviceWasAddedNotification: &'static MTLDeviceNotificationName;
67}
68
69extern "C" {
70    /// This notification is posted when the user has requested that applications cease using a particular device.  Applications
71    /// should assume that the device will be removed (terminated) imminently.  Additionally, the device will be removed from the internal
72    /// device array prior to this notification being posted.  Applications should immediately begin the process of releasing all resources
73    /// created on the given device, as well as any references to the device itself.
74    ///
75    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldeviceremovalrequestednotification?language=objc)
76    pub static MTLDeviceRemovalRequestedNotification: &'static MTLDeviceNotificationName;
77}
78
79extern "C" {
80    /// This notification is posted if the device is removed while there are still outstanding references to it, due to either a surprise
81    /// or forced disconnect by the user.  Applications must expect that any attempt to use the device after this point will fail.
82    ///
83    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevicewasremovednotification?language=objc)
84    pub static MTLDeviceWasRemovedNotification: &'static MTLDeviceNotificationName;
85}
86
87/// Block signature for device notifications
88///
89/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevicenotificationhandler?language=objc)
90#[cfg(feature = "block2")]
91pub type MTLDeviceNotificationHandler = *mut block2::DynBlock<
92    dyn Fn(NonNull<ProtocolObject<dyn MTLDevice>>, NonNull<MTLDeviceNotificationName>),
93>;
94
95/// Returns an NSArray of the current set of available Metal devices and installs a notification handler
96/// to be notified of any further changes (additions, removals, etc.).  The observer return value is retained by Metal and may be
97/// passed to MTLRemoveDeviceObserver() if the application no longer wishes to receive notifications.
98///
99/// Note: The observer out parameter is returned with a +1 retain count in addition to the retain mentioned above.
100///
101/// # Safety
102///
103/// - `observer` must be a valid pointer.
104/// - `handler` must be a valid pointer.
105#[cfg(feature = "block2")]
106#[inline]
107pub unsafe extern "C-unwind" fn MTLCopyAllDevicesWithObserver(
108    observer: NonNull<*mut ProtocolObject<dyn NSObjectProtocol>>,
109    handler: MTLDeviceNotificationHandler,
110) -> Retained<NSArray<ProtocolObject<dyn MTLDevice>>> {
111    extern "C-unwind" {
112        fn MTLCopyAllDevicesWithObserver(
113            observer: NonNull<*mut ProtocolObject<dyn NSObjectProtocol>>,
114            handler: MTLDeviceNotificationHandler,
115        ) -> *mut NSArray<ProtocolObject<dyn MTLDevice>>;
116    }
117    let ret = unsafe { MTLCopyAllDevicesWithObserver(observer, handler) };
118    unsafe { Retained::from_raw(ret) }
119        .expect("function was marked as returning non-null, but actually returned NULL")
120}
121
122extern "C-unwind" {
123    /// Removes a previously installed observer for device change notifications.
124    ///
125    /// # Safety
126    ///
127    /// `observer` should be of the correct type.
128    pub fn MTLRemoveDeviceObserver(observer: &ProtocolObject<dyn NSObjectProtocol>);
129}
130
131/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlfeatureset?language=objc)
132// NS_ENUM
133#[deprecated = "Use MTLGPUFamily instead"]
134#[repr(transparent)]
135#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
136pub struct MTLFeatureSet(pub NSUInteger);
137impl MTLFeatureSet {
138    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily1_v1")]
139    pub const iOS_GPUFamily1_v1: Self = Self(0);
140    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily2_v1")]
141    pub const iOS_GPUFamily2_v1: Self = Self(1);
142    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily1_v2")]
143    pub const iOS_GPUFamily1_v2: Self = Self(2);
144    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily2_v2")]
145    pub const iOS_GPUFamily2_v2: Self = Self(3);
146    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily3_v1")]
147    pub const iOS_GPUFamily3_v1: Self = Self(4);
148    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily1_v3")]
149    pub const iOS_GPUFamily1_v3: Self = Self(5);
150    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily2_v3")]
151    pub const iOS_GPUFamily2_v3: Self = Self(6);
152    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily3_v2")]
153    pub const iOS_GPUFamily3_v2: Self = Self(7);
154    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily1_v4")]
155    pub const iOS_GPUFamily1_v4: Self = Self(8);
156    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily2_v4")]
157    pub const iOS_GPUFamily2_v4: Self = Self(9);
158    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily3_v3")]
159    pub const iOS_GPUFamily3_v3: Self = Self(10);
160    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily4_v1")]
161    pub const iOS_GPUFamily4_v1: Self = Self(11);
162    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily1_v5")]
163    pub const iOS_GPUFamily1_v5: Self = Self(12);
164    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily2_v5")]
165    pub const iOS_GPUFamily2_v5: Self = Self(13);
166    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily3_v4")]
167    pub const iOS_GPUFamily3_v4: Self = Self(14);
168    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily4_v2")]
169    pub const iOS_GPUFamily4_v2: Self = Self(15);
170    #[doc(alias = "MTLFeatureSet_iOS_GPUFamily5_v1")]
171    pub const iOS_GPUFamily5_v1: Self = Self(16);
172    #[doc(alias = "MTLFeatureSet_macOS_GPUFamily1_v1")]
173    pub const macOS_GPUFamily1_v1: Self = Self(10000);
174    #[doc(alias = "MTLFeatureSet_OSX_GPUFamily1_v1")]
175    pub const OSX_GPUFamily1_v1: Self = Self(MTLFeatureSet::macOS_GPUFamily1_v1.0);
176    #[doc(alias = "MTLFeatureSet_macOS_GPUFamily1_v2")]
177    pub const macOS_GPUFamily1_v2: Self = Self(10001);
178    #[doc(alias = "MTLFeatureSet_OSX_GPUFamily1_v2")]
179    pub const OSX_GPUFamily1_v2: Self = Self(MTLFeatureSet::macOS_GPUFamily1_v2.0);
180    #[doc(alias = "MTLFeatureSet_macOS_ReadWriteTextureTier2")]
181    pub const macOS_ReadWriteTextureTier2: Self = Self(10002);
182    #[doc(alias = "MTLFeatureSet_OSX_ReadWriteTextureTier2")]
183    pub const OSX_ReadWriteTextureTier2: Self = Self(MTLFeatureSet::macOS_ReadWriteTextureTier2.0);
184    #[doc(alias = "MTLFeatureSet_macOS_GPUFamily1_v3")]
185    pub const macOS_GPUFamily1_v3: Self = Self(10003);
186    #[doc(alias = "MTLFeatureSet_macOS_GPUFamily1_v4")]
187    pub const macOS_GPUFamily1_v4: Self = Self(10004);
188    #[doc(alias = "MTLFeatureSet_macOS_GPUFamily2_v1")]
189    pub const macOS_GPUFamily2_v1: Self = Self(10005);
190    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily1_v1")]
191    pub const tvOS_GPUFamily1_v1: Self = Self(30000);
192    #[doc(alias = "MTLFeatureSet_TVOS_GPUFamily1_v1")]
193    pub const TVOS_GPUFamily1_v1: Self = Self(MTLFeatureSet::tvOS_GPUFamily1_v1.0);
194    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily1_v2")]
195    pub const tvOS_GPUFamily1_v2: Self = Self(30001);
196    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily1_v3")]
197    pub const tvOS_GPUFamily1_v3: Self = Self(30002);
198    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily2_v1")]
199    pub const tvOS_GPUFamily2_v1: Self = Self(30003);
200    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily1_v4")]
201    pub const tvOS_GPUFamily1_v4: Self = Self(30004);
202    #[doc(alias = "MTLFeatureSet_tvOS_GPUFamily2_v2")]
203    pub const tvOS_GPUFamily2_v2: Self = Self(30005);
204}
205
206unsafe impl Encode for MTLFeatureSet {
207    const ENCODING: Encoding = NSUInteger::ENCODING;
208}
209
210unsafe impl RefEncode for MTLFeatureSet {
211    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
212}
213
214/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlgpufamily?language=objc)
215// NS_ENUM
216#[repr(transparent)]
217#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
218pub struct MTLGPUFamily(pub NSInteger);
219impl MTLGPUFamily {
220    #[doc(alias = "MTLGPUFamilyApple1")]
221    pub const Apple1: Self = Self(1001);
222    #[doc(alias = "MTLGPUFamilyApple2")]
223    pub const Apple2: Self = Self(1002);
224    #[doc(alias = "MTLGPUFamilyApple3")]
225    pub const Apple3: Self = Self(1003);
226    #[doc(alias = "MTLGPUFamilyApple4")]
227    pub const Apple4: Self = Self(1004);
228    #[doc(alias = "MTLGPUFamilyApple5")]
229    pub const Apple5: Self = Self(1005);
230    #[doc(alias = "MTLGPUFamilyApple6")]
231    pub const Apple6: Self = Self(1006);
232    #[doc(alias = "MTLGPUFamilyApple7")]
233    pub const Apple7: Self = Self(1007);
234    #[doc(alias = "MTLGPUFamilyApple8")]
235    pub const Apple8: Self = Self(1008);
236    #[doc(alias = "MTLGPUFamilyApple9")]
237    pub const Apple9: Self = Self(1009);
238    #[doc(alias = "MTLGPUFamilyApple10")]
239    pub const Apple10: Self = Self(1010);
240    #[doc(alias = "MTLGPUFamilyMac1")]
241    #[deprecated]
242    pub const Mac1: Self = Self(2001);
243    #[doc(alias = "MTLGPUFamilyMac2")]
244    pub const Mac2: Self = Self(2002);
245    #[doc(alias = "MTLGPUFamilyCommon1")]
246    pub const Common1: Self = Self(3001);
247    #[doc(alias = "MTLGPUFamilyCommon2")]
248    pub const Common2: Self = Self(3002);
249    #[doc(alias = "MTLGPUFamilyCommon3")]
250    pub const Common3: Self = Self(3003);
251    #[doc(alias = "MTLGPUFamilyMacCatalyst1")]
252    #[deprecated]
253    pub const MacCatalyst1: Self = Self(4001);
254    #[doc(alias = "MTLGPUFamilyMacCatalyst2")]
255    #[deprecated]
256    pub const MacCatalyst2: Self = Self(4002);
257    #[doc(alias = "MTLGPUFamilyMetal3")]
258    pub const Metal3: Self = Self(5001);
259    #[doc(alias = "MTLGPUFamilyMetal4")]
260    pub const Metal4: Self = Self(5002);
261}
262
263unsafe impl Encode for MTLGPUFamily {
264    const ENCODING: Encoding = NSInteger::ENCODING;
265}
266
267unsafe impl RefEncode for MTLGPUFamily {
268    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
269}
270
271/// Specifies the location of the GPU on macOS
272///
273/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevicelocation?language=objc)
274// NS_ENUM
275#[repr(transparent)]
276#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
277pub struct MTLDeviceLocation(pub NSUInteger);
278impl MTLDeviceLocation {
279    #[doc(alias = "MTLDeviceLocationBuiltIn")]
280    pub const BuiltIn: Self = Self(0);
281    #[doc(alias = "MTLDeviceLocationSlot")]
282    pub const Slot: Self = Self(1);
283    #[doc(alias = "MTLDeviceLocationExternal")]
284    pub const External: Self = Self(2);
285    #[doc(alias = "MTLDeviceLocationUnspecified")]
286    pub const Unspecified: Self = Self(NSUIntegerMax as _);
287}
288
289unsafe impl Encode for MTLDeviceLocation {
290    const ENCODING: Encoding = NSUInteger::ENCODING;
291}
292
293unsafe impl RefEncode for MTLDeviceLocation {
294    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
295}
296
297/// Controls the creation of the pipeline
298///
299/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlpipelineoption?language=objc)
300// NS_OPTIONS
301#[repr(transparent)]
302#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
303pub struct MTLPipelineOption(pub NSUInteger);
304bitflags::bitflags! {
305    impl MTLPipelineOption: NSUInteger {
306        #[doc(alias = "MTLPipelineOptionNone")]
307        const None = 0;
308        #[doc(alias = "MTLPipelineOptionArgumentInfo")]
309#[deprecated]
310        const ArgumentInfo = 1<<0;
311        #[doc(alias = "MTLPipelineOptionBindingInfo")]
312        const BindingInfo = 1<<0;
313        #[doc(alias = "MTLPipelineOptionBufferTypeInfo")]
314        const BufferTypeInfo = 1<<1;
315        #[doc(alias = "MTLPipelineOptionFailOnBinaryArchiveMiss")]
316        const FailOnBinaryArchiveMiss = 1<<2;
317    }
318}
319
320unsafe impl Encode for MTLPipelineOption {
321    const ENCODING: Encoding = NSUInteger::ENCODING;
322}
323
324unsafe impl RefEncode for MTLPipelineOption {
325    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
326}
327
328/// MTLReadWriteTextureTier determines support level for read-write texture formats.
329///
330/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlreadwritetexturetier?language=objc)
331// NS_ENUM
332#[repr(transparent)]
333#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
334pub struct MTLReadWriteTextureTier(pub NSUInteger);
335impl MTLReadWriteTextureTier {
336    #[doc(alias = "MTLReadWriteTextureTierNone")]
337    pub const TierNone: Self = Self(0);
338    #[doc(alias = "MTLReadWriteTextureTier1")]
339    pub const Tier1: Self = Self(1);
340    #[doc(alias = "MTLReadWriteTextureTier2")]
341    pub const Tier2: Self = Self(2);
342}
343
344unsafe impl Encode for MTLReadWriteTextureTier {
345    const ENCODING: Encoding = NSUInteger::ENCODING;
346}
347
348unsafe impl RefEncode for MTLReadWriteTextureTier {
349    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
350}
351
352/// MTLArgumentBuffersTier determines support level for argument buffers.
353///
354/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlargumentbufferstier?language=objc)
355// NS_ENUM
356#[repr(transparent)]
357#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
358pub struct MTLArgumentBuffersTier(pub NSUInteger);
359impl MTLArgumentBuffersTier {
360    #[doc(alias = "MTLArgumentBuffersTier1")]
361    pub const Tier1: Self = Self(0);
362    #[doc(alias = "MTLArgumentBuffersTier2")]
363    pub const Tier2: Self = Self(1);
364}
365
366unsafe impl Encode for MTLArgumentBuffersTier {
367    const ENCODING: Encoding = NSUInteger::ENCODING;
368}
369
370unsafe impl RefEncode for MTLArgumentBuffersTier {
371    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
372}
373
374/// MTLSparseTextureRegionAlignmentMode determines type of alignment used when converting from pixel region to tile region.
375///
376/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsparsetextureregionalignmentmode?language=objc)
377// NS_ENUM
378#[repr(transparent)]
379#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
380pub struct MTLSparseTextureRegionAlignmentMode(pub NSUInteger);
381impl MTLSparseTextureRegionAlignmentMode {
382    #[doc(alias = "MTLSparseTextureRegionAlignmentModeOutward")]
383    pub const Outward: Self = Self(0);
384    #[doc(alias = "MTLSparseTextureRegionAlignmentModeInward")]
385    pub const Inward: Self = Self(1);
386}
387
388unsafe impl Encode for MTLSparseTextureRegionAlignmentMode {
389    const ENCODING: Encoding = NSUInteger::ENCODING;
390}
391
392unsafe impl RefEncode for MTLSparseTextureRegionAlignmentMode {
393    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
394}
395
396/// Describes the memory requirements for an acceleration structure
397///
398/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlaccelerationstructuresizes?language=objc)
399#[repr(C)]
400#[derive(Clone, Copy, Debug, PartialEq)]
401pub struct MTLAccelerationStructureSizes {
402    /// The required size, in bytes, of the built acceleration structure
403    pub accelerationStructureSize: NSUInteger,
404    /// The required size, in bytes, of the scratch buffer used to build the acceleration structure
405    pub buildScratchBufferSize: NSUInteger,
406    /// The required size, in bytes, of the scratch buffer used to refit the acceleration structure
407    pub refitScratchBufferSize: NSUInteger,
408}
409
410unsafe impl Encode for MTLAccelerationStructureSizes {
411    const ENCODING: Encoding = Encoding::Struct(
412        "?",
413        &[
414            <NSUInteger>::ENCODING,
415            <NSUInteger>::ENCODING,
416            <NSUInteger>::ENCODING,
417        ],
418    );
419}
420
421unsafe impl RefEncode for MTLAccelerationStructureSizes {
422    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
423}
424
425/// MTLCounterSamplingPoint determines type of sampling points that are supported on given device.
426///
427///
428/// Counter sampling points at render, compute, and blit command encoder stage boundary are supported.
429///
430///
431/// Counter sampling at draw boundary is supported, render encoder method sampleCountersInBuffer can be used for sampling.
432///
433///
434/// Counter sampling at compute dispatch boundary is supported, compute encoder method sampleCountersInBuffer can be used for sampling.
435///
436///
437/// Counter sampling at tile shader dispatch boundary is supported.
438///
439///
440/// Counter sampling at blit boundary is supported, blit encoder method sampleCountersInBuffer can be used for sampling.
441///
442/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcountersamplingpoint?language=objc)
443// NS_ENUM
444#[repr(transparent)]
445#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
446pub struct MTLCounterSamplingPoint(pub NSUInteger);
447impl MTLCounterSamplingPoint {
448    #[doc(alias = "MTLCounterSamplingPointAtStageBoundary")]
449    pub const AtStageBoundary: Self = Self(0);
450    #[doc(alias = "MTLCounterSamplingPointAtDrawBoundary")]
451    pub const AtDrawBoundary: Self = Self(1);
452    #[doc(alias = "MTLCounterSamplingPointAtDispatchBoundary")]
453    pub const AtDispatchBoundary: Self = Self(2);
454    #[doc(alias = "MTLCounterSamplingPointAtTileDispatchBoundary")]
455    pub const AtTileDispatchBoundary: Self = Self(3);
456    #[doc(alias = "MTLCounterSamplingPointAtBlitBoundary")]
457    pub const AtBlitBoundary: Self = Self(4);
458}
459
460unsafe impl Encode for MTLCounterSamplingPoint {
461    const ENCODING: Encoding = NSUInteger::ENCODING;
462}
463
464unsafe impl RefEncode for MTLCounterSamplingPoint {
465    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
466}
467
468/// Represent a memory size and alignment in bytes.
469///
470/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsizeandalign?language=objc)
471#[repr(C)]
472#[derive(Clone, Copy, Debug, PartialEq)]
473pub struct MTLSizeAndAlign {
474    pub size: NSUInteger,
475    pub align: NSUInteger,
476}
477
478unsafe impl Encode for MTLSizeAndAlign {
479    const ENCODING: Encoding =
480        Encoding::Struct("?", &[<NSUInteger>::ENCODING, <NSUInteger>::ENCODING]);
481}
482
483unsafe impl RefEncode for MTLSizeAndAlign {
484    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
485}
486
487extern_class!(
488    /// Represents a member of an argument buffer
489    ///
490    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlargumentdescriptor?language=objc)
491    #[unsafe(super(NSObject))]
492    #[derive(Debug, PartialEq, Eq, Hash)]
493    pub struct MTLArgumentDescriptor;
494);
495
496extern_conformance!(
497    unsafe impl NSCopying for MTLArgumentDescriptor {}
498);
499
500unsafe impl CopyingHelper for MTLArgumentDescriptor {
501    type Result = Self;
502}
503
504extern_conformance!(
505    unsafe impl NSObjectProtocol for MTLArgumentDescriptor {}
506);
507
508impl MTLArgumentDescriptor {
509    extern_methods!(
510        /// Create an autoreleased default argument descriptor
511        #[unsafe(method(argumentDescriptor))]
512        #[unsafe(method_family = none)]
513        pub fn argumentDescriptor() -> Retained<MTLArgumentDescriptor>;
514
515        #[cfg(feature = "MTLDataType")]
516        /// For constants, the data type. Otherwise, MTLDataTypeTexture, MTLDataTypeSampler, or
517        /// MTLDataTypePointer.
518        #[unsafe(method(dataType))]
519        #[unsafe(method_family = none)]
520        pub fn dataType(&self) -> MTLDataType;
521
522        #[cfg(feature = "MTLDataType")]
523        /// Setter for [`dataType`][Self::dataType].
524        #[unsafe(method(setDataType:))]
525        #[unsafe(method_family = none)]
526        pub fn setDataType(&self, data_type: MTLDataType);
527
528        /// The binding point index of the argument
529        #[unsafe(method(index))]
530        #[unsafe(method_family = none)]
531        pub fn index(&self) -> NSUInteger;
532
533        /// Setter for [`index`][Self::index].
534        #[unsafe(method(setIndex:))]
535        #[unsafe(method_family = none)]
536        pub fn setIndex(&self, index: NSUInteger);
537
538        /// The length of an array of constants, textures, or samplers, or 0 for non-array arguments
539        #[unsafe(method(arrayLength))]
540        #[unsafe(method_family = none)]
541        pub fn arrayLength(&self) -> NSUInteger;
542
543        /// Setter for [`arrayLength`][Self::arrayLength].
544        #[unsafe(method(setArrayLength:))]
545        #[unsafe(method_family = none)]
546        pub fn setArrayLength(&self, array_length: NSUInteger);
547
548        #[cfg(feature = "MTLArgument")]
549        /// Access flags for the argument
550        #[unsafe(method(access))]
551        #[unsafe(method_family = none)]
552        pub fn access(&self) -> MTLBindingAccess;
553
554        #[cfg(feature = "MTLArgument")]
555        /// Setter for [`access`][Self::access].
556        #[unsafe(method(setAccess:))]
557        #[unsafe(method_family = none)]
558        pub fn setAccess(&self, access: MTLBindingAccess);
559
560        #[cfg(feature = "MTLTexture")]
561        /// For texture arguments, the texture type
562        #[unsafe(method(textureType))]
563        #[unsafe(method_family = none)]
564        pub fn textureType(&self) -> MTLTextureType;
565
566        #[cfg(feature = "MTLTexture")]
567        /// Setter for [`textureType`][Self::textureType].
568        #[unsafe(method(setTextureType:))]
569        #[unsafe(method_family = none)]
570        pub fn setTextureType(&self, texture_type: MTLTextureType);
571
572        /// if set forces the constant block to be aligned to the given alignment
573        ///
574        /// Should only be set on the first constant of the block and is only valid if a corresponding
575        /// explicit "alignas" is applied to the constant in the metal shader language.
576        #[unsafe(method(constantBlockAlignment))]
577        #[unsafe(method_family = none)]
578        pub fn constantBlockAlignment(&self) -> NSUInteger;
579
580        /// Setter for [`constantBlockAlignment`][Self::constantBlockAlignment].
581        #[unsafe(method(setConstantBlockAlignment:))]
582        #[unsafe(method_family = none)]
583        pub fn setConstantBlockAlignment(&self, constant_block_alignment: NSUInteger);
584    );
585}
586
587/// Methods declared on superclass `NSObject`.
588impl MTLArgumentDescriptor {
589    extern_methods!(
590        #[unsafe(method(init))]
591        #[unsafe(method_family = init)]
592        pub fn init(this: Allocated<Self>) -> Retained<Self>;
593
594        #[unsafe(method(new))]
595        #[unsafe(method_family = new)]
596        pub fn new() -> Retained<Self>;
597    );
598}
599
600impl DefaultRetained for MTLArgumentDescriptor {
601    #[inline]
602    fn default_retained() -> Retained<Self> {
603        Self::new()
604    }
605}
606
607extern_class!(
608    /// Contains information about the device's architecture
609    ///
610    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlarchitecture?language=objc)
611    #[unsafe(super(NSObject))]
612    #[derive(Debug, PartialEq, Eq, Hash)]
613    pub struct MTLArchitecture;
614);
615
616extern_conformance!(
617    unsafe impl NSCopying for MTLArchitecture {}
618);
619
620unsafe impl CopyingHelper for MTLArchitecture {
621    type Result = Self;
622}
623
624extern_conformance!(
625    unsafe impl NSObjectProtocol for MTLArchitecture {}
626);
627
628impl MTLArchitecture {
629    extern_methods!(
630        /// The device's architecture name.
631        #[unsafe(method(name))]
632        #[unsafe(method_family = none)]
633        pub fn name(&self) -> Retained<NSString>;
634    );
635}
636
637/// Methods declared on superclass `NSObject`.
638impl MTLArchitecture {
639    extern_methods!(
640        #[unsafe(method(init))]
641        #[unsafe(method_family = init)]
642        pub fn init(this: Allocated<Self>) -> Retained<Self>;
643
644        #[unsafe(method(new))]
645        #[unsafe(method_family = new)]
646        pub fn new() -> Retained<Self>;
647    );
648}
649
650impl DefaultRetained for MTLArchitecture {
651    #[inline]
652    fn default_retained() -> Retained<Self> {
653        Self::new()
654    }
655}
656
657/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtltimestamp?language=objc)
658pub type MTLTimestamp = u64;
659
660extern_protocol!(
661    /// MTLDevice represents a processor capable of data parallel computations
662    ///
663    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldevice?language=objc)
664    pub unsafe trait MTLDevice: NSObjectProtocol + Send + Sync {
665        /// The full name of the vendor device.
666        #[unsafe(method(name))]
667        #[unsafe(method_family = none)]
668        fn name(&self) -> Retained<NSString>;
669
670        /// Returns the IORegistry ID for the Metal device
671        ///
672        /// The registryID value for a Metal device is global to all tasks, and may be used
673        /// to identify the GPU across task boundaries.
674        #[unsafe(method(registryID))]
675        #[unsafe(method_family = none)]
676        fn registryID(&self) -> u64;
677
678        /// Returns the device's architecture information.
679        #[unsafe(method(architecture))]
680        #[unsafe(method_family = none)]
681        fn architecture(&self) -> Retained<MTLArchitecture>;
682
683        #[cfg(feature = "MTLTypes")]
684        /// The maximum number of threads along each dimension.
685        #[unsafe(method(maxThreadsPerThreadgroup))]
686        #[unsafe(method_family = none)]
687        fn maxThreadsPerThreadgroup(&self) -> MTLSize;
688
689        /// On systems that support automatic graphics switching, this will return YES for the the low power device.
690        #[unsafe(method(isLowPower))]
691        #[unsafe(method_family = none)]
692        fn isLowPower(&self) -> bool;
693
694        /// On systems that include more that one GPU, this will return YES for any device that does not support any displays.  Only available on Mac OS X.
695        #[unsafe(method(isHeadless))]
696        #[unsafe(method_family = none)]
697        fn isHeadless(&self) -> bool;
698
699        /// If this GPU is removable, this property will return YES.
700        ///
701        /// If a GPU is is removed without warning, APIs may fail even with good input, even before a notification can get posted informing
702        /// the application that the device has been removed.
703        #[unsafe(method(isRemovable))]
704        #[unsafe(method_family = none)]
705        fn isRemovable(&self) -> bool;
706
707        /// Returns YES if this GPU shares its memory with the rest of the machine (CPU, etc.)
708        ///
709        /// Some GPU architectures do not have dedicated local memory and instead only use the same memory shared with the rest
710        /// of the machine.  This property will return YES for GPUs that fall into that category.
711        #[unsafe(method(hasUnifiedMemory))]
712        #[unsafe(method_family = none)]
713        fn hasUnifiedMemory(&self) -> bool;
714
715        /// Returns an approximation of how much memory this device can use with good performance.
716        ///
717        /// Performance may be improved by keeping the total size of all resources (texture and buffers)
718        /// and heaps less than this threshold, beyond which the device is likely to be overcommitted and incur a
719        /// performance penalty.
720        #[unsafe(method(recommendedMaxWorkingSetSize))]
721        #[unsafe(method_family = none)]
722        fn recommendedMaxWorkingSetSize(&self) -> u64;
723
724        /// Returns an enum that indicates where the GPU is located relative to the host computer.
725        ///
726        /// The returned value indicates if the GPU is built into the computer, inserted into
727        /// a slot internal to the computer, or external to the computer. Otherwise it is Unspecified
728        #[unsafe(method(location))]
729        #[unsafe(method_family = none)]
730        fn location(&self) -> MTLDeviceLocation;
731
732        /// Returns a value that further specifies the GPU's location
733        ///
734        /// The returned value indicates which slot or Thunderbolt port the GPU is attached
735        /// to. For Built-in GPUs, if LowPower this value is 0, otherwise it is 1.  It is possible for multiple GPUs to have
736        /// the same location and locationNumber; e.g.: A PCI card with multiple GPUs, or an eGPU
737        /// daisy-chained off of another eGPU attached to a host Thunderbolt port.
738        #[unsafe(method(locationNumber))]
739        #[unsafe(method_family = none)]
740        fn locationNumber(&self) -> NSUInteger;
741
742        /// Upper bound of System RAM
743        /// <
744        /// => VRAM transfer rate in bytes/sec
745        ///
746        /// The returned value indicates the theoretical maximum data rate in bytes/second
747        /// from host memory to the GPU's VRAM. This is derived from the raw data clock rate and as
748        /// such may not be reachable under real-world conditions. For Built-in GPUs this value is 0.
749        #[unsafe(method(maxTransferRate))]
750        #[unsafe(method_family = none)]
751        fn maxTransferRate(&self) -> u64;
752
753        /// If YES, device supports MTLPixelFormatDepth24Unorm_Stencil8.
754        #[unsafe(method(isDepth24Stencil8PixelFormatSupported))]
755        #[unsafe(method_family = none)]
756        fn isDepth24Stencil8PixelFormatSupported(&self) -> bool;
757
758        /// Query support tier for read-write texture formats.
759        ///
760        /// Returns: MTLReadWriteTextureTier enum value.
761        #[unsafe(method(readWriteTextureSupport))]
762        #[unsafe(method_family = none)]
763        fn readWriteTextureSupport(&self) -> MTLReadWriteTextureTier;
764
765        /// Query support tier for Argument Buffers.
766        ///
767        /// Returns: MTLArgumentBuffersTier enum value.
768        #[unsafe(method(argumentBuffersSupport))]
769        #[unsafe(method_family = none)]
770        fn argumentBuffersSupport(&self) -> MTLArgumentBuffersTier;
771
772        /// Query device for raster order groups support.
773        ///
774        /// Returns: BOOL value. If YES, the device supports raster order groups. If NO, the device does not.
775        #[unsafe(method(areRasterOrderGroupsSupported))]
776        #[unsafe(method_family = none)]
777        fn areRasterOrderGroupsSupported(&self) -> bool;
778
779        /// Query device for 32-bit Float texture filtering support. Specifically, R32Float, RG32Float, and RGBA32Float.
780        ///
781        /// Returns: BOOL value. If YES, the device supports filtering 32-bit Float textures. If NO, the device does not.
782        #[unsafe(method(supports32BitFloatFiltering))]
783        #[unsafe(method_family = none)]
784        fn supports32BitFloatFiltering(&self) -> bool;
785
786        /// Query device for 32-bit MSAA texture support. Specifically, added support for allocating 32-bit Integer format textures (R32Uint, R32Sint, RG32Uint, RG32Sint, RGBA32Uint, and RGBA32Sint) and resolving 32-bit Float format textures (R32Float, RG32Float, and RGBA32Float).
787        ///
788        /// Returns: BOOL value. If YES, the device supports these additional 32-bit MSAA texture capabilities. If NO, the devices does not.
789        #[unsafe(method(supports32BitMSAA))]
790        #[unsafe(method_family = none)]
791        fn supports32BitMSAA(&self) -> bool;
792
793        /// Query device for whether it supports the `calculate_clampled_lod` and `calculate_unclamped_lod` Metal shading language functionality.
794        ///
795        /// Returns: BOOL value. If YES, the device supports the calculate LOD functionality. If NO, the device does not.
796        #[unsafe(method(supportsQueryTextureLOD))]
797        #[unsafe(method_family = none)]
798        fn supportsQueryTextureLOD(&self) -> bool;
799
800        /// Query device for BC Texture format support
801        ///
802        /// Returns: BOOL value. If YES, the device supports compressed BC Texture formats. If NO, the device does not.
803        #[unsafe(method(supportsBCTextureCompression))]
804        #[unsafe(method_family = none)]
805        fn supportsBCTextureCompression(&self) -> bool;
806
807        /// Query device for pull model interpolation support which allows a fragment shader to compute multiple interpolations (at center, at centroid, at offset, at sample) of a fragment input.
808        ///
809        /// Returns: BOOL value. If YES, the device supports pull model interpolation. If NO, the device does not.
810        #[unsafe(method(supportsPullModelInterpolation))]
811        #[unsafe(method_family = none)]
812        fn supportsPullModelInterpolation(&self) -> bool;
813
814        /// Query device for Barycentric coordinates support; deprecated, use supportsShaderBarycentricCoordinates
815        ///
816        /// Returns: BOOL value. If YES, the device barycentric coordinates
817        #[deprecated]
818        #[unsafe(method(areBarycentricCoordsSupported))]
819        #[unsafe(method_family = none)]
820        fn areBarycentricCoordsSupported(&self) -> bool;
821
822        /// Query device for Barycentric Coordinates support.
823        ///
824        /// Returns: BOOL value. If YES, the device supports barycentric coordinates. If NO, the device does not.
825        #[unsafe(method(supportsShaderBarycentricCoordinates))]
826        #[unsafe(method_family = none)]
827        fn supportsShaderBarycentricCoordinates(&self) -> bool;
828
829        /// The current size in bytes of all resources allocated by this device
830        #[unsafe(method(currentAllocatedSize))]
831        #[unsafe(method_family = none)]
832        fn currentAllocatedSize(&self) -> NSUInteger;
833
834        #[cfg(feature = "MTLLogState")]
835        /// This method will create a new MTLLogState.
836        #[unsafe(method(newLogStateWithDescriptor:error:_))]
837        #[unsafe(method_family = new)]
838        fn newLogStateWithDescriptor_error(
839            &self,
840            descriptor: &MTLLogStateDescriptor,
841        ) -> Result<Retained<ProtocolObject<dyn MTLLogState>>, Retained<NSError>>;
842
843        #[cfg(feature = "MTLCommandQueue")]
844        /// Create and return a new command queue.   Command Queues created via this method will only allow up to 64 non-completed command buffers.
845        ///
846        /// Returns: The new command queue object
847        #[unsafe(method(newCommandQueue))]
848        #[unsafe(method_family = new)]
849        fn newCommandQueue(&self) -> Option<Retained<ProtocolObject<dyn MTLCommandQueue>>>;
850
851        #[cfg(feature = "MTLCommandQueue")]
852        /// Create and return a new command queue with a given upper bound on non-completed command buffers.
853        ///
854        /// Returns: The new command queue object
855        #[unsafe(method(newCommandQueueWithMaxCommandBufferCount:))]
856        #[unsafe(method_family = new)]
857        fn newCommandQueueWithMaxCommandBufferCount(
858            &self,
859            max_command_buffer_count: NSUInteger,
860        ) -> Option<Retained<ProtocolObject<dyn MTLCommandQueue>>>;
861
862        #[cfg(feature = "MTLCommandQueue")]
863        /// Create a MTLCommandQueue according to MTLCommandQueueDescriptor.
864        #[unsafe(method(newCommandQueueWithDescriptor:))]
865        #[unsafe(method_family = new)]
866        fn newCommandQueueWithDescriptor(
867            &self,
868            descriptor: &MTLCommandQueueDescriptor,
869        ) -> Option<Retained<ProtocolObject<dyn MTLCommandQueue>>>;
870
871        #[cfg(feature = "MTLTexture")]
872        /// Determine the byte size of textures when sub-allocated from a heap.
873        ///
874        /// This method can be used to help determine the required heap size.
875        #[unsafe(method(heapTextureSizeAndAlignWithDescriptor:))]
876        #[unsafe(method_family = none)]
877        fn heapTextureSizeAndAlignWithDescriptor(
878            &self,
879            desc: &MTLTextureDescriptor,
880        ) -> MTLSizeAndAlign;
881
882        #[cfg(feature = "MTLResource")]
883        /// Determine the byte size of buffers when sub-allocated from a heap.
884        ///
885        /// This method can be used to help determine the required heap size.
886        #[unsafe(method(heapBufferSizeAndAlignWithLength:options:))]
887        #[unsafe(method_family = none)]
888        fn heapBufferSizeAndAlignWithLength_options(
889            &self,
890            length: NSUInteger,
891            options: MTLResourceOptions,
892        ) -> MTLSizeAndAlign;
893
894        #[cfg(all(feature = "MTLAllocation", feature = "MTLHeap"))]
895        /// Create a new heap with the given descriptor.
896        #[unsafe(method(newHeapWithDescriptor:))]
897        #[unsafe(method_family = new)]
898        fn newHeapWithDescriptor(
899            &self,
900            descriptor: &MTLHeapDescriptor,
901        ) -> Option<Retained<ProtocolObject<dyn MTLHeap>>>;
902
903        #[cfg(all(
904            feature = "MTLAllocation",
905            feature = "MTLBuffer",
906            feature = "MTLResource"
907        ))]
908        /// Create a buffer by allocating new memory.
909        #[unsafe(method(newBufferWithLength:options:))]
910        #[unsafe(method_family = new)]
911        fn newBufferWithLength_options(
912            &self,
913            length: NSUInteger,
914            options: MTLResourceOptions,
915        ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
916
917        #[cfg(all(
918            feature = "MTLAllocation",
919            feature = "MTLBuffer",
920            feature = "MTLResource"
921        ))]
922        /// Create a buffer by allocating new memory and specifing the initial contents to be copied into it.
923        ///
924        /// # Safety
925        ///
926        /// `pointer` must be a valid pointer.
927        #[unsafe(method(newBufferWithBytes:length:options:))]
928        #[unsafe(method_family = new)]
929        unsafe fn newBufferWithBytes_length_options(
930            &self,
931            pointer: NonNull<c_void>,
932            length: NSUInteger,
933            options: MTLResourceOptions,
934        ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
935
936        #[cfg(all(
937            feature = "MTLAllocation",
938            feature = "MTLBuffer",
939            feature = "MTLResource",
940            feature = "block2"
941        ))]
942        /// Create a buffer by wrapping an existing part of the address space.
943        ///
944        /// # Safety
945        ///
946        /// - `pointer` must be a valid pointer.
947        /// - `deallocator` block must be sendable.
948        #[unsafe(method(newBufferWithBytesNoCopy:length:options:deallocator:))]
949        #[unsafe(method_family = new)]
950        unsafe fn newBufferWithBytesNoCopy_length_options_deallocator(
951            &self,
952            pointer: NonNull<c_void>,
953            length: NSUInteger,
954            options: MTLResourceOptions,
955            deallocator: Option<&block2::DynBlock<dyn Fn(NonNull<c_void>, NSUInteger)>>,
956        ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
957
958        #[cfg(feature = "MTLDepthStencil")]
959        /// Create a depth/stencil test state object.
960        #[unsafe(method(newDepthStencilStateWithDescriptor:))]
961        #[unsafe(method_family = new)]
962        fn newDepthStencilStateWithDescriptor(
963            &self,
964            descriptor: &MTLDepthStencilDescriptor,
965        ) -> Option<Retained<ProtocolObject<dyn MTLDepthStencilState>>>;
966
967        #[cfg(all(
968            feature = "MTLAllocation",
969            feature = "MTLResource",
970            feature = "MTLTexture"
971        ))]
972        /// Allocate a new texture with privately owned storage.
973        #[unsafe(method(newTextureWithDescriptor:))]
974        #[unsafe(method_family = new)]
975        fn newTextureWithDescriptor(
976            &self,
977            descriptor: &MTLTextureDescriptor,
978        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
979
980        #[cfg(all(
981            feature = "MTLAllocation",
982            feature = "MTLResource",
983            feature = "MTLTexture",
984            feature = "objc2-io-surface"
985        ))]
986        /// Create a new texture from an IOSurface.
987        ///
988        /// Parameter `descriptor`: A description of the properties for the new texture.
989        ///
990        /// Parameter `iosurface`: The IOSurface to use as storage for the new texture.
991        ///
992        /// Parameter `plane`: The plane within the IOSurface to use.
993        ///
994        /// Returns: A new texture object.
995        #[unsafe(method(newTextureWithDescriptor:iosurface:plane:))]
996        #[unsafe(method_family = new)]
997        fn newTextureWithDescriptor_iosurface_plane(
998            &self,
999            descriptor: &MTLTextureDescriptor,
1000            iosurface: &IOSurfaceRef,
1001            plane: NSUInteger,
1002        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
1003
1004        #[cfg(all(
1005            feature = "MTLAllocation",
1006            feature = "MTLResource",
1007            feature = "MTLTexture"
1008        ))]
1009        /// Create a new texture that can be shared across process boundaries.
1010        ///
1011        /// This texture can be shared between process boundaries
1012        /// but not between different GPUs, by passing its MTLSharedTextureHandle.
1013        ///
1014        /// Parameter `descriptor`: A description of the properties for the new texture.
1015        ///
1016        /// Returns: A new texture object.
1017        #[unsafe(method(newSharedTextureWithDescriptor:))]
1018        #[unsafe(method_family = new)]
1019        fn newSharedTextureWithDescriptor(
1020            &self,
1021            descriptor: &MTLTextureDescriptor,
1022        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
1023
1024        #[cfg(all(
1025            feature = "MTLAllocation",
1026            feature = "MTLResource",
1027            feature = "MTLTexture"
1028        ))]
1029        /// Recreate shared texture from received texture handle.
1030        ///
1031        /// This texture was shared between process boundaries by other
1032        /// process using MTLSharedTextureHandle. Current process will now share
1033        /// it with other processes and will be able to interact with it (but still
1034        /// in scope of the same GPUs).
1035        ///
1036        /// Parameter `sharedHandle`: Handle to shared texture in this process space.
1037        ///
1038        /// Returns: A new texture object.
1039        #[unsafe(method(newSharedTextureWithHandle:))]
1040        #[unsafe(method_family = new)]
1041        fn newSharedTextureWithHandle(
1042            &self,
1043            shared_handle: &MTLSharedTextureHandle,
1044        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
1045
1046        #[cfg(feature = "MTLSampler")]
1047        /// Create a new sampler.
1048        #[unsafe(method(newSamplerStateWithDescriptor:))]
1049        #[unsafe(method_family = new)]
1050        fn newSamplerStateWithDescriptor(
1051            &self,
1052            descriptor: &MTLSamplerDescriptor,
1053        ) -> Option<Retained<ProtocolObject<dyn MTLSamplerState>>>;
1054
1055        #[cfg(feature = "MTLLibrary")]
1056        /// Returns the default library for the main bundle.
1057        ///
1058        /// use newDefaultLibraryWithBundle:error: to get an NSError in case of failure.
1059        #[unsafe(method(newDefaultLibrary))]
1060        #[unsafe(method_family = new)]
1061        fn newDefaultLibrary(&self) -> Option<Retained<ProtocolObject<dyn MTLLibrary>>>;
1062
1063        #[cfg(feature = "MTLLibrary")]
1064        #[unsafe(method(newDefaultLibraryWithBundle:error:_))]
1065        #[unsafe(method_family = new)]
1066        fn newDefaultLibraryWithBundle_error(
1067            &self,
1068            bundle: &NSBundle,
1069        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1070
1071        #[cfg(feature = "MTLLibrary")]
1072        /// Load a MTLLibrary from a metallib file.
1073        #[deprecated = "Use -newLibraryWithURL:error: instead"]
1074        #[unsafe(method(newLibraryWithFile:error:_))]
1075        #[unsafe(method_family = new)]
1076        fn newLibraryWithFile_error(
1077            &self,
1078            filepath: &NSString,
1079        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1080
1081        #[cfg(feature = "MTLLibrary")]
1082        /// Load a MTLLibrary from a metallib file.
1083        #[unsafe(method(newLibraryWithURL:error:_))]
1084        #[unsafe(method_family = new)]
1085        fn newLibraryWithURL_error(
1086            &self,
1087            url: &NSURL,
1088        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1089
1090        #[cfg(all(feature = "MTLLibrary", feature = "dispatch2"))]
1091        /// Load a MTLLibrary from a dispatch_data_t
1092        ///
1093        /// Parameter `data`: A metallib file already loaded as data in the form of dispatch_data_t.
1094        ///
1095        /// Parameter `error`: An error if we fail to open the metallib data.
1096        #[unsafe(method(newLibraryWithData:error:_))]
1097        #[unsafe(method_family = new)]
1098        fn newLibraryWithData_error(
1099            &self,
1100            data: &DispatchData,
1101        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1102
1103        #[cfg(feature = "MTLLibrary")]
1104        /// Load a MTLLibrary from source.
1105        #[unsafe(method(newLibraryWithSource:options:error:_))]
1106        #[unsafe(method_family = new)]
1107        fn newLibraryWithSource_options_error(
1108            &self,
1109            source: &NSString,
1110            options: Option<&MTLCompileOptions>,
1111        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1112
1113        #[cfg(all(feature = "MTLLibrary", feature = "block2"))]
1114        /// Load a MTLLibrary from source.
1115        ///
1116        /// # Safety
1117        ///
1118        /// `completion_handler` must be a valid pointer.
1119        #[unsafe(method(newLibraryWithSource:options:completionHandler:))]
1120        #[unsafe(method_family = none)]
1121        unsafe fn newLibraryWithSource_options_completionHandler(
1122            &self,
1123            source: &NSString,
1124            options: Option<&MTLCompileOptions>,
1125            completion_handler: MTLNewLibraryCompletionHandler,
1126        );
1127
1128        #[cfg(all(feature = "MTLFunctionStitching", feature = "MTLLibrary"))]
1129        /// Returns a library generated using the graphs in the descriptor.
1130        #[unsafe(method(newLibraryWithStitchedDescriptor:error:_))]
1131        #[unsafe(method_family = new)]
1132        fn newLibraryWithStitchedDescriptor_error(
1133            &self,
1134            descriptor: &MTLStitchedLibraryDescriptor,
1135        ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>, Retained<NSError>>;
1136
1137        #[cfg(all(
1138            feature = "MTLFunctionStitching",
1139            feature = "MTLLibrary",
1140            feature = "block2"
1141        ))]
1142        /// Generates a new library using the graphs in the descriptor.
1143        ///
1144        /// # Safety
1145        ///
1146        /// `completion_handler` must be a valid pointer.
1147        #[unsafe(method(newLibraryWithStitchedDescriptor:completionHandler:))]
1148        #[unsafe(method_family = none)]
1149        unsafe fn newLibraryWithStitchedDescriptor_completionHandler(
1150            &self,
1151            descriptor: &MTLStitchedLibraryDescriptor,
1152            completion_handler: MTLNewLibraryCompletionHandler,
1153        );
1154
1155        #[cfg(all(feature = "MTLAllocation", feature = "MTLRenderPipeline"))]
1156        /// Create and compile a new MTLRenderPipelineState object synchronously.
1157        #[unsafe(method(newRenderPipelineStateWithDescriptor:error:_))]
1158        #[unsafe(method_family = new)]
1159        fn newRenderPipelineStateWithDescriptor_error(
1160            &self,
1161            descriptor: &MTLRenderPipelineDescriptor,
1162        ) -> Result<Retained<ProtocolObject<dyn MTLRenderPipelineState>>, Retained<NSError>>;
1163
1164        #[cfg(all(
1165            feature = "MTLAllocation",
1166            feature = "MTLLibrary",
1167            feature = "MTLRenderPipeline"
1168        ))]
1169        /// Create and compile a new MTLRenderPipelineState object synchronously and returns additional reflection information.
1170        #[unsafe(method(newRenderPipelineStateWithDescriptor:options:reflection:error:_))]
1171        #[unsafe(method_family = new)]
1172        fn newRenderPipelineStateWithDescriptor_options_reflection_error(
1173            &self,
1174            descriptor: &MTLRenderPipelineDescriptor,
1175            options: MTLPipelineOption,
1176            reflection: Option<&mut Option<Retained<MTLAutoreleasedRenderPipelineReflection>>>,
1177        ) -> Result<Retained<ProtocolObject<dyn MTLRenderPipelineState>>, Retained<NSError>>;
1178
1179        #[cfg(all(
1180            feature = "MTLAllocation",
1181            feature = "MTLLibrary",
1182            feature = "MTLRenderPipeline",
1183            feature = "block2"
1184        ))]
1185        /// Create and compile a new MTLRenderPipelineState object asynchronously.
1186        ///
1187        /// # Safety
1188        ///
1189        /// `completion_handler` must be a valid pointer.
1190        #[unsafe(method(newRenderPipelineStateWithDescriptor:completionHandler:))]
1191        #[unsafe(method_family = none)]
1192        unsafe fn newRenderPipelineStateWithDescriptor_completionHandler(
1193            &self,
1194            descriptor: &MTLRenderPipelineDescriptor,
1195            completion_handler: MTLNewRenderPipelineStateCompletionHandler,
1196        );
1197
1198        #[cfg(all(
1199            feature = "MTLAllocation",
1200            feature = "MTLLibrary",
1201            feature = "MTLRenderPipeline",
1202            feature = "block2"
1203        ))]
1204        /// Create and compile a new MTLRenderPipelineState object asynchronously and returns additional reflection information
1205        ///
1206        /// # Safety
1207        ///
1208        /// `completion_handler` must be a valid pointer.
1209        #[unsafe(method(newRenderPipelineStateWithDescriptor:options:completionHandler:))]
1210        #[unsafe(method_family = none)]
1211        unsafe fn newRenderPipelineStateWithDescriptor_options_completionHandler(
1212            &self,
1213            descriptor: &MTLRenderPipelineDescriptor,
1214            options: MTLPipelineOption,
1215            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
1216        );
1217
1218        #[cfg(all(
1219            feature = "MTLAllocation",
1220            feature = "MTLComputePipeline",
1221            feature = "MTLLibrary"
1222        ))]
1223        /// Create and compile a new MTLComputePipelineState object synchronously.
1224        #[unsafe(method(newComputePipelineStateWithFunction:error:_))]
1225        #[unsafe(method_family = new)]
1226        fn newComputePipelineStateWithFunction_error(
1227            &self,
1228            compute_function: &ProtocolObject<dyn MTLFunction>,
1229        ) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>, Retained<NSError>>;
1230
1231        #[cfg(all(
1232            feature = "MTLAllocation",
1233            feature = "MTLComputePipeline",
1234            feature = "MTLLibrary"
1235        ))]
1236        /// Create and compile a new MTLComputePipelineState object synchronously.
1237        ///
1238        /// # Safety
1239        ///
1240        /// - `compute_function` must be safe to call.
1241        /// - `compute_function` must have the correct argument and return types.
1242        #[unsafe(method(newComputePipelineStateWithFunction:options:reflection:error:_))]
1243        #[unsafe(method_family = new)]
1244        unsafe fn newComputePipelineStateWithFunction_options_reflection_error(
1245            &self,
1246            compute_function: &ProtocolObject<dyn MTLFunction>,
1247            options: MTLPipelineOption,
1248            reflection: Option<&mut Option<Retained<MTLAutoreleasedComputePipelineReflection>>>,
1249        ) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>, Retained<NSError>>;
1250
1251        #[cfg(all(
1252            feature = "MTLAllocation",
1253            feature = "MTLComputePipeline",
1254            feature = "MTLLibrary",
1255            feature = "block2"
1256        ))]
1257        /// Create and compile a new MTLComputePipelineState object asynchronously.
1258        ///
1259        /// # Safety
1260        ///
1261        /// - `compute_function` must be safe to call.
1262        /// - `compute_function` must have the correct argument and return types.
1263        /// - `completion_handler` must be a valid pointer.
1264        #[unsafe(method(newComputePipelineStateWithFunction:completionHandler:))]
1265        #[unsafe(method_family = none)]
1266        unsafe fn newComputePipelineStateWithFunction_completionHandler(
1267            &self,
1268            compute_function: &ProtocolObject<dyn MTLFunction>,
1269            completion_handler: MTLNewComputePipelineStateCompletionHandler,
1270        );
1271
1272        #[cfg(all(
1273            feature = "MTLAllocation",
1274            feature = "MTLComputePipeline",
1275            feature = "MTLLibrary",
1276            feature = "block2"
1277        ))]
1278        /// Create and compile a new MTLComputePipelineState object asynchronously.
1279        ///
1280        /// # Safety
1281        ///
1282        /// - `compute_function` must be safe to call.
1283        /// - `compute_function` must have the correct argument and return types.
1284        /// - `completion_handler` must be a valid pointer.
1285        #[unsafe(method(newComputePipelineStateWithFunction:options:completionHandler:))]
1286        #[unsafe(method_family = none)]
1287        unsafe fn newComputePipelineStateWithFunction_options_completionHandler(
1288            &self,
1289            compute_function: &ProtocolObject<dyn MTLFunction>,
1290            options: MTLPipelineOption,
1291            completion_handler: MTLNewComputePipelineStateWithReflectionCompletionHandler,
1292        );
1293
1294        #[cfg(all(
1295            feature = "MTLAllocation",
1296            feature = "MTLComputePipeline",
1297            feature = "MTLLibrary"
1298        ))]
1299        /// Create and compile a new MTLComputePipelineState object synchronously.
1300        #[unsafe(method(newComputePipelineStateWithDescriptor:options:reflection:error:_))]
1301        #[unsafe(method_family = new)]
1302        fn newComputePipelineStateWithDescriptor_options_reflection_error(
1303            &self,
1304            descriptor: &MTLComputePipelineDescriptor,
1305            options: MTLPipelineOption,
1306            reflection: Option<&mut Option<Retained<MTLAutoreleasedComputePipelineReflection>>>,
1307        ) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>, Retained<NSError>>;
1308
1309        #[cfg(all(
1310            feature = "MTLAllocation",
1311            feature = "MTLComputePipeline",
1312            feature = "MTLLibrary",
1313            feature = "block2"
1314        ))]
1315        /// Create and compile a new MTLComputePipelineState object asynchronously.
1316        ///
1317        /// # Safety
1318        ///
1319        /// `completion_handler` must be a valid pointer.
1320        #[unsafe(method(newComputePipelineStateWithDescriptor:options:completionHandler:))]
1321        #[unsafe(method_family = none)]
1322        unsafe fn newComputePipelineStateWithDescriptor_options_completionHandler(
1323            &self,
1324            descriptor: &MTLComputePipelineDescriptor,
1325            options: MTLPipelineOption,
1326            completion_handler: MTLNewComputePipelineStateWithReflectionCompletionHandler,
1327        );
1328
1329        #[cfg(feature = "MTLFence")]
1330        /// Create a new MTLFence object
1331        #[unsafe(method(newFence))]
1332        #[unsafe(method_family = new)]
1333        fn newFence(&self) -> Option<Retained<ProtocolObject<dyn MTLFence>>>;
1334
1335        /// Returns TRUE if the feature set is supported by this MTLDevice.
1336        #[deprecated = "Use supportsFamily instead"]
1337        #[unsafe(method(supportsFeatureSet:))]
1338        #[unsafe(method_family = none)]
1339        fn supportsFeatureSet(&self, feature_set: MTLFeatureSet) -> bool;
1340
1341        /// Returns TRUE if the GPU Family is supported by this MTLDevice.
1342        #[unsafe(method(supportsFamily:))]
1343        #[unsafe(method_family = none)]
1344        fn supportsFamily(&self, gpu_family: MTLGPUFamily) -> bool;
1345
1346        /// Query device if it support textures with a given sampleCount.
1347        ///
1348        /// Returns: BOOL value. If YES, device supports the given sampleCount for textures. If NO, device does not support the given sampleCount.
1349        #[unsafe(method(supportsTextureSampleCount:))]
1350        #[unsafe(method_family = none)]
1351        fn supportsTextureSampleCount(&self, sample_count: NSUInteger) -> bool;
1352
1353        #[cfg(feature = "MTLPixelFormat")]
1354        /// Returns the minimum alignment required for offset and rowBytes when creating a linear texture. An error is thrown for queries with invalid pixel formats (depth, stencil, or compressed formats).
1355        #[unsafe(method(minimumLinearTextureAlignmentForPixelFormat:))]
1356        #[unsafe(method_family = none)]
1357        fn minimumLinearTextureAlignmentForPixelFormat(&self, format: MTLPixelFormat)
1358            -> NSUInteger;
1359
1360        #[cfg(feature = "MTLPixelFormat")]
1361        /// Returns the minimum alignment required for offset and rowBytes when creating a texture buffer from a buffer.
1362        #[unsafe(method(minimumTextureBufferAlignmentForPixelFormat:))]
1363        #[unsafe(method_family = none)]
1364        fn minimumTextureBufferAlignmentForPixelFormat(&self, format: MTLPixelFormat)
1365            -> NSUInteger;
1366
1367        #[cfg(all(
1368            feature = "MTLAllocation",
1369            feature = "MTLLibrary",
1370            feature = "MTLRenderPipeline"
1371        ))]
1372        /// Create and compile a new MTLRenderPipelineState object synchronously given a MTLTileRenderPipelineDescriptor.
1373        #[unsafe(method(newRenderPipelineStateWithTileDescriptor:options:reflection:error:_))]
1374        #[unsafe(method_family = new)]
1375        fn newRenderPipelineStateWithTileDescriptor_options_reflection_error(
1376            &self,
1377            descriptor: &MTLTileRenderPipelineDescriptor,
1378            options: MTLPipelineOption,
1379            reflection: Option<&mut Option<Retained<MTLAutoreleasedRenderPipelineReflection>>>,
1380        ) -> Result<Retained<ProtocolObject<dyn MTLRenderPipelineState>>, Retained<NSError>>;
1381
1382        #[cfg(all(
1383            feature = "MTLAllocation",
1384            feature = "MTLLibrary",
1385            feature = "MTLRenderPipeline",
1386            feature = "block2"
1387        ))]
1388        /// Create and compile a new MTLRenderPipelineState object asynchronously given a MTLTileRenderPipelineDescriptor.
1389        ///
1390        /// # Safety
1391        ///
1392        /// `completion_handler` must be a valid pointer.
1393        #[unsafe(method(newRenderPipelineStateWithTileDescriptor:options:completionHandler:))]
1394        #[unsafe(method_family = none)]
1395        unsafe fn newRenderPipelineStateWithTileDescriptor_options_completionHandler(
1396            &self,
1397            descriptor: &MTLTileRenderPipelineDescriptor,
1398            options: MTLPipelineOption,
1399            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
1400        );
1401
1402        #[cfg(all(
1403            feature = "MTLAllocation",
1404            feature = "MTLLibrary",
1405            feature = "MTLRenderPipeline"
1406        ))]
1407        /// Create and compile a new MTLRenderPipelineState object synchronously given a MTLMeshRenderPipelineDescriptor.
1408        #[unsafe(method(newRenderPipelineStateWithMeshDescriptor:options:reflection:error:_))]
1409        #[unsafe(method_family = new)]
1410        fn newRenderPipelineStateWithMeshDescriptor_options_reflection_error(
1411            &self,
1412            descriptor: &MTLMeshRenderPipelineDescriptor,
1413            options: MTLPipelineOption,
1414            reflection: Option<&mut Option<Retained<MTLAutoreleasedRenderPipelineReflection>>>,
1415        ) -> Result<Retained<ProtocolObject<dyn MTLRenderPipelineState>>, Retained<NSError>>;
1416
1417        #[cfg(all(
1418            feature = "MTLAllocation",
1419            feature = "MTLLibrary",
1420            feature = "MTLRenderPipeline",
1421            feature = "block2"
1422        ))]
1423        /// Create and compile a new MTLRenderPipelineState object asynchronously given a MTLMeshRenderPipelineDescriptor.
1424        ///
1425        /// # Safety
1426        ///
1427        /// `completion_handler` must be a valid pointer.
1428        #[unsafe(method(newRenderPipelineStateWithMeshDescriptor:options:completionHandler:))]
1429        #[unsafe(method_family = none)]
1430        unsafe fn newRenderPipelineStateWithMeshDescriptor_options_completionHandler(
1431            &self,
1432            descriptor: &MTLMeshRenderPipelineDescriptor,
1433            options: MTLPipelineOption,
1434            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
1435        );
1436
1437        /// The maximum threadgroup memory available, in bytes.
1438        #[unsafe(method(maxThreadgroupMemoryLength))]
1439        #[unsafe(method_family = none)]
1440        fn maxThreadgroupMemoryLength(&self) -> NSUInteger;
1441
1442        /// The maximum number of unique argument buffer samplers per app.
1443        ///
1444        /// This limit is only applicable to samplers that have their supportArgumentBuffers property set to true. A MTLSamplerState object is considered unique if the configuration of its originating MTLSamplerDescriptor properties is unique. For example, two samplers with equal minFilter values but different magFilter values are considered unique.
1445        #[unsafe(method(maxArgumentBufferSamplerCount))]
1446        #[unsafe(method_family = none)]
1447        fn maxArgumentBufferSamplerCount(&self) -> NSUInteger;
1448
1449        /// Query device for programmable sample position support.
1450        ///
1451        /// Returns: BOOL value. If YES, the device supports programmable sample positions. If NO, the device does not.
1452        #[unsafe(method(areProgrammableSamplePositionsSupported))]
1453        #[unsafe(method_family = none)]
1454        fn areProgrammableSamplePositionsSupported(&self) -> bool;
1455
1456        #[cfg(feature = "MTLTypes")]
1457        /// Retrieve the default sample positions.
1458        ///
1459        /// Parameter `positions`: The destination array for default sample position data.
1460        ///
1461        /// Parameter `count`: Specifies the sample count for which to retrieve the default positions, the length of the positions array, and must be set to a valid sample count.
1462        ///
1463        /// # Safety
1464        ///
1465        /// - `positions` must be a valid pointer.
1466        /// - `count` might not be bounds-checked.
1467        #[unsafe(method(getDefaultSamplePositions:count:))]
1468        #[unsafe(method_family = none)]
1469        unsafe fn getDefaultSamplePositions_count(
1470            &self,
1471            positions: NonNull<MTLSamplePosition>,
1472            count: NSUInteger,
1473        );
1474
1475        #[cfg(feature = "MTLArgumentEncoder")]
1476        /// Creates an argument encoder for an array of argument descriptors which will be encoded sequentially.
1477        #[unsafe(method(newArgumentEncoderWithArguments:))]
1478        #[unsafe(method_family = new)]
1479        fn newArgumentEncoderWithArguments(
1480            &self,
1481            arguments: &NSArray<MTLArgumentDescriptor>,
1482        ) -> Option<Retained<ProtocolObject<dyn MTLArgumentEncoder>>>;
1483
1484        /// Query device for variable rasterization rate support with the given number of layers.
1485        ///
1486        /// Parameter `layerCount`: The number of layers for which to query device support.
1487        ///
1488        /// Returns: YES if the device supports creation of rendering using a MTLRasterizationRateMap with the given number of layers.
1489        ///
1490        /// # Safety
1491        ///
1492        /// `layerCount` might not be bounds-checked.
1493        #[unsafe(method(supportsRasterizationRateMapWithLayerCount:))]
1494        #[unsafe(method_family = none)]
1495        unsafe fn supportsRasterizationRateMapWithLayerCount(
1496            &self,
1497            layer_count: NSUInteger,
1498        ) -> bool;
1499
1500        #[cfg(feature = "MTLRasterizationRate")]
1501        /// Creates a new variable rasterization rate map with the given descriptor.
1502        ///
1503        /// If '[self supportsRasterizationRateMapWithLayerCount:descriptor.layerCount]' returns NO, or descriptor.screenSize describes an empty region, the result will always be nil.
1504        ///
1505        /// Returns: A MTLRasterizationRateMap instance that can be used for rendering on this MTLDevice, or nil if the device does not support the combination of parameters stored in the descriptor.
1506        #[unsafe(method(newRasterizationRateMapWithDescriptor:))]
1507        #[unsafe(method_family = new)]
1508        fn newRasterizationRateMapWithDescriptor(
1509            &self,
1510            descriptor: &MTLRasterizationRateMapDescriptor,
1511        ) -> Option<Retained<ProtocolObject<dyn MTLRasterizationRateMap>>>;
1512
1513        #[cfg(all(
1514            feature = "MTLAllocation",
1515            feature = "MTLIndirectCommandBuffer",
1516            feature = "MTLResource"
1517        ))]
1518        /// Creates a new indirect command buffer with the given descriptor and count.
1519        ///
1520        /// Parameter `descriptor`: The descriptor encodes the maximum logical stride of each command.
1521        ///
1522        /// Parameter `maxCount`: The maximum number of commands that this buffer can contain.
1523        ///
1524        /// Parameter `options`: The options for the indirect command buffer.
1525        ///
1526        /// The returned buffer can be safely executed without first encoding into (but is wasteful).
1527        ///
1528        /// # Safety
1529        ///
1530        /// `maxCount` might not be bounds-checked.
1531        #[unsafe(method(newIndirectCommandBufferWithDescriptor:maxCommandCount:options:))]
1532        #[unsafe(method_family = new)]
1533        unsafe fn newIndirectCommandBufferWithDescriptor_maxCommandCount_options(
1534            &self,
1535            descriptor: &MTLIndirectCommandBufferDescriptor,
1536            max_count: NSUInteger,
1537            options: MTLResourceOptions,
1538        ) -> Option<Retained<ProtocolObject<dyn MTLIndirectCommandBuffer>>>;
1539
1540        #[cfg(feature = "MTLEvent")]
1541        /// Returns a new single-device non-shareable Metal event object
1542        #[unsafe(method(newEvent))]
1543        #[unsafe(method_family = new)]
1544        fn newEvent(&self) -> Option<Retained<ProtocolObject<dyn MTLEvent>>>;
1545
1546        #[cfg(feature = "MTLEvent")]
1547        /// Returns a shareable multi-device event.
1548        #[unsafe(method(newSharedEvent))]
1549        #[unsafe(method_family = new)]
1550        fn newSharedEvent(&self) -> Option<Retained<ProtocolObject<dyn MTLSharedEvent>>>;
1551
1552        #[cfg(feature = "MTLEvent")]
1553        /// Creates a shareable multi-device event from an existing shared event handle.
1554        #[unsafe(method(newSharedEventWithHandle:))]
1555        #[unsafe(method_family = new)]
1556        fn newSharedEventWithHandle(
1557            &self,
1558            shared_event_handle: &MTLSharedEventHandle,
1559        ) -> Option<Retained<ProtocolObject<dyn MTLSharedEvent>>>;
1560
1561        /// If a device supports peer to peer transfers with another device (or devices), this property will return
1562        /// a unique 64-bit identifier associated with all devices in the same peer group.
1563        #[unsafe(method(peerGroupID))]
1564        #[unsafe(method_family = none)]
1565        fn peerGroupID(&self) -> u64;
1566
1567        /// All Metal devices that are part of the same peer group will have a unique index value within the group in
1568        /// the range from 0 to peerCount - 1.
1569        #[unsafe(method(peerIndex))]
1570        #[unsafe(method_family = none)]
1571        fn peerIndex(&self) -> u32;
1572
1573        /// For Metal devices that are part of a peer group, this property returns the total number of devices in that group.
1574        #[unsafe(method(peerCount))]
1575        #[unsafe(method_family = none)]
1576        fn peerCount(&self) -> u32;
1577
1578        #[cfg(feature = "MTLIOCommandQueue")]
1579        /// Create and return a handle that points to a raw file on disk. This object can be used by
1580        /// MTLIOCommandBuffer load commands to source data for MTLResources. If the creation
1581        /// of the handle fails the return value will be nil and the optional error if passed in will be non-nil
1582        /// with details of the error.
1583        #[deprecated]
1584        #[unsafe(method(newIOHandleWithURL:error:_))]
1585        #[unsafe(method_family = new)]
1586        fn newIOHandleWithURL_error(
1587            &self,
1588            url: &NSURL,
1589        ) -> Result<Retained<ProtocolObject<dyn MTLIOFileHandle>>, Retained<NSError>>;
1590
1591        #[cfg(feature = "MTLIOCommandQueue")]
1592        /// Create and return an IO queue. If the creation
1593        /// of the queue fails the return value will be nil and the optional error if passed in will be non-nil
1594        /// with details of the error.
1595        #[unsafe(method(newIOCommandQueueWithDescriptor:error:_))]
1596        #[unsafe(method_family = new)]
1597        fn newIOCommandQueueWithDescriptor_error(
1598            &self,
1599            descriptor: &MTLIOCommandQueueDescriptor,
1600        ) -> Result<Retained<ProtocolObject<dyn MTLIOCommandQueue>>, Retained<NSError>>;
1601
1602        #[cfg(feature = "MTLIOCommandQueue")]
1603        /// Create and return a handle that points to a compressed file on disk (a file that was
1604        /// created with MTLIOCompressionContext). This object can be used by
1605        /// MTLIOCommandBuffer load commands to source data for MTLResources. If the creation
1606        /// of the handle fails the return value will be nil and the optional error if passed in will be non-nil
1607        /// with details of the error.
1608        #[deprecated]
1609        #[unsafe(method(newIOHandleWithURL:compressionMethod:error:_))]
1610        #[unsafe(method_family = new)]
1611        fn newIOHandleWithURL_compressionMethod_error(
1612            &self,
1613            url: &NSURL,
1614            compression_method: MTLIOCompressionMethod,
1615        ) -> Result<Retained<ProtocolObject<dyn MTLIOFileHandle>>, Retained<NSError>>;
1616
1617        #[cfg(feature = "MTLIOCommandQueue")]
1618        /// Create and return a handle that points to a raw file on disk. This object can be used by
1619        /// MTLIOCommandBuffer load commands to source data for MTLResources. If the creation
1620        /// of the handle fails the return value will be nil and the optional error if passed in will be non-nil
1621        /// with details of the error.
1622        #[unsafe(method(newIOFileHandleWithURL:error:_))]
1623        #[unsafe(method_family = new)]
1624        fn newIOFileHandleWithURL_error(
1625            &self,
1626            url: &NSURL,
1627        ) -> Result<Retained<ProtocolObject<dyn MTLIOFileHandle>>, Retained<NSError>>;
1628
1629        #[cfg(feature = "MTLIOCommandQueue")]
1630        /// Create and return a handle that points to a compressed file on disk (a file that was
1631        /// created with MTLIOCompressionContext). This object can be used by
1632        /// MTLIOCommandBuffer load commands to source data for MTLResources. If the creation
1633        /// of the handle fails the return value will be nil and the optional error if passed in will be non-nil
1634        /// with details of the error.
1635        #[unsafe(method(newIOFileHandleWithURL:compressionMethod:error:_))]
1636        #[unsafe(method_family = new)]
1637        fn newIOFileHandleWithURL_compressionMethod_error(
1638            &self,
1639            url: &NSURL,
1640            compression_method: MTLIOCompressionMethod,
1641        ) -> Result<Retained<ProtocolObject<dyn MTLIOFileHandle>>, Retained<NSError>>;
1642
1643        #[cfg(all(
1644            feature = "MTLPixelFormat",
1645            feature = "MTLTexture",
1646            feature = "MTLTypes"
1647        ))]
1648        /// Returns tile size for sparse texture with given type, pixel format and sample count.
1649        ///
1650        /// # Safety
1651        ///
1652        /// `sampleCount` might not be bounds-checked.
1653        #[unsafe(method(sparseTileSizeWithTextureType:pixelFormat:sampleCount:))]
1654        #[unsafe(method_family = none)]
1655        unsafe fn sparseTileSizeWithTextureType_pixelFormat_sampleCount(
1656            &self,
1657            texture_type: MTLTextureType,
1658            pixel_format: MTLPixelFormat,
1659            sample_count: NSUInteger,
1660        ) -> MTLSize;
1661
1662        /// Returns the number of bytes required to map one sparse texture tile.
1663        #[unsafe(method(sparseTileSizeInBytes))]
1664        #[unsafe(method_family = none)]
1665        fn sparseTileSizeInBytes(&self) -> NSUInteger;
1666
1667        #[cfg(feature = "MTLTypes")]
1668        /// Converts regions in pixels to regions in sparse tiles using specified alignment mode.
1669        /// Tile size can be obtained from tileSizeWithTextureType:pixelFormat:sampleCount: method.
1670        ///
1671        /// # Safety
1672        ///
1673        /// - `pixel_regions` must be a valid pointer.
1674        /// - `tile_regions` must be a valid pointer.
1675        /// - `tileSize` might not be bounds-checked.
1676        #[optional]
1677        #[unsafe(method(convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions:))]
1678        #[unsafe(method_family = none)]
1679        unsafe fn convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions(
1680            &self,
1681            pixel_regions: NonNull<MTLRegion>,
1682            tile_regions: NonNull<MTLRegion>,
1683            tile_size: MTLSize,
1684            mode: MTLSparseTextureRegionAlignmentMode,
1685            num_regions: NSUInteger,
1686        );
1687
1688        #[cfg(feature = "MTLTypes")]
1689        /// Convertes region in sparse tiles to region in pixels
1690        /// Tile size can be obtained from tileSizeWithTextureType:pixelFormat:sampleCount: method.
1691        ///
1692        /// # Safety
1693        ///
1694        /// - `tile_regions` must be a valid pointer.
1695        /// - `pixel_regions` must be a valid pointer.
1696        /// - `tileSize` might not be bounds-checked.
1697        #[optional]
1698        #[unsafe(method(convertSparseTileRegions:toPixelRegions:withTileSize:numRegions:))]
1699        #[unsafe(method_family = none)]
1700        unsafe fn convertSparseTileRegions_toPixelRegions_withTileSize_numRegions(
1701            &self,
1702            tile_regions: NonNull<MTLRegion>,
1703            pixel_regions: NonNull<MTLRegion>,
1704            tile_size: MTLSize,
1705            num_regions: NSUInteger,
1706        );
1707
1708        #[cfg(feature = "MTLResource")]
1709        /// Returns the number of bytes required to map one sparse texture tile for a given MTLSparsePageSize
1710        #[unsafe(method(sparseTileSizeInBytesForSparsePageSize:))]
1711        #[unsafe(method_family = none)]
1712        fn sparseTileSizeInBytesForSparsePageSize(
1713            &self,
1714            sparse_page_size: MTLSparsePageSize,
1715        ) -> NSUInteger;
1716
1717        #[cfg(all(
1718            feature = "MTLPixelFormat",
1719            feature = "MTLResource",
1720            feature = "MTLTexture",
1721            feature = "MTLTypes"
1722        ))]
1723        /// Returns tile size for sparse texture with given type, pixel format and sample count.
1724        ///
1725        /// # Safety
1726        ///
1727        /// `sampleCount` might not be bounds-checked.
1728        #[unsafe(method(sparseTileSizeWithTextureType:pixelFormat:sampleCount:sparsePageSize:))]
1729        #[unsafe(method_family = none)]
1730        unsafe fn sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize(
1731            &self,
1732            texture_type: MTLTextureType,
1733            pixel_format: MTLPixelFormat,
1734            sample_count: NSUInteger,
1735            sparse_page_size: MTLSparsePageSize,
1736        ) -> MTLSize;
1737
1738        #[unsafe(method(maxBufferLength))]
1739        #[unsafe(method_family = none)]
1740        fn maxBufferLength(&self) -> NSUInteger;
1741
1742        #[cfg(feature = "MTLCounters")]
1743        /// Returns the set of Counter Sets exposed by the device.
1744        #[unsafe(method(counterSets))]
1745        #[unsafe(method_family = none)]
1746        fn counterSets(&self) -> Option<Retained<NSArray<ProtocolObject<dyn MTLCounterSet>>>>;
1747
1748        #[cfg(feature = "MTLCounters")]
1749        /// Given a counter sample buffer descriptor, allocate a new counter
1750        /// sample buffer.
1751        /// This may return nil if the counters may not all be collected simultaneously.
1752        ///
1753        /// Parameter `descriptor`: The descriptor to create a sample buffer for
1754        ///
1755        /// Parameter `error`: An error return on failure.
1756        #[unsafe(method(newCounterSampleBufferWithDescriptor:error:_))]
1757        #[unsafe(method_family = new)]
1758        fn newCounterSampleBufferWithDescriptor_error(
1759            &self,
1760            descriptor: &MTLCounterSampleBufferDescriptor,
1761        ) -> Result<Retained<ProtocolObject<dyn MTLCounterSampleBuffer>>, Retained<NSError>>;
1762
1763        /// Sample the CPU and GPU timestamps as closely as possible.
1764        ///
1765        /// Parameter `cpuTimestamp`: The timestamp on the CPU
1766        ///
1767        /// Parameter `gpuTimestamp`: The timestamp on the GPU
1768        ///
1769        /// # Safety
1770        ///
1771        /// - `cpu_timestamp` must be a valid pointer.
1772        /// - `gpu_timestamp` must be a valid pointer.
1773        #[unsafe(method(sampleTimestamps:gpuTimestamp:))]
1774        #[unsafe(method_family = none)]
1775        unsafe fn sampleTimestamps_gpuTimestamp(
1776            &self,
1777            cpu_timestamp: NonNull<MTLTimestamp>,
1778            gpu_timestamp: NonNull<MTLTimestamp>,
1779        );
1780
1781        #[cfg(all(feature = "MTLArgument", feature = "MTLArgumentEncoder"))]
1782        #[unsafe(method(newArgumentEncoderWithBufferBinding:))]
1783        #[unsafe(method_family = new)]
1784        fn newArgumentEncoderWithBufferBinding(
1785            &self,
1786            buffer_binding: &ProtocolObject<dyn MTLBufferBinding>,
1787        ) -> Retained<ProtocolObject<dyn MTLArgumentEncoder>>;
1788
1789        /// Query device for counter sampling points support.
1790        ///
1791        /// Parameter `samplingPoint`: Query index
1792        ///
1793        /// Returns: BOOL value. If YES, the device supports counter sampling at given point.
1794        #[unsafe(method(supportsCounterSampling:))]
1795        #[unsafe(method_family = none)]
1796        fn supportsCounterSampling(&self, sampling_point: MTLCounterSamplingPoint) -> bool;
1797
1798        /// Query device for vertex amplification support.
1799        ///
1800        /// Parameter `count`: The amplification count to check
1801        ///
1802        /// Returns: BOOL value. If YES, the device supports vertex amplification with the given count. If NO, the device does not.
1803        #[unsafe(method(supportsVertexAmplificationCount:))]
1804        #[unsafe(method_family = none)]
1805        fn supportsVertexAmplificationCount(&self, count: NSUInteger) -> bool;
1806
1807        /// Query device support for creating and using dynamic libraries in a compute pipeline.
1808        ///
1809        /// Returns: BOOL value. If YES, the device supports creating and using dynamic libraries in a compute pipeline. If NO, the device does not.
1810        #[unsafe(method(supportsDynamicLibraries))]
1811        #[unsafe(method_family = none)]
1812        fn supportsDynamicLibraries(&self) -> bool;
1813
1814        /// Query device support for creating and using dynamic libraries in render pipeline stages.
1815        ///
1816        /// Returns: BOOL value. If YES, the device supports creating and using dynamic libraries in render pipeline stages. If NO, the device does not.
1817        #[unsafe(method(supportsRenderDynamicLibraries))]
1818        #[unsafe(method_family = none)]
1819        fn supportsRenderDynamicLibraries(&self) -> bool;
1820
1821        #[cfg(all(feature = "MTLDynamicLibrary", feature = "MTLLibrary"))]
1822        /// Creates a MTLDynamicLibrary by compiling the code in a MTLLibrary.
1823        ///
1824        /// See: MTLDynamicLibrary
1825        ///
1826        /// Parameter `library`: The MTLLibrary from which to compile code. This library must have .type set to MTLLibraryTypeDynamic.
1827        ///
1828        /// Parameter `error`: If an error occurs during creation, this parameter is updated to describe the failure.
1829        ///
1830        /// Returns: On success, the MTLDynamicLibrary containing compiled code. On failure, nil.
1831        #[unsafe(method(newDynamicLibrary:error:_))]
1832        #[unsafe(method_family = new)]
1833        fn newDynamicLibrary_error(
1834            &self,
1835            library: &ProtocolObject<dyn MTLLibrary>,
1836        ) -> Result<Retained<ProtocolObject<dyn MTLDynamicLibrary>>, Retained<NSError>>;
1837
1838        #[cfg(feature = "MTLDynamicLibrary")]
1839        /// Creates a MTLDynamicLibrary by loading compiled code from a file.
1840        ///
1841        /// See: MTLDynamicLibrary
1842        ///
1843        /// Parameter `url`: The file URL from which to load. If the file contains no compiled code for this device, compilation is attempted as with newDynamicLibrary:error:
1844        ///
1845        /// Parameter `error`: If an error occurs during creation, this parameter is updated to describe the failure.
1846        ///
1847        /// Returns: On success, the MTLDynamicLibrary containing compiled code (either loaded or compiled). On failure, nil.
1848        #[unsafe(method(newDynamicLibraryWithURL:error:_))]
1849        #[unsafe(method_family = new)]
1850        fn newDynamicLibraryWithURL_error(
1851            &self,
1852            url: &NSURL,
1853        ) -> Result<Retained<ProtocolObject<dyn MTLDynamicLibrary>>, Retained<NSError>>;
1854
1855        #[cfg(feature = "MTLBinaryArchive")]
1856        /// Creates a MTLBinaryArchive using the configuration in the descriptor.
1857        ///
1858        /// See: MTLBinaryArchive
1859        ///
1860        /// Parameter `descriptor`: The descriptor for the configuration of the binary archive to create.
1861        ///
1862        /// Parameter `error`: If an error occurs during creation, this parameter is updated to describe the failure.
1863        ///
1864        /// Returns: On success, the created MTLBinaryArchive. On failure, nil.
1865        #[unsafe(method(newBinaryArchiveWithDescriptor:error:_))]
1866        #[unsafe(method_family = new)]
1867        fn newBinaryArchiveWithDescriptor_error(
1868            &self,
1869            descriptor: &MTLBinaryArchiveDescriptor,
1870        ) -> Result<Retained<ProtocolObject<dyn MTLBinaryArchive>>, Retained<NSError>>;
1871
1872        /// Query device support for using ray tracing from compute pipelines.
1873        ///
1874        /// Returns: BOOL value. If YES, the device supports ray tracing from compute pipelines. If NO, the device does not.
1875        #[unsafe(method(supportsRaytracing))]
1876        #[unsafe(method_family = none)]
1877        fn supportsRaytracing(&self) -> bool;
1878
1879        #[cfg(feature = "MTLAccelerationStructure")]
1880        #[unsafe(method(accelerationStructureSizesWithDescriptor:))]
1881        #[unsafe(method_family = none)]
1882        fn accelerationStructureSizesWithDescriptor(
1883            &self,
1884            descriptor: &MTLAccelerationStructureDescriptor,
1885        ) -> MTLAccelerationStructureSizes;
1886
1887        #[cfg(all(
1888            feature = "MTLAccelerationStructure",
1889            feature = "MTLAllocation",
1890            feature = "MTLResource"
1891        ))]
1892        #[unsafe(method(newAccelerationStructureWithSize:))]
1893        #[unsafe(method_family = new)]
1894        fn newAccelerationStructureWithSize(
1895            &self,
1896            size: NSUInteger,
1897        ) -> Option<Retained<ProtocolObject<dyn MTLAccelerationStructure>>>;
1898
1899        #[cfg(all(
1900            feature = "MTLAccelerationStructure",
1901            feature = "MTLAllocation",
1902            feature = "MTLResource"
1903        ))]
1904        #[unsafe(method(newAccelerationStructureWithDescriptor:))]
1905        #[unsafe(method_family = new)]
1906        fn newAccelerationStructureWithDescriptor(
1907            &self,
1908            descriptor: &MTLAccelerationStructureDescriptor,
1909        ) -> Option<Retained<ProtocolObject<dyn MTLAccelerationStructure>>>;
1910
1911        /// Determine the byte size of acceleration structures when sub-allocated from a heap.
1912        ///
1913        /// This method can be used to help determine the required heap size.
1914        ///
1915        /// # Safety
1916        ///
1917        /// `size` might not be bounds-checked.
1918        #[unsafe(method(heapAccelerationStructureSizeAndAlignWithSize:))]
1919        #[unsafe(method_family = none)]
1920        unsafe fn heapAccelerationStructureSizeAndAlignWithSize(
1921            &self,
1922            size: NSUInteger,
1923        ) -> MTLSizeAndAlign;
1924
1925        #[cfg(feature = "MTLAccelerationStructure")]
1926        /// Determine the byte size of acceleration structures when sub-allocated from a heap. This is a convenience method which computes the acceleration structure size based on the descriptor.
1927        ///
1928        /// This method can be used to help determine the required heap size.
1929        #[unsafe(method(heapAccelerationStructureSizeAndAlignWithDescriptor:))]
1930        #[unsafe(method_family = none)]
1931        fn heapAccelerationStructureSizeAndAlignWithDescriptor(
1932            &self,
1933            descriptor: &MTLAccelerationStructureDescriptor,
1934        ) -> MTLSizeAndAlign;
1935
1936        /// Query device support for using function pointers from compute pipelines.
1937        ///
1938        /// Returns: BOOL value. If YES, the device supports function pointers from compute pipelines. If NO, the device does not.
1939        #[unsafe(method(supportsFunctionPointers))]
1940        #[unsafe(method_family = none)]
1941        fn supportsFunctionPointers(&self) -> bool;
1942
1943        /// Query device support for using function pointers from render pipeline stages.
1944        ///
1945        /// Returns: BOOL value. If YES, the device supports function pointers from render pipeline stages. If NO, the device does not.
1946        #[unsafe(method(supportsFunctionPointersFromRender))]
1947        #[unsafe(method_family = none)]
1948        fn supportsFunctionPointersFromRender(&self) -> bool;
1949
1950        /// Query device support for using ray tracing from render pipeline stages.
1951        ///
1952        /// Returns: BOOL value. If YES, the device supports ray tracing from render pipeline stages. If NO, the device does not.
1953        #[unsafe(method(supportsRaytracingFromRender))]
1954        #[unsafe(method_family = none)]
1955        fn supportsRaytracingFromRender(&self) -> bool;
1956
1957        /// Query device support for using ray tracing primitive motion blur.
1958        ///
1959        /// Returns: BOOL value. If YES, the device supports the primitive motion blur api. If NO, the device does not.
1960        #[unsafe(method(supportsPrimitiveMotionBlur))]
1961        #[unsafe(method_family = none)]
1962        fn supportsPrimitiveMotionBlur(&self) -> bool;
1963
1964        /// Allow this device to use additional CPU threads (scaled automatically to the host machine) to be used for compilation tasks. Default is `NO`.
1965        ///
1966        /// Use the `maximumConcurrentCompilationTaskCount` property to determine the current number of concurrent CPU threads that this device is using.
1967        #[unsafe(method(shouldMaximizeConcurrentCompilation))]
1968        #[unsafe(method_family = none)]
1969        fn shouldMaximizeConcurrentCompilation(&self) -> bool;
1970
1971        /// Setter for [`shouldMaximizeConcurrentCompilation`][Self::shouldMaximizeConcurrentCompilation].
1972        #[unsafe(method(setShouldMaximizeConcurrentCompilation:))]
1973        #[unsafe(method_family = none)]
1974        fn setShouldMaximizeConcurrentCompilation(
1975            &self,
1976            should_maximize_concurrent_compilation: bool,
1977        );
1978
1979        /// Returns the maximum count of concurrent executing compilation tasks.
1980        ///
1981        /// The property returns a different value depending on the value of the property `shouldMaximizeConcurrentCompilation`.
1982        #[unsafe(method(maximumConcurrentCompilationTaskCount))]
1983        #[unsafe(method_family = none)]
1984        fn maximumConcurrentCompilationTaskCount(&self) -> NSUInteger;
1985
1986        #[cfg(feature = "MTLResidencySet")]
1987        /// Creates a new residency set with a descriptor.
1988        #[unsafe(method(newResidencySetWithDescriptor:error:_))]
1989        #[unsafe(method_family = new)]
1990        fn newResidencySetWithDescriptor_error(
1991            &self,
1992            desc: &MTLResidencySetDescriptor,
1993        ) -> Result<Retained<ProtocolObject<dyn MTLResidencySet>>, Retained<NSError>>;
1994
1995        #[cfg(feature = "MTLTensor")]
1996        /// Determines the size and alignment required to hold the data of a tensor you create with a descriptor in a buffer.
1997        ///
1998        /// - Parameters:
1999        /// - descriptor: A description of the properties for the new tensor.
2000        /// - Returns: The size and alignment required to hold the data of a tensor you create with `descriptor` in a buffer.
2001        #[unsafe(method(tensorSizeAndAlignWithDescriptor:))]
2002        #[unsafe(method_family = none)]
2003        fn tensorSizeAndAlignWithDescriptor(
2004            &self,
2005            descriptor: &MTLTensorDescriptor,
2006        ) -> MTLSizeAndAlign;
2007
2008        #[cfg(all(
2009            feature = "MTLAllocation",
2010            feature = "MTLResource",
2011            feature = "MTLTensor"
2012        ))]
2013        /// Creates a tensor by allocating new memory.
2014        ///
2015        /// - Parameters:
2016        /// - descriptor: A description of the properties for the new tensor.
2017        /// - error: Metal populates this parameter with information in case an error occurs.
2018        /// - Returns: A new tensor instance that Metal configures using `descriptor` or `nil` if an error occurred.
2019        #[unsafe(method(newTensorWithDescriptor:error:_))]
2020        #[unsafe(method_family = new)]
2021        fn newTensorWithDescriptor_error(
2022            &self,
2023            descriptor: &MTLTensorDescriptor,
2024        ) -> Result<Retained<ProtocolObject<dyn MTLTensor>>, Retained<NSError>>;
2025
2026        #[cfg(all(feature = "MTLFunctionHandle", feature = "MTLLibrary"))]
2027        /// Returns the function handle for a function that was compiled with MTLFunctionOptionPipelineIndependent and MTLFunctionOptionCompileToBinary.
2028        ///
2029        /// # Safety
2030        ///
2031        /// - `function` must be safe to call.
2032        /// - `function` must have the correct argument and return types.
2033        #[unsafe(method(functionHandleWithFunction:))]
2034        #[unsafe(method_family = none)]
2035        unsafe fn functionHandleWithFunction(
2036            &self,
2037            function: &ProtocolObject<dyn MTLFunction>,
2038        ) -> Option<Retained<ProtocolObject<dyn MTLFunctionHandle>>>;
2039
2040        #[cfg(feature = "MTL4CommandAllocator")]
2041        /// Creates a new command allocator.
2042        ///
2043        /// - Returns: A ``MTL4CommandAllocator`` instance, or `nil` if the function failed.
2044        #[unsafe(method(newCommandAllocator))]
2045        #[unsafe(method_family = new)]
2046        fn newCommandAllocator(&self)
2047            -> Option<Retained<ProtocolObject<dyn MTL4CommandAllocator>>>;
2048
2049        #[cfg(feature = "MTL4CommandAllocator")]
2050        /// Creates a new command allocator from a command allocator descriptor.
2051        ///
2052        /// - Parameters:
2053        /// - descriptor: A ``MTL4CommandAllocatorDescriptor`` instance that configures the
2054        /// ``MTL4CommandAllocator`` instance.
2055        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2056        /// if this function fails.
2057        ///
2058        /// - Returns: A ``MTL4CommandAllocator`` instance, or `nil` if the function failed.
2059        #[unsafe(method(newCommandAllocatorWithDescriptor:error:_))]
2060        #[unsafe(method_family = new)]
2061        fn newCommandAllocatorWithDescriptor_error(
2062            &self,
2063            descriptor: &MTL4CommandAllocatorDescriptor,
2064        ) -> Result<Retained<ProtocolObject<dyn MTL4CommandAllocator>>, Retained<NSError>>;
2065
2066        #[cfg(feature = "MTL4CommandQueue")]
2067        /// Creates a new command queue.
2068        ///
2069        /// - Returns: A ``MTL4CommandQueue`` instance, or `nil` if the function failed.
2070        #[unsafe(method(newMTL4CommandQueue))]
2071        #[unsafe(method_family = new)]
2072        fn newMTL4CommandQueue(&self) -> Option<Retained<ProtocolObject<dyn MTL4CommandQueue>>>;
2073
2074        #[cfg(feature = "MTL4CommandQueue")]
2075        /// Creates a new command queue from a queue descriptor.
2076        ///
2077        /// - Parameters:
2078        /// - descriptor: A ``MTL4CommandQueueDescriptor`` instance that configures the
2079        /// ``MTL4CommandQueue`` instance.
2080        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2081        /// if this function fails.
2082        ///
2083        /// - Returns: A ``MTL4CommandQueue`` instance, or `nil` if the function failed.
2084        #[unsafe(method(newMTL4CommandQueueWithDescriptor:error:_))]
2085        #[unsafe(method_family = new)]
2086        fn newMTL4CommandQueueWithDescriptor_error(
2087            &self,
2088            descriptor: &MTL4CommandQueueDescriptor,
2089        ) -> Result<Retained<ProtocolObject<dyn MTL4CommandQueue>>, Retained<NSError>>;
2090
2091        #[cfg(feature = "MTL4CommandBuffer")]
2092        /// Creates a new command buffer.
2093        ///
2094        /// - Returns: A ``MTL4CommandBuffer`` instance, or `nil` if the function failed.
2095        #[unsafe(method(newCommandBuffer))]
2096        #[unsafe(method_family = new)]
2097        fn newCommandBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTL4CommandBuffer>>>;
2098
2099        #[cfg(feature = "MTL4ArgumentTable")]
2100        /// Creates a new argument table from an argument table descriptor.
2101        ///
2102        /// - Parameters:
2103        /// - descriptor: A ``MTL4ArgumentTableDescriptor`` instance that configures the
2104        /// ``MTL4ArgumentTable`` instance.
2105        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2106        /// if this function fails.
2107        ///
2108        /// - Returns: A ``MTL4ArgumentTable`` instance, or `nil` if the function failed.
2109        #[unsafe(method(newArgumentTableWithDescriptor:error:_))]
2110        #[unsafe(method_family = new)]
2111        fn newArgumentTableWithDescriptor_error(
2112            &self,
2113            descriptor: &MTL4ArgumentTableDescriptor,
2114        ) -> Result<Retained<ProtocolObject<dyn MTL4ArgumentTable>>, Retained<NSError>>;
2115
2116        #[cfg(all(feature = "MTLResourceViewPool", feature = "MTLTextureViewPool"))]
2117        /// Creates a new texture view pool from a resource view pool descriptor.
2118        ///
2119        /// - Parameters:
2120        /// - descriptor: A ``MTLResourceViewPoolDescriptor`` instance that configures the
2121        /// ``MTLTextureViewPool`` instance.
2122        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2123        /// if this function fails.
2124        ///
2125        /// - Returns: A ``MTLTextureViewPool`` instance, or `nil` if the function failed.
2126        #[unsafe(method(newTextureViewPoolWithDescriptor:error:_))]
2127        #[unsafe(method_family = new)]
2128        fn newTextureViewPoolWithDescriptor_error(
2129            &self,
2130            descriptor: &MTLResourceViewPoolDescriptor,
2131        ) -> Result<Retained<ProtocolObject<dyn MTLTextureViewPool>>, Retained<NSError>>;
2132
2133        #[cfg(feature = "MTL4Compiler")]
2134        /// Creates a new compiler from a compiler descriptor.
2135        ///
2136        /// - Parameters:
2137        /// - descriptor: A ``MTL4CompilerDescriptor`` instance that configures the
2138        /// ``MTL4Compiler`` instance.
2139        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2140        /// if this function fails.
2141        ///
2142        /// - Returns: A ``MTL4Compiler`` instance, or `nil` if the function failed.
2143        #[unsafe(method(newCompilerWithDescriptor:error:_))]
2144        #[unsafe(method_family = new)]
2145        fn newCompilerWithDescriptor_error(
2146            &self,
2147            descriptor: &MTL4CompilerDescriptor,
2148        ) -> Result<Retained<ProtocolObject<dyn MTL4Compiler>>, Retained<NSError>>;
2149
2150        #[cfg(feature = "MTL4Archive")]
2151        /// Creates a new archive from data available at an `NSURL` address.
2152        ///
2153        /// - Parameters:
2154        /// - url:   An `NSURL` instance that represents the path from which the device loads the ``MTL4Archive``.
2155        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2156        /// if this function fails.
2157        ///
2158        /// - Returns: A ``MTL4Archive`` instance, or `nil` if the function failed.
2159        #[unsafe(method(newArchiveWithURL:error:_))]
2160        #[unsafe(method_family = new)]
2161        fn newArchiveWithURL_error(
2162            &self,
2163            url: &NSURL,
2164        ) -> Result<Retained<ProtocolObject<dyn MTL4Archive>>, Retained<NSError>>;
2165
2166        #[cfg(feature = "MTL4PipelineDataSetSerializer")]
2167        /// Creates a new pipeline data set serializer instance from a descriptor.
2168        ///
2169        /// - Parameter descriptor: A ``MTL4PipelineDataSetSerializerDescriptor`` instance that configures
2170        /// the new ``MTL4PipelineDataSetSerializer`` instance.
2171        ///
2172        /// - Returns: A ``MTL4PipelineDataSetSerializer`` instance, or `nil` if the function failed.
2173        #[unsafe(method(newPipelineDataSetSerializerWithDescriptor:))]
2174        #[unsafe(method_family = new)]
2175        fn newPipelineDataSetSerializerWithDescriptor(
2176            &self,
2177            descriptor: &MTL4PipelineDataSetSerializerDescriptor,
2178        ) -> Retained<ProtocolObject<dyn MTL4PipelineDataSetSerializer>>;
2179
2180        #[cfg(all(
2181            feature = "MTLAllocation",
2182            feature = "MTLBuffer",
2183            feature = "MTLResource"
2184        ))]
2185        /// Creates a new placement sparse buffer of a specific length.
2186        ///
2187        /// This method creates a new placement sparse ``MTLBuffer`` of a specific length. You assign memory to
2188        /// placement sparse buffers using a ``MTLHeap`` of type ``MTLHeapType/MTLHeapTypePlacement``.
2189        ///
2190        /// - Parameters:
2191        /// - length:                  The size of the ``MTLBuffer``, in bytes.
2192        /// - options:                 A ``MTLResourceOptions`` instance that establishes the buffer’s storage modes.
2193        /// - placementSparsePageSize: ``MTLSparsePageSize`` to use for the placement sparse buffer.
2194        ///
2195        /// - Returns: A ``MTLBuffer`` instance, or `nil` if the function failed.
2196        ///
2197        /// # Safety
2198        ///
2199        /// This might not be bounds-checked.
2200        #[unsafe(method(newBufferWithLength:options:placementSparsePageSize:))]
2201        #[unsafe(method_family = new)]
2202        unsafe fn newBufferWithLength_options_placementSparsePageSize(
2203            &self,
2204            length: NSUInteger,
2205            options: MTLResourceOptions,
2206            placement_sparse_page_size: MTLSparsePageSize,
2207        ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
2208
2209        #[cfg(feature = "MTL4Counters")]
2210        /// Creates a new counter heap configured from a counter heap descriptor.
2211        ///
2212        /// - Parameters:
2213        /// - descriptor: ``MTL4CounterHeapDescriptor`` instance that configures the ``MTL4CounterHeap`` instance.
2214        /// - error:      Optional pointer to a `NSError` instance that Metal uses to describe the failure
2215        /// if this function fails.
2216        ///
2217        /// - Returns: A ``MTL4CounterHeap`` instance, or `nil` if the function failed.
2218        #[unsafe(method(newCounterHeapWithDescriptor:error:_))]
2219        #[unsafe(method_family = new)]
2220        fn newCounterHeapWithDescriptor_error(
2221            &self,
2222            descriptor: &MTL4CounterHeapDescriptor,
2223        ) -> Result<Retained<ProtocolObject<dyn MTL4CounterHeap>>, Retained<NSError>>;
2224
2225        #[cfg(feature = "MTL4Counters")]
2226        /// Returns the size, in bytes, of each entry in a counter heap of a specific counter heap type when
2227        /// your app resolves it into a usable format.
2228        ///
2229        /// In order to use the data available in a ``MTL4CounterHeap``, your app first resolves it either in the CPU timeline
2230        /// or in the GPU timeline. When your app calls ``MTL4CommandBuffer/resolveCounterHeap:withRange:intoBuffer:waitFence:updateFence:``
2231        /// to resolve counter data in the GPU timeline, Metal writes the data into a ``MTLBuffer``.
2232        ///
2233        /// During this process, Metal transform the data in the heap into a format consisting of entries of the size
2234        /// that this method advertises, based on the ``MTL4CounterHeapType``.
2235        ///
2236        /// - Parameters:
2237        /// - type: ``MTL4CounterHeapType`` value that represents the type of the ``MTL4CounterHeap`` to resolve.
2238        ///
2239        /// - Returns: The size of the post-transformation entry from a ``MTL4CounterHeap`` of type ``MTL4CounterHeapType``.
2240        #[unsafe(method(sizeOfCounterHeapEntry:))]
2241        #[unsafe(method_family = none)]
2242        fn sizeOfCounterHeapEntry(&self, r#type: MTL4CounterHeapType) -> NSUInteger;
2243
2244        /// Queries the frequency of the GPU timestamp in ticks per second.
2245        ///
2246        /// - Returns: The frequency of the GPU timestamp in ticks per second.
2247        #[unsafe(method(queryTimestampFrequency))]
2248        #[unsafe(method_family = none)]
2249        fn queryTimestampFrequency(&self) -> u64;
2250
2251        #[cfg(all(feature = "MTL4BinaryFunction", feature = "MTLFunctionHandle"))]
2252        /// Get the function handle for the specified binary-linked function from the pipeline state.
2253        ///
2254        /// - Parameters:
2255        /// - function: A ``MTL4BinaryFunction`` instance representing the function binary.
2256        ///
2257        /// - Returns: A ``MTLFunctionHandle`` instance  for a binary function that was compiled with ``MTLFunctionOptionPipelineIndependent``, otherwise `nil`.
2258        #[unsafe(method(functionHandleWithBinaryFunction:))]
2259        #[unsafe(method_family = none)]
2260        fn functionHandleWithBinaryFunction(
2261            &self,
2262            function: &ProtocolObject<dyn MTL4BinaryFunction>,
2263        ) -> Option<Retained<ProtocolObject<dyn MTLFunctionHandle>>>;
2264    }
2265);