icrate/generated/Metal/
MTLDevice.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use crate::common::*;
4use crate::Foundation::*;
5use crate::Metal::*;
6
7ns_enum!(
8    #[underlying(NSInteger)]
9    pub enum MTLIOCompressionMethod {
10        MTLIOCompressionMethodZlib = 0,
11        MTLIOCompressionMethodLZFSE = 1,
12        MTLIOCompressionMethodLZ4 = 2,
13        MTLIOCompressionMethodLZMA = 3,
14        MTLIOCompressionMethodLZBitmap = 4,
15    }
16);
17
18extern_fn!(
19    pub unsafe fn MTLCreateSystemDefaultDevice() -> *mut ProtocolObject<dyn MTLDevice>;
20);
21
22extern_fn!(
23    #[cfg(feature = "Foundation_NSArray")]
24    pub unsafe fn MTLCopyAllDevices() -> NonNull<NSArray<ProtocolObject<dyn MTLDevice>>>;
25);
26
27typed_enum!(
28    pub type MTLDeviceNotificationName = NSString;
29);
30
31extern_static!(MTLDeviceWasAddedNotification: &'static MTLDeviceNotificationName);
32
33extern_static!(MTLDeviceRemovalRequestedNotification: &'static MTLDeviceNotificationName);
34
35extern_static!(MTLDeviceWasRemovedNotification: &'static MTLDeviceNotificationName);
36
37pub type MTLDeviceNotificationHandler = *mut Block<
38    (
39        NonNull<ProtocolObject<dyn MTLDevice>>,
40        NonNull<MTLDeviceNotificationName>,
41    ),
42    (),
43>;
44
45extern_fn!(
46    pub unsafe fn MTLRemoveDeviceObserver(observer: &NSObject);
47);
48
49ns_enum!(
50    #[underlying(NSUInteger)]
51    #[deprecated = "Use MTLGPUFamily instead"]
52    pub enum MTLFeatureSet {
53        MTLFeatureSet_iOS_GPUFamily1_v1 = 0,
54        MTLFeatureSet_iOS_GPUFamily2_v1 = 1,
55        MTLFeatureSet_iOS_GPUFamily1_v2 = 2,
56        MTLFeatureSet_iOS_GPUFamily2_v2 = 3,
57        MTLFeatureSet_iOS_GPUFamily3_v1 = 4,
58        MTLFeatureSet_iOS_GPUFamily1_v3 = 5,
59        MTLFeatureSet_iOS_GPUFamily2_v3 = 6,
60        MTLFeatureSet_iOS_GPUFamily3_v2 = 7,
61        MTLFeatureSet_iOS_GPUFamily1_v4 = 8,
62        MTLFeatureSet_iOS_GPUFamily2_v4 = 9,
63        MTLFeatureSet_iOS_GPUFamily3_v3 = 10,
64        MTLFeatureSet_iOS_GPUFamily4_v1 = 11,
65        MTLFeatureSet_iOS_GPUFamily1_v5 = 12,
66        MTLFeatureSet_iOS_GPUFamily2_v5 = 13,
67        MTLFeatureSet_iOS_GPUFamily3_v4 = 14,
68        MTLFeatureSet_iOS_GPUFamily4_v2 = 15,
69        MTLFeatureSet_iOS_GPUFamily5_v1 = 16,
70        MTLFeatureSet_macOS_GPUFamily1_v1 = 10000,
71        MTLFeatureSet_OSX_GPUFamily1_v1 = MTLFeatureSet_macOS_GPUFamily1_v1,
72        MTLFeatureSet_macOS_GPUFamily1_v2 = 10001,
73        MTLFeatureSet_OSX_GPUFamily1_v2 = MTLFeatureSet_macOS_GPUFamily1_v2,
74        MTLFeatureSet_macOS_ReadWriteTextureTier2 = 10002,
75        MTLFeatureSet_OSX_ReadWriteTextureTier2 = MTLFeatureSet_macOS_ReadWriteTextureTier2,
76        MTLFeatureSet_macOS_GPUFamily1_v3 = 10003,
77        MTLFeatureSet_macOS_GPUFamily1_v4 = 10004,
78        MTLFeatureSet_macOS_GPUFamily2_v1 = 10005,
79        MTLFeatureSet_tvOS_GPUFamily1_v1 = 30000,
80        MTLFeatureSet_TVOS_GPUFamily1_v1 = MTLFeatureSet_tvOS_GPUFamily1_v1,
81        MTLFeatureSet_tvOS_GPUFamily1_v2 = 30001,
82        MTLFeatureSet_tvOS_GPUFamily1_v3 = 30002,
83        MTLFeatureSet_tvOS_GPUFamily2_v1 = 30003,
84        MTLFeatureSet_tvOS_GPUFamily1_v4 = 30004,
85        MTLFeatureSet_tvOS_GPUFamily2_v2 = 30005,
86    }
87);
88
89ns_enum!(
90    #[underlying(NSInteger)]
91    pub enum MTLGPUFamily {
92        MTLGPUFamilyApple1 = 1001,
93        MTLGPUFamilyApple2 = 1002,
94        MTLGPUFamilyApple3 = 1003,
95        MTLGPUFamilyApple4 = 1004,
96        MTLGPUFamilyApple5 = 1005,
97        MTLGPUFamilyApple6 = 1006,
98        MTLGPUFamilyApple7 = 1007,
99        MTLGPUFamilyApple8 = 1008,
100        MTLGPUFamilyApple9 = 1009,
101        #[deprecated]
102        MTLGPUFamilyMac1 = 2001,
103        MTLGPUFamilyMac2 = 2002,
104        MTLGPUFamilyCommon1 = 3001,
105        MTLGPUFamilyCommon2 = 3002,
106        MTLGPUFamilyCommon3 = 3003,
107        #[deprecated]
108        MTLGPUFamilyMacCatalyst1 = 4001,
109        #[deprecated]
110        MTLGPUFamilyMacCatalyst2 = 4002,
111        MTLGPUFamilyMetal3 = 5001,
112    }
113);
114
115ns_enum!(
116    #[underlying(NSUInteger)]
117    pub enum MTLDeviceLocation {
118        MTLDeviceLocationBuiltIn = 0,
119        MTLDeviceLocationSlot = 1,
120        MTLDeviceLocationExternal = 2,
121        MTLDeviceLocationUnspecified = NSUIntegerMax as _,
122    }
123);
124
125ns_options!(
126    #[underlying(NSUInteger)]
127    pub enum MTLPipelineOption {
128        MTLPipelineOptionNone = 0,
129        MTLPipelineOptionArgumentInfo = 1 << 0,
130        MTLPipelineOptionBufferTypeInfo = 1 << 1,
131        MTLPipelineOptionFailOnBinaryArchiveMiss = 1 << 2,
132    }
133);
134
135ns_enum!(
136    #[underlying(NSUInteger)]
137    pub enum MTLReadWriteTextureTier {
138        MTLReadWriteTextureTierNone = 0,
139        MTLReadWriteTextureTier1 = 1,
140        MTLReadWriteTextureTier2 = 2,
141    }
142);
143
144ns_enum!(
145    #[underlying(NSUInteger)]
146    pub enum MTLArgumentBuffersTier {
147        MTLArgumentBuffersTier1 = 0,
148        MTLArgumentBuffersTier2 = 1,
149    }
150);
151
152ns_enum!(
153    #[underlying(NSUInteger)]
154    pub enum MTLSparseTextureRegionAlignmentMode {
155        MTLSparseTextureRegionAlignmentModeOutward = 0,
156        MTLSparseTextureRegionAlignmentModeInward = 1,
157    }
158);
159
160ns_enum!(
161    #[underlying(NSInteger)]
162    pub enum MTLSparsePageSize {
163        MTLSparsePageSize16 = 101,
164        MTLSparsePageSize64 = 102,
165        MTLSparsePageSize256 = 103,
166    }
167);
168
169extern_struct!(
170    #[encoding_name("?")]
171    pub struct MTLAccelerationStructureSizes {
172        pub accelerationStructureSize: NSUInteger,
173        pub buildScratchBufferSize: NSUInteger,
174        pub refitScratchBufferSize: NSUInteger,
175    }
176);
177
178ns_enum!(
179    #[underlying(NSUInteger)]
180    pub enum MTLCounterSamplingPoint {
181        MTLCounterSamplingPointAtStageBoundary = 0,
182        MTLCounterSamplingPointAtDrawBoundary = 1,
183        MTLCounterSamplingPointAtDispatchBoundary = 2,
184        MTLCounterSamplingPointAtTileDispatchBoundary = 3,
185        MTLCounterSamplingPointAtBlitBoundary = 4,
186    }
187);
188
189extern_struct!(
190    #[encoding_name("?")]
191    pub struct MTLSizeAndAlign {
192        pub size: NSUInteger,
193        pub align: NSUInteger,
194    }
195);
196
197pub type MTLNewLibraryCompletionHandler =
198    *mut Block<(*mut ProtocolObject<dyn MTLLibrary>, *mut NSError), ()>;
199
200pub type MTLNewRenderPipelineStateCompletionHandler = *mut Block<
201    (
202        *mut ProtocolObject<dyn MTLRenderPipelineState>,
203        *mut NSError,
204    ),
205    (),
206>;
207
208pub type MTLNewRenderPipelineStateWithReflectionCompletionHandler = *mut Block<
209    (
210        *mut ProtocolObject<dyn MTLRenderPipelineState>,
211        *mut MTLRenderPipelineReflection,
212        *mut NSError,
213    ),
214    (),
215>;
216
217pub type MTLNewComputePipelineStateCompletionHandler = *mut Block<
218    (
219        *mut ProtocolObject<dyn MTLComputePipelineState>,
220        *mut NSError,
221    ),
222    (),
223>;
224
225pub type MTLNewComputePipelineStateWithReflectionCompletionHandler = *mut Block<
226    (
227        *mut ProtocolObject<dyn MTLComputePipelineState>,
228        *mut MTLComputePipelineReflection,
229        *mut NSError,
230    ),
231    (),
232>;
233
234extern_class!(
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    #[cfg(feature = "Metal_MTLArgumentDescriptor")]
237    pub struct MTLArgumentDescriptor;
238
239    #[cfg(feature = "Metal_MTLArgumentDescriptor")]
240    unsafe impl ClassType for MTLArgumentDescriptor {
241        type Super = NSObject;
242        type Mutability = InteriorMutable;
243    }
244);
245
246#[cfg(feature = "Metal_MTLArgumentDescriptor")]
247unsafe impl NSCopying for MTLArgumentDescriptor {}
248
249#[cfg(feature = "Metal_MTLArgumentDescriptor")]
250unsafe impl NSObjectProtocol for MTLArgumentDescriptor {}
251
252extern_methods!(
253    #[cfg(feature = "Metal_MTLArgumentDescriptor")]
254    unsafe impl MTLArgumentDescriptor {
255        #[method_id(@__retain_semantics Other argumentDescriptor)]
256        pub fn argumentDescriptor() -> Id<MTLArgumentDescriptor>;
257
258        #[method(dataType)]
259        pub unsafe fn dataType(&self) -> MTLDataType;
260
261        #[method(setDataType:)]
262        pub fn setDataType(&self, data_type: MTLDataType);
263
264        #[method(index)]
265        pub unsafe fn index(&self) -> NSUInteger;
266
267        #[method(setIndex:)]
268        pub fn setIndex(&self, index: NSUInteger);
269
270        #[method(arrayLength)]
271        pub unsafe fn arrayLength(&self) -> NSUInteger;
272
273        #[method(setArrayLength:)]
274        pub unsafe fn setArrayLength(&self, array_length: NSUInteger);
275
276        #[method(access)]
277        pub unsafe fn access(&self) -> MTLBindingAccess;
278
279        #[method(setAccess:)]
280        pub fn setAccess(&self, access: MTLBindingAccess);
281
282        #[method(textureType)]
283        pub unsafe fn textureType(&self) -> MTLTextureType;
284
285        #[method(setTextureType:)]
286        pub fn setTextureType(&self, texture_type: MTLTextureType);
287
288        #[method(constantBlockAlignment)]
289        pub unsafe fn constantBlockAlignment(&self) -> NSUInteger;
290
291        #[method(setConstantBlockAlignment:)]
292        pub unsafe fn setConstantBlockAlignment(&self, constant_block_alignment: NSUInteger);
293    }
294);
295
296extern_methods!(
297    /// Methods declared on superclass `NSObject`
298    #[cfg(feature = "Metal_MTLArgumentDescriptor")]
299    unsafe impl MTLArgumentDescriptor {
300        #[method_id(@__retain_semantics Init init)]
301        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
302
303        #[method_id(@__retain_semantics New new)]
304        pub unsafe fn new() -> Id<Self>;
305    }
306);
307
308extern_class!(
309    #[derive(Debug, PartialEq, Eq, Hash)]
310    #[cfg(feature = "Metal_MTLArchitecture")]
311    pub struct MTLArchitecture;
312
313    #[cfg(feature = "Metal_MTLArchitecture")]
314    unsafe impl ClassType for MTLArchitecture {
315        type Super = NSObject;
316        type Mutability = InteriorMutable;
317    }
318);
319
320#[cfg(feature = "Metal_MTLArchitecture")]
321unsafe impl NSCopying for MTLArchitecture {}
322
323#[cfg(feature = "Metal_MTLArchitecture")]
324unsafe impl NSObjectProtocol for MTLArchitecture {}
325
326extern_methods!(
327    #[cfg(feature = "Metal_MTLArchitecture")]
328    unsafe impl MTLArchitecture {
329        #[cfg(feature = "Foundation_NSString")]
330        #[method_id(@__retain_semantics Other name)]
331        pub unsafe fn name(&self) -> Id<NSString>;
332    }
333);
334
335extern_methods!(
336    /// Methods declared on superclass `NSObject`
337    #[cfg(feature = "Metal_MTLArchitecture")]
338    unsafe impl MTLArchitecture {
339        #[method_id(@__retain_semantics Init init)]
340        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
341
342        #[method_id(@__retain_semantics New new)]
343        pub unsafe fn new() -> Id<Self>;
344    }
345);
346
347pub type MTLTimestamp = u64;
348
349extern_protocol!(
350    pub unsafe trait MTLDevice: NSObjectProtocol {
351        #[cfg(feature = "Foundation_NSString")]
352        #[method_id(@__retain_semantics Other name)]
353        fn name(&self) -> Id<NSString>;
354
355        #[method(registryID)]
356        fn registryID(&self) -> u64;
357
358        #[cfg(feature = "Metal_MTLArchitecture")]
359        #[method_id(@__retain_semantics Other architecture)]
360        unsafe fn architecture(&self) -> Id<MTLArchitecture>;
361
362        #[method(maxThreadsPerThreadgroup)]
363        fn maxThreadsPerThreadgroup(&self) -> MTLSize;
364
365        #[method(isLowPower)]
366        fn isLowPower(&self) -> bool;
367
368        #[method(isHeadless)]
369        fn isHeadless(&self) -> bool;
370
371        #[method(isRemovable)]
372        fn isRemovable(&self) -> bool;
373
374        #[method(hasUnifiedMemory)]
375        fn hasUnifiedMemory(&self) -> bool;
376
377        #[method(recommendedMaxWorkingSetSize)]
378        fn recommendedMaxWorkingSetSize(&self) -> u64;
379
380        #[method(location)]
381        fn location(&self) -> MTLDeviceLocation;
382
383        #[method(locationNumber)]
384        fn locationNumber(&self) -> NSUInteger;
385
386        #[method(maxTransferRate)]
387        fn maxTransferRate(&self) -> u64;
388
389        #[method(isDepth24Stencil8PixelFormatSupported)]
390        fn isDepth24Stencil8PixelFormatSupported(&self) -> bool;
391
392        #[method(readWriteTextureSupport)]
393        fn readWriteTextureSupport(&self) -> MTLReadWriteTextureTier;
394
395        #[method(argumentBuffersSupport)]
396        fn argumentBuffersSupport(&self) -> MTLArgumentBuffersTier;
397
398        #[method(areRasterOrderGroupsSupported)]
399        unsafe fn areRasterOrderGroupsSupported(&self) -> bool;
400
401        #[method(supports32BitFloatFiltering)]
402        fn supports32BitFloatFiltering(&self) -> bool;
403
404        #[method(supports32BitMSAA)]
405        fn supports32BitMSAA(&self) -> bool;
406
407        #[method(supportsQueryTextureLOD)]
408        fn supportsQueryTextureLOD(&self) -> bool;
409
410        #[method(supportsBCTextureCompression)]
411        fn supportsBCTextureCompression(&self) -> bool;
412
413        #[method(supportsPullModelInterpolation)]
414        fn supportsPullModelInterpolation(&self) -> bool;
415
416        #[deprecated]
417        #[method(areBarycentricCoordsSupported)]
418        unsafe fn areBarycentricCoordsSupported(&self) -> bool;
419
420        #[method(supportsShaderBarycentricCoordinates)]
421        fn supportsShaderBarycentricCoordinates(&self) -> bool;
422
423        #[method(currentAllocatedSize)]
424        fn currentAllocatedSize(&self) -> NSUInteger;
425
426        #[method_id(@__retain_semantics New newCommandQueue)]
427        fn newCommandQueue(&self) -> Option<Id<ProtocolObject<dyn MTLCommandQueue>>>;
428
429        #[method_id(@__retain_semantics New newCommandQueueWithMaxCommandBufferCount:)]
430        fn newCommandQueueWithMaxCommandBufferCount(
431            &self,
432            max_command_buffer_count: NSUInteger,
433        ) -> Option<Id<ProtocolObject<dyn MTLCommandQueue>>>;
434
435        #[cfg(feature = "Metal_MTLTextureDescriptor")]
436        #[method(heapTextureSizeAndAlignWithDescriptor:)]
437        fn heapTextureSizeAndAlignWithDescriptor(
438            &self,
439            desc: &MTLTextureDescriptor,
440        ) -> MTLSizeAndAlign;
441
442        #[method(heapBufferSizeAndAlignWithLength:options:)]
443        fn heapBufferSizeAndAlignWithLength_options(
444            &self,
445            length: NSUInteger,
446            options: MTLResourceOptions,
447        ) -> MTLSizeAndAlign;
448
449        #[cfg(feature = "Metal_MTLHeapDescriptor")]
450        #[method_id(@__retain_semantics New newHeapWithDescriptor:)]
451        fn newHeapWithDescriptor(
452            &self,
453            descriptor: &MTLHeapDescriptor,
454        ) -> Option<Id<ProtocolObject<dyn MTLHeap>>>;
455
456        #[method_id(@__retain_semantics New newBufferWithLength:options:)]
457        fn newBufferWithLength_options(
458            &self,
459            length: NSUInteger,
460            options: MTLResourceOptions,
461        ) -> Option<Id<ProtocolObject<dyn MTLBuffer>>>;
462
463        #[method_id(@__retain_semantics New newBufferWithBytes:length:options:)]
464        unsafe fn newBufferWithBytes_length_options(
465            &self,
466            pointer: NonNull<c_void>,
467            length: NSUInteger,
468            options: MTLResourceOptions,
469        ) -> Option<Id<ProtocolObject<dyn MTLBuffer>>>;
470
471        #[method_id(@__retain_semantics New newBufferWithBytesNoCopy:length:options:deallocator:)]
472        unsafe fn newBufferWithBytesNoCopy_length_options_deallocator(
473            &self,
474            pointer: NonNull<c_void>,
475            length: NSUInteger,
476            options: MTLResourceOptions,
477            deallocator: Option<&Block<(NonNull<c_void>, NSUInteger), ()>>,
478        ) -> Option<Id<ProtocolObject<dyn MTLBuffer>>>;
479
480        #[cfg(feature = "Metal_MTLDepthStencilDescriptor")]
481        #[method_id(@__retain_semantics New newDepthStencilStateWithDescriptor:)]
482        fn newDepthStencilStateWithDescriptor(
483            &self,
484            descriptor: &MTLDepthStencilDescriptor,
485        ) -> Option<Id<ProtocolObject<dyn MTLDepthStencilState>>>;
486
487        #[cfg(feature = "Metal_MTLTextureDescriptor")]
488        #[method_id(@__retain_semantics New newTextureWithDescriptor:)]
489        fn newTextureWithDescriptor(
490            &self,
491            descriptor: &MTLTextureDescriptor,
492        ) -> Option<Id<ProtocolObject<dyn MTLTexture>>>;
493
494        #[cfg(feature = "Metal_MTLTextureDescriptor")]
495        #[method_id(@__retain_semantics New newSharedTextureWithDescriptor:)]
496        unsafe fn newSharedTextureWithDescriptor(
497            &self,
498            descriptor: &MTLTextureDescriptor,
499        ) -> Option<Id<ProtocolObject<dyn MTLTexture>>>;
500
501        #[cfg(feature = "Metal_MTLSharedTextureHandle")]
502        #[method_id(@__retain_semantics New newSharedTextureWithHandle:)]
503        unsafe fn newSharedTextureWithHandle(
504            &self,
505            shared_handle: &MTLSharedTextureHandle,
506        ) -> Option<Id<ProtocolObject<dyn MTLTexture>>>;
507
508        #[cfg(feature = "Metal_MTLSamplerDescriptor")]
509        #[method_id(@__retain_semantics New newSamplerStateWithDescriptor:)]
510        fn newSamplerStateWithDescriptor(
511            &self,
512            descriptor: &MTLSamplerDescriptor,
513        ) -> Option<Id<ProtocolObject<dyn MTLSamplerState>>>;
514
515        #[method_id(@__retain_semantics New newDefaultLibrary)]
516        fn newDefaultLibrary(&self) -> Option<Id<ProtocolObject<dyn MTLLibrary>>>;
517
518        #[cfg(all(feature = "Foundation_NSBundle", feature = "Foundation_NSError"))]
519        #[method_id(@__retain_semantics New newDefaultLibraryWithBundle:error:_)]
520        unsafe fn newDefaultLibraryWithBundle_error(
521            &self,
522            bundle: &NSBundle,
523        ) -> Result<Id<ProtocolObject<dyn MTLLibrary>>, Id<NSError>>;
524
525        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSString"))]
526        #[deprecated = "Use -newLibraryWithURL:error: instead"]
527        #[method_id(@__retain_semantics New newLibraryWithFile:error:_)]
528        fn newLibraryWithFile_error(
529            &self,
530            filepath: &NSString,
531        ) -> Result<Id<ProtocolObject<dyn MTLLibrary>>, Id<NSError>>;
532
533        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
534        #[method_id(@__retain_semantics New newLibraryWithURL:error:_)]
535        unsafe fn newLibraryWithURL_error(
536            &self,
537            url: &NSURL,
538        ) -> Result<Id<ProtocolObject<dyn MTLLibrary>>, Id<NSError>>;
539
540        #[cfg(all(
541            feature = "Foundation_NSError",
542            feature = "Foundation_NSString",
543            feature = "Metal_MTLCompileOptions"
544        ))]
545        #[method_id(@__retain_semantics New newLibraryWithSource:options:error:_)]
546        fn newLibraryWithSource_options_error(
547            &self,
548            source: &NSString,
549            options: Option<&MTLCompileOptions>,
550        ) -> Result<Id<ProtocolObject<dyn MTLLibrary>>, Id<NSError>>;
551
552        #[cfg(all(feature = "Foundation_NSString", feature = "Metal_MTLCompileOptions"))]
553        #[method(newLibraryWithSource:options:completionHandler:)]
554        unsafe fn newLibraryWithSource_options_completionHandler(
555            &self,
556            source: &NSString,
557            options: Option<&MTLCompileOptions>,
558            completion_handler: MTLNewLibraryCompletionHandler,
559        );
560
561        #[cfg(all(
562            feature = "Foundation_NSError",
563            feature = "Metal_MTLStitchedLibraryDescriptor"
564        ))]
565        #[method_id(@__retain_semantics New newLibraryWithStitchedDescriptor:error:_)]
566        unsafe fn newLibraryWithStitchedDescriptor_error(
567            &self,
568            descriptor: &MTLStitchedLibraryDescriptor,
569        ) -> Result<Id<ProtocolObject<dyn MTLLibrary>>, Id<NSError>>;
570
571        #[cfg(feature = "Metal_MTLStitchedLibraryDescriptor")]
572        #[method(newLibraryWithStitchedDescriptor:completionHandler:)]
573        unsafe fn newLibraryWithStitchedDescriptor_completionHandler(
574            &self,
575            descriptor: &MTLStitchedLibraryDescriptor,
576            completion_handler: MTLNewLibraryCompletionHandler,
577        );
578
579        #[cfg(all(
580            feature = "Foundation_NSError",
581            feature = "Metal_MTLRenderPipelineDescriptor"
582        ))]
583        #[method_id(@__retain_semantics New newRenderPipelineStateWithDescriptor:error:_)]
584        fn newRenderPipelineStateWithDescriptor_error(
585            &self,
586            descriptor: &MTLRenderPipelineDescriptor,
587        ) -> Result<Id<ProtocolObject<dyn MTLRenderPipelineState>>, Id<NSError>>;
588
589        #[cfg(feature = "Metal_MTLRenderPipelineDescriptor")]
590        #[method(newRenderPipelineStateWithDescriptor:completionHandler:)]
591        unsafe fn newRenderPipelineStateWithDescriptor_completionHandler(
592            &self,
593            descriptor: &MTLRenderPipelineDescriptor,
594            completion_handler: MTLNewRenderPipelineStateCompletionHandler,
595        );
596
597        #[cfg(feature = "Metal_MTLRenderPipelineDescriptor")]
598        #[method(newRenderPipelineStateWithDescriptor:options:completionHandler:)]
599        unsafe fn newRenderPipelineStateWithDescriptor_options_completionHandler(
600            &self,
601            descriptor: &MTLRenderPipelineDescriptor,
602            options: MTLPipelineOption,
603            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
604        );
605
606        #[cfg(feature = "Foundation_NSError")]
607        #[method_id(@__retain_semantics New newComputePipelineStateWithFunction:error:_)]
608        fn newComputePipelineStateWithFunction_error(
609            &self,
610            compute_function: &ProtocolObject<dyn MTLFunction>,
611        ) -> Result<Id<ProtocolObject<dyn MTLComputePipelineState>>, Id<NSError>>;
612
613        #[method(newComputePipelineStateWithFunction:completionHandler:)]
614        unsafe fn newComputePipelineStateWithFunction_completionHandler(
615            &self,
616            compute_function: &ProtocolObject<dyn MTLFunction>,
617            completion_handler: MTLNewComputePipelineStateCompletionHandler,
618        );
619
620        #[method(newComputePipelineStateWithFunction:options:completionHandler:)]
621        unsafe fn newComputePipelineStateWithFunction_options_completionHandler(
622            &self,
623            compute_function: &ProtocolObject<dyn MTLFunction>,
624            options: MTLPipelineOption,
625            completion_handler: MTLNewComputePipelineStateWithReflectionCompletionHandler,
626        );
627
628        #[cfg(feature = "Metal_MTLComputePipelineDescriptor")]
629        #[method(newComputePipelineStateWithDescriptor:options:completionHandler:)]
630        unsafe fn newComputePipelineStateWithDescriptor_options_completionHandler(
631            &self,
632            descriptor: &MTLComputePipelineDescriptor,
633            options: MTLPipelineOption,
634            completion_handler: MTLNewComputePipelineStateWithReflectionCompletionHandler,
635        );
636
637        #[method_id(@__retain_semantics New newFence)]
638        fn newFence(&self) -> Option<Id<ProtocolObject<dyn MTLFence>>>;
639
640        #[deprecated = "Use supportsFamily instead"]
641        #[method(supportsFeatureSet:)]
642        fn supportsFeatureSet(&self, feature_set: MTLFeatureSet) -> bool;
643
644        #[method(supportsFamily:)]
645        fn supportsFamily(&self, gpu_family: MTLGPUFamily) -> bool;
646
647        #[method(supportsTextureSampleCount:)]
648        fn supportsTextureSampleCount(&self, sample_count: NSUInteger) -> bool;
649
650        #[method(minimumLinearTextureAlignmentForPixelFormat:)]
651        fn minimumLinearTextureAlignmentForPixelFormat(&self, format: MTLPixelFormat)
652            -> NSUInteger;
653
654        #[method(minimumTextureBufferAlignmentForPixelFormat:)]
655        fn minimumTextureBufferAlignmentForPixelFormat(&self, format: MTLPixelFormat)
656            -> NSUInteger;
657
658        #[cfg(feature = "Metal_MTLTileRenderPipelineDescriptor")]
659        #[method(newRenderPipelineStateWithTileDescriptor:options:completionHandler:)]
660        unsafe fn newRenderPipelineStateWithTileDescriptor_options_completionHandler(
661            &self,
662            descriptor: &MTLTileRenderPipelineDescriptor,
663            options: MTLPipelineOption,
664            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
665        );
666
667        #[cfg(feature = "Metal_MTLMeshRenderPipelineDescriptor")]
668        #[method(newRenderPipelineStateWithMeshDescriptor:options:completionHandler:)]
669        unsafe fn newRenderPipelineStateWithMeshDescriptor_options_completionHandler(
670            &self,
671            descriptor: &MTLMeshRenderPipelineDescriptor,
672            options: MTLPipelineOption,
673            completion_handler: MTLNewRenderPipelineStateWithReflectionCompletionHandler,
674        );
675
676        #[method(maxThreadgroupMemoryLength)]
677        fn maxThreadgroupMemoryLength(&self) -> NSUInteger;
678
679        #[method(maxArgumentBufferSamplerCount)]
680        fn maxArgumentBufferSamplerCount(&self) -> NSUInteger;
681
682        #[method(areProgrammableSamplePositionsSupported)]
683        unsafe fn areProgrammableSamplePositionsSupported(&self) -> bool;
684
685        #[method(getDefaultSamplePositions:count:)]
686        unsafe fn getDefaultSamplePositions_count(
687            &self,
688            positions: NonNull<MTLSamplePosition>,
689            count: NSUInteger,
690        );
691
692        #[cfg(all(
693            feature = "Foundation_NSArray",
694            feature = "Metal_MTLArgumentDescriptor"
695        ))]
696        #[method_id(@__retain_semantics New newArgumentEncoderWithArguments:)]
697        fn newArgumentEncoderWithArguments(
698            &self,
699            arguments: &NSArray<MTLArgumentDescriptor>,
700        ) -> Option<Id<ProtocolObject<dyn MTLArgumentEncoder>>>;
701
702        #[method(supportsRasterizationRateMapWithLayerCount:)]
703        unsafe fn supportsRasterizationRateMapWithLayerCount(
704            &self,
705            layer_count: NSUInteger,
706        ) -> bool;
707
708        #[cfg(feature = "Metal_MTLRasterizationRateMapDescriptor")]
709        #[method_id(@__retain_semantics New newRasterizationRateMapWithDescriptor:)]
710        unsafe fn newRasterizationRateMapWithDescriptor(
711            &self,
712            descriptor: &MTLRasterizationRateMapDescriptor,
713        ) -> Option<Id<ProtocolObject<dyn MTLRasterizationRateMap>>>;
714
715        #[cfg(feature = "Metal_MTLIndirectCommandBufferDescriptor")]
716        #[method_id(@__retain_semantics New newIndirectCommandBufferWithDescriptor:maxCommandCount:options:)]
717        unsafe fn newIndirectCommandBufferWithDescriptor_maxCommandCount_options(
718            &self,
719            descriptor: &MTLIndirectCommandBufferDescriptor,
720            max_count: NSUInteger,
721            options: MTLResourceOptions,
722        ) -> Option<Id<ProtocolObject<dyn MTLIndirectCommandBuffer>>>;
723
724        #[method_id(@__retain_semantics New newEvent)]
725        fn newEvent(&self) -> Option<Id<ProtocolObject<dyn MTLEvent>>>;
726
727        #[method_id(@__retain_semantics New newSharedEvent)]
728        fn newSharedEvent(&self) -> Option<Id<ProtocolObject<dyn MTLSharedEvent>>>;
729
730        #[cfg(feature = "Metal_MTLSharedEventHandle")]
731        #[method_id(@__retain_semantics New newSharedEventWithHandle:)]
732        unsafe fn newSharedEventWithHandle(
733            &self,
734            shared_event_handle: &MTLSharedEventHandle,
735        ) -> Option<Id<ProtocolObject<dyn MTLSharedEvent>>>;
736
737        #[method(peerGroupID)]
738        unsafe fn peerGroupID(&self) -> u64;
739
740        #[method(peerIndex)]
741        unsafe fn peerIndex(&self) -> u32;
742
743        #[method(peerCount)]
744        unsafe fn peerCount(&self) -> u32;
745
746        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
747        #[deprecated]
748        #[method_id(@__retain_semantics New newIOHandleWithURL:error:_)]
749        unsafe fn newIOHandleWithURL_error(
750            &self,
751            url: &NSURL,
752        ) -> Result<Id<ProtocolObject<dyn MTLIOFileHandle>>, Id<NSError>>;
753
754        #[cfg(all(
755            feature = "Foundation_NSError",
756            feature = "Metal_MTLIOCommandQueueDescriptor"
757        ))]
758        #[method_id(@__retain_semantics New newIOCommandQueueWithDescriptor:error:_)]
759        unsafe fn newIOCommandQueueWithDescriptor_error(
760            &self,
761            descriptor: &MTLIOCommandQueueDescriptor,
762        ) -> Result<Id<ProtocolObject<dyn MTLIOCommandQueue>>, Id<NSError>>;
763
764        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
765        #[deprecated]
766        #[method_id(@__retain_semantics New newIOHandleWithURL:compressionMethod:error:_)]
767        unsafe fn newIOHandleWithURL_compressionMethod_error(
768            &self,
769            url: &NSURL,
770            compression_method: MTLIOCompressionMethod,
771        ) -> Result<Id<ProtocolObject<dyn MTLIOFileHandle>>, Id<NSError>>;
772
773        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
774        #[method_id(@__retain_semantics New newIOFileHandleWithURL:error:_)]
775        unsafe fn newIOFileHandleWithURL_error(
776            &self,
777            url: &NSURL,
778        ) -> Result<Id<ProtocolObject<dyn MTLIOFileHandle>>, Id<NSError>>;
779
780        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
781        #[method_id(@__retain_semantics New newIOFileHandleWithURL:compressionMethod:error:_)]
782        unsafe fn newIOFileHandleWithURL_compressionMethod_error(
783            &self,
784            url: &NSURL,
785            compression_method: MTLIOCompressionMethod,
786        ) -> Result<Id<ProtocolObject<dyn MTLIOFileHandle>>, Id<NSError>>;
787
788        #[method(sparseTileSizeWithTextureType:pixelFormat:sampleCount:)]
789        unsafe fn sparseTileSizeWithTextureType_pixelFormat_sampleCount(
790            &self,
791            texture_type: MTLTextureType,
792            pixel_format: MTLPixelFormat,
793            sample_count: NSUInteger,
794        ) -> MTLSize;
795
796        #[method(sparseTileSizeInBytes)]
797        unsafe fn sparseTileSizeInBytes(&self) -> NSUInteger;
798
799        #[optional]
800        #[method(convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions:)]
801        unsafe fn convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions(
802            &self,
803            pixel_regions: NonNull<MTLRegion>,
804            tile_regions: NonNull<MTLRegion>,
805            tile_size: MTLSize,
806            mode: MTLSparseTextureRegionAlignmentMode,
807            num_regions: NSUInteger,
808        );
809
810        #[optional]
811        #[method(convertSparseTileRegions:toPixelRegions:withTileSize:numRegions:)]
812        unsafe fn convertSparseTileRegions_toPixelRegions_withTileSize_numRegions(
813            &self,
814            tile_regions: NonNull<MTLRegion>,
815            pixel_regions: NonNull<MTLRegion>,
816            tile_size: MTLSize,
817            num_regions: NSUInteger,
818        );
819
820        #[method(sparseTileSizeInBytesForSparsePageSize:)]
821        unsafe fn sparseTileSizeInBytesForSparsePageSize(
822            &self,
823            sparse_page_size: MTLSparsePageSize,
824        ) -> NSUInteger;
825
826        #[method(sparseTileSizeWithTextureType:pixelFormat:sampleCount:sparsePageSize:)]
827        unsafe fn sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize(
828            &self,
829            texture_type: MTLTextureType,
830            pixel_format: MTLPixelFormat,
831            sample_count: NSUInteger,
832            sparse_page_size: MTLSparsePageSize,
833        ) -> MTLSize;
834
835        #[method(maxBufferLength)]
836        fn maxBufferLength(&self) -> NSUInteger;
837
838        #[cfg(feature = "Foundation_NSArray")]
839        #[method_id(@__retain_semantics Other counterSets)]
840        unsafe fn counterSets(&self) -> Option<Id<NSArray<ProtocolObject<dyn MTLCounterSet>>>>;
841
842        #[cfg(all(
843            feature = "Foundation_NSError",
844            feature = "Metal_MTLCounterSampleBufferDescriptor"
845        ))]
846        #[method_id(@__retain_semantics New newCounterSampleBufferWithDescriptor:error:_)]
847        unsafe fn newCounterSampleBufferWithDescriptor_error(
848            &self,
849            descriptor: &MTLCounterSampleBufferDescriptor,
850        ) -> Result<Id<ProtocolObject<dyn MTLCounterSampleBuffer>>, Id<NSError>>;
851
852        #[method(sampleTimestamps:gpuTimestamp:)]
853        unsafe fn sampleTimestamps_gpuTimestamp(
854            &self,
855            cpu_timestamp: NonNull<MTLTimestamp>,
856            gpu_timestamp: NonNull<MTLTimestamp>,
857        );
858
859        #[method_id(@__retain_semantics New newArgumentEncoderWithBufferBinding:)]
860        unsafe fn newArgumentEncoderWithBufferBinding(
861            &self,
862            buffer_binding: &ProtocolObject<dyn MTLBufferBinding>,
863        ) -> Id<ProtocolObject<dyn MTLArgumentEncoder>>;
864
865        #[method(supportsCounterSampling:)]
866        fn supportsCounterSampling(&self, sampling_point: MTLCounterSamplingPoint) -> bool;
867
868        #[method(supportsVertexAmplificationCount:)]
869        fn supportsVertexAmplificationCount(&self, count: NSUInteger) -> bool;
870
871        #[method(supportsDynamicLibraries)]
872        fn supportsDynamicLibraries(&self) -> bool;
873
874        #[method(supportsRenderDynamicLibraries)]
875        unsafe fn supportsRenderDynamicLibraries(&self) -> bool;
876
877        #[cfg(feature = "Foundation_NSError")]
878        #[method_id(@__retain_semantics New newDynamicLibrary:error:_)]
879        fn newDynamicLibrary_error(
880            &self,
881            library: &ProtocolObject<dyn MTLLibrary>,
882        ) -> Result<Id<ProtocolObject<dyn MTLDynamicLibrary>>, Id<NSError>>;
883
884        #[cfg(all(feature = "Foundation_NSError", feature = "Foundation_NSURL"))]
885        #[method_id(@__retain_semantics New newDynamicLibraryWithURL:error:_)]
886        fn newDynamicLibraryWithURL_error(
887            &self,
888            url: &NSURL,
889        ) -> Result<Id<ProtocolObject<dyn MTLDynamicLibrary>>, Id<NSError>>;
890
891        #[cfg(all(
892            feature = "Foundation_NSError",
893            feature = "Metal_MTLBinaryArchiveDescriptor"
894        ))]
895        #[method_id(@__retain_semantics New newBinaryArchiveWithDescriptor:error:_)]
896        fn newBinaryArchiveWithDescriptor_error(
897            &self,
898            descriptor: &MTLBinaryArchiveDescriptor,
899        ) -> Result<Id<ProtocolObject<dyn MTLBinaryArchive>>, Id<NSError>>;
900
901        #[method(supportsRaytracing)]
902        fn supportsRaytracing(&self) -> bool;
903
904        #[cfg(feature = "Metal_MTLAccelerationStructureDescriptor")]
905        #[method(accelerationStructureSizesWithDescriptor:)]
906        fn accelerationStructureSizesWithDescriptor(
907            &self,
908            descriptor: &MTLAccelerationStructureDescriptor,
909        ) -> MTLAccelerationStructureSizes;
910
911        #[method_id(@__retain_semantics New newAccelerationStructureWithSize:)]
912        fn newAccelerationStructureWithSize(
913            &self,
914            size: NSUInteger,
915        ) -> Option<Id<ProtocolObject<dyn MTLAccelerationStructure>>>;
916
917        #[cfg(feature = "Metal_MTLAccelerationStructureDescriptor")]
918        #[method_id(@__retain_semantics New newAccelerationStructureWithDescriptor:)]
919        unsafe fn newAccelerationStructureWithDescriptor(
920            &self,
921            descriptor: &MTLAccelerationStructureDescriptor,
922        ) -> Option<Id<ProtocolObject<dyn MTLAccelerationStructure>>>;
923
924        #[method(heapAccelerationStructureSizeAndAlignWithSize:)]
925        unsafe fn heapAccelerationStructureSizeAndAlignWithSize(
926            &self,
927            size: NSUInteger,
928        ) -> MTLSizeAndAlign;
929
930        #[cfg(feature = "Metal_MTLAccelerationStructureDescriptor")]
931        #[method(heapAccelerationStructureSizeAndAlignWithDescriptor:)]
932        unsafe fn heapAccelerationStructureSizeAndAlignWithDescriptor(
933            &self,
934            descriptor: &MTLAccelerationStructureDescriptor,
935        ) -> MTLSizeAndAlign;
936
937        #[method(supportsFunctionPointers)]
938        fn supportsFunctionPointers(&self) -> bool;
939
940        #[method(supportsFunctionPointersFromRender)]
941        unsafe fn supportsFunctionPointersFromRender(&self) -> bool;
942
943        #[method(supportsRaytracingFromRender)]
944        unsafe fn supportsRaytracingFromRender(&self) -> bool;
945
946        #[method(supportsPrimitiveMotionBlur)]
947        unsafe fn supportsPrimitiveMotionBlur(&self) -> bool;
948
949        #[method(shouldMaximizeConcurrentCompilation)]
950        unsafe fn shouldMaximizeConcurrentCompilation(&self) -> bool;
951
952        #[method(setShouldMaximizeConcurrentCompilation:)]
953        unsafe fn setShouldMaximizeConcurrentCompilation(
954            &self,
955            should_maximize_concurrent_compilation: bool,
956        );
957
958        #[method(maximumConcurrentCompilationTaskCount)]
959        unsafe fn maximumConcurrentCompilationTaskCount(&self) -> NSUInteger;
960    }
961
962    unsafe impl ProtocolType for dyn MTLDevice {}
963);