objc2_metal/generated/
MTLBlitCommandEncoder.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/// Controls the blit operation
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlblitoption?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MTLBlitOption(pub NSUInteger);
17bitflags::bitflags! {
18    impl MTLBlitOption: NSUInteger {
19        #[doc(alias = "MTLBlitOptionNone")]
20        const None = 0;
21        #[doc(alias = "MTLBlitOptionDepthFromDepthStencil")]
22        const DepthFromDepthStencil = 1<<0;
23        #[doc(alias = "MTLBlitOptionStencilFromDepthStencil")]
24        const StencilFromDepthStencil = 1<<1;
25        #[doc(alias = "MTLBlitOptionRowLinearPVRTC")]
26        const RowLinearPVRTC = 1<<2;
27    }
28}
29
30unsafe impl Encode for MTLBlitOption {
31    const ENCODING: Encoding = NSUInteger::ENCODING;
32}
33
34unsafe impl RefEncode for MTLBlitOption {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_protocol!(
39    /// A command encoder that performs basic copies and blits between buffers and textures.
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlblitcommandencoder?language=objc)
42    #[cfg(feature = "MTLCommandEncoder")]
43    pub unsafe trait MTLBlitCommandEncoder: MTLCommandEncoder {
44        #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
45        /// Flush any copy of this resource from the device's caches, and invalidate any CPU caches if needed.
46        ///
47        /// Parameter `resource`: The resource to page off.
48        ///
49        /// When the device writes to a resource with a storage mode of MTLResourceStorageModeManaged, those writes may be cached (for example, in VRAM or on chip renderer cache),
50        /// making any CPU access (either MTLBuffer.contents or -[MTLTexture getBytes:...] and -[MTLTexture replaceRegion:]) produce undefined results.  To allow the CPU to see what the device
51        /// has written, a CommandBuffer containing this synchronization must be executed.  After completion of the CommandBuffer, the CPU can access the contents of the resource safely.
52        #[unsafe(method(synchronizeResource:))]
53        #[unsafe(method_family = none)]
54        fn synchronizeResource(&self, resource: &ProtocolObject<dyn MTLResource>);
55
56        #[cfg(all(
57            feature = "MTLAllocation",
58            feature = "MTLResource",
59            feature = "MTLTexture"
60        ))]
61        /// Flush any copy of this image from the device's caches, and invalidate CPU caches if needed.
62        ///
63        /// Parameter `texture`: The texture to page off.
64        ///
65        /// Parameter `slice`: The slice of the texture to page off.
66        ///
67        /// Parameter `level`: The mipmap level of the texture to flush.
68        ///
69        /// See the discussion of -synchronizeResource.   -synchronizeTexture:slice:mipmapLevel performs the same role, except it may flush only a subset of the texture storage, rather than the entire texture.
70        ///
71        /// # Safety
72        ///
73        /// - `texture` may need to be synchronized.
74        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
75        #[unsafe(method(synchronizeTexture:slice:level:))]
76        #[unsafe(method_family = none)]
77        unsafe fn synchronizeTexture_slice_level(
78            &self,
79            texture: &ProtocolObject<dyn MTLTexture>,
80            slice: NSUInteger,
81            level: NSUInteger,
82        );
83
84        #[cfg(all(
85            feature = "MTLAllocation",
86            feature = "MTLResource",
87            feature = "MTLTexture",
88            feature = "MTLTypes"
89        ))]
90        /// Copy a rectangle of pixels between textures.
91        ///
92        /// # Safety
93        ///
94        /// - `source_texture` may need to be synchronized.
95        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
96        /// - `sourceSize` might not be bounds-checked.
97        /// - `destination_texture` may need to be synchronized.
98        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
99        #[unsafe(method(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:))]
100        #[unsafe(method_family = none)]
101        unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
102            &self,
103            source_texture: &ProtocolObject<dyn MTLTexture>,
104            source_slice: NSUInteger,
105            source_level: NSUInteger,
106            source_origin: MTLOrigin,
107            source_size: MTLSize,
108            destination_texture: &ProtocolObject<dyn MTLTexture>,
109            destination_slice: NSUInteger,
110            destination_level: NSUInteger,
111            destination_origin: MTLOrigin,
112        );
113
114        #[cfg(all(
115            feature = "MTLAllocation",
116            feature = "MTLBuffer",
117            feature = "MTLResource",
118            feature = "MTLTexture",
119            feature = "MTLTypes"
120        ))]
121        /// Copy an image from a buffer into a texture.
122        ///
123        /// # Safety
124        ///
125        /// - `source_buffer` may need to be synchronized.
126        /// - `source_buffer` may be unretained, you must ensure it is kept alive while in use.
127        /// - `source_buffer` contents should be of the correct type.
128        /// - `sourceOffset` might not be bounds-checked.
129        /// - `sourceSize` might not be bounds-checked.
130        /// - `destination_texture` may need to be synchronized.
131        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
132        #[unsafe(method(copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:))]
133        #[unsafe(method_family = none)]
134        unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
135            &self,
136            source_buffer: &ProtocolObject<dyn MTLBuffer>,
137            source_offset: NSUInteger,
138            source_bytes_per_row: NSUInteger,
139            source_bytes_per_image: NSUInteger,
140            source_size: MTLSize,
141            destination_texture: &ProtocolObject<dyn MTLTexture>,
142            destination_slice: NSUInteger,
143            destination_level: NSUInteger,
144            destination_origin: MTLOrigin,
145        );
146
147        #[cfg(all(
148            feature = "MTLAllocation",
149            feature = "MTLBuffer",
150            feature = "MTLResource",
151            feature = "MTLTexture",
152            feature = "MTLTypes"
153        ))]
154        /// Copy an image from a buffer into a texture.
155        ///
156        /// # Safety
157        ///
158        /// - `source_buffer` may need to be synchronized.
159        /// - `source_buffer` may be unretained, you must ensure it is kept alive while in use.
160        /// - `source_buffer` contents should be of the correct type.
161        /// - `sourceOffset` might not be bounds-checked.
162        /// - `sourceSize` might not be bounds-checked.
163        /// - `destination_texture` may need to be synchronized.
164        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
165        #[unsafe(method(copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:))]
166        #[unsafe(method_family = none)]
167        unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options(
168            &self,
169            source_buffer: &ProtocolObject<dyn MTLBuffer>,
170            source_offset: NSUInteger,
171            source_bytes_per_row: NSUInteger,
172            source_bytes_per_image: NSUInteger,
173            source_size: MTLSize,
174            destination_texture: &ProtocolObject<dyn MTLTexture>,
175            destination_slice: NSUInteger,
176            destination_level: NSUInteger,
177            destination_origin: MTLOrigin,
178            options: MTLBlitOption,
179        );
180
181        #[cfg(all(
182            feature = "MTLAllocation",
183            feature = "MTLBuffer",
184            feature = "MTLResource",
185            feature = "MTLTexture",
186            feature = "MTLTypes"
187        ))]
188        /// Copy an image from a texture into a buffer.
189        ///
190        /// # Safety
191        ///
192        /// - `source_texture` may need to be synchronized.
193        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
194        /// - `sourceSize` might not be bounds-checked.
195        /// - `destination_buffer` may need to be synchronized.
196        /// - `destination_buffer` may be unretained, you must ensure it is kept alive while in use.
197        /// - `destination_buffer` contents should be of the correct type.
198        /// - `destinationOffset` might not be bounds-checked.
199        #[unsafe(method(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:))]
200        #[unsafe(method_family = none)]
201        unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage(
202            &self,
203            source_texture: &ProtocolObject<dyn MTLTexture>,
204            source_slice: NSUInteger,
205            source_level: NSUInteger,
206            source_origin: MTLOrigin,
207            source_size: MTLSize,
208            destination_buffer: &ProtocolObject<dyn MTLBuffer>,
209            destination_offset: NSUInteger,
210            destination_bytes_per_row: NSUInteger,
211            destination_bytes_per_image: NSUInteger,
212        );
213
214        #[cfg(all(
215            feature = "MTLAllocation",
216            feature = "MTLBuffer",
217            feature = "MTLResource",
218            feature = "MTLTexture",
219            feature = "MTLTypes"
220        ))]
221        /// Copy an image from a texture into a buffer.
222        ///
223        /// # Safety
224        ///
225        /// - `source_texture` may need to be synchronized.
226        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
227        /// - `sourceSize` might not be bounds-checked.
228        /// - `destination_buffer` may need to be synchronized.
229        /// - `destination_buffer` may be unretained, you must ensure it is kept alive while in use.
230        /// - `destination_buffer` contents should be of the correct type.
231        /// - `destinationOffset` might not be bounds-checked.
232        #[unsafe(method(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:))]
233        #[unsafe(method_family = none)]
234        unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options(
235            &self,
236            source_texture: &ProtocolObject<dyn MTLTexture>,
237            source_slice: NSUInteger,
238            source_level: NSUInteger,
239            source_origin: MTLOrigin,
240            source_size: MTLSize,
241            destination_buffer: &ProtocolObject<dyn MTLBuffer>,
242            destination_offset: NSUInteger,
243            destination_bytes_per_row: NSUInteger,
244            destination_bytes_per_image: NSUInteger,
245            options: MTLBlitOption,
246        );
247
248        #[cfg(all(
249            feature = "MTLAllocation",
250            feature = "MTLResource",
251            feature = "MTLTexture"
252        ))]
253        /// Generate mipmaps for a texture from the base level up to the max level.
254        #[unsafe(method(generateMipmapsForTexture:))]
255        #[unsafe(method_family = none)]
256        fn generateMipmapsForTexture(&self, texture: &ProtocolObject<dyn MTLTexture>);
257
258        #[cfg(all(
259            feature = "MTLAllocation",
260            feature = "MTLBuffer",
261            feature = "MTLResource"
262        ))]
263        /// Fill a buffer with a fixed value in each byte.
264        #[unsafe(method(fillBuffer:range:value:))]
265        #[unsafe(method_family = none)]
266        fn fillBuffer_range_value(
267            &self,
268            buffer: &ProtocolObject<dyn MTLBuffer>,
269            range: NSRange,
270            value: u8,
271        );
272
273        #[cfg(all(
274            feature = "MTLAllocation",
275            feature = "MTLResource",
276            feature = "MTLTexture"
277        ))]
278        /// Copy whole surfaces between textures.
279        ///
280        /// Convenience function to copy sliceCount * levelCount whole surfaces between textures
281        /// The source and destination pixel format must be identical.
282        /// The source and destination sample count must be identical.
283        /// The sourceLevel mip in sourceTexture must have the same dimension as the destinationLevel mip in destinationTexture.
284        /// The sourceTexture must have at least sourceLevel + levelCount mips
285        /// The destinationTexture must have at least destinationLevel + levelCount mips
286        /// The sourceTexture must have at least sourceSlice + sliceCount array slices
287        /// The destinationTexture must have at least destinationSlice + sliceCount array slices
288        ///
289        /// # Safety
290        ///
291        /// - `source_texture` may need to be synchronized.
292        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
293        /// - `destination_texture` may need to be synchronized.
294        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
295        /// - `sliceCount` might not be bounds-checked.
296        /// - `levelCount` might not be bounds-checked.
297        #[unsafe(method(copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:))]
298        #[unsafe(method_family = none)]
299        unsafe fn copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount(
300            &self,
301            source_texture: &ProtocolObject<dyn MTLTexture>,
302            source_slice: NSUInteger,
303            source_level: NSUInteger,
304            destination_texture: &ProtocolObject<dyn MTLTexture>,
305            destination_slice: NSUInteger,
306            destination_level: NSUInteger,
307            slice_count: NSUInteger,
308            level_count: NSUInteger,
309        );
310
311        #[cfg(all(
312            feature = "MTLAllocation",
313            feature = "MTLResource",
314            feature = "MTLTexture"
315        ))]
316        /// Copy as many whole surfaces as possible between textures.
317        ///
318        /// Convenience function that calls copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:
319        /// The source and destination pixel format must be identical.
320        /// The source and destination sample count must be identical.
321        /// Either:
322        /// - sourceTexture must have a mip M with identical dimensions as the first mip of destinationTexture: sourceLevel = M, destinationLevel = 0
323        /// - destinationTexture must have a mip M with identical dimensions as the first mip of sourceTexture: sourceLevel = 0, destinationLevel = M
324        /// Computes: levelCount = min(sourceTexture.mipmapLevelCount - sourceLevel, destinationTexture.mipmapLevelCount - destinationLevel)
325        /// sliceCount = min(sourceTexture.arrayLength, destinationTexture.arrayLength)
326        /// Then invokes the method above using the computed parameters.
327        ///
328        /// # Safety
329        ///
330        /// - `source_texture` may need to be synchronized.
331        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
332        /// - `destination_texture` may need to be synchronized.
333        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
334        #[unsafe(method(copyFromTexture:toTexture:))]
335        #[unsafe(method_family = none)]
336        unsafe fn copyFromTexture_toTexture(
337            &self,
338            source_texture: &ProtocolObject<dyn MTLTexture>,
339            destination_texture: &ProtocolObject<dyn MTLTexture>,
340        );
341
342        #[cfg(all(
343            feature = "MTLAllocation",
344            feature = "MTLBuffer",
345            feature = "MTLResource"
346        ))]
347        /// Basic memory copy between buffers.
348        ///
349        /// # Safety
350        ///
351        /// - `source_buffer` may need to be synchronized.
352        /// - `source_buffer` may be unretained, you must ensure it is kept alive while in use.
353        /// - `source_buffer` contents should be of the correct type.
354        /// - `sourceOffset` might not be bounds-checked.
355        /// - `destination_buffer` may need to be synchronized.
356        /// - `destination_buffer` may be unretained, you must ensure it is kept alive while in use.
357        /// - `destination_buffer` contents should be of the correct type.
358        /// - `destinationOffset` might not be bounds-checked.
359        /// - `size` might not be bounds-checked.
360        #[unsafe(method(copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:))]
361        #[unsafe(method_family = none)]
362        unsafe fn copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size(
363            &self,
364            source_buffer: &ProtocolObject<dyn MTLBuffer>,
365            source_offset: NSUInteger,
366            destination_buffer: &ProtocolObject<dyn MTLBuffer>,
367            destination_offset: NSUInteger,
368            size: NSUInteger,
369        );
370
371        #[cfg(feature = "MTLFence")]
372        /// Update the fence to capture all GPU work so far enqueued by this encoder.
373        ///
374        /// The fence is updated at kernel submission to maintain global order and prevent deadlock.
375        /// Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
376        #[unsafe(method(updateFence:))]
377        #[unsafe(method_family = none)]
378        fn updateFence(&self, fence: &ProtocolObject<dyn MTLFence>);
379
380        #[cfg(feature = "MTLFence")]
381        /// Prevent further GPU work until the fence is reached.
382        ///
383        /// The fence is evaluated at kernel submission to maintain global order and prevent deadlock.
384        /// Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
385        #[unsafe(method(waitForFence:))]
386        #[unsafe(method_family = none)]
387        fn waitForFence(&self, fence: &ProtocolObject<dyn MTLFence>);
388
389        #[cfg(all(
390            feature = "MTLAllocation",
391            feature = "MTLBuffer",
392            feature = "MTLResource",
393            feature = "MTLTexture",
394            feature = "MTLTypes"
395        ))]
396        /// Copies tile access counters within specified region into provided buffer
397        ///
398        /// # Safety
399        ///
400        /// - `texture` may need to be synchronized.
401        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
402        /// - `counters_buffer` may need to be synchronized.
403        /// - `counters_buffer` may be unretained, you must ensure it is kept alive while in use.
404        /// - `counters_buffer` contents should be of the correct type.
405        /// - `countersBufferOffset` might not be bounds-checked.
406        #[optional]
407        #[unsafe(method(getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:))]
408        #[unsafe(method_family = none)]
409        unsafe fn getTextureAccessCounters_region_mipLevel_slice_resetCounters_countersBuffer_countersBufferOffset(
410            &self,
411            texture: &ProtocolObject<dyn MTLTexture>,
412            region: MTLRegion,
413            mip_level: NSUInteger,
414            slice: NSUInteger,
415            reset_counters: bool,
416            counters_buffer: &ProtocolObject<dyn MTLBuffer>,
417            counters_buffer_offset: NSUInteger,
418        );
419
420        #[cfg(all(
421            feature = "MTLAllocation",
422            feature = "MTLResource",
423            feature = "MTLTexture",
424            feature = "MTLTypes"
425        ))]
426        /// Resets tile access counters within specified region
427        ///
428        /// # Safety
429        ///
430        /// - `texture` may need to be synchronized.
431        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
432        /// - This might not be bounds-checked.
433        #[optional]
434        #[unsafe(method(resetTextureAccessCounters:region:mipLevel:slice:))]
435        #[unsafe(method_family = none)]
436        unsafe fn resetTextureAccessCounters_region_mipLevel_slice(
437            &self,
438            texture: &ProtocolObject<dyn MTLTexture>,
439            region: MTLRegion,
440            mip_level: NSUInteger,
441            slice: NSUInteger,
442        );
443
444        #[cfg(all(
445            feature = "MTLAllocation",
446            feature = "MTLResource",
447            feature = "MTLTexture"
448        ))]
449        /// Optimizes the texture data to ensure the best possible performance when accessing content on the GPU at the expense of CPU-access performance.
450        #[unsafe(method(optimizeContentsForGPUAccess:))]
451        #[unsafe(method_family = none)]
452        fn optimizeContentsForGPUAccess(&self, texture: &ProtocolObject<dyn MTLTexture>);
453
454        #[cfg(all(
455            feature = "MTLAllocation",
456            feature = "MTLResource",
457            feature = "MTLTexture"
458        ))]
459        /// Optimizes a subset of the texture data to ensure the best possible performance when accessing content on the GPU at the expense of CPU-access performance.
460        ///
461        /// # Safety
462        ///
463        /// - `texture` may need to be synchronized.
464        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
465        #[unsafe(method(optimizeContentsForGPUAccess:slice:level:))]
466        #[unsafe(method_family = none)]
467        unsafe fn optimizeContentsForGPUAccess_slice_level(
468            &self,
469            texture: &ProtocolObject<dyn MTLTexture>,
470            slice: NSUInteger,
471            level: NSUInteger,
472        );
473
474        #[cfg(all(
475            feature = "MTLAllocation",
476            feature = "MTLResource",
477            feature = "MTLTexture"
478        ))]
479        /// Optimizes the texture data to ensure the best possible performance when accessing content on the CPU at the expense of GPU-access performance.
480        ///
481        /// # Safety
482        ///
483        /// - `texture` may need to be synchronized.
484        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
485        #[unsafe(method(optimizeContentsForCPUAccess:))]
486        #[unsafe(method_family = none)]
487        unsafe fn optimizeContentsForCPUAccess(&self, texture: &ProtocolObject<dyn MTLTexture>);
488
489        #[cfg(all(
490            feature = "MTLAllocation",
491            feature = "MTLResource",
492            feature = "MTLTexture"
493        ))]
494        /// Optimizes a subset of the texture data to ensure the best possible performance when accessing content on the CPU at the expense of GPU-access performance.
495        ///
496        /// # Safety
497        ///
498        /// - `texture` may need to be synchronized.
499        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
500        #[unsafe(method(optimizeContentsForCPUAccess:slice:level:))]
501        #[unsafe(method_family = none)]
502        unsafe fn optimizeContentsForCPUAccess_slice_level(
503            &self,
504            texture: &ProtocolObject<dyn MTLTexture>,
505            slice: NSUInteger,
506            level: NSUInteger,
507        );
508
509        #[cfg(all(
510            feature = "MTLAllocation",
511            feature = "MTLIndirectCommandBuffer",
512            feature = "MTLResource"
513        ))]
514        /// reset commands in a indirect command buffer using the GPU
515        ///
516        /// # Safety
517        ///
518        /// - `buffer` may need to be synchronized.
519        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
520        /// - `range` might not be bounds-checked.
521        #[unsafe(method(resetCommandsInBuffer:withRange:))]
522        #[unsafe(method_family = none)]
523        unsafe fn resetCommandsInBuffer_withRange(
524            &self,
525            buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
526            range: NSRange,
527        );
528
529        #[cfg(all(
530            feature = "MTLAllocation",
531            feature = "MTLIndirectCommandBuffer",
532            feature = "MTLResource"
533        ))]
534        /// copy a region of a buffer into a destination buffer starting at destinationIndex using the GPU
535        ///
536        /// # Safety
537        ///
538        /// - `source` may need to be synchronized.
539        /// - `source` may be unretained, you must ensure it is kept alive while in use.
540        /// - `sourceRange` might not be bounds-checked.
541        /// - `destination` may need to be synchronized.
542        /// - `destination` may be unretained, you must ensure it is kept alive while in use.
543        /// - `destinationIndex` might not be bounds-checked.
544        #[unsafe(method(copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:))]
545        #[unsafe(method_family = none)]
546        unsafe fn copyIndirectCommandBuffer_sourceRange_destination_destinationIndex(
547            &self,
548            source: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
549            source_range: NSRange,
550            destination: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
551            destination_index: NSUInteger,
552        );
553
554        #[cfg(all(
555            feature = "MTLAllocation",
556            feature = "MTLIndirectCommandBuffer",
557            feature = "MTLResource"
558        ))]
559        /// Encodes a command that can improve the performance of a range of commands within an indirect command buffer.
560        ///
561        /// # Safety
562        ///
563        /// - `indirect_command_buffer` may need to be synchronized.
564        /// - `indirect_command_buffer` may be unretained, you must ensure it is kept alive while in use.
565        /// - `range` might not be bounds-checked.
566        #[unsafe(method(optimizeIndirectCommandBuffer:withRange:))]
567        #[unsafe(method_family = none)]
568        unsafe fn optimizeIndirectCommandBuffer_withRange(
569            &self,
570            indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
571            range: NSRange,
572        );
573
574        #[cfg(feature = "MTLCounters")]
575        /// Sample hardware counters at this point in the blit encoder and
576        /// store the counter sample into the sample buffer at the specified index.
577        ///
578        /// Parameter `sampleBuffer`: The sample buffer to sample into
579        ///
580        /// Parameter `sampleIndex`: The index into the counter buffer to write the sample.
581        ///
582        /// Parameter `barrier`: Insert a barrier before taking the sample.  Passing
583        /// YES will ensure that all work encoded before this operation in the encoder is
584        /// complete but does not isolate the work with respect to other encoders.  Passing
585        /// NO will allow the sample to be taken concurrently with other operations in this
586        /// encoder.
587        /// In general, passing YES will lead to more repeatable counter results but
588        /// may negatively impact performance.  Passing NO will generally be higher performance
589        /// but counter results may not be repeatable.
590        ///
591        /// On devices where MTLCounterSamplingPointAtBlitBoundary is unsupported,
592        /// this method is not available and will generate an error if called.
593        ///
594        /// # Safety
595        ///
596        /// `sampleIndex` might not be bounds-checked.
597        #[unsafe(method(sampleCountersInBuffer:atSampleIndex:withBarrier:))]
598        #[unsafe(method_family = none)]
599        unsafe fn sampleCountersInBuffer_atSampleIndex_withBarrier(
600            &self,
601            sample_buffer: &ProtocolObject<dyn MTLCounterSampleBuffer>,
602            sample_index: NSUInteger,
603            barrier: bool,
604        );
605
606        #[cfg(all(
607            feature = "MTLAllocation",
608            feature = "MTLBuffer",
609            feature = "MTLCounters",
610            feature = "MTLResource"
611        ))]
612        /// Parameter `sampleBuffer`: The sample buffer to resolve.
613        ///
614        /// Parameter `range`: The range of indices to resolve.
615        ///
616        /// Parameter `destinationBuffer`: The buffer to resolve values into.
617        ///
618        /// Parameter `destinationOffset`: The offset to begin writing values out to.  This must be a multiple of
619        /// the minimum constant buffer alignment.
620        ///
621        /// Resolve the counters from the raw buffer to a processed buffer.
622        ///
623        /// Samples that encountered an error during resolve will be set to
624        /// MTLCounterErrorValue.
625        ///
626        /// # Safety
627        ///
628        /// - `range` might not be bounds-checked.
629        /// - `destination_buffer` may need to be synchronized.
630        /// - `destination_buffer` may be unretained, you must ensure it is kept alive while in use.
631        /// - `destination_buffer` contents should be of the correct type.
632        /// - `destinationOffset` might not be bounds-checked.
633        #[unsafe(method(resolveCounters:inRange:destinationBuffer:destinationOffset:))]
634        #[unsafe(method_family = none)]
635        unsafe fn resolveCounters_inRange_destinationBuffer_destinationOffset(
636            &self,
637            sample_buffer: &ProtocolObject<dyn MTLCounterSampleBuffer>,
638            range: NSRange,
639            destination_buffer: &ProtocolObject<dyn MTLBuffer>,
640            destination_offset: NSUInteger,
641        );
642
643        #[cfg(all(
644            feature = "MTLAllocation",
645            feature = "MTLResource",
646            feature = "MTLTensor"
647        ))]
648        /// Encodes a command to copy data from a slice of one tensor into a slice of another tensor.
649        ///
650        /// This command applies reshapes if `sourceTensor` and `destinationTensor` are not aliasable.
651        /// - Parameters:
652        /// - sourceTensor: A tensor instance that this command copies data from.
653        /// - sourceOrigin: An array of offsets, in elements, to the first element of the slice of `sourceTensor` that this command copies data from.
654        /// - sourceDimensions: An array of sizes, in elements, of the slice `sourceTensor` that this command copies data from.
655        /// - destinationTensor: A tensor instance that this command copies data to.
656        /// - destinationOrigin: An array of offsets, in elements, to the first element of the slice of `destinationTensor` that this command copies data to.
657        /// - destinationDimensions: An array of sizes, in elements, of the slice of `destinationTensor` that this command copies data to.
658        ///
659        /// # Safety
660        ///
661        /// - `source_tensor` may need to be synchronized.
662        /// - `source_tensor` may be unretained, you must ensure it is kept alive while in use.
663        /// - `destination_tensor` may need to be synchronized.
664        /// - `destination_tensor` may be unretained, you must ensure it is kept alive while in use.
665        #[unsafe(method(copyFromTensor:sourceOrigin:sourceDimensions:toTensor:destinationOrigin:destinationDimensions:))]
666        #[unsafe(method_family = none)]
667        unsafe fn copyFromTensor_sourceOrigin_sourceDimensions_toTensor_destinationOrigin_destinationDimensions(
668            &self,
669            source_tensor: &ProtocolObject<dyn MTLTensor>,
670            source_origin: &MTLTensorExtents,
671            source_dimensions: &MTLTensorExtents,
672            destination_tensor: &ProtocolObject<dyn MTLTensor>,
673            destination_origin: &MTLTensorExtents,
674            destination_dimensions: &MTLTensorExtents,
675        );
676    }
677);