objc2_metal_performance_shaders/generated/MPSNDArray/
MPSNDArrayIdentity.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    /// Dependencies: This depends on Metal.framework.
12    ///
13    /// An efficient kernel to handle copies, transposed-copies and reshapes.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayidentity?language=objc)
16    #[unsafe(super(
17        MPSNDArrayUnaryKernel,
18        MPSNDArrayMultiaryKernel,
19        MPSNDArrayMultiaryBase,
20        MPSKernel,
21        NSObject
22    ))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    #[cfg(all(
25        feature = "MPSCore",
26        feature = "MPSKernel",
27        feature = "MPSNDArrayKernel"
28    ))]
29    pub struct MPSNDArrayIdentity;
30);
31
32#[cfg(all(
33    feature = "MPSCore",
34    feature = "MPSKernel",
35    feature = "MPSNDArrayKernel"
36))]
37extern_conformance!(
38    unsafe impl NSCoding for MPSNDArrayIdentity {}
39);
40
41#[cfg(all(
42    feature = "MPSCore",
43    feature = "MPSKernel",
44    feature = "MPSNDArrayKernel"
45))]
46extern_conformance!(
47    unsafe impl NSCopying for MPSNDArrayIdentity {}
48);
49
50#[cfg(all(
51    feature = "MPSCore",
52    feature = "MPSKernel",
53    feature = "MPSNDArrayKernel"
54))]
55unsafe impl CopyingHelper for MPSNDArrayIdentity {
56    type Result = Self;
57}
58
59#[cfg(all(
60    feature = "MPSCore",
61    feature = "MPSKernel",
62    feature = "MPSNDArrayKernel"
63))]
64extern_conformance!(
65    unsafe impl NSObjectProtocol for MPSNDArrayIdentity {}
66);
67
68#[cfg(all(
69    feature = "MPSCore",
70    feature = "MPSKernel",
71    feature = "MPSNDArrayKernel"
72))]
73extern_conformance!(
74    unsafe impl NSSecureCoding for MPSNDArrayIdentity {}
75);
76
77#[cfg(all(
78    feature = "MPSCore",
79    feature = "MPSKernel",
80    feature = "MPSNDArrayKernel"
81))]
82impl MPSNDArrayIdentity {
83    extern_methods!(
84        #[unsafe(method(initWithDevice:))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn initWithDevice(
87            this: Allocated<Self>,
88            device: &ProtocolObject<dyn MTLDevice>,
89        ) -> Retained<Self>;
90
91        #[cfg(feature = "MPSCoreTypes")]
92        /// Do a reshape operation, either by trying to alias the array, returning an arrayview, or by copying.
93        ///
94        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel, or to create a temporary array alias.
95        ///
96        /// Parameter `sourceArray`: Source array. If this function returns a non-nil result, then the readCount of `sourceArray` is decremented.
97        ///
98        /// Parameter `shape`: The new shape, given in TF dimension ordering (as always with MPSShape).
99        ///
100        /// Parameter `destinationArray`: If not nil, then the result of reshape will be copied to this. Shape of `destinationArray` must match `shape`.
101        ///
102        /// Returns: If `destinationArray` is not nil, then `destinationArray`. Otherwise aliasing is tried, and if aliasing is not possible
103        /// due to existing slices or transposes nil is returned. If aliasing is successful, then a new arrayview of `sourceArray`
104        /// is returned; If `sourceArray` is a `MPSTemporaryArray` then a `MPSTemporaryArray` is returned referencing the same data,
105        /// otherwise a `MPSNDArray` type result is returned.
106        #[unsafe(method(reshapeWithCommandBuffer:sourceArray:shape:destinationArray:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn reshapeWithCommandBuffer_sourceArray_shape_destinationArray(
109            &self,
110            cmd_buf: Option<&ProtocolObject<dyn MTLCommandBuffer>>,
111            source_array: &MPSNDArray,
112            shape: &MPSShape,
113            destination_array: Option<&MPSNDArray>,
114        ) -> Option<Retained<MPSNDArray>>;
115
116        /// # Safety
117        ///
118        /// `dimension_sizes` must be a valid pointer.
119        #[unsafe(method(reshapeWithCommandBuffer:sourceArray:dimensionCount:dimensionSizes:destinationArray:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn reshapeWithCommandBuffer_sourceArray_dimensionCount_dimensionSizes_destinationArray(
122            &self,
123            cmd_buf: Option<&ProtocolObject<dyn MTLCommandBuffer>>,
124            source_array: &MPSNDArray,
125            number_of_dimensions: NSUInteger,
126            dimension_sizes: NonNull<NSUInteger>,
127            destination_array: Option<&MPSNDArray>,
128        ) -> Option<Retained<MPSNDArray>>;
129
130        #[cfg(feature = "MPSCoreTypes")]
131        #[unsafe(method(reshapeWithCommandEncoder:commandBuffer:sourceArray:shape:destinationArray:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn reshapeWithCommandEncoder_commandBuffer_sourceArray_shape_destinationArray(
134            &self,
135            encoder: Option<&ProtocolObject<dyn MTLComputeCommandEncoder>>,
136            cmd_buf: Option<&ProtocolObject<dyn MTLCommandBuffer>>,
137            source_array: &MPSNDArray,
138            shape: &MPSShape,
139            destination_array: Option<&MPSNDArray>,
140        ) -> Option<Retained<MPSNDArray>>;
141
142        /// # Safety
143        ///
144        /// `dimension_sizes` must be a valid pointer.
145        #[unsafe(method(reshapeWithCommandEncoder:commandBuffer:sourceArray:dimensionCount:dimensionSizes:destinationArray:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn reshapeWithCommandEncoder_commandBuffer_sourceArray_dimensionCount_dimensionSizes_destinationArray(
148            &self,
149            encoder: Option<&ProtocolObject<dyn MTLComputeCommandEncoder>>,
150            cmd_buf: Option<&ProtocolObject<dyn MTLCommandBuffer>>,
151            source_array: &MPSNDArray,
152            number_of_dimensions: NSUInteger,
153            dimension_sizes: NonNull<NSUInteger>,
154            destination_array: Option<&MPSNDArray>,
155        ) -> Option<Retained<MPSNDArray>>;
156    );
157}
158
159/// Methods declared on superclass `MPSNDArrayUnaryKernel`.
160#[cfg(all(
161    feature = "MPSCore",
162    feature = "MPSKernel",
163    feature = "MPSNDArrayKernel"
164))]
165impl MPSNDArrayIdentity {
166    extern_methods!(
167        #[unsafe(method(initWithDevice:sourceCount:))]
168        #[unsafe(method_family = init)]
169        pub unsafe fn initWithDevice_sourceCount(
170            this: Allocated<Self>,
171            device: &ProtocolObject<dyn MTLDevice>,
172            count: NSUInteger,
173        ) -> Retained<Self>;
174
175        /// # Safety
176        ///
177        /// `coder` possibly has further requirements.
178        #[unsafe(method(initWithCoder:device:))]
179        #[unsafe(method_family = init)]
180        pub unsafe fn initWithCoder_device(
181            this: Allocated<Self>,
182            coder: &NSCoder,
183            device: &ProtocolObject<dyn MTLDevice>,
184        ) -> Retained<Self>;
185    );
186}
187
188/// Methods declared on superclass `MPSKernel`.
189#[cfg(all(
190    feature = "MPSCore",
191    feature = "MPSKernel",
192    feature = "MPSNDArrayKernel"
193))]
194impl MPSNDArrayIdentity {
195    extern_methods!(
196        /// Called by NSCoder to decode MPSKernels
197        ///
198        /// This isn't the right interface to decode a MPSKernel, but
199        /// it is the one that NSCoder uses. To enable your NSCoder
200        /// (e.g. NSKeyedUnarchiver) to set which device to use
201        /// extend the object to adopt the MPSDeviceProvider
202        /// protocol. Otherwise, the Metal system default device
203        /// will be used.
204        ///
205        /// # Safety
206        ///
207        /// `a_decoder` possibly has further requirements.
208        #[unsafe(method(initWithCoder:))]
209        #[unsafe(method_family = init)]
210        pub unsafe fn initWithCoder(
211            this: Allocated<Self>,
212            a_decoder: &NSCoder,
213        ) -> Option<Retained<Self>>;
214    );
215}
216
217/// Methods declared on superclass `NSObject`.
218#[cfg(all(
219    feature = "MPSCore",
220    feature = "MPSKernel",
221    feature = "MPSNDArrayKernel"
222))]
223impl MPSNDArrayIdentity {
224    extern_methods!(
225        #[unsafe(method(init))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
228
229        #[unsafe(method(new))]
230        #[unsafe(method_family = new)]
231        pub unsafe fn new() -> Retained<Self>;
232    );
233}