1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[cfg(feature = "MTLRenderPipeline")]
12pub type MTLAutoreleasedRenderPipelineReflection = MTLRenderPipelineReflection;
13
14#[cfg(feature = "MTLComputePipeline")]
16pub type MTLAutoreleasedComputePipelineReflection = MTLComputePipelineReflection;
17
18#[cfg(feature = "block2")]
20pub type MTLNewLibraryCompletionHandler =
21 *mut block2::DynBlock<dyn Fn(*mut ProtocolObject<dyn MTLLibrary>, *mut NSError)>;
22
23#[cfg(all(
25 feature = "MTLAllocation",
26 feature = "MTLRenderPipeline",
27 feature = "block2"
28))]
29pub type MTLNewRenderPipelineStateCompletionHandler =
30 *mut block2::DynBlock<dyn Fn(*mut ProtocolObject<dyn MTLRenderPipelineState>, *mut NSError)>;
31
32#[cfg(all(
34 feature = "MTLAllocation",
35 feature = "MTLRenderPipeline",
36 feature = "block2"
37))]
38pub type MTLNewRenderPipelineStateWithReflectionCompletionHandler = *mut block2::DynBlock<
39 dyn Fn(
40 *mut ProtocolObject<dyn MTLRenderPipelineState>,
41 *mut MTLRenderPipelineReflection,
42 *mut NSError,
43 ),
44>;
45
46#[cfg(all(
48 feature = "MTLAllocation",
49 feature = "MTLComputePipeline",
50 feature = "block2"
51))]
52pub type MTLNewComputePipelineStateCompletionHandler =
53 *mut block2::DynBlock<dyn Fn(*mut ProtocolObject<dyn MTLComputePipelineState>, *mut NSError)>;
54
55#[cfg(all(
57 feature = "MTLAllocation",
58 feature = "MTLComputePipeline",
59 feature = "block2"
60))]
61pub type MTLNewComputePipelineStateWithReflectionCompletionHandler = *mut block2::DynBlock<
62 dyn Fn(
63 *mut ProtocolObject<dyn MTLComputePipelineState>,
64 *mut MTLComputePipelineReflection,
65 *mut NSError,
66 ),
67>;
68
69#[cfg(all(feature = "MTLDynamicLibrary", feature = "block2"))]
71pub type MTLNewDynamicLibraryCompletionHandler =
72 *mut block2::DynBlock<dyn Fn(*mut ProtocolObject<dyn MTLDynamicLibrary>, *mut NSError)>;
73
74#[deprecated = "Use MTLBinding and cast to specific Binding (MTLTextureBinding, MTLBufferBinding, .etc) instead"]
76#[cfg(feature = "MTLArgument")]
77pub type MTLAutoreleasedArgument = MTLArgument;
78
79#[repr(transparent)]
82#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
83pub struct MTLPatchType(pub NSUInteger);
84impl MTLPatchType {
85 #[doc(alias = "MTLPatchTypeNone")]
86 pub const None: Self = Self(0);
87 #[doc(alias = "MTLPatchTypeTriangle")]
88 pub const Triangle: Self = Self(1);
89 #[doc(alias = "MTLPatchTypeQuad")]
90 pub const Quad: Self = Self(2);
91}
92
93unsafe impl Encode for MTLPatchType {
94 const ENCODING: Encoding = NSUInteger::ENCODING;
95}
96
97unsafe impl RefEncode for MTLPatchType {
98 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
99}
100
101extern_class!(
102 #[unsafe(super(NSObject))]
104 #[derive(Debug, PartialEq, Eq, Hash)]
105 pub struct MTLVertexAttribute;
106);
107
108extern_conformance!(
109 unsafe impl NSObjectProtocol for MTLVertexAttribute {}
110);
111
112impl MTLVertexAttribute {
113 extern_methods!(
114 #[unsafe(method(name))]
115 #[unsafe(method_family = none)]
116 pub fn name(&self) -> Retained<NSString>;
117
118 #[unsafe(method(attributeIndex))]
119 #[unsafe(method_family = none)]
120 pub fn attributeIndex(&self) -> NSUInteger;
121
122 #[cfg(feature = "MTLDataType")]
123 #[unsafe(method(attributeType))]
124 #[unsafe(method_family = none)]
125 pub fn attributeType(&self) -> MTLDataType;
126
127 #[unsafe(method(isActive))]
128 #[unsafe(method_family = none)]
129 pub fn isActive(&self) -> bool;
130
131 #[unsafe(method(isPatchData))]
132 #[unsafe(method_family = none)]
133 pub fn isPatchData(&self) -> bool;
134
135 #[unsafe(method(isPatchControlPointData))]
136 #[unsafe(method_family = none)]
137 pub fn isPatchControlPointData(&self) -> bool;
138 );
139}
140
141impl MTLVertexAttribute {
143 extern_methods!(
144 #[unsafe(method(init))]
145 #[unsafe(method_family = init)]
146 pub fn init(this: Allocated<Self>) -> Retained<Self>;
147
148 #[unsafe(method(new))]
149 #[unsafe(method_family = new)]
150 pub fn new() -> Retained<Self>;
151 );
152}
153
154impl DefaultRetained for MTLVertexAttribute {
155 #[inline]
156 fn default_retained() -> Retained<Self> {
157 Self::new()
158 }
159}
160
161extern_class!(
162 #[unsafe(super(NSObject))]
164 #[derive(Debug, PartialEq, Eq, Hash)]
165 pub struct MTLAttribute;
166);
167
168extern_conformance!(
169 unsafe impl NSObjectProtocol for MTLAttribute {}
170);
171
172impl MTLAttribute {
173 extern_methods!(
174 #[unsafe(method(name))]
175 #[unsafe(method_family = none)]
176 pub fn name(&self) -> Retained<NSString>;
177
178 #[unsafe(method(attributeIndex))]
179 #[unsafe(method_family = none)]
180 pub fn attributeIndex(&self) -> NSUInteger;
181
182 #[cfg(feature = "MTLDataType")]
183 #[unsafe(method(attributeType))]
184 #[unsafe(method_family = none)]
185 pub fn attributeType(&self) -> MTLDataType;
186
187 #[unsafe(method(isActive))]
188 #[unsafe(method_family = none)]
189 pub fn isActive(&self) -> bool;
190
191 #[unsafe(method(isPatchData))]
192 #[unsafe(method_family = none)]
193 pub fn isPatchData(&self) -> bool;
194
195 #[unsafe(method(isPatchControlPointData))]
196 #[unsafe(method_family = none)]
197 pub fn isPatchControlPointData(&self) -> bool;
198 );
199}
200
201impl MTLAttribute {
203 extern_methods!(
204 #[unsafe(method(init))]
205 #[unsafe(method_family = init)]
206 pub fn init(this: Allocated<Self>) -> Retained<Self>;
207
208 #[unsafe(method(new))]
209 #[unsafe(method_family = new)]
210 pub fn new() -> Retained<Self>;
211 );
212}
213
214impl DefaultRetained for MTLAttribute {
215 #[inline]
216 fn default_retained() -> Retained<Self> {
217 Self::new()
218 }
219}
220
221#[repr(transparent)]
237#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
238pub struct MTLFunctionType(pub NSUInteger);
239impl MTLFunctionType {
240 #[doc(alias = "MTLFunctionTypeVertex")]
241 pub const Vertex: Self = Self(1);
242 #[doc(alias = "MTLFunctionTypeFragment")]
243 pub const Fragment: Self = Self(2);
244 #[doc(alias = "MTLFunctionTypeKernel")]
245 pub const Kernel: Self = Self(3);
246 #[doc(alias = "MTLFunctionTypeVisible")]
247 pub const Visible: Self = Self(5);
248 #[doc(alias = "MTLFunctionTypeIntersection")]
249 pub const Intersection: Self = Self(6);
250 #[doc(alias = "MTLFunctionTypeMesh")]
251 pub const Mesh: Self = Self(7);
252 #[doc(alias = "MTLFunctionTypeObject")]
253 pub const Object: Self = Self(8);
254}
255
256unsafe impl Encode for MTLFunctionType {
257 const ENCODING: Encoding = NSUInteger::ENCODING;
258}
259
260unsafe impl RefEncode for MTLFunctionType {
261 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
262}
263
264extern_class!(
265 #[unsafe(super(NSObject))]
269 #[derive(Debug, PartialEq, Eq, Hash)]
270 pub struct MTLFunctionConstant;
271);
272
273extern_conformance!(
274 unsafe impl NSObjectProtocol for MTLFunctionConstant {}
275);
276
277impl MTLFunctionConstant {
278 extern_methods!(
279 #[unsafe(method(name))]
280 #[unsafe(method_family = none)]
281 pub fn name(&self) -> Retained<NSString>;
282
283 #[cfg(feature = "MTLDataType")]
284 #[unsafe(method(type))]
285 #[unsafe(method_family = none)]
286 pub fn r#type(&self) -> MTLDataType;
287
288 #[unsafe(method(index))]
289 #[unsafe(method_family = none)]
290 pub fn index(&self) -> NSUInteger;
291
292 #[unsafe(method(required))]
293 #[unsafe(method_family = none)]
294 pub fn required(&self) -> bool;
295 );
296}
297
298impl MTLFunctionConstant {
300 extern_methods!(
301 #[unsafe(method(init))]
302 #[unsafe(method_family = init)]
303 pub fn init(this: Allocated<Self>) -> Retained<Self>;
304
305 #[unsafe(method(new))]
306 #[unsafe(method_family = new)]
307 pub fn new() -> Retained<Self>;
308 );
309}
310
311impl DefaultRetained for MTLFunctionConstant {
312 #[inline]
313 fn default_retained() -> Retained<Self> {
314 Self::new()
315 }
316}
317
318extern_protocol!(
319 pub unsafe trait MTLFunction: NSObjectProtocol + Send + Sync {
325 #[unsafe(method(label))]
327 #[unsafe(method_family = none)]
328 fn label(&self) -> Option<Retained<NSString>>;
329
330 #[unsafe(method(setLabel:))]
334 #[unsafe(method_family = none)]
335 fn setLabel(&self, label: Option<&NSString>);
336
337 #[cfg(feature = "MTLDevice")]
338 #[unsafe(method(device))]
340 #[unsafe(method_family = none)]
341 fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
342
343 #[unsafe(method(functionType))]
345 #[unsafe(method_family = none)]
346 fn functionType(&self) -> MTLFunctionType;
347
348 #[unsafe(method(patchType))]
350 #[unsafe(method_family = none)]
351 fn patchType(&self) -> MTLPatchType;
352
353 #[unsafe(method(patchControlPointCount))]
356 #[unsafe(method_family = none)]
357 fn patchControlPointCount(&self) -> NSInteger;
358
359 #[unsafe(method(vertexAttributes))]
360 #[unsafe(method_family = none)]
361 fn vertexAttributes(&self) -> Option<Retained<NSArray<MTLVertexAttribute>>>;
362
363 #[unsafe(method(stageInputAttributes))]
365 #[unsafe(method_family = none)]
366 fn stageInputAttributes(&self) -> Option<Retained<NSArray<MTLAttribute>>>;
367
368 #[unsafe(method(name))]
370 #[unsafe(method_family = none)]
371 fn name(&self) -> Retained<NSString>;
372
373 #[unsafe(method(functionConstantsDictionary))]
375 #[unsafe(method_family = none)]
376 fn functionConstantsDictionary(
377 &self,
378 ) -> Retained<NSDictionary<NSString, MTLFunctionConstant>>;
379
380 #[cfg(feature = "MTLArgumentEncoder")]
381 #[unsafe(method(newArgumentEncoderWithBufferIndex:))]
387 #[unsafe(method_family = new)]
388 unsafe fn newArgumentEncoderWithBufferIndex(
389 &self,
390 buffer_index: NSUInteger,
391 ) -> Retained<ProtocolObject<dyn MTLArgumentEncoder>>;
392
393 #[cfg(all(feature = "MTLArgument", feature = "MTLArgumentEncoder"))]
394 #[deprecated = "Use MTLDevice's newArgumentEncoderWithBufferBinding: instead"]
400 #[unsafe(method(newArgumentEncoderWithBufferIndex:reflection:))]
401 #[unsafe(method_family = new)]
402 unsafe fn newArgumentEncoderWithBufferIndex_reflection(
403 &self,
404 buffer_index: NSUInteger,
405 reflection: Option<&mut Option<Retained<MTLAutoreleasedArgument>>>,
406 ) -> Retained<ProtocolObject<dyn MTLArgumentEncoder>>;
407
408 #[cfg(feature = "MTLFunctionDescriptor")]
409 #[unsafe(method(options))]
411 #[unsafe(method_family = none)]
412 fn options(&self) -> MTLFunctionOptions;
413 }
414);
415
416#[repr(transparent)]
419#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
420pub struct MTLLanguageVersion(pub NSUInteger);
421impl MTLLanguageVersion {
422 #[doc(alias = "MTLLanguageVersion1_0")]
423 #[deprecated = "Use a newer language standard"]
424 pub const Version1_0: Self = Self(1 << 16);
425 #[doc(alias = "MTLLanguageVersion1_1")]
426 pub const Version1_1: Self = Self((1 << 16) + 1);
427 #[doc(alias = "MTLLanguageVersion1_2")]
428 pub const Version1_2: Self = Self((1 << 16) + 2);
429 #[doc(alias = "MTLLanguageVersion2_0")]
430 pub const Version2_0: Self = Self(2 << 16);
431 #[doc(alias = "MTLLanguageVersion2_1")]
432 pub const Version2_1: Self = Self((2 << 16) + 1);
433 #[doc(alias = "MTLLanguageVersion2_2")]
434 pub const Version2_2: Self = Self((2 << 16) + 2);
435 #[doc(alias = "MTLLanguageVersion2_3")]
436 pub const Version2_3: Self = Self((2 << 16) + 3);
437 #[doc(alias = "MTLLanguageVersion2_4")]
438 pub const Version2_4: Self = Self((2 << 16) + 4);
439 #[doc(alias = "MTLLanguageVersion3_0")]
440 pub const Version3_0: Self = Self((3 << 16) + 0);
441 #[doc(alias = "MTLLanguageVersion3_1")]
442 pub const Version3_1: Self = Self((3 << 16) + 1);
443 #[doc(alias = "MTLLanguageVersion3_2")]
444 pub const Version3_2: Self = Self((3 << 16) + 2);
445 #[doc(alias = "MTLLanguageVersion4_0")]
446 pub const Version4_0: Self = Self((4 << 16) + 0);
447}
448
449unsafe impl Encode for MTLLanguageVersion {
450 const ENCODING: Encoding = NSUInteger::ENCODING;
451}
452
453unsafe impl RefEncode for MTLLanguageVersion {
454 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
455}
456
457#[repr(transparent)]
460#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
461pub struct MTLLibraryType(pub NSInteger);
462impl MTLLibraryType {
463 #[doc(alias = "MTLLibraryTypeExecutable")]
464 pub const Executable: Self = Self(0);
465 #[doc(alias = "MTLLibraryTypeDynamic")]
466 pub const Dynamic: Self = Self(1);
467}
468
469unsafe impl Encode for MTLLibraryType {
470 const ENCODING: Encoding = NSInteger::ENCODING;
471}
472
473unsafe impl RefEncode for MTLLibraryType {
474 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
475}
476
477#[repr(transparent)]
488#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
489pub struct MTLLibraryOptimizationLevel(pub NSInteger);
490impl MTLLibraryOptimizationLevel {
491 #[doc(alias = "MTLLibraryOptimizationLevelDefault")]
492 pub const Default: Self = Self(0);
493 #[doc(alias = "MTLLibraryOptimizationLevelSize")]
494 pub const Size: Self = Self(1);
495}
496
497unsafe impl Encode for MTLLibraryOptimizationLevel {
498 const ENCODING: Encoding = NSInteger::ENCODING;
499}
500
501unsafe impl RefEncode for MTLLibraryOptimizationLevel {
502 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
503}
504
505#[repr(transparent)]
508#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
509pub struct MTLCompileSymbolVisibility(pub NSInteger);
510impl MTLCompileSymbolVisibility {
511 #[doc(alias = "MTLCompileSymbolVisibilityDefault")]
512 pub const Default: Self = Self(0);
513 #[doc(alias = "MTLCompileSymbolVisibilityHidden")]
514 pub const Hidden: Self = Self(1);
515}
516
517unsafe impl Encode for MTLCompileSymbolVisibility {
518 const ENCODING: Encoding = NSInteger::ENCODING;
519}
520
521unsafe impl RefEncode for MTLCompileSymbolVisibility {
522 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
523}
524
525#[repr(transparent)]
539#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
540pub struct MTLMathMode(pub NSInteger);
541impl MTLMathMode {
542 #[doc(alias = "MTLMathModeSafe")]
543 pub const Safe: Self = Self(0);
544 #[doc(alias = "MTLMathModeRelaxed")]
545 pub const Relaxed: Self = Self(1);
546 #[doc(alias = "MTLMathModeFast")]
547 pub const Fast: Self = Self(2);
548}
549
550unsafe impl Encode for MTLMathMode {
551 const ENCODING: Encoding = NSInteger::ENCODING;
552}
553
554unsafe impl RefEncode for MTLMathMode {
555 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
556}
557
558#[repr(transparent)]
569#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
570pub struct MTLMathFloatingPointFunctions(pub NSInteger);
571impl MTLMathFloatingPointFunctions {
572 #[doc(alias = "MTLMathFloatingPointFunctionsFast")]
573 pub const Fast: Self = Self(0);
574 #[doc(alias = "MTLMathFloatingPointFunctionsPrecise")]
575 pub const Precise: Self = Self(1);
576}
577
578unsafe impl Encode for MTLMathFloatingPointFunctions {
579 const ENCODING: Encoding = NSInteger::ENCODING;
580}
581
582unsafe impl RefEncode for MTLMathFloatingPointFunctions {
583 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
584}
585
586extern_class!(
587 #[unsafe(super(NSObject))]
589 #[derive(Debug, PartialEq, Eq, Hash)]
590 pub struct MTLCompileOptions;
591);
592
593extern_conformance!(
594 unsafe impl NSCopying for MTLCompileOptions {}
595);
596
597unsafe impl CopyingHelper for MTLCompileOptions {
598 type Result = Self;
599}
600
601extern_conformance!(
602 unsafe impl NSObjectProtocol for MTLCompileOptions {}
603);
604
605impl MTLCompileOptions {
606 extern_methods!(
607 #[unsafe(method(preprocessorMacros))]
611 #[unsafe(method_family = none)]
612 pub fn preprocessorMacros(&self) -> Option<Retained<NSDictionary<NSString, NSObject>>>;
613
614 #[unsafe(method(setPreprocessorMacros:))]
622 #[unsafe(method_family = none)]
623 pub unsafe fn setPreprocessorMacros(
624 &self,
625 preprocessor_macros: Option<&NSDictionary<NSString, NSObject>>,
626 );
627
628 #[deprecated = "Use mathMode instead"]
630 #[unsafe(method(fastMathEnabled))]
631 #[unsafe(method_family = none)]
632 pub fn fastMathEnabled(&self) -> bool;
633
634 #[deprecated = "Use mathMode instead"]
636 #[unsafe(method(setFastMathEnabled:))]
637 #[unsafe(method_family = none)]
638 pub fn setFastMathEnabled(&self, fast_math_enabled: bool);
639
640 #[unsafe(method(mathMode))]
642 #[unsafe(method_family = none)]
643 pub fn mathMode(&self) -> MTLMathMode;
644
645 #[unsafe(method(setMathMode:))]
647 #[unsafe(method_family = none)]
648 pub fn setMathMode(&self, math_mode: MTLMathMode);
649
650 #[unsafe(method(mathFloatingPointFunctions))]
652 #[unsafe(method_family = none)]
653 pub fn mathFloatingPointFunctions(&self) -> MTLMathFloatingPointFunctions;
654
655 #[unsafe(method(setMathFloatingPointFunctions:))]
657 #[unsafe(method_family = none)]
658 pub fn setMathFloatingPointFunctions(
659 &self,
660 math_floating_point_functions: MTLMathFloatingPointFunctions,
661 );
662
663 #[unsafe(method(languageVersion))]
665 #[unsafe(method_family = none)]
666 pub fn languageVersion(&self) -> MTLLanguageVersion;
667
668 #[unsafe(method(setLanguageVersion:))]
670 #[unsafe(method_family = none)]
671 pub fn setLanguageVersion(&self, language_version: MTLLanguageVersion);
672
673 #[unsafe(method(libraryType))]
679 #[unsafe(method_family = none)]
680 pub fn libraryType(&self) -> MTLLibraryType;
681
682 #[unsafe(method(setLibraryType:))]
684 #[unsafe(method_family = none)]
685 pub fn setLibraryType(&self, library_type: MTLLibraryType);
686
687 #[unsafe(method(installName))]
709 #[unsafe(method_family = none)]
710 pub fn installName(&self) -> Option<Retained<NSString>>;
711
712 #[unsafe(method(setInstallName:))]
716 #[unsafe(method_family = none)]
717 pub fn setInstallName(&self, install_name: Option<&NSString>);
718
719 #[cfg(feature = "MTLDynamicLibrary")]
720 #[unsafe(method(libraries))]
725 #[unsafe(method_family = none)]
726 pub fn libraries(&self)
727 -> Option<Retained<NSArray<ProtocolObject<dyn MTLDynamicLibrary>>>>;
728
729 #[cfg(feature = "MTLDynamicLibrary")]
730 #[unsafe(method(setLibraries:))]
734 #[unsafe(method_family = none)]
735 pub fn setLibraries(
736 &self,
737 libraries: Option<&NSArray<ProtocolObject<dyn MTLDynamicLibrary>>>,
738 );
739
740 #[unsafe(method(preserveInvariance))]
742 #[unsafe(method_family = none)]
743 pub fn preserveInvariance(&self) -> bool;
744
745 #[unsafe(method(setPreserveInvariance:))]
747 #[unsafe(method_family = none)]
748 pub fn setPreserveInvariance(&self, preserve_invariance: bool);
749
750 #[unsafe(method(optimizationLevel))]
752 #[unsafe(method_family = none)]
753 pub fn optimizationLevel(&self) -> MTLLibraryOptimizationLevel;
754
755 #[unsafe(method(setOptimizationLevel:))]
757 #[unsafe(method_family = none)]
758 pub fn setOptimizationLevel(&self, optimization_level: MTLLibraryOptimizationLevel);
759
760 #[unsafe(method(compileSymbolVisibility))]
762 #[unsafe(method_family = none)]
763 pub fn compileSymbolVisibility(&self) -> MTLCompileSymbolVisibility;
764
765 #[unsafe(method(setCompileSymbolVisibility:))]
767 #[unsafe(method_family = none)]
768 pub fn setCompileSymbolVisibility(
769 &self,
770 compile_symbol_visibility: MTLCompileSymbolVisibility,
771 );
772
773 #[unsafe(method(allowReferencingUndefinedSymbols))]
775 #[unsafe(method_family = none)]
776 pub fn allowReferencingUndefinedSymbols(&self) -> bool;
777
778 #[unsafe(method(setAllowReferencingUndefinedSymbols:))]
780 #[unsafe(method_family = none)]
781 pub fn setAllowReferencingUndefinedSymbols(
782 &self,
783 allow_referencing_undefined_symbols: bool,
784 );
785
786 #[unsafe(method(maxTotalThreadsPerThreadgroup))]
788 #[unsafe(method_family = none)]
789 pub fn maxTotalThreadsPerThreadgroup(&self) -> NSUInteger;
790
791 #[unsafe(method(setMaxTotalThreadsPerThreadgroup:))]
793 #[unsafe(method_family = none)]
794 pub fn setMaxTotalThreadsPerThreadgroup(
795 &self,
796 max_total_threads_per_threadgroup: NSUInteger,
797 );
798
799 #[cfg(feature = "MTLTypes")]
800 #[unsafe(method(requiredThreadsPerThreadgroup))]
804 #[unsafe(method_family = none)]
805 pub fn requiredThreadsPerThreadgroup(&self) -> MTLSize;
806
807 #[cfg(feature = "MTLTypes")]
808 #[unsafe(method(setRequiredThreadsPerThreadgroup:))]
810 #[unsafe(method_family = none)]
811 pub fn setRequiredThreadsPerThreadgroup(&self, required_threads_per_threadgroup: MTLSize);
812
813 #[unsafe(method(enableLogging))]
815 #[unsafe(method_family = none)]
816 pub fn enableLogging(&self) -> bool;
817
818 #[unsafe(method(setEnableLogging:))]
820 #[unsafe(method_family = none)]
821 pub fn setEnableLogging(&self, enable_logging: bool);
822 );
823}
824
825impl MTLCompileOptions {
827 extern_methods!(
828 #[unsafe(method(init))]
829 #[unsafe(method_family = init)]
830 pub fn init(this: Allocated<Self>) -> Retained<Self>;
831
832 #[unsafe(method(new))]
833 #[unsafe(method_family = new)]
834 pub fn new() -> Retained<Self>;
835 );
836}
837
838impl DefaultRetained for MTLCompileOptions {
839 #[inline]
840 fn default_retained() -> Retained<Self> {
841 Self::new()
842 }
843}
844
845extern_class!(
846 #[unsafe(super(NSObject))]
850 #[derive(Debug, PartialEq, Eq, Hash)]
851 pub struct MTLFunctionReflection;
852);
853
854unsafe impl Send for MTLFunctionReflection {}
855
856unsafe impl Sync for MTLFunctionReflection {}
857
858extern_conformance!(
859 unsafe impl NSObjectProtocol for MTLFunctionReflection {}
860);
861
862impl MTLFunctionReflection {
863 extern_methods!(
864 #[cfg(feature = "MTLArgument")]
865 #[unsafe(method(bindings))]
867 #[unsafe(method_family = none)]
868 pub fn bindings(&self) -> Retained<NSArray<ProtocolObject<dyn MTLBinding>>>;
869 );
870}
871
872impl MTLFunctionReflection {
874 extern_methods!(
875 #[unsafe(method(init))]
876 #[unsafe(method_family = init)]
877 pub fn init(this: Allocated<Self>) -> Retained<Self>;
878
879 #[unsafe(method(new))]
880 #[unsafe(method_family = new)]
881 pub fn new() -> Retained<Self>;
882 );
883}
884
885impl DefaultRetained for MTLFunctionReflection {
886 #[inline]
887 fn default_retained() -> Retained<Self> {
888 Self::new()
889 }
890}
891
892extern "C" {
893 pub static MTLLibraryErrorDomain: &'static NSErrorDomain;
897}
898
899#[repr(transparent)]
904#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
905pub struct MTLLibraryError(pub NSUInteger);
906impl MTLLibraryError {
907 #[doc(alias = "MTLLibraryErrorUnsupported")]
908 pub const Unsupported: Self = Self(1);
909 #[doc(alias = "MTLLibraryErrorInternal")]
910 pub const Internal: Self = Self(2);
911 #[doc(alias = "MTLLibraryErrorCompileFailure")]
912 pub const CompileFailure: Self = Self(3);
913 #[doc(alias = "MTLLibraryErrorCompileWarning")]
914 pub const CompileWarning: Self = Self(4);
915 #[doc(alias = "MTLLibraryErrorFunctionNotFound")]
916 pub const FunctionNotFound: Self = Self(5);
917 #[doc(alias = "MTLLibraryErrorFileNotFound")]
918 pub const FileNotFound: Self = Self(6);
919}
920
921unsafe impl Encode for MTLLibraryError {
922 const ENCODING: Encoding = NSUInteger::ENCODING;
923}
924
925unsafe impl RefEncode for MTLLibraryError {
926 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
927}
928
929extern_protocol!(
930 pub unsafe trait MTLLibrary: NSObjectProtocol + Send + Sync {
932 #[unsafe(method(label))]
934 #[unsafe(method_family = none)]
935 fn label(&self) -> Option<Retained<NSString>>;
936
937 #[unsafe(method(setLabel:))]
941 #[unsafe(method_family = none)]
942 fn setLabel(&self, label: Option<&NSString>);
943
944 #[cfg(feature = "MTLDevice")]
945 #[unsafe(method(device))]
947 #[unsafe(method_family = none)]
948 fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
949
950 #[unsafe(method(newFunctionWithName:))]
952 #[unsafe(method_family = new)]
953 fn newFunctionWithName(
954 &self,
955 function_name: &NSString,
956 ) -> Option<Retained<ProtocolObject<dyn MTLFunction>>>;
957
958 #[cfg(feature = "MTLFunctionConstantValues")]
959 #[unsafe(method(newFunctionWithName:constantValues:error:_))]
964 #[unsafe(method_family = new)]
965 fn newFunctionWithName_constantValues_error(
966 &self,
967 name: &NSString,
968 constant_values: &MTLFunctionConstantValues,
969 ) -> Result<Retained<ProtocolObject<dyn MTLFunction>>, Retained<NSError>>;
970
971 #[cfg(all(feature = "MTLFunctionConstantValues", feature = "block2"))]
972 #[unsafe(method(newFunctionWithName:constantValues:completionHandler:))]
976 #[unsafe(method_family = none)]
977 fn newFunctionWithName_constantValues_completionHandler(
978 &self,
979 name: &NSString,
980 constant_values: &MTLFunctionConstantValues,
981 completion_handler: &block2::DynBlock<
982 dyn Fn(*mut ProtocolObject<dyn MTLFunction>, *mut NSError),
983 >,
984 );
985
986 #[unsafe(method(reflectionForFunctionWithName:))]
993 #[unsafe(method_family = none)]
994 fn reflectionForFunctionWithName(
995 &self,
996 function_name: &NSString,
997 ) -> Option<Retained<MTLFunctionReflection>>;
998
999 #[cfg(all(feature = "MTLFunctionDescriptor", feature = "block2"))]
1000 #[unsafe(method(newFunctionWithDescriptor:completionHandler:))]
1002 #[unsafe(method_family = none)]
1003 fn newFunctionWithDescriptor_completionHandler(
1004 &self,
1005 descriptor: &MTLFunctionDescriptor,
1006 completion_handler: &block2::DynBlock<
1007 dyn Fn(*mut ProtocolObject<dyn MTLFunction>, *mut NSError),
1008 >,
1009 );
1010
1011 #[cfg(feature = "MTLFunctionDescriptor")]
1012 #[unsafe(method(newFunctionWithDescriptor:error:_))]
1014 #[unsafe(method_family = new)]
1015 fn newFunctionWithDescriptor_error(
1016 &self,
1017 descriptor: &MTLFunctionDescriptor,
1018 ) -> Result<Retained<ProtocolObject<dyn MTLFunction>>, Retained<NSError>>;
1019
1020 #[cfg(all(feature = "MTLFunctionDescriptor", feature = "block2"))]
1021 #[unsafe(method(newIntersectionFunctionWithDescriptor:completionHandler:))]
1023 #[unsafe(method_family = none)]
1024 fn newIntersectionFunctionWithDescriptor_completionHandler(
1025 &self,
1026 descriptor: &MTLIntersectionFunctionDescriptor,
1027 completion_handler: &block2::DynBlock<
1028 dyn Fn(*mut ProtocolObject<dyn MTLFunction>, *mut NSError),
1029 >,
1030 );
1031
1032 #[cfg(feature = "MTLFunctionDescriptor")]
1033 #[unsafe(method(newIntersectionFunctionWithDescriptor:error:_))]
1035 #[unsafe(method_family = new)]
1036 fn newIntersectionFunctionWithDescriptor_error(
1037 &self,
1038 descriptor: &MTLIntersectionFunctionDescriptor,
1039 ) -> Result<Retained<ProtocolObject<dyn MTLFunction>>, Retained<NSError>>;
1040
1041 #[unsafe(method(functionNames))]
1043 #[unsafe(method_family = none)]
1044 fn functionNames(&self) -> Retained<NSArray<NSString>>;
1045
1046 #[unsafe(method(type))]
1052 #[unsafe(method_family = none)]
1053 fn r#type(&self) -> MTLLibraryType;
1054
1055 #[unsafe(method(installName))]
1061 #[unsafe(method_family = none)]
1062 fn installName(&self) -> Option<Retained<NSString>>;
1063 }
1064);