objc2_metal/generated/
MTLCommandBuffer.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// MTLCommandBufferStatus reports the current stage in the lifetime of MTLCommandBuffer, as it proceeds to enqueued, committed, scheduled, and completed.
13///
14///
15/// The command buffer has not been enqueued yet.
16///
17///
18/// This command buffer is enqueued, but not committed.
19///
20///
21/// Commited to its command queue, but not yet scheduled for execution.
22///
23///
24/// All dependencies have been resolved and the command buffer has been scheduled for execution.
25///
26///
27/// The command buffer has finished executing successfully: any blocks set with -addCompletedHandler: may now be called.
28///
29///
30/// Execution of the command buffer was aborted due to an error during execution.  Check -error for more information.
31///
32/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbufferstatus?language=objc)
33// NS_ENUM
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct MTLCommandBufferStatus(pub NSUInteger);
37impl MTLCommandBufferStatus {
38    #[doc(alias = "MTLCommandBufferStatusNotEnqueued")]
39    pub const NotEnqueued: Self = Self(0);
40    #[doc(alias = "MTLCommandBufferStatusEnqueued")]
41    pub const Enqueued: Self = Self(1);
42    #[doc(alias = "MTLCommandBufferStatusCommitted")]
43    pub const Committed: Self = Self(2);
44    #[doc(alias = "MTLCommandBufferStatusScheduled")]
45    pub const Scheduled: Self = Self(3);
46    #[doc(alias = "MTLCommandBufferStatusCompleted")]
47    pub const Completed: Self = Self(4);
48    #[doc(alias = "MTLCommandBufferStatusError")]
49    pub const Error: Self = Self(5);
50}
51
52unsafe impl Encode for MTLCommandBufferStatus {
53    const ENCODING: Encoding = NSUInteger::ENCODING;
54}
55
56unsafe impl RefEncode for MTLCommandBufferStatus {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60extern "C" {
61    /// An error domain for NSError objects produced by MTLCommandBuffer
62    ///
63    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbuffererrordomain?language=objc)
64    pub static MTLCommandBufferErrorDomain: &'static NSErrorDomain;
65}
66
67/// Error codes that can be found in MTLCommandBuffer.error
68///
69///
70/// An internal error that doesn't fit into the other categories. The actual low level error code is encoded in the local description.
71///
72///
73/// Execution of this command buffer took too long, execution of this command was interrupted and aborted.
74///
75///
76/// Execution of this command buffer generated an unserviceable GPU page fault. This can caused by buffer read write attribute mismatch or out of boundary access.
77///
78///
79/// Access to this device has been revoked because this client has been responsible for too many timeouts or hangs.
80///
81///
82/// This process does not have access to use this device.
83///
84///
85/// Insufficient memory was available to execute this command buffer.
86///
87///
88/// The command buffer referenced an invalid resource.  This is most commonly caused when the caller deletes a resource before executing a command buffer that refers to it.
89///
90///
91/// One or more internal resources limits reached that prevent using memoryless render pass attachments. See error string for more detail.
92///
93///
94/// The device was physically removed before the command could finish execution
95///
96///
97/// Execution of the command buffer was stopped due to Stack Overflow Exception. [MTLComputePipelineDescriptor maxCallStackDepth] setting needs to be checked.
98///
99/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbuffererror?language=objc)
100// NS_ENUM
101#[repr(transparent)]
102#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
103pub struct MTLCommandBufferError(pub NSUInteger);
104impl MTLCommandBufferError {
105    #[doc(alias = "MTLCommandBufferErrorNone")]
106    pub const None: Self = Self(0);
107    #[doc(alias = "MTLCommandBufferErrorInternal")]
108    pub const Internal: Self = Self(1);
109    #[doc(alias = "MTLCommandBufferErrorTimeout")]
110    pub const Timeout: Self = Self(2);
111    #[doc(alias = "MTLCommandBufferErrorPageFault")]
112    pub const PageFault: Self = Self(3);
113    #[doc(alias = "MTLCommandBufferErrorBlacklisted")]
114    #[deprecated]
115    pub const Blacklisted: Self = Self(4);
116    #[doc(alias = "MTLCommandBufferErrorAccessRevoked")]
117    pub const AccessRevoked: Self = Self(4);
118    #[doc(alias = "MTLCommandBufferErrorNotPermitted")]
119    pub const NotPermitted: Self = Self(7);
120    #[doc(alias = "MTLCommandBufferErrorOutOfMemory")]
121    pub const OutOfMemory: Self = Self(8);
122    #[doc(alias = "MTLCommandBufferErrorInvalidResource")]
123    pub const InvalidResource: Self = Self(9);
124    #[doc(alias = "MTLCommandBufferErrorMemoryless")]
125    pub const Memoryless: Self = Self(10);
126    #[doc(alias = "MTLCommandBufferErrorDeviceRemoved")]
127    pub const DeviceRemoved: Self = Self(11);
128    #[doc(alias = "MTLCommandBufferErrorStackOverflow")]
129    pub const StackOverflow: Self = Self(12);
130}
131
132unsafe impl Encode for MTLCommandBufferError {
133    const ENCODING: Encoding = NSUInteger::ENCODING;
134}
135
136unsafe impl RefEncode for MTLCommandBufferError {
137    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
138}
139
140extern "C" {
141    /// Key in the userInfo for MTLCommandBufferError NSErrors. Value is an NSArray of MTLCommandBufferEncoderInfo objects in recorded order if an appropriate MTLCommandBufferErrorOption was set, otherwise the key will not exist in the userInfo dictionary.
142    ///
143    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbufferencoderinfoerrorkey?language=objc)
144    pub static MTLCommandBufferEncoderInfoErrorKey: &'static NSErrorUserInfoKey;
145}
146
147/// Options for controlling the error reporting for Metal command buffer objects.
148///
149///
150/// No special error reporting.
151///
152///
153/// Provide the execution status of the individual encoders within the command buffer. In the event of a command buffer error, populate the `userInfo` dictionary of the command buffer's NSError parameter, see MTLCommandBufferEncoderInfoErrorKey and MTLCommandBufferEncoderInfo. Note that enabling this error reporting option may increase CPU, GPU, and/or memory overhead on some platforms; testing for impact is suggested.
154///
155/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbuffererroroption?language=objc)
156// NS_OPTIONS
157#[repr(transparent)]
158#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
159pub struct MTLCommandBufferErrorOption(pub NSUInteger);
160bitflags::bitflags! {
161    impl MTLCommandBufferErrorOption: NSUInteger {
162        #[doc(alias = "MTLCommandBufferErrorOptionNone")]
163        const None = 0;
164        #[doc(alias = "MTLCommandBufferErrorOptionEncoderExecutionStatus")]
165        const EncoderExecutionStatus = 1<<0;
166    }
167}
168
169unsafe impl Encode for MTLCommandBufferErrorOption {
170    const ENCODING: Encoding = NSUInteger::ENCODING;
171}
172
173unsafe impl RefEncode for MTLCommandBufferErrorOption {
174    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
175}
176
177/// The error states for a Metal command encoder after command buffer execution.
178///
179///
180/// The state of the commands associated with the encoder is unknown (the error information was likely not requested).
181///
182///
183/// The commands associated with the encoder were completed.
184///
185///
186/// The commands associated with the encoder were affected by an error, which may or may not have been caused by the commands themselves, and failed to execute in full.
187///
188///
189/// The commands associated with the encoder never started execution.
190///
191///
192/// The commands associated with the encoder caused an error.
193///
194/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandencodererrorstate?language=objc)
195// NS_ENUM
196#[repr(transparent)]
197#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
198pub struct MTLCommandEncoderErrorState(pub NSInteger);
199impl MTLCommandEncoderErrorState {
200    #[doc(alias = "MTLCommandEncoderErrorStateUnknown")]
201    pub const Unknown: Self = Self(0);
202    #[doc(alias = "MTLCommandEncoderErrorStateCompleted")]
203    pub const Completed: Self = Self(1);
204    #[doc(alias = "MTLCommandEncoderErrorStateAffected")]
205    pub const Affected: Self = Self(2);
206    #[doc(alias = "MTLCommandEncoderErrorStatePending")]
207    pub const Pending: Self = Self(3);
208    #[doc(alias = "MTLCommandEncoderErrorStateFaulted")]
209    pub const Faulted: Self = Self(4);
210}
211
212unsafe impl Encode for MTLCommandEncoderErrorState {
213    const ENCODING: Encoding = NSInteger::ENCODING;
214}
215
216unsafe impl RefEncode for MTLCommandEncoderErrorState {
217    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
218}
219
220extern_class!(
221    /// An object that you use to configure new Metal command buffer objects.
222    ///
223    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbufferdescriptor?language=objc)
224    #[unsafe(super(NSObject))]
225    #[derive(Debug, PartialEq, Eq, Hash)]
226    pub struct MTLCommandBufferDescriptor;
227);
228
229extern_conformance!(
230    unsafe impl NSCopying for MTLCommandBufferDescriptor {}
231);
232
233unsafe impl CopyingHelper for MTLCommandBufferDescriptor {
234    type Result = Self;
235}
236
237extern_conformance!(
238    unsafe impl NSObjectProtocol for MTLCommandBufferDescriptor {}
239);
240
241impl MTLCommandBufferDescriptor {
242    extern_methods!(
243        /// If YES, the created command buffer holds strong references to objects needed for it to execute. If NO, the created command buffer does not hold strong references to objects needed for it to execute.
244        #[unsafe(method(retainedReferences))]
245        #[unsafe(method_family = none)]
246        pub fn retainedReferences(&self) -> bool;
247
248        /// Setter for [`retainedReferences`][Self::retainedReferences].
249        #[unsafe(method(setRetainedReferences:))]
250        #[unsafe(method_family = none)]
251        pub fn setRetainedReferences(&self, retained_references: bool);
252
253        /// A set of options to influence the error reporting of the created command buffer. See MTLCommandBufferErrorOption.
254        #[unsafe(method(errorOptions))]
255        #[unsafe(method_family = none)]
256        pub fn errorOptions(&self) -> MTLCommandBufferErrorOption;
257
258        /// Setter for [`errorOptions`][Self::errorOptions].
259        #[unsafe(method(setErrorOptions:))]
260        #[unsafe(method_family = none)]
261        pub fn setErrorOptions(&self, error_options: MTLCommandBufferErrorOption);
262
263        #[cfg(feature = "MTLLogState")]
264        /// Contains information related to shader logging.
265        #[unsafe(method(logState))]
266        #[unsafe(method_family = none)]
267        pub fn logState(&self) -> Option<Retained<ProtocolObject<dyn MTLLogState>>>;
268
269        #[cfg(feature = "MTLLogState")]
270        /// Setter for [`logState`][Self::logState].
271        #[unsafe(method(setLogState:))]
272        #[unsafe(method_family = none)]
273        pub fn setLogState(&self, log_state: Option<&ProtocolObject<dyn MTLLogState>>);
274    );
275}
276
277/// Methods declared on superclass `NSObject`.
278impl MTLCommandBufferDescriptor {
279    extern_methods!(
280        #[unsafe(method(init))]
281        #[unsafe(method_family = init)]
282        pub fn init(this: Allocated<Self>) -> Retained<Self>;
283
284        #[unsafe(method(new))]
285        #[unsafe(method_family = new)]
286        pub fn new() -> Retained<Self>;
287    );
288}
289
290impl DefaultRetained for MTLCommandBufferDescriptor {
291    #[inline]
292    fn default_retained() -> Retained<Self> {
293        Self::new()
294    }
295}
296
297extern_protocol!(
298    /// Provides execution status information for a Metal command encoder.
299    ///
300    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbufferencoderinfo?language=objc)
301    pub unsafe trait MTLCommandBufferEncoderInfo: NSObjectProtocol {
302        /// The debug label given to the associated Metal command encoder at command buffer submission.
303        #[unsafe(method(label))]
304        #[unsafe(method_family = none)]
305        fn label(&self) -> Retained<NSString>;
306
307        /// The debug signposts inserted into the associated Metal command encoder.
308        #[unsafe(method(debugSignposts))]
309        #[unsafe(method_family = none)]
310        fn debugSignposts(&self) -> Retained<NSArray<NSString>>;
311
312        /// The error state of the associated Metal command encoder.
313        #[unsafe(method(errorState))]
314        #[unsafe(method_family = none)]
315        fn errorState(&self) -> MTLCommandEncoderErrorState;
316    }
317);
318
319/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbufferhandler?language=objc)
320#[cfg(feature = "block2")]
321pub type MTLCommandBufferHandler =
322    *mut block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn MTLCommandBuffer>>)>;
323
324/// MTLDispatchType Describes how a command encoder will execute dispatched work.
325///
326///
327/// Command encoder dispatches are executed in dispatched order.
328///
329///
330/// Command encoder dispatches are executed in parallel with each other.
331///
332/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtldispatchtype?language=objc)
333// NS_ENUM
334#[repr(transparent)]
335#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
336pub struct MTLDispatchType(pub NSUInteger);
337impl MTLDispatchType {
338    #[doc(alias = "MTLDispatchTypeSerial")]
339    pub const Serial: Self = Self(0);
340    #[doc(alias = "MTLDispatchTypeConcurrent")]
341    pub const Concurrent: Self = Self(1);
342}
343
344unsafe impl Encode for MTLDispatchType {
345    const ENCODING: Encoding = NSUInteger::ENCODING;
346}
347
348unsafe impl RefEncode for MTLDispatchType {
349    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
350}
351
352extern_protocol!(
353    /// A serial list of commands for the device to execute.
354    ///
355    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcommandbuffer?language=objc)
356    pub unsafe trait MTLCommandBuffer: NSObjectProtocol {
357        #[cfg(feature = "MTLDevice")]
358        /// The device this resource was created against.
359        #[unsafe(method(device))]
360        #[unsafe(method_family = none)]
361        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
362
363        #[cfg(feature = "MTLCommandQueue")]
364        /// The command queue this command buffer was created from.
365        #[unsafe(method(commandQueue))]
366        #[unsafe(method_family = none)]
367        fn commandQueue(&self) -> Retained<ProtocolObject<dyn MTLCommandQueue>>;
368
369        /// If YES, this command buffer holds strong references to objects needed to execute this command buffer.
370        #[unsafe(method(retainedReferences))]
371        #[unsafe(method_family = none)]
372        fn retainedReferences(&self) -> bool;
373
374        /// The set of options configuring the error reporting of the created command buffer.
375        #[unsafe(method(errorOptions))]
376        #[unsafe(method_family = none)]
377        fn errorOptions(&self) -> MTLCommandBufferErrorOption;
378
379        /// A string to help identify this object.
380        #[unsafe(method(label))]
381        #[unsafe(method_family = none)]
382        fn label(&self) -> Option<Retained<NSString>>;
383
384        /// Setter for [`label`][Self::label].
385        ///
386        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
387        #[unsafe(method(setLabel:))]
388        #[unsafe(method_family = none)]
389        fn setLabel(&self, label: Option<&NSString>);
390
391        #[cfg(feature = "objc2-core-foundation")]
392        #[unsafe(method(kernelStartTime))]
393        #[unsafe(method_family = none)]
394        fn kernelStartTime(&self) -> CFTimeInterval;
395
396        #[cfg(feature = "objc2-core-foundation")]
397        #[unsafe(method(kernelEndTime))]
398        #[unsafe(method_family = none)]
399        fn kernelEndTime(&self) -> CFTimeInterval;
400
401        #[cfg(feature = "MTLFunctionLog")]
402        /// Logs generated by the command buffer during execution of the GPU commands. Valid after GPU execution is completed
403        #[unsafe(method(logs))]
404        #[unsafe(method_family = none)]
405        fn logs(&self) -> Retained<ProtocolObject<dyn MTLLogContainer>>;
406
407        #[cfg(feature = "objc2-core-foundation")]
408        /// The host time in seconds that GPU starts executing this command buffer. Returns zero if it has not started. This usually can be called in command buffer completion handler.
409        #[unsafe(method(GPUStartTime))]
410        #[unsafe(method_family = none)]
411        fn GPUStartTime(&self) -> CFTimeInterval;
412
413        #[cfg(feature = "objc2-core-foundation")]
414        /// The host time in seconds that GPU finishes executing this command buffer. Returns zero if CPU has not received completion notification. This usually can be called in command buffer completion handler.
415        #[unsafe(method(GPUEndTime))]
416        #[unsafe(method_family = none)]
417        fn GPUEndTime(&self) -> CFTimeInterval;
418
419        /// Append this command buffer to the end of its MTLCommandQueue.
420        #[unsafe(method(enqueue))]
421        #[unsafe(method_family = none)]
422        fn enqueue(&self);
423
424        /// Commit a command buffer so it can be executed as soon as possible.
425        #[unsafe(method(commit))]
426        #[unsafe(method_family = none)]
427        fn commit(&self);
428
429        #[cfg(feature = "block2")]
430        /// Adds a block to be called when this command buffer has been scheduled for execution.
431        ///
432        /// # Safety
433        ///
434        /// `block` must be a valid pointer.
435        #[unsafe(method(addScheduledHandler:))]
436        #[unsafe(method_family = none)]
437        unsafe fn addScheduledHandler(&self, block: MTLCommandBufferHandler);
438
439        #[cfg(feature = "MTLDrawable")]
440        /// Add a drawable present that will be invoked when this command buffer has been scheduled for execution.
441        ///
442        /// The submission thread will be lock stepped with present call been serviced by window server
443        #[unsafe(method(presentDrawable:))]
444        #[unsafe(method_family = none)]
445        fn presentDrawable(&self, drawable: &ProtocolObject<dyn MTLDrawable>);
446
447        #[cfg(all(feature = "MTLDrawable", feature = "objc2-core-foundation"))]
448        /// Add a drawable present for a specific host time that will be invoked when this command buffer has been scheduled for execution.
449        ///
450        /// The submission thread will be lock stepped with present call been serviced by window server
451        #[unsafe(method(presentDrawable:atTime:))]
452        #[unsafe(method_family = none)]
453        fn presentDrawable_atTime(
454            &self,
455            drawable: &ProtocolObject<dyn MTLDrawable>,
456            presentation_time: CFTimeInterval,
457        );
458
459        #[cfg(all(feature = "MTLDrawable", feature = "objc2-core-foundation"))]
460        /// Add a drawable present for a specific host time that allows previous frame to be on screen for at least duration time.
461        ///
462        /// Parameter `drawable`: The drawable to be presented
463        ///
464        /// Parameter `duration`: The minimum time that previous frame should be displayed. The time is double preceision floating point in the unit of seconds.
465        ///
466        /// The difference of this API versus presentDrawable:atTime is that this API defers calculation of the presentation time until the previous frame's actual presentation time is known, thus to be able to maintain a more consistent and stable frame time. This also provides an easy way to set frame rate.
467        /// The submission thread will be lock stepped with present call been serviced by window server
468        #[unsafe(method(presentDrawable:afterMinimumDuration:))]
469        #[unsafe(method_family = none)]
470        fn presentDrawable_afterMinimumDuration(
471            &self,
472            drawable: &ProtocolObject<dyn MTLDrawable>,
473            duration: CFTimeInterval,
474        );
475
476        /// Synchronously wait for this command buffer to be scheduled.
477        #[unsafe(method(waitUntilScheduled))]
478        #[unsafe(method_family = none)]
479        fn waitUntilScheduled(&self);
480
481        #[cfg(feature = "block2")]
482        /// Add a block to be called when this command buffer has completed execution.
483        ///
484        /// # Safety
485        ///
486        /// `block` must be a valid pointer.
487        #[unsafe(method(addCompletedHandler:))]
488        #[unsafe(method_family = none)]
489        unsafe fn addCompletedHandler(&self, block: MTLCommandBufferHandler);
490
491        /// Synchronously wait for this command buffer to complete.
492        #[unsafe(method(waitUntilCompleted))]
493        #[unsafe(method_family = none)]
494        fn waitUntilCompleted(&self);
495
496        /// status reports the current stage in the lifetime of MTLCommandBuffer, as it proceeds to enqueued, committed, scheduled, and completed.
497        #[unsafe(method(status))]
498        #[unsafe(method_family = none)]
499        fn status(&self) -> MTLCommandBufferStatus;
500
501        /// If an error occurred during execution, the NSError may contain more details about the problem.
502        #[unsafe(method(error))]
503        #[unsafe(method_family = none)]
504        fn error(&self) -> Option<Retained<NSError>>;
505
506        #[cfg(all(feature = "MTLBlitCommandEncoder", feature = "MTLCommandEncoder"))]
507        /// returns a blit command encoder to encode into this command buffer.
508        #[unsafe(method(blitCommandEncoder))]
509        #[unsafe(method_family = none)]
510        fn blitCommandEncoder(&self)
511            -> Option<Retained<ProtocolObject<dyn MTLBlitCommandEncoder>>>;
512
513        #[cfg(all(
514            feature = "MTLCommandEncoder",
515            feature = "MTLRenderCommandEncoder",
516            feature = "MTLRenderPass"
517        ))]
518        /// returns a render command endcoder to encode into this command buffer.
519        #[unsafe(method(renderCommandEncoderWithDescriptor:))]
520        #[unsafe(method_family = none)]
521        fn renderCommandEncoderWithDescriptor(
522            &self,
523            render_pass_descriptor: &MTLRenderPassDescriptor,
524        ) -> Option<Retained<ProtocolObject<dyn MTLRenderCommandEncoder>>>;
525
526        #[cfg(all(
527            feature = "MTLCommandEncoder",
528            feature = "MTLComputeCommandEncoder",
529            feature = "MTLComputePass"
530        ))]
531        /// returns a compute command endcoder to encode into this command buffer.
532        #[unsafe(method(computeCommandEncoderWithDescriptor:))]
533        #[unsafe(method_family = none)]
534        fn computeCommandEncoderWithDescriptor(
535            &self,
536            compute_pass_descriptor: &MTLComputePassDescriptor,
537        ) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
538
539        #[cfg(all(
540            feature = "MTLBlitCommandEncoder",
541            feature = "MTLBlitPass",
542            feature = "MTLCommandEncoder"
543        ))]
544        /// returns a blit command endcoder to encode into this command buffer.
545        #[unsafe(method(blitCommandEncoderWithDescriptor:))]
546        #[unsafe(method_family = none)]
547        fn blitCommandEncoderWithDescriptor(
548            &self,
549            blit_pass_descriptor: &MTLBlitPassDescriptor,
550        ) -> Option<Retained<ProtocolObject<dyn MTLBlitCommandEncoder>>>;
551
552        #[cfg(all(feature = "MTLCommandEncoder", feature = "MTLComputeCommandEncoder"))]
553        /// returns a compute command encoder to encode into this command buffer.
554        #[unsafe(method(computeCommandEncoder))]
555        #[unsafe(method_family = none)]
556        fn computeCommandEncoder(
557            &self,
558        ) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
559
560        #[cfg(all(feature = "MTLCommandEncoder", feature = "MTLComputeCommandEncoder"))]
561        /// returns a compute command encoder to encode into this command buffer. Optionally allow this command encoder to execute dispatches concurrently.
562        ///
563        /// On devices that do not support concurrent command encoders, this call is equivalent to computeCommandEncoder
564        #[unsafe(method(computeCommandEncoderWithDispatchType:))]
565        #[unsafe(method_family = none)]
566        fn computeCommandEncoderWithDispatchType(
567            &self,
568            dispatch_type: MTLDispatchType,
569        ) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
570
571        #[cfg(feature = "MTLEvent")]
572        /// Encodes a command that pauses execution of this command buffer until the specified event reaches a given value.
573        ///
574        /// This method may only be called if there is no current command encoder on the receiver.
575        #[unsafe(method(encodeWaitForEvent:value:))]
576        #[unsafe(method_family = none)]
577        fn encodeWaitForEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
578
579        #[cfg(feature = "MTLEvent")]
580        /// Encodes a command that signals an event with a given value.
581        ///
582        /// This method may only be called if there is no current command encoder on the receiver.
583        #[unsafe(method(encodeSignalEvent:value:))]
584        #[unsafe(method_family = none)]
585        fn encodeSignalEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
586
587        #[cfg(all(
588            feature = "MTLCommandEncoder",
589            feature = "MTLParallelRenderCommandEncoder",
590            feature = "MTLRenderPass"
591        ))]
592        /// returns a parallel render pass encoder to encode into this command buffer.
593        #[unsafe(method(parallelRenderCommandEncoderWithDescriptor:))]
594        #[unsafe(method_family = none)]
595        fn parallelRenderCommandEncoderWithDescriptor(
596            &self,
597            render_pass_descriptor: &MTLRenderPassDescriptor,
598        ) -> Option<Retained<ProtocolObject<dyn MTLParallelRenderCommandEncoder>>>;
599
600        #[cfg(all(
601            feature = "MTLCommandEncoder",
602            feature = "MTLResourceStateCommandEncoder"
603        ))]
604        #[unsafe(method(resourceStateCommandEncoder))]
605        #[unsafe(method_family = none)]
606        fn resourceStateCommandEncoder(
607            &self,
608        ) -> Option<Retained<ProtocolObject<dyn MTLResourceStateCommandEncoder>>>;
609
610        #[cfg(all(
611            feature = "MTLCommandEncoder",
612            feature = "MTLResourceStateCommandEncoder",
613            feature = "MTLResourceStatePass"
614        ))]
615        #[unsafe(method(resourceStateCommandEncoderWithDescriptor:))]
616        #[unsafe(method_family = none)]
617        fn resourceStateCommandEncoderWithDescriptor(
618            &self,
619            resource_state_pass_descriptor: &MTLResourceStatePassDescriptor,
620        ) -> Option<Retained<ProtocolObject<dyn MTLResourceStateCommandEncoder>>>;
621
622        #[cfg(all(
623            feature = "MTLAccelerationStructureCommandEncoder",
624            feature = "MTLCommandEncoder"
625        ))]
626        #[unsafe(method(accelerationStructureCommandEncoder))]
627        #[unsafe(method_family = none)]
628        fn accelerationStructureCommandEncoder(
629            &self,
630        ) -> Option<Retained<ProtocolObject<dyn MTLAccelerationStructureCommandEncoder>>>;
631
632        #[cfg(all(
633            feature = "MTLAccelerationStructureCommandEncoder",
634            feature = "MTLCommandEncoder"
635        ))]
636        #[unsafe(method(accelerationStructureCommandEncoderWithDescriptor:))]
637        #[unsafe(method_family = none)]
638        fn accelerationStructureCommandEncoderWithDescriptor(
639            &self,
640            descriptor: &MTLAccelerationStructurePassDescriptor,
641        ) -> Retained<ProtocolObject<dyn MTLAccelerationStructureCommandEncoder>>;
642
643        /// Push a new named string onto a stack of string labels.
644        #[unsafe(method(pushDebugGroup:))]
645        #[unsafe(method_family = none)]
646        fn pushDebugGroup(&self, string: &NSString);
647
648        /// Pop the latest named string off of the stack.
649        #[unsafe(method(popDebugGroup))]
650        #[unsafe(method_family = none)]
651        fn popDebugGroup(&self);
652
653        #[cfg(feature = "MTLResidencySet")]
654        /// Marks the residency set as part of the current command buffer execution. This ensures that the residency set is resident during execution of the command buffer.
655        #[unsafe(method(useResidencySet:))]
656        #[unsafe(method_family = none)]
657        fn useResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>);
658
659        #[cfg(feature = "MTLResidencySet")]
660        /// Marks the residency sets as part of the current command buffer execution. This ensures that the residency sets are resident during execution of the command buffer.
661        ///
662        /// # Safety
663        ///
664        /// - `residency_sets` must be a valid pointer.
665        /// - `count` might not be bounds-checked.
666        #[unsafe(method(useResidencySets:count:))]
667        #[unsafe(method_family = none)]
668        unsafe fn useResidencySets_count(
669            &self,
670            residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>,
671            count: NSUInteger,
672        );
673    }
674);