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