objc2_metal/generated/
MTLFunctionDescriptor.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlfunctionoptions?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct MTLFunctionOptions(pub NSUInteger);
15bitflags::bitflags! {
16    impl MTLFunctionOptions: NSUInteger {
17/// Default usage
18        #[doc(alias = "MTLFunctionOptionNone")]
19        const None = 0;
20/// Compiles the found function. This enables dynamic linking of this `MTLFunction`.
21/// Only supported for `visible` functions.
22        #[doc(alias = "MTLFunctionOptionCompileToBinary")]
23        const CompileToBinary = 1<<0;
24/// stores and tracks this function in a Metal Pipelines Script
25/// This flag is optional and only supported in the context of binary archives.
26///
27/// This flag is required for inspecting and consuming binary archives with specialized MTLFunctions via the metal-source tool. It is not required for recompilation, nor for storing functions in binary archives. Set this flag only if you intend to use metal-source on a serialized binary archive.
28        #[doc(alias = "MTLFunctionOptionStoreFunctionInMetalPipelinesScript")]
29        const StoreFunctionInMetalPipelinesScript = 1<<1;
30/// stores and tracks this function in a Metal Pipelines Script
31/// This flag is optional and only supported in the context of binary archives.
32///
33/// This flag is required for inspecting and consuming binary archives with specialized MTLFunctions via the metal-source tool. It is not required for recompilation, nor for storing functions in binary archives. Set this flag only if you intend to use metal-source on a serialized binary archive.
34        #[doc(alias = "MTLFunctionOptionStoreFunctionInMetalScript")]
35#[deprecated]
36        const StoreFunctionInMetalScript = 1<<1;
37/// Function creation fails (i.e nil is returned) if:
38/// - A lookup binary archive has been specified
39/// - The function has not been found in the archive
40        #[doc(alias = "MTLFunctionOptionFailOnBinaryArchiveMiss")]
41        const FailOnBinaryArchiveMiss = 1<<2;
42/// Compiles the function to have its function handles return a constant MTLResourceID across
43/// all pipeline states. The function needs to be linked to the pipeline that will use this function.
44/// This function option can only be used for functions that are compiled with `MTLFunctionOptionCompileToBinary`.
45        #[doc(alias = "MTLFunctionOptionPipelineIndependent")]
46        const PipelineIndependent = 1<<3;
47    }
48}
49
50unsafe impl Encode for MTLFunctionOptions {
51    const ENCODING: Encoding = NSUInteger::ENCODING;
52}
53
54unsafe impl RefEncode for MTLFunctionOptions {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
56}
57
58extern_class!(
59    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlfunctiondescriptor?language=objc)
60    #[unsafe(super(NSObject))]
61    #[derive(Debug, PartialEq, Eq, Hash)]
62    pub struct MTLFunctionDescriptor;
63);
64
65extern_conformance!(
66    unsafe impl NSCopying for MTLFunctionDescriptor {}
67);
68
69unsafe impl CopyingHelper for MTLFunctionDescriptor {
70    type Result = Self;
71}
72
73extern_conformance!(
74    unsafe impl NSObjectProtocol for MTLFunctionDescriptor {}
75);
76
77impl MTLFunctionDescriptor {
78    extern_methods!(
79        /// Create an autoreleased function descriptor
80        #[unsafe(method(functionDescriptor))]
81        #[unsafe(method_family = none)]
82        pub fn functionDescriptor() -> Retained<MTLFunctionDescriptor>;
83
84        /// The name of the `visible` function to find.
85        #[unsafe(method(name))]
86        #[unsafe(method_family = none)]
87        pub fn name(&self) -> Option<Retained<NSString>>;
88
89        /// Setter for [`name`][Self::name].
90        ///
91        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
92        #[unsafe(method(setName:))]
93        #[unsafe(method_family = none)]
94        pub fn setName(&self, name: Option<&NSString>);
95
96        /// An optional new name for a `visible` function to allow reuse with different specializations.
97        #[unsafe(method(specializedName))]
98        #[unsafe(method_family = none)]
99        pub fn specializedName(&self) -> Option<Retained<NSString>>;
100
101        /// Setter for [`specializedName`][Self::specializedName].
102        ///
103        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
104        #[unsafe(method(setSpecializedName:))]
105        #[unsafe(method_family = none)]
106        pub fn setSpecializedName(&self, specialized_name: Option<&NSString>);
107
108        #[cfg(feature = "MTLFunctionConstantValues")]
109        /// The set of constant values assigned to the function constants. Compilation fails if you do not provide valid constant values for all required function constants.
110        #[unsafe(method(constantValues))]
111        #[unsafe(method_family = none)]
112        pub fn constantValues(&self) -> Option<Retained<MTLFunctionConstantValues>>;
113
114        #[cfg(feature = "MTLFunctionConstantValues")]
115        /// Setter for [`constantValues`][Self::constantValues].
116        ///
117        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
118        #[unsafe(method(setConstantValues:))]
119        #[unsafe(method_family = none)]
120        pub fn setConstantValues(&self, constant_values: Option<&MTLFunctionConstantValues>);
121
122        /// The options to use for this new `MTLFunction`.
123        #[unsafe(method(options))]
124        #[unsafe(method_family = none)]
125        pub fn options(&self) -> MTLFunctionOptions;
126
127        /// Setter for [`options`][Self::options].
128        #[unsafe(method(setOptions:))]
129        #[unsafe(method_family = none)]
130        pub fn setOptions(&self, options: MTLFunctionOptions);
131
132        #[cfg(feature = "MTLBinaryArchive")]
133        /// The array of archives to be searched.
134        ///
135        /// Binary archives to be searched for precompiled functions during the compilation of this function.
136        #[unsafe(method(binaryArchives))]
137        #[unsafe(method_family = none)]
138        pub fn binaryArchives(
139            &self,
140        ) -> Option<Retained<NSArray<ProtocolObject<dyn MTLBinaryArchive>>>>;
141
142        #[cfg(feature = "MTLBinaryArchive")]
143        /// Setter for [`binaryArchives`][Self::binaryArchives].
144        ///
145        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
146        #[unsafe(method(setBinaryArchives:))]
147        #[unsafe(method_family = none)]
148        pub fn setBinaryArchives(
149            &self,
150            binary_archives: Option<&NSArray<ProtocolObject<dyn MTLBinaryArchive>>>,
151        );
152    );
153}
154
155/// Methods declared on superclass `NSObject`.
156impl MTLFunctionDescriptor {
157    extern_methods!(
158        #[unsafe(method(init))]
159        #[unsafe(method_family = init)]
160        pub fn init(this: Allocated<Self>) -> Retained<Self>;
161
162        #[unsafe(method(new))]
163        #[unsafe(method_family = new)]
164        pub fn new() -> Retained<Self>;
165    );
166}
167
168impl DefaultRetained for MTLFunctionDescriptor {
169    #[inline]
170    fn default_retained() -> Retained<Self> {
171        Self::new()
172    }
173}
174
175extern_class!(
176    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlintersectionfunctiondescriptor?language=objc)
177    #[unsafe(super(MTLFunctionDescriptor, NSObject))]
178    #[derive(Debug, PartialEq, Eq, Hash)]
179    pub struct MTLIntersectionFunctionDescriptor;
180);
181
182extern_conformance!(
183    unsafe impl NSCopying for MTLIntersectionFunctionDescriptor {}
184);
185
186unsafe impl CopyingHelper for MTLIntersectionFunctionDescriptor {
187    type Result = Self;
188}
189
190extern_conformance!(
191    unsafe impl NSObjectProtocol for MTLIntersectionFunctionDescriptor {}
192);
193
194impl MTLIntersectionFunctionDescriptor {
195    extern_methods!();
196}
197
198/// Methods declared on superclass `NSObject`.
199impl MTLIntersectionFunctionDescriptor {
200    extern_methods!(
201        #[unsafe(method(init))]
202        #[unsafe(method_family = init)]
203        pub fn init(this: Allocated<Self>) -> Retained<Self>;
204
205        #[unsafe(method(new))]
206        #[unsafe(method_family = new)]
207        pub fn new() -> Retained<Self>;
208    );
209}
210
211impl DefaultRetained for MTLIntersectionFunctionDescriptor {
212    #[inline]
213    fn default_retained() -> Retained<Self> {
214        Self::new()
215    }
216}