objc2_metal_performance_shaders/generated/MPSImage/MPSImageCopy.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::*;
7use objc2_metal::*;
8
9use crate::*;
10
11extern_class!(
12 /// The MPSImageCopyToMatrix copies image data to a MPSMatrix.
13 /// The image data is stored in a row of a matrix. The dataLayout
14 /// specifies the order in which the feature channels in the MPSImage
15 /// get stored in the matrix. If MPSImage stores a batch of images,
16 /// the images are copied into multiple rows, one row per image.
17 ///
18 /// The number of elements in a row in the matrix must be >= image width *
19 /// image height * number of featureChannels in the image.
20 ///
21 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagecopytomatrix?language=objc)
22 #[unsafe(super(MPSKernel, NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
25 pub struct MPSImageCopyToMatrix;
26);
27
28#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
29extern_conformance!(
30 unsafe impl NSCoding for MPSImageCopyToMatrix {}
31);
32
33#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
34extern_conformance!(
35 unsafe impl NSCopying for MPSImageCopyToMatrix {}
36);
37
38#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
39unsafe impl CopyingHelper for MPSImageCopyToMatrix {
40 type Result = Self;
41}
42
43#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
44extern_conformance!(
45 unsafe impl NSObjectProtocol for MPSImageCopyToMatrix {}
46);
47
48#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
49extern_conformance!(
50 unsafe impl NSSecureCoding for MPSImageCopyToMatrix {}
51);
52
53#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
54impl MPSImageCopyToMatrix {
55 extern_methods!(
56 /// The origin, relative to [0, 0] in the destination matrix, at which to
57 /// start writing results. This property is modifiable and defaults
58 /// to [0, 0] at initialization time. If a different origin is desired
59 /// then this should be modified prior to encoding the kernel. The z
60 /// value must be 0.
61 #[unsafe(method(destinationMatrixOrigin))]
62 #[unsafe(method_family = none)]
63 pub unsafe fn destinationMatrixOrigin(&self) -> MTLOrigin;
64
65 /// Setter for [`destinationMatrixOrigin`][Self::destinationMatrixOrigin].
66 #[unsafe(method(setDestinationMatrixOrigin:))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn setDestinationMatrixOrigin(&self, destination_matrix_origin: MTLOrigin);
69
70 /// The index of the destination matrix in the batch. This property is
71 /// modifiable and defaults to 0 at initialization time.
72 #[unsafe(method(destinationMatrixBatchIndex))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn destinationMatrixBatchIndex(&self) -> NSUInteger;
75
76 /// Setter for [`destinationMatrixBatchIndex`][Self::destinationMatrixBatchIndex].
77 #[unsafe(method(setDestinationMatrixBatchIndex:))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn setDestinationMatrixBatchIndex(
80 &self,
81 destination_matrix_batch_index: NSUInteger,
82 );
83
84 /// The data layout to use
85 ///
86 /// Returns the data layout. When copying from a MPSImage to a MPSMatrix, this
87 /// describes the order in which the image values are stored in the buffer associated
88 /// with the MPSMatrix.
89 /// Default: MPSDataLayoutFeatureChannelsxHeightxWidth
90 #[unsafe(method(dataLayout))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn dataLayout(&self) -> MPSDataLayout;
93
94 /// Initialize a MPSMatrixCopy object on a device
95 ///
96 /// Parameter `device`: The device the kernel will run on
97 ///
98 /// Parameter `dataLayout`: The data layout
99 ///
100 /// Returns: A valid MPSMatrixCopy object or nil, if failure.
101 #[unsafe(method(initWithDevice:dataLayout:))]
102 #[unsafe(method_family = init)]
103 pub unsafe fn initWithDevice_dataLayout(
104 this: Allocated<Self>,
105 device: &ProtocolObject<dyn MTLDevice>,
106 data_layout: MPSDataLayout,
107 ) -> Retained<Self>;
108
109 /// NSSecureCoding compatability
110 ///
111 /// While the standard NSSecureCoding/NSCoding method
112 /// -initWithCoder: should work, since the file can't
113 /// know which device your data is allocated on, we
114 /// have to guess and may guess incorrectly. To avoid
115 /// that problem, use initWithCoder:device instead.
116 ///
117 /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
118 ///
119 /// Parameter `device`: The MTLDevice on which to make the MPSKernel
120 ///
121 /// Returns: A new MPSKernel object, or nil if failure.
122 ///
123 /// # Safety
124 ///
125 /// `a_decoder` possibly has further requirements.
126 #[unsafe(method(initWithCoder:device:))]
127 #[unsafe(method_family = init)]
128 pub unsafe fn initWithCoder_device(
129 this: Allocated<Self>,
130 a_decoder: &NSCoder,
131 device: &ProtocolObject<dyn MTLDevice>,
132 ) -> Option<Retained<Self>>;
133
134 #[cfg(feature = "MPSMatrix")]
135 /// Encode a kernel that copies a MPSImage to a MPSMatrix into a command buffer
136 /// using a MTLComputeCommandEncoder.
137 ///
138 /// The kernel copies feature channels from sourceImage to the buffer
139 /// associated with destinationMatrix. The kernel will not begin to execute until
140 /// after the command buffer has been enqueued and committed.
141 ///
142 /// NOTE: The destinationMatrix.dataType must match the feature channel data type in sourceImage.
143 ///
144 ///
145 /// Parameter `commandBuffer`: A valid MTLCommandBuffer.
146 ///
147 /// Parameter `sourceImage`: A valid MPSImage describing the image to copy from.
148 ///
149 /// Parameter `destinationMatrix`: A valid MPSMatrix or MPSTemporaryMatrix object describing the matrix to copy to.
150 #[unsafe(method(encodeToCommandBuffer:sourceImage:destinationMatrix:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn encodeToCommandBuffer_sourceImage_destinationMatrix(
153 &self,
154 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
155 source_image: &MPSImage,
156 destination_matrix: &MPSMatrix,
157 );
158
159 #[cfg(all(feature = "MPSMatrix", feature = "MPSNDArray"))]
160 /// Encode a kernel that copies a MPSImageBatch to a MPSMatrix into a command buffer
161 /// using a MTLComputeCommandEncoder.
162 ///
163 /// The kernel copies feature channels from sourceImage to the buffer
164 /// associated with destinationMatrix. The kernel will not begin to execute until
165 /// after the command buffer has been enqueued and committed.
166 /// Each image will be copied to its own row in the matrix, starting with row
167 /// destinationMatrixOrigin.x.
168 ///
169 /// NOTE: The destinationMatrix.dataType must match the feature channel data type in sourceImage.
170 /// NOTE: All the images in the source batch should be of the same size and have numberOfImages = 1.
171 ///
172 ///
173 /// Parameter `commandBuffer`: A valid MTLCommandBuffer.
174 ///
175 /// Parameter `sourceImages`: A valid MPSImageBatch describing the images to copy from.
176 ///
177 /// Parameter `destinationMatrix`: A valid MPSMatrix or MPSTemporaryMatrix object describing the matrix to copy to.
178 #[unsafe(method(encodeBatchToCommandBuffer:sourceImages:destinationMatrix:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn encodeBatchToCommandBuffer_sourceImages_destinationMatrix(
181 &self,
182 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
183 source_images: &MPSImageBatch,
184 destination_matrix: &MPSMatrix,
185 );
186 );
187}
188
189/// Methods declared on superclass `MPSKernel`.
190#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
191impl MPSImageCopyToMatrix {
192 extern_methods!(
193 /// Standard init with default properties per filter type
194 ///
195 /// Parameter `device`: The device that the filter will be used on. May not be NULL.
196 ///
197 /// Returns: a pointer to the newly initialized object. This will fail, returning
198 /// nil if the device is not supported. Devices must be
199 /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
200 #[unsafe(method(initWithDevice:))]
201 #[unsafe(method_family = init)]
202 pub unsafe fn initWithDevice(
203 this: Allocated<Self>,
204 device: &ProtocolObject<dyn MTLDevice>,
205 ) -> Retained<Self>;
206
207 /// Called by NSCoder to decode MPSKernels
208 ///
209 /// This isn't the right interface to decode a MPSKernel, but
210 /// it is the one that NSCoder uses. To enable your NSCoder
211 /// (e.g. NSKeyedUnarchiver) to set which device to use
212 /// extend the object to adopt the MPSDeviceProvider
213 /// protocol. Otherwise, the Metal system default device
214 /// will be used.
215 ///
216 /// # Safety
217 ///
218 /// `a_decoder` possibly has further requirements.
219 #[unsafe(method(initWithCoder:))]
220 #[unsafe(method_family = init)]
221 pub unsafe fn initWithCoder(
222 this: Allocated<Self>,
223 a_decoder: &NSCoder,
224 ) -> Option<Retained<Self>>;
225 );
226}
227
228/// Methods declared on superclass `NSObject`.
229#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
230impl MPSImageCopyToMatrix {
231 extern_methods!(
232 #[unsafe(method(init))]
233 #[unsafe(method_family = init)]
234 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
235
236 #[unsafe(method(new))]
237 #[unsafe(method_family = new)]
238 pub unsafe fn new() -> Retained<Self>;
239 );
240}
241
242extern_class!(
243 /// The MPSMatrixCopyToImage copies matrix data to a MPSImage.
244 /// The operation is the reverse of MPSImageCopyToMatrix.
245 ///
246 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsmatrixcopytoimage?language=objc)
247 #[unsafe(super(MPSKernel, NSObject))]
248 #[derive(Debug, PartialEq, Eq, Hash)]
249 #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
250 pub struct MPSMatrixCopyToImage;
251);
252
253#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
254extern_conformance!(
255 unsafe impl NSCoding for MPSMatrixCopyToImage {}
256);
257
258#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
259extern_conformance!(
260 unsafe impl NSCopying for MPSMatrixCopyToImage {}
261);
262
263#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
264unsafe impl CopyingHelper for MPSMatrixCopyToImage {
265 type Result = Self;
266}
267
268#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
269extern_conformance!(
270 unsafe impl NSObjectProtocol for MPSMatrixCopyToImage {}
271);
272
273#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
274extern_conformance!(
275 unsafe impl NSSecureCoding for MPSMatrixCopyToImage {}
276);
277
278#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
279impl MPSMatrixCopyToImage {
280 extern_methods!(
281 /// The origin, relative to [0, 0] in the source matrix.
282 /// This property is modifiable and defaults
283 /// to [0, 0] at initialization time. If a different origin is desired
284 /// then this should be modified prior to encoding the kernel. The z
285 /// value must be 0.
286 #[unsafe(method(sourceMatrixOrigin))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn sourceMatrixOrigin(&self) -> MTLOrigin;
289
290 /// Setter for [`sourceMatrixOrigin`][Self::sourceMatrixOrigin].
291 #[unsafe(method(setSourceMatrixOrigin:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn setSourceMatrixOrigin(&self, source_matrix_origin: MTLOrigin);
294
295 /// The index of the source matrix in the batch. This property is
296 /// modifiable and defaults to 0 at initialization time.
297 #[unsafe(method(sourceMatrixBatchIndex))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn sourceMatrixBatchIndex(&self) -> NSUInteger;
300
301 /// Setter for [`sourceMatrixBatchIndex`][Self::sourceMatrixBatchIndex].
302 #[unsafe(method(setSourceMatrixBatchIndex:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn setSourceMatrixBatchIndex(&self, source_matrix_batch_index: NSUInteger);
305
306 /// The data layout to use
307 ///
308 /// Returns the data layout. When copying from a MPSMatrix to a MPSImage, this
309 /// describes the order in which the image values are to be stored in the buffer associated
310 /// with the MPSMatrix.
311 /// Default: MPSDataLayoutFeatureChannelsxHeightxWidth
312 #[unsafe(method(dataLayout))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn dataLayout(&self) -> MPSDataLayout;
315
316 /// Initialize a MPSMatrixCopyToImage object on a device
317 ///
318 /// Parameter `device`: The device the kernel will run on
319 ///
320 /// Parameter `dataLayout`: The data layout
321 ///
322 /// Returns: A valid MPSMatrixCopyToImage object or nil, if failure.
323 #[unsafe(method(initWithDevice:dataLayout:))]
324 #[unsafe(method_family = init)]
325 pub unsafe fn initWithDevice_dataLayout(
326 this: Allocated<Self>,
327 device: &ProtocolObject<dyn MTLDevice>,
328 data_layout: MPSDataLayout,
329 ) -> Retained<Self>;
330
331 /// NSSecureCoding compatability
332 ///
333 /// While the standard NSSecureCoding/NSCoding method
334 /// -initWithCoder: should work, since the file can't
335 /// know which device your data is allocated on, we
336 /// have to guess and may guess incorrectly. To avoid
337 /// that problem, use initWithCoder:device instead.
338 ///
339 /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
340 ///
341 /// Parameter `device`: The MTLDevice on which to make the MPSKernel
342 ///
343 /// Returns: A new MPSKernel object, or nil if failure.
344 ///
345 /// # Safety
346 ///
347 /// `a_decoder` possibly has further requirements.
348 #[unsafe(method(initWithCoder:device:))]
349 #[unsafe(method_family = init)]
350 pub unsafe fn initWithCoder_device(
351 this: Allocated<Self>,
352 a_decoder: &NSCoder,
353 device: &ProtocolObject<dyn MTLDevice>,
354 ) -> Option<Retained<Self>>;
355
356 #[cfg(feature = "MPSMatrix")]
357 /// Encode a kernel that copies a MPSMatrix to a MPSImage into a command buffer
358 /// using a MTLComputeCommandEncoder.
359 ///
360 /// The kernel copies feature channels from sourceMatrix to the destinationImage.
361 /// The kernel will not begin to execute until
362 /// after the command buffer has been enqueued and committed.
363 ///
364 /// NOTE: The sourceMatrix.dataType must match the feature channel data type in destinationImage.
365 ///
366 ///
367 /// Parameter `commandBuffer`: A valid MTLCommandBuffer.
368 ///
369 /// Parameter `sourceMatrix`: A valid MPSMatrix or MPSTemporaryMatrix object describing the source matrix.
370 ///
371 /// Parameter `destinationImage`: A valid MPSImage describing the image to copy to.
372 #[unsafe(method(encodeToCommandBuffer:sourceMatrix:destinationImage:))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn encodeToCommandBuffer_sourceMatrix_destinationImage(
375 &self,
376 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
377 source_matrix: &MPSMatrix,
378 destination_image: &MPSImage,
379 );
380
381 #[cfg(all(feature = "MPSMatrix", feature = "MPSNDArray"))]
382 /// Encode a kernel that copies a MPSMatrix to a MPSImageBatch into a command buffer
383 /// using a MTLComputeCommandEncoder.
384 ///
385 /// The kernel copies feature channels from sourceImage to the buffer
386 /// associated with destinationMatrix. The kernel will not begin to execute until
387 /// after the command buffer has been enqueued and committed.
388 /// Each image will be copied to its own row in the matrix, starting with row
389 /// destinationMatrixOrigin.x.
390 ///
391 /// NOTE: The destinationMatrix.dataType must match the feature channel data type in sourceImage.
392 /// NOTE: All the images in the source batch should be of the same size and have numberOfImages = 1.
393 ///
394 ///
395 /// Parameter `commandBuffer`: A valid MTLCommandBuffer.
396 ///
397 /// Parameter `sourceMatrix`: A valid MPSMatrix or MPSTemporaryMatrix object describing the source matrix.
398 ///
399 /// Parameter `destinationImages`: A valid MPSImageBatch describing the images to copy to.
400 #[unsafe(method(encodeBatchToCommandBuffer:sourceMatrix:destinationImages:))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn encodeBatchToCommandBuffer_sourceMatrix_destinationImages(
403 &self,
404 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
405 source_matrix: &MPSMatrix,
406 destination_images: &MPSImageBatch,
407 );
408 );
409}
410
411/// Methods declared on superclass `MPSKernel`.
412#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
413impl MPSMatrixCopyToImage {
414 extern_methods!(
415 /// Standard init with default properties per filter type
416 ///
417 /// Parameter `device`: The device that the filter will be used on. May not be NULL.
418 ///
419 /// Returns: a pointer to the newly initialized object. This will fail, returning
420 /// nil if the device is not supported. Devices must be
421 /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
422 #[unsafe(method(initWithDevice:))]
423 #[unsafe(method_family = init)]
424 pub unsafe fn initWithDevice(
425 this: Allocated<Self>,
426 device: &ProtocolObject<dyn MTLDevice>,
427 ) -> Retained<Self>;
428
429 /// Called by NSCoder to decode MPSKernels
430 ///
431 /// This isn't the right interface to decode a MPSKernel, but
432 /// it is the one that NSCoder uses. To enable your NSCoder
433 /// (e.g. NSKeyedUnarchiver) to set which device to use
434 /// extend the object to adopt the MPSDeviceProvider
435 /// protocol. Otherwise, the Metal system default device
436 /// will be used.
437 ///
438 /// # Safety
439 ///
440 /// `a_decoder` possibly has further requirements.
441 #[unsafe(method(initWithCoder:))]
442 #[unsafe(method_family = init)]
443 pub unsafe fn initWithCoder(
444 this: Allocated<Self>,
445 a_decoder: &NSCoder,
446 ) -> Option<Retained<Self>>;
447 );
448}
449
450/// Methods declared on superclass `NSObject`.
451#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
452impl MPSMatrixCopyToImage {
453 extern_methods!(
454 #[unsafe(method(init))]
455 #[unsafe(method_family = init)]
456 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
457
458 #[unsafe(method(new))]
459 #[unsafe(method_family = new)]
460 pub unsafe fn new() -> Retained<Self>;
461 );
462}