objc2_metal_performance_shaders/generated/MPSNeuralNetwork/
MPSNNGradientState.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6use objc2_metal::*;
7
8use crate::*;
9
10extern_class!(
11    /// at the time an -encode call was made. The contents are opaque.
12    ///
13    /// Gradient states must be created with [MPSCNNKernel resultStateForSourceImage:sourceStates:destinationImage:]
14    /// or analogous interfaces.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnngradientstate?language=objc)
17    #[unsafe(super(MPSState, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(all(feature = "MPSCore", feature = "MPSState"))]
20    pub struct MPSNNGradientState;
21);
22
23#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
24extern_conformance!(
25    unsafe impl NSObjectProtocol for MPSNNGradientState {}
26);
27
28#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
29impl MPSNNGradientState {
30    extern_methods!();
31}
32
33/// Methods declared on superclass `MPSState`.
34#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
35impl MPSNNGradientState {
36    extern_methods!(
37        /// Create a MPSState holding a temporary MTLBuffer
38        ///
39        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
40        ///
41        /// Parameter `bufferSize`: The size of the buffer in bytes
42        #[unsafe(method(temporaryStateWithCommandBuffer:bufferSize:))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn temporaryStateWithCommandBuffer_bufferSize(
45            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
46            buffer_size: usize,
47        ) -> Retained<Self>;
48
49        /// Create a MPSState holding a temporary MTLTexture
50        ///
51        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
52        ///
53        /// Parameter `descriptor`: A descriptor for the new temporary texture
54        #[unsafe(method(temporaryStateWithCommandBuffer:textureDescriptor:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn temporaryStateWithCommandBuffer_textureDescriptor(
57            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
58            descriptor: &MTLTextureDescriptor,
59        ) -> Retained<Self>;
60
61        /// Create a new autoreleased temporary state object without underlying resource
62        ///
63        /// Parameter `cmdBuf`: The command buffer with which the temporary resource is associated
64        #[unsafe(method(temporaryStateWithCommandBuffer:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn temporaryStateWithCommandBuffer(
67            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
68        ) -> Retained<Self>;
69
70        #[unsafe(method(initWithDevice:bufferSize:))]
71        #[unsafe(method_family = init)]
72        pub unsafe fn initWithDevice_bufferSize(
73            this: Allocated<Self>,
74            device: &ProtocolObject<dyn MTLDevice>,
75            buffer_size: usize,
76        ) -> Retained<Self>;
77
78        #[unsafe(method(initWithDevice:textureDescriptor:))]
79        #[unsafe(method_family = init)]
80        pub unsafe fn initWithDevice_textureDescriptor(
81            this: Allocated<Self>,
82            device: &ProtocolObject<dyn MTLDevice>,
83            descriptor: &MTLTextureDescriptor,
84        ) -> Retained<Self>;
85
86        /// Create a MPSState with a non-temporary MTLResource
87        ///
88        /// Parameter `resource`: A MTLBuffer or MTLTexture. May be nil.
89        ///
90        /// # Safety
91        ///
92        /// - `resource` may need to be synchronized.
93        /// - `resource` may be unretained, you must ensure it is kept alive while in use.
94        #[unsafe(method(initWithResource:))]
95        #[unsafe(method_family = init)]
96        pub unsafe fn initWithResource(
97            this: Allocated<Self>,
98            resource: Option<&ProtocolObject<dyn MTLResource>>,
99        ) -> Retained<Self>;
100
101        #[unsafe(method(init))]
102        #[unsafe(method_family = init)]
103        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
104
105        /// Initialize a non-temporary state to hold a number of textures and buffers
106        ///
107        /// The allocation of each resource will be deferred  until it is needed.
108        /// This occurs when -resource or -resourceAtIndex: is called.
109        ///
110        /// Parameter `resourceList`: The list of resources to create.
111        #[unsafe(method(initWithDevice:resourceList:))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn initWithDevice_resourceList(
114            this: Allocated<Self>,
115            device: &ProtocolObject<dyn MTLDevice>,
116            resource_list: &MPSStateResourceList,
117        ) -> Retained<Self>;
118
119        /// Initialize a temporary state to hold a number of textures and buffers
120        ///
121        /// The textures occur first in sequence
122        #[unsafe(method(temporaryStateWithCommandBuffer:resourceList:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn temporaryStateWithCommandBuffer_resourceList(
125            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
126            resource_list: &MPSStateResourceList,
127        ) -> Retained<Self>;
128
129        /// Create a state object with a list of MTLResources
130        ///
131        /// Because MPS prefers deferred allocation of resources
132        /// your application should use -initWithTextures:bufferSizes:bufferCount:
133        /// whenever possible. This method is useful for cases when the
134        /// MTLResources must be initialized by the CPU.
135        ///
136        /// # Safety
137        ///
138        /// - `resources` generic may need to be synchronized.
139        /// - `resources` generic may be unretained, you must ensure it is kept alive while in use.
140        #[unsafe(method(initWithResources:))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn initWithResources(
143            this: Allocated<Self>,
144            resources: Option<&NSArray<ProtocolObject<dyn MTLResource>>>,
145        ) -> Retained<Self>;
146    );
147}
148
149/// Methods declared on superclass `NSObject`.
150#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
151impl MPSNNGradientState {
152    extern_methods!(
153        #[unsafe(method(new))]
154        #[unsafe(method_family = new)]
155        pub unsafe fn new() -> Retained<Self>;
156    );
157}
158
159/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnngradientstatebatch?language=objc)
160#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
161pub type MPSNNGradientStateBatch = NSArray<MPSNNGradientState>;
162
163extern_class!(
164    /// at the time an -encode call was made. The contents are opaque.
165    ///
166    /// Gradient states must be created with [MPSCNNBinaryKernel resultStateForPrimaryImage:secondaryImage:sourceStates:destinationImage:]
167    /// or analogous interfaces.
168    ///
169    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnnbinarygradientstate?language=objc)
170    #[unsafe(super(MPSState, NSObject))]
171    #[derive(Debug, PartialEq, Eq, Hash)]
172    #[cfg(all(feature = "MPSCore", feature = "MPSState"))]
173    pub struct MPSNNBinaryGradientState;
174);
175
176#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
177extern_conformance!(
178    unsafe impl NSObjectProtocol for MPSNNBinaryGradientState {}
179);
180
181#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
182impl MPSNNBinaryGradientState {
183    extern_methods!();
184}
185
186/// Methods declared on superclass `MPSState`.
187#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
188impl MPSNNBinaryGradientState {
189    extern_methods!(
190        /// Create a MPSState holding a temporary MTLBuffer
191        ///
192        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
193        ///
194        /// Parameter `bufferSize`: The size of the buffer in bytes
195        #[unsafe(method(temporaryStateWithCommandBuffer:bufferSize:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn temporaryStateWithCommandBuffer_bufferSize(
198            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
199            buffer_size: usize,
200        ) -> Retained<Self>;
201
202        /// Create a MPSState holding a temporary MTLTexture
203        ///
204        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
205        ///
206        /// Parameter `descriptor`: A descriptor for the new temporary texture
207        #[unsafe(method(temporaryStateWithCommandBuffer:textureDescriptor:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn temporaryStateWithCommandBuffer_textureDescriptor(
210            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
211            descriptor: &MTLTextureDescriptor,
212        ) -> Retained<Self>;
213
214        /// Create a new autoreleased temporary state object without underlying resource
215        ///
216        /// Parameter `cmdBuf`: The command buffer with which the temporary resource is associated
217        #[unsafe(method(temporaryStateWithCommandBuffer:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn temporaryStateWithCommandBuffer(
220            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
221        ) -> Retained<Self>;
222
223        #[unsafe(method(initWithDevice:bufferSize:))]
224        #[unsafe(method_family = init)]
225        pub unsafe fn initWithDevice_bufferSize(
226            this: Allocated<Self>,
227            device: &ProtocolObject<dyn MTLDevice>,
228            buffer_size: usize,
229        ) -> Retained<Self>;
230
231        #[unsafe(method(initWithDevice:textureDescriptor:))]
232        #[unsafe(method_family = init)]
233        pub unsafe fn initWithDevice_textureDescriptor(
234            this: Allocated<Self>,
235            device: &ProtocolObject<dyn MTLDevice>,
236            descriptor: &MTLTextureDescriptor,
237        ) -> Retained<Self>;
238
239        /// Create a MPSState with a non-temporary MTLResource
240        ///
241        /// Parameter `resource`: A MTLBuffer or MTLTexture. May be nil.
242        ///
243        /// # Safety
244        ///
245        /// - `resource` may need to be synchronized.
246        /// - `resource` may be unretained, you must ensure it is kept alive while in use.
247        #[unsafe(method(initWithResource:))]
248        #[unsafe(method_family = init)]
249        pub unsafe fn initWithResource(
250            this: Allocated<Self>,
251            resource: Option<&ProtocolObject<dyn MTLResource>>,
252        ) -> Retained<Self>;
253
254        #[unsafe(method(init))]
255        #[unsafe(method_family = init)]
256        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
257
258        /// Initialize a non-temporary state to hold a number of textures and buffers
259        ///
260        /// The allocation of each resource will be deferred  until it is needed.
261        /// This occurs when -resource or -resourceAtIndex: is called.
262        ///
263        /// Parameter `resourceList`: The list of resources to create.
264        #[unsafe(method(initWithDevice:resourceList:))]
265        #[unsafe(method_family = init)]
266        pub unsafe fn initWithDevice_resourceList(
267            this: Allocated<Self>,
268            device: &ProtocolObject<dyn MTLDevice>,
269            resource_list: &MPSStateResourceList,
270        ) -> Retained<Self>;
271
272        /// Initialize a temporary state to hold a number of textures and buffers
273        ///
274        /// The textures occur first in sequence
275        #[unsafe(method(temporaryStateWithCommandBuffer:resourceList:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn temporaryStateWithCommandBuffer_resourceList(
278            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
279            resource_list: &MPSStateResourceList,
280        ) -> Retained<Self>;
281
282        /// Create a state object with a list of MTLResources
283        ///
284        /// Because MPS prefers deferred allocation of resources
285        /// your application should use -initWithTextures:bufferSizes:bufferCount:
286        /// whenever possible. This method is useful for cases when the
287        /// MTLResources must be initialized by the CPU.
288        ///
289        /// # Safety
290        ///
291        /// - `resources` generic may need to be synchronized.
292        /// - `resources` generic may be unretained, you must ensure it is kept alive while in use.
293        #[unsafe(method(initWithResources:))]
294        #[unsafe(method_family = init)]
295        pub unsafe fn initWithResources(
296            this: Allocated<Self>,
297            resources: Option<&NSArray<ProtocolObject<dyn MTLResource>>>,
298        ) -> Retained<Self>;
299    );
300}
301
302/// Methods declared on superclass `NSObject`.
303#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
304impl MPSNNBinaryGradientState {
305    extern_methods!(
306        #[unsafe(method(new))]
307        #[unsafe(method_family = new)]
308        pub unsafe fn new() -> Retained<Self>;
309    );
310}
311
312/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnnbinarygradientstatebatch?language=objc)
313#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
314pub type MPSNNBinaryGradientStateBatch = NSArray<MPSNNBinaryGradientState>;
315
316extern_class!(
317    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnnmultiarygradientstate?language=objc)
318    #[unsafe(super(MPSState, NSObject))]
319    #[derive(Debug, PartialEq, Eq, Hash)]
320    #[cfg(all(feature = "MPSCore", feature = "MPSState"))]
321    pub struct MPSNNMultiaryGradientState;
322);
323
324#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
325extern_conformance!(
326    unsafe impl NSObjectProtocol for MPSNNMultiaryGradientState {}
327);
328
329#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
330impl MPSNNMultiaryGradientState {
331    extern_methods!();
332}
333
334/// Methods declared on superclass `MPSState`.
335#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
336impl MPSNNMultiaryGradientState {
337    extern_methods!(
338        /// Create a MPSState holding a temporary MTLBuffer
339        ///
340        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
341        ///
342        /// Parameter `bufferSize`: The size of the buffer in bytes
343        #[unsafe(method(temporaryStateWithCommandBuffer:bufferSize:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn temporaryStateWithCommandBuffer_bufferSize(
346            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
347            buffer_size: usize,
348        ) -> Retained<Self>;
349
350        /// Create a MPSState holding a temporary MTLTexture
351        ///
352        /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
353        ///
354        /// Parameter `descriptor`: A descriptor for the new temporary texture
355        #[unsafe(method(temporaryStateWithCommandBuffer:textureDescriptor:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn temporaryStateWithCommandBuffer_textureDescriptor(
358            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
359            descriptor: &MTLTextureDescriptor,
360        ) -> Retained<Self>;
361
362        /// Create a new autoreleased temporary state object without underlying resource
363        ///
364        /// Parameter `cmdBuf`: The command buffer with which the temporary resource is associated
365        #[unsafe(method(temporaryStateWithCommandBuffer:))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn temporaryStateWithCommandBuffer(
368            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
369        ) -> Retained<Self>;
370
371        #[unsafe(method(initWithDevice:bufferSize:))]
372        #[unsafe(method_family = init)]
373        pub unsafe fn initWithDevice_bufferSize(
374            this: Allocated<Self>,
375            device: &ProtocolObject<dyn MTLDevice>,
376            buffer_size: usize,
377        ) -> Retained<Self>;
378
379        #[unsafe(method(initWithDevice:textureDescriptor:))]
380        #[unsafe(method_family = init)]
381        pub unsafe fn initWithDevice_textureDescriptor(
382            this: Allocated<Self>,
383            device: &ProtocolObject<dyn MTLDevice>,
384            descriptor: &MTLTextureDescriptor,
385        ) -> Retained<Self>;
386
387        /// Create a MPSState with a non-temporary MTLResource
388        ///
389        /// Parameter `resource`: A MTLBuffer or MTLTexture. May be nil.
390        ///
391        /// # Safety
392        ///
393        /// - `resource` may need to be synchronized.
394        /// - `resource` may be unretained, you must ensure it is kept alive while in use.
395        #[unsafe(method(initWithResource:))]
396        #[unsafe(method_family = init)]
397        pub unsafe fn initWithResource(
398            this: Allocated<Self>,
399            resource: Option<&ProtocolObject<dyn MTLResource>>,
400        ) -> Retained<Self>;
401
402        #[unsafe(method(init))]
403        #[unsafe(method_family = init)]
404        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
405
406        /// Initialize a non-temporary state to hold a number of textures and buffers
407        ///
408        /// The allocation of each resource will be deferred  until it is needed.
409        /// This occurs when -resource or -resourceAtIndex: is called.
410        ///
411        /// Parameter `resourceList`: The list of resources to create.
412        #[unsafe(method(initWithDevice:resourceList:))]
413        #[unsafe(method_family = init)]
414        pub unsafe fn initWithDevice_resourceList(
415            this: Allocated<Self>,
416            device: &ProtocolObject<dyn MTLDevice>,
417            resource_list: &MPSStateResourceList,
418        ) -> Retained<Self>;
419
420        /// Initialize a temporary state to hold a number of textures and buffers
421        ///
422        /// The textures occur first in sequence
423        #[unsafe(method(temporaryStateWithCommandBuffer:resourceList:))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn temporaryStateWithCommandBuffer_resourceList(
426            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
427            resource_list: &MPSStateResourceList,
428        ) -> Retained<Self>;
429
430        /// Create a state object with a list of MTLResources
431        ///
432        /// Because MPS prefers deferred allocation of resources
433        /// your application should use -initWithTextures:bufferSizes:bufferCount:
434        /// whenever possible. This method is useful for cases when the
435        /// MTLResources must be initialized by the CPU.
436        ///
437        /// # Safety
438        ///
439        /// - `resources` generic may need to be synchronized.
440        /// - `resources` generic may be unretained, you must ensure it is kept alive while in use.
441        #[unsafe(method(initWithResources:))]
442        #[unsafe(method_family = init)]
443        pub unsafe fn initWithResources(
444            this: Allocated<Self>,
445            resources: Option<&NSArray<ProtocolObject<dyn MTLResource>>>,
446        ) -> Retained<Self>;
447    );
448}
449
450/// Methods declared on superclass `NSObject`.
451#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
452impl MPSNNMultiaryGradientState {
453    extern_methods!(
454        #[unsafe(method(new))]
455        #[unsafe(method_family = new)]
456        pub unsafe fn new() -> Retained<Self>;
457    );
458}
459
460/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsnnmultiarygradientstatebatch?language=objc)
461#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
462pub type MPSNNMultiaryGradientStateBatch = NSArray<MPSNNMultiaryGradientState>;