objc2_metal/generated/
MTLComputeCommandEncoder.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/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtldispatchthreadgroupsindirectarguments?language=objc)
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq)]
13pub struct MTLDispatchThreadgroupsIndirectArguments {
14    pub threadgroupsPerGrid: [u32; 3],
15}
16
17unsafe impl Encode for MTLDispatchThreadgroupsIndirectArguments {
18    const ENCODING: Encoding = Encoding::Struct("?", &[<[u32; 3]>::ENCODING]);
19}
20
21unsafe impl RefEncode for MTLDispatchThreadgroupsIndirectArguments {
22    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
23}
24
25/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtldispatchthreadsindirectarguments?language=objc)
26#[repr(C)]
27#[derive(Clone, Copy, Debug, PartialEq)]
28pub struct MTLDispatchThreadsIndirectArguments {
29    pub threadsPerGrid: [u32; 3],
30    pub threadsPerThreadgroup: [u32; 3],
31}
32
33unsafe impl Encode for MTLDispatchThreadsIndirectArguments {
34    const ENCODING: Encoding = Encoding::Struct("?", &[<[u32; 3]>::ENCODING, <[u32; 3]>::ENCODING]);
35}
36
37unsafe impl RefEncode for MTLDispatchThreadsIndirectArguments {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstageinregionindirectarguments?language=objc)
42#[repr(C)]
43#[derive(Clone, Copy, Debug, PartialEq)]
44pub struct MTLStageInRegionIndirectArguments {
45    pub stageInOrigin: [u32; 3],
46    pub stageInSize: [u32; 3],
47}
48
49unsafe impl Encode for MTLStageInRegionIndirectArguments {
50    const ENCODING: Encoding = Encoding::Struct("?", &[<[u32; 3]>::ENCODING, <[u32; 3]>::ENCODING]);
51}
52
53unsafe impl RefEncode for MTLStageInRegionIndirectArguments {
54    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
55}
56
57extern_protocol!(
58    /// A command encoder that writes data parallel compute commands.
59    ///
60    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcomputecommandencoder?language=objc)
61    #[cfg(feature = "MTLCommandEncoder")]
62    pub unsafe trait MTLComputeCommandEncoder: MTLCommandEncoder {
63        #[cfg(feature = "MTLCommandBuffer")]
64        /// The dispatch type of the compute command encoder.
65        #[unsafe(method(dispatchType))]
66        #[unsafe(method_family = none)]
67        fn dispatchType(&self) -> MTLDispatchType;
68
69        #[cfg(all(feature = "MTLAllocation", feature = "MTLComputePipeline"))]
70        /// Set the compute pipeline state that will be used.
71        #[unsafe(method(setComputePipelineState:))]
72        #[unsafe(method_family = none)]
73        fn setComputePipelineState(&self, state: &ProtocolObject<dyn MTLComputePipelineState>);
74
75        /// Set the data (by copy) for a given buffer binding point.  This will remove any existing MTLBuffer from the binding point.
76        ///
77        /// # Safety
78        ///
79        /// - `bytes` must be a valid pointer.
80        /// - `index` might not be bounds-checked.
81        #[unsafe(method(setBytes:length:atIndex:))]
82        #[unsafe(method_family = none)]
83        unsafe fn setBytes_length_atIndex(
84            &self,
85            bytes: NonNull<c_void>,
86            length: NSUInteger,
87            index: NSUInteger,
88        );
89
90        #[cfg(all(
91            feature = "MTLAllocation",
92            feature = "MTLBuffer",
93            feature = "MTLResource"
94        ))]
95        /// Set a global buffer for all compute kernels at the given bind point index.
96        ///
97        /// # Safety
98        ///
99        /// - `buffer` may need to be synchronized.
100        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
101        /// - `buffer` contents should be of the correct type.
102        /// - `offset` might not be bounds-checked.
103        /// - `index` might not be bounds-checked.
104        #[unsafe(method(setBuffer:offset:atIndex:))]
105        #[unsafe(method_family = none)]
106        unsafe fn setBuffer_offset_atIndex(
107            &self,
108            buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
109            offset: NSUInteger,
110            index: NSUInteger,
111        );
112
113        /// Set the offset within the current global buffer for all compute kernels at the given bind point index.
114        ///
115        /// # Safety
116        ///
117        /// - `offset` might not be bounds-checked.
118        /// - `index` might not be bounds-checked.
119        #[unsafe(method(setBufferOffset:atIndex:))]
120        #[unsafe(method_family = none)]
121        unsafe fn setBufferOffset_atIndex(&self, offset: NSUInteger, index: NSUInteger);
122
123        #[cfg(all(
124            feature = "MTLAllocation",
125            feature = "MTLBuffer",
126            feature = "MTLResource"
127        ))]
128        /// Set an array of global buffers for all compute kernels with the given bind point range.
129        ///
130        /// # Safety
131        ///
132        /// - `buffers` must be a valid pointer.
133        /// - `offsets` might not be bounds-checked.
134        /// - `offsets` must be a valid pointer.
135        /// - `range` might not be bounds-checked.
136        #[unsafe(method(setBuffers:offsets:withRange:))]
137        #[unsafe(method_family = none)]
138        unsafe fn setBuffers_offsets_withRange(
139            &self,
140            buffers: NonNull<*const ProtocolObject<dyn MTLBuffer>>,
141            offsets: NonNull<NSUInteger>,
142            range: NSRange,
143        );
144
145        #[cfg(all(
146            feature = "MTLAllocation",
147            feature = "MTLBuffer",
148            feature = "MTLResource"
149        ))]
150        /// sets kernel buffer at specified index with provided offset and stride.
151        /// only call this when the kernel-buffer is part of the stageInputDescriptor
152        /// and has set its stride to `MTLBufferLayoutStrideDynamic`
153        ///
154        /// # Safety
155        ///
156        /// - `buffer` may need to be synchronized.
157        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
158        /// - `buffer` contents should be of the correct type.
159        /// - `offset` might not be bounds-checked.
160        /// - `stride` might not be bounds-checked.
161        /// - `index` might not be bounds-checked.
162        #[unsafe(method(setBuffer:offset:attributeStride:atIndex:))]
163        #[unsafe(method_family = none)]
164        unsafe fn setBuffer_offset_attributeStride_atIndex(
165            &self,
166            buffer: &ProtocolObject<dyn MTLBuffer>,
167            offset: NSUInteger,
168            stride: NSUInteger,
169            index: NSUInteger,
170        );
171
172        #[cfg(all(
173            feature = "MTLAllocation",
174            feature = "MTLBuffer",
175            feature = "MTLResource"
176        ))]
177        /// sets an array of kernel buffers with provided offsets and strides with the
178        /// given bind point range. Only call this when at least one buffer is part of
179        /// the vertexDescriptor, other buffers must set `MTLAttributeStrideStatic`
180        ///
181        /// # Safety
182        ///
183        /// - `buffers` must be a valid pointer.
184        /// - `offsets` might not be bounds-checked.
185        /// - `offsets` must be a valid pointer.
186        /// - `strides` might not be bounds-checked.
187        /// - `strides` must be a valid pointer.
188        /// - `range` might not be bounds-checked.
189        #[unsafe(method(setBuffers:offsets:attributeStrides:withRange:))]
190        #[unsafe(method_family = none)]
191        unsafe fn setBuffers_offsets_attributeStrides_withRange(
192            &self,
193            buffers: NonNull<*const ProtocolObject<dyn MTLBuffer>>,
194            offsets: NonNull<NSUInteger>,
195            strides: NonNull<NSUInteger>,
196            range: NSRange,
197        );
198
199        /// only call this when the buffer-index is part of the stageInputDescriptor
200        /// and has set its stride to `MTLBufferLayoutStrideDynamic`
201        ///
202        /// # Safety
203        ///
204        /// - `offset` might not be bounds-checked.
205        /// - `stride` might not be bounds-checked.
206        /// - `index` might not be bounds-checked.
207        #[unsafe(method(setBufferOffset:attributeStride:atIndex:))]
208        #[unsafe(method_family = none)]
209        unsafe fn setBufferOffset_attributeStride_atIndex(
210            &self,
211            offset: NSUInteger,
212            stride: NSUInteger,
213            index: NSUInteger,
214        );
215
216        /// only call this when the buffer-index is part of the stageInputDescriptor
217        /// and has set its stride to `MTLBufferLayoutStrideDynamic`
218        ///
219        /// # Safety
220        ///
221        /// - `bytes` must be a valid pointer.
222        /// - `stride` might not be bounds-checked.
223        /// - `index` might not be bounds-checked.
224        #[unsafe(method(setBytes:length:attributeStride:atIndex:))]
225        #[unsafe(method_family = none)]
226        unsafe fn setBytes_length_attributeStride_atIndex(
227            &self,
228            bytes: NonNull<c_void>,
229            length: NSUInteger,
230            stride: NSUInteger,
231            index: NSUInteger,
232        );
233
234        #[cfg(all(
235            feature = "MTLAllocation",
236            feature = "MTLResource",
237            feature = "MTLVisibleFunctionTable"
238        ))]
239        /// Set a visible function table at the given buffer index
240        ///
241        /// # Safety
242        ///
243        /// - `visible_function_table` may need to be synchronized.
244        /// - `visible_function_table` may be unretained, you must ensure it is kept alive while in use.
245        /// - `bufferIndex` might not be bounds-checked.
246        #[unsafe(method(setVisibleFunctionTable:atBufferIndex:))]
247        #[unsafe(method_family = none)]
248        unsafe fn setVisibleFunctionTable_atBufferIndex(
249            &self,
250            visible_function_table: Option<&ProtocolObject<dyn MTLVisibleFunctionTable>>,
251            buffer_index: NSUInteger,
252        );
253
254        #[cfg(all(
255            feature = "MTLAllocation",
256            feature = "MTLResource",
257            feature = "MTLVisibleFunctionTable"
258        ))]
259        /// Set visible function tables at the given buffer index range
260        ///
261        /// # Safety
262        ///
263        /// - `visible_function_tables` must be a valid pointer.
264        /// - `range` might not be bounds-checked.
265        #[unsafe(method(setVisibleFunctionTables:withBufferRange:))]
266        #[unsafe(method_family = none)]
267        unsafe fn setVisibleFunctionTables_withBufferRange(
268            &self,
269            visible_function_tables: NonNull<*const ProtocolObject<dyn MTLVisibleFunctionTable>>,
270            range: NSRange,
271        );
272
273        #[cfg(all(
274            feature = "MTLAllocation",
275            feature = "MTLIntersectionFunctionTable",
276            feature = "MTLResource"
277        ))]
278        /// Set a visible function table at the given buffer index
279        ///
280        /// # Safety
281        ///
282        /// - `intersection_function_table` may need to be synchronized.
283        /// - `intersection_function_table` may be unretained, you must ensure it is kept alive while in use.
284        /// - `bufferIndex` might not be bounds-checked.
285        #[unsafe(method(setIntersectionFunctionTable:atBufferIndex:))]
286        #[unsafe(method_family = none)]
287        unsafe fn setIntersectionFunctionTable_atBufferIndex(
288            &self,
289            intersection_function_table: Option<&ProtocolObject<dyn MTLIntersectionFunctionTable>>,
290            buffer_index: NSUInteger,
291        );
292
293        #[cfg(all(
294            feature = "MTLAllocation",
295            feature = "MTLIntersectionFunctionTable",
296            feature = "MTLResource"
297        ))]
298        /// Set visible function tables at the given buffer index range
299        ///
300        /// # Safety
301        ///
302        /// - `intersection_function_tables` must be a valid pointer.
303        /// - `range` might not be bounds-checked.
304        #[unsafe(method(setIntersectionFunctionTables:withBufferRange:))]
305        #[unsafe(method_family = none)]
306        unsafe fn setIntersectionFunctionTables_withBufferRange(
307            &self,
308            intersection_function_tables: NonNull<
309                *const ProtocolObject<dyn MTLIntersectionFunctionTable>,
310            >,
311            range: NSRange,
312        );
313
314        #[cfg(all(
315            feature = "MTLAccelerationStructure",
316            feature = "MTLAllocation",
317            feature = "MTLResource"
318        ))]
319        /// Set a global raytracing acceleration structure for all compute kernels at the given buffer bind point index.
320        ///
321        /// # Safety
322        ///
323        /// - `acceleration_structure` may need to be synchronized.
324        /// - `acceleration_structure` may be unretained, you must ensure it is kept alive while in use.
325        /// - `bufferIndex` might not be bounds-checked.
326        #[unsafe(method(setAccelerationStructure:atBufferIndex:))]
327        #[unsafe(method_family = none)]
328        unsafe fn setAccelerationStructure_atBufferIndex(
329            &self,
330            acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
331            buffer_index: NSUInteger,
332        );
333
334        #[cfg(all(
335            feature = "MTLAllocation",
336            feature = "MTLResource",
337            feature = "MTLTexture"
338        ))]
339        /// Set a global texture for all compute kernels at the given bind point index.
340        ///
341        /// # Safety
342        ///
343        /// - `texture` may need to be synchronized.
344        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
345        /// - `index` might not be bounds-checked.
346        #[unsafe(method(setTexture:atIndex:))]
347        #[unsafe(method_family = none)]
348        unsafe fn setTexture_atIndex(
349            &self,
350            texture: Option<&ProtocolObject<dyn MTLTexture>>,
351            index: NSUInteger,
352        );
353
354        #[cfg(all(
355            feature = "MTLAllocation",
356            feature = "MTLResource",
357            feature = "MTLTexture"
358        ))]
359        /// Set an array of global textures for all compute kernels with the given bind point range.
360        ///
361        /// # Safety
362        ///
363        /// - `textures` must be a valid pointer.
364        /// - `range` might not be bounds-checked.
365        #[unsafe(method(setTextures:withRange:))]
366        #[unsafe(method_family = none)]
367        unsafe fn setTextures_withRange(
368            &self,
369            textures: NonNull<*const ProtocolObject<dyn MTLTexture>>,
370            range: NSRange,
371        );
372
373        #[cfg(feature = "MTLSampler")]
374        /// Set a global sampler for all compute kernels at the given bind point index.
375        ///
376        /// # Safety
377        ///
378        /// `index` might not be bounds-checked.
379        #[unsafe(method(setSamplerState:atIndex:))]
380        #[unsafe(method_family = none)]
381        unsafe fn setSamplerState_atIndex(
382            &self,
383            sampler: Option<&ProtocolObject<dyn MTLSamplerState>>,
384            index: NSUInteger,
385        );
386
387        #[cfg(feature = "MTLSampler")]
388        /// Set an array of global samplers for all compute kernels with the given bind point range.
389        ///
390        /// # Safety
391        ///
392        /// - `samplers` must be a valid pointer.
393        /// - `range` might not be bounds-checked.
394        #[unsafe(method(setSamplerStates:withRange:))]
395        #[unsafe(method_family = none)]
396        unsafe fn setSamplerStates_withRange(
397            &self,
398            samplers: NonNull<*const ProtocolObject<dyn MTLSamplerState>>,
399            range: NSRange,
400        );
401
402        #[cfg(feature = "MTLSampler")]
403        /// Set a global sampler for all compute kernels at the given bind point index.
404        ///
405        /// # Safety
406        ///
407        /// `index` might not be bounds-checked.
408        #[unsafe(method(setSamplerState:lodMinClamp:lodMaxClamp:atIndex:))]
409        #[unsafe(method_family = none)]
410        unsafe fn setSamplerState_lodMinClamp_lodMaxClamp_atIndex(
411            &self,
412            sampler: Option<&ProtocolObject<dyn MTLSamplerState>>,
413            lod_min_clamp: c_float,
414            lod_max_clamp: c_float,
415            index: NSUInteger,
416        );
417
418        #[cfg(feature = "MTLSampler")]
419        /// Set an array of global samplers for all compute kernels with the given bind point range.
420        ///
421        /// # Safety
422        ///
423        /// - `samplers` must be a valid pointer.
424        /// - `lod_min_clamps` must be a valid pointer.
425        /// - `lod_max_clamps` must be a valid pointer.
426        /// - `range` might not be bounds-checked.
427        #[unsafe(method(setSamplerStates:lodMinClamps:lodMaxClamps:withRange:))]
428        #[unsafe(method_family = none)]
429        unsafe fn setSamplerStates_lodMinClamps_lodMaxClamps_withRange(
430            &self,
431            samplers: NonNull<*const ProtocolObject<dyn MTLSamplerState>>,
432            lod_min_clamps: NonNull<c_float>,
433            lod_max_clamps: NonNull<c_float>,
434            range: NSRange,
435        );
436
437        /// Set the threadgroup memory byte length at the binding point specified by the index. This applies to all compute kernels.
438        ///
439        /// # Safety
440        ///
441        /// `index` might not be bounds-checked.
442        #[unsafe(method(setThreadgroupMemoryLength:atIndex:))]
443        #[unsafe(method_family = none)]
444        unsafe fn setThreadgroupMemoryLength_atIndex(&self, length: NSUInteger, index: NSUInteger);
445
446        /// Set imageblock sizes.
447        #[unsafe(method(setImageblockWidth:height:))]
448        #[unsafe(method_family = none)]
449        fn setImageblockWidth_height(&self, width: NSUInteger, height: NSUInteger);
450
451        #[cfg(feature = "MTLTypes")]
452        #[unsafe(method(setStageInRegion:))]
453        #[unsafe(method_family = none)]
454        fn setStageInRegion(&self, region: MTLRegion);
455
456        #[cfg(all(
457            feature = "MTLAllocation",
458            feature = "MTLBuffer",
459            feature = "MTLResource"
460        ))]
461        /// # Safety
462        ///
463        /// - `indirect_buffer` may need to be synchronized.
464        /// - `indirect_buffer` may be unretained, you must ensure it is kept alive while in use.
465        /// - `indirect_buffer` contents should be of the correct type.
466        /// - `indirectBufferOffset` might not be bounds-checked.
467        #[unsafe(method(setStageInRegionWithIndirectBuffer:indirectBufferOffset:))]
468        #[unsafe(method_family = none)]
469        unsafe fn setStageInRegionWithIndirectBuffer_indirectBufferOffset(
470            &self,
471            indirect_buffer: &ProtocolObject<dyn MTLBuffer>,
472            indirect_buffer_offset: NSUInteger,
473        );
474
475        #[cfg(feature = "MTLTypes")]
476        #[unsafe(method(dispatchThreadgroups:threadsPerThreadgroup:))]
477        #[unsafe(method_family = none)]
478        fn dispatchThreadgroups_threadsPerThreadgroup(
479            &self,
480            threadgroups_per_grid: MTLSize,
481            threads_per_threadgroup: MTLSize,
482        );
483
484        #[cfg(all(
485            feature = "MTLAllocation",
486            feature = "MTLBuffer",
487            feature = "MTLResource",
488            feature = "MTLTypes"
489        ))]
490        /// # Safety
491        ///
492        /// - `indirect_buffer` may need to be synchronized.
493        /// - `indirect_buffer` may be unretained, you must ensure it is kept alive while in use.
494        /// - `indirect_buffer` contents should be of the correct type.
495        /// - `indirectBufferOffset` might not be bounds-checked.
496        #[unsafe(method(dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:))]
497        #[unsafe(method_family = none)]
498        unsafe fn dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup(
499            &self,
500            indirect_buffer: &ProtocolObject<dyn MTLBuffer>,
501            indirect_buffer_offset: NSUInteger,
502            threads_per_threadgroup: MTLSize,
503        );
504
505        #[cfg(feature = "MTLTypes")]
506        #[unsafe(method(dispatchThreads:threadsPerThreadgroup:))]
507        #[unsafe(method_family = none)]
508        fn dispatchThreads_threadsPerThreadgroup(
509            &self,
510            threads_per_grid: MTLSize,
511            threads_per_threadgroup: MTLSize,
512        );
513
514        #[cfg(feature = "MTLFence")]
515        /// Update the fence to capture all GPU work so far enqueued by this encoder.
516        ///
517        /// The fence is updated at kernel submission to maintain global order and prevent deadlock.
518        /// 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.
519        #[unsafe(method(updateFence:))]
520        #[unsafe(method_family = none)]
521        fn updateFence(&self, fence: &ProtocolObject<dyn MTLFence>);
522
523        #[cfg(feature = "MTLFence")]
524        /// Prevent further GPU work until the fence is reached.
525        ///
526        /// The fence is evaluated at kernel submission to maintain global order and prevent deadlock.
527        /// 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.
528        #[unsafe(method(waitForFence:))]
529        #[unsafe(method_family = none)]
530        fn waitForFence(&self, fence: &ProtocolObject<dyn MTLFence>);
531
532        #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
533        /// Declare that a resource may be accessed by the command encoder through an argument buffer
534        ///
535        ///
536        /// For tracked MTLResources, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resource through an argument buffer.
537        ///
538        /// Warning: Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
539        #[unsafe(method(useResource:usage:))]
540        #[unsafe(method_family = none)]
541        fn useResource_usage(
542            &self,
543            resource: &ProtocolObject<dyn MTLResource>,
544            usage: MTLResourceUsage,
545        );
546
547        #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
548        /// Declare that an array of resources may be accessed through an argument buffer by the command encoder
549        ///
550        /// For tracked MTL Resources, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources through an argument buffer.
551        ///
552        /// Warning: Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
553        ///
554        /// # Safety
555        ///
556        /// - `resources` must be a valid pointer.
557        /// - `count` might not be bounds-checked.
558        #[unsafe(method(useResources:count:usage:))]
559        #[unsafe(method_family = none)]
560        unsafe fn useResources_count_usage(
561            &self,
562            resources: NonNull<NonNull<ProtocolObject<dyn MTLResource>>>,
563            count: NSUInteger,
564            usage: MTLResourceUsage,
565        );
566
567        #[cfg(all(feature = "MTLAllocation", feature = "MTLHeap"))]
568        /// Declare that the resources allocated from a heap may be accessed as readonly by the render pass through an argument buffer
569        ///
570        /// For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources allocated from the heap through an argument buffer. This method may cause all of the color attachments allocated from the heap to become decompressed. Therefore, it is recommended that the useResource:usage: or useResources:count:usage: methods be used for color attachments instead, with a minimal (i.e. read-only) usage.
571        ///
572        /// Warning: Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
573        #[unsafe(method(useHeap:))]
574        #[unsafe(method_family = none)]
575        fn useHeap(&self, heap: &ProtocolObject<dyn MTLHeap>);
576
577        #[cfg(all(feature = "MTLAllocation", feature = "MTLHeap"))]
578        /// Declare that the resources allocated from an array of heaps may be accessed as readonly by the render pass through an argument buffer
579        ///
580        /// For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources allocated from the heaps through an argument buffer. This method may cause all of the color attachments allocated from the heaps to become decompressed. Therefore, it is recommended that the useResource:usage: or useResources:count:usage: methods be used for color attachments instead, with a minimal (i.e. read-only) usage.
581        ///
582        /// Warning: Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
583        ///
584        /// # Safety
585        ///
586        /// - `heaps` must be a valid pointer.
587        /// - `count` might not be bounds-checked.
588        #[unsafe(method(useHeaps:count:))]
589        #[unsafe(method_family = none)]
590        unsafe fn useHeaps_count(
591            &self,
592            heaps: NonNull<NonNull<ProtocolObject<dyn MTLHeap>>>,
593            count: NSUInteger,
594        );
595
596        #[cfg(all(
597            feature = "MTLAllocation",
598            feature = "MTLIndirectCommandBuffer",
599            feature = "MTLResource"
600        ))]
601        /// Execute commands in the buffer within the range specified.
602        ///
603        /// The same indirect command buffer may be executed any number of times within the same encoder.
604        ///
605        /// # Safety
606        ///
607        /// - `indirect_command_buffer` may need to be synchronized.
608        /// - `indirect_command_buffer` may be unretained, you must ensure it is kept alive while in use.
609        /// - `executionRange` might not be bounds-checked.
610        #[unsafe(method(executeCommandsInBuffer:withRange:))]
611        #[unsafe(method_family = none)]
612        unsafe fn executeCommandsInBuffer_withRange(
613            &self,
614            indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
615            execution_range: NSRange,
616        );
617
618        #[cfg(all(
619            feature = "MTLAllocation",
620            feature = "MTLBuffer",
621            feature = "MTLIndirectCommandBuffer",
622            feature = "MTLResource"
623        ))]
624        /// Execute commands in the buffer within the range specified by the indirect range buffer.
625        ///
626        /// Parameter `indirectRangeBuffer`: An indirect buffer from which the device reads the execution range parameter, as laid out in the MTLIndirectCommandBufferExecutionRange structure.
627        ///
628        /// Parameter `indirectBufferOffset`: The byte offset within indirectBuffer where the execution range parameter is located. Must be a multiple of 4 bytes.
629        ///
630        /// The same indirect command buffer may be executed any number of times within the same encoder.
631        ///
632        /// # Safety
633        ///
634        /// - `indirect_commandbuffer` may need to be synchronized.
635        /// - `indirect_commandbuffer` may be unretained, you must ensure it is kept alive while in use.
636        /// - `indirect_range_buffer` may need to be synchronized.
637        /// - `indirect_range_buffer` may be unretained, you must ensure it is kept alive while in use.
638        /// - `indirect_range_buffer` contents should be of the correct type.
639        /// - `indirectBufferOffset` might not be bounds-checked.
640        #[unsafe(method(executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:))]
641        #[unsafe(method_family = none)]
642        unsafe fn executeCommandsInBuffer_indirectBuffer_indirectBufferOffset(
643            &self,
644            indirect_commandbuffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
645            indirect_range_buffer: &ProtocolObject<dyn MTLBuffer>,
646            indirect_buffer_offset: NSUInteger,
647        );
648
649        /// Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on a specified resource group
650        ///
651        /// This API ensures that all dispatches in the encoder have completed execution and their side effects are visible to subsequent dispatches in that encoder. Calling barrier on a serial encoder is allowed, but ignored.
652        #[unsafe(method(memoryBarrierWithScope:))]
653        #[unsafe(method_family = none)]
654        fn memoryBarrierWithScope(&self, scope: MTLBarrierScope);
655
656        #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
657        /// Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on an array of resources.
658        ///
659        /// This API ensures that all dispatches in the encoder have completed execution and side effects on the specified resources are visible to subsequent dispatches in that encoder. Calling barrier on a serial encoder is allowed, but ignored.
660        ///
661        /// # Safety
662        ///
663        /// - `resources` must be a valid pointer.
664        /// - `count` might not be bounds-checked.
665        #[unsafe(method(memoryBarrierWithResources:count:))]
666        #[unsafe(method_family = none)]
667        unsafe fn memoryBarrierWithResources_count(
668            &self,
669            resources: NonNull<NonNull<ProtocolObject<dyn MTLResource>>>,
670            count: NSUInteger,
671        );
672
673        #[cfg(feature = "MTLCounters")]
674        /// Sample hardware counters at this point in the compute encoder and
675        /// store the counter sample into the sample buffer at the specified index.
676        ///
677        /// Parameter `sampleBuffer`: The sample buffer to sample into
678        ///
679        /// Parameter `sampleIndex`: The index into the counter buffer to write the sample
680        ///
681        /// Parameter `barrier`: Insert a barrier before taking the sample.  Passing
682        /// YES will ensure that all work encoded before this operation in the encoder is
683        /// complete but does not isolate the work with respect to other encoders.  Passing
684        /// NO will allow the sample to be taken concurrently with other operations in this
685        /// encoder.
686        /// In general, passing YES will lead to more repeatable counter results but
687        /// may negatively impact performance.  Passing NO will generally be higher performance
688        /// but counter results may not be repeatable.
689        ///
690        /// On devices where MTLCounterSamplingPointAtDispatchBoundary is unsupported,
691        /// this method is not available and will generate an error if called.
692        ///
693        /// # Safety
694        ///
695        /// `sampleIndex` might not be bounds-checked.
696        #[unsafe(method(sampleCountersInBuffer:atSampleIndex:withBarrier:))]
697        #[unsafe(method_family = none)]
698        unsafe fn sampleCountersInBuffer_atSampleIndex_withBarrier(
699            &self,
700            sample_buffer: &ProtocolObject<dyn MTLCounterSampleBuffer>,
701            sample_index: NSUInteger,
702            barrier: bool,
703        );
704    }
705);