objc2_metal/generated/
MTLCaptureManager.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
10extern "C" {
11    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcaptureerrordomain?language=objc)
12    pub static MTLCaptureErrorDomain: &'static NSErrorDomain;
13}
14
15/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcaptureerror?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct MTLCaptureError(pub NSInteger);
20impl MTLCaptureError {
21    /// Capturing is not supported, maybe the destination is not supported.
22    #[doc(alias = "MTLCaptureErrorNotSupported")]
23    pub const NotSupported: Self = Self(1);
24    /// A capture is already in progress.
25    #[doc(alias = "MTLCaptureErrorAlreadyCapturing")]
26    pub const AlreadyCapturing: Self = Self(2);
27    /// The MTLCaptureDescriptor contains an invalid parameters.
28    #[doc(alias = "MTLCaptureErrorInvalidDescriptor")]
29    pub const InvalidDescriptor: Self = Self(3);
30}
31
32unsafe impl Encode for MTLCaptureError {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for MTLCaptureError {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// The destination where you want the GPU trace to be captured to.
41///
42/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcapturedestination?language=objc)
43// NS_ENUM
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct MTLCaptureDestination(pub NSInteger);
47impl MTLCaptureDestination {
48    /// Capture to Developer Tools (Xcode) and stop the execution after capturing.
49    #[doc(alias = "MTLCaptureDestinationDeveloperTools")]
50    pub const DeveloperTools: Self = Self(1);
51    /// Capture to a GPU Trace document and continue execution after capturing.
52    #[doc(alias = "MTLCaptureDestinationGPUTraceDocument")]
53    pub const GPUTraceDocument: Self = Self(2);
54}
55
56unsafe impl Encode for MTLCaptureDestination {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for MTLCaptureDestination {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern_class!(
65    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcapturedescriptor?language=objc)
66    #[unsafe(super(NSObject))]
67    #[derive(Debug, PartialEq, Eq, Hash)]
68    pub struct MTLCaptureDescriptor;
69);
70
71extern_conformance!(
72    unsafe impl NSCopying for MTLCaptureDescriptor {}
73);
74
75unsafe impl CopyingHelper for MTLCaptureDescriptor {
76    type Result = Self;
77}
78
79extern_conformance!(
80    unsafe impl NSObjectProtocol for MTLCaptureDescriptor {}
81);
82
83impl MTLCaptureDescriptor {
84    extern_methods!(
85        /// The object that is captured.
86        ///
87        /// Must be one of the following:
88        ///
89        /// MTLDevice captures all command queues of the device.
90        ///
91        /// MTLCommandQueue captures a single command queue.
92        ///
93        /// MTLCaptureScope captures between the next begin and end of the scope.
94        #[unsafe(method(captureObject))]
95        #[unsafe(method_family = none)]
96        pub fn captureObject(&self) -> Option<Retained<AnyObject>>;
97
98        /// Setter for [`captureObject`][Self::captureObject].
99        ///
100        /// # Safety
101        ///
102        /// `capture_object` should be of the correct type.
103        #[unsafe(method(setCaptureObject:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn setCaptureObject(&self, capture_object: Option<&AnyObject>);
106
107        /// The destination you want the GPU trace to be captured to.
108        #[unsafe(method(destination))]
109        #[unsafe(method_family = none)]
110        pub fn destination(&self) -> MTLCaptureDestination;
111
112        /// Setter for [`destination`][Self::destination].
113        #[unsafe(method(setDestination:))]
114        #[unsafe(method_family = none)]
115        pub fn setDestination(&self, destination: MTLCaptureDestination);
116
117        /// URL the GPU Trace document will be captured to.
118        /// Must be specified when destiation is MTLCaptureDestinationGPUTraceDocument.
119        #[unsafe(method(outputURL))]
120        #[unsafe(method_family = none)]
121        pub fn outputURL(&self) -> Option<Retained<NSURL>>;
122
123        /// Setter for [`outputURL`][Self::outputURL].
124        ///
125        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
126        #[unsafe(method(setOutputURL:))]
127        #[unsafe(method_family = none)]
128        pub fn setOutputURL(&self, output_url: Option<&NSURL>);
129    );
130}
131
132/// Methods declared on superclass `NSObject`.
133impl MTLCaptureDescriptor {
134    extern_methods!(
135        #[unsafe(method(init))]
136        #[unsafe(method_family = init)]
137        pub fn init(this: Allocated<Self>) -> Retained<Self>;
138
139        #[unsafe(method(new))]
140        #[unsafe(method_family = new)]
141        pub fn new() -> Retained<Self>;
142    );
143}
144
145impl DefaultRetained for MTLCaptureDescriptor {
146    #[inline]
147    fn default_retained() -> Retained<Self> {
148        Self::new()
149    }
150}
151
152extern_class!(
153    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlcapturemanager?language=objc)
154    #[unsafe(super(NSObject))]
155    #[derive(Debug, PartialEq, Eq, Hash)]
156    pub struct MTLCaptureManager;
157);
158
159extern_conformance!(
160    unsafe impl NSObjectProtocol for MTLCaptureManager {}
161);
162
163impl MTLCaptureManager {
164    extern_methods!(
165        /// Retrieves the shared capture manager for this process. There is only one capture manager per process.
166        /// The capture manager allows the user to create capture scopes and trigger captures from code.
167        /// When a capture has been completed, it will be displayed in Xcode and the application will be paused.
168        ///
169        /// : only MTLCommandBuffers created after starting a capture and committed before stopping it are captured.
170        #[unsafe(method(sharedCaptureManager))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn sharedCaptureManager() -> Retained<MTLCaptureManager>;
173
174        #[unsafe(method(init))]
175        #[unsafe(method_family = init)]
176        pub fn init(this: Allocated<Self>) -> Retained<Self>;
177
178        #[cfg(all(feature = "MTLCaptureScope", feature = "MTLDevice"))]
179        #[unsafe(method(newCaptureScopeWithDevice:))]
180        #[unsafe(method_family = new)]
181        pub fn newCaptureScopeWithDevice(
182            &self,
183            device: &ProtocolObject<dyn MTLDevice>,
184        ) -> Retained<ProtocolObject<dyn MTLCaptureScope>>;
185
186        #[cfg(all(feature = "MTLCaptureScope", feature = "MTLCommandQueue"))]
187        #[unsafe(method(newCaptureScopeWithCommandQueue:))]
188        #[unsafe(method_family = new)]
189        pub fn newCaptureScopeWithCommandQueue(
190            &self,
191            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
192        ) -> Retained<ProtocolObject<dyn MTLCaptureScope>>;
193
194        #[cfg(all(feature = "MTL4CommandQueue", feature = "MTLCaptureScope"))]
195        #[unsafe(method(newCaptureScopeWithMTL4CommandQueue:))]
196        #[unsafe(method_family = new)]
197        pub fn newCaptureScopeWithMTL4CommandQueue(
198            &self,
199            command_queue: &ProtocolObject<dyn MTL4CommandQueue>,
200        ) -> Retained<ProtocolObject<dyn MTLCaptureScope>>;
201
202        #[unsafe(method(supportsDestination:))]
203        #[unsafe(method_family = none)]
204        pub fn supportsDestination(&self, destination: MTLCaptureDestination) -> bool;
205
206        /// Start capturing until stopCapture is called.
207        ///
208        /// Parameter `descriptor`: MTLCaptureDescriptor specifies the parameters.
209        ///
210        /// Parameter `error`: Optional error output to check why a capture could not be started.
211        ///
212        /// Returns: true if the capture was successfully started, otherwise false.
213        ///
214        /// Only MTLCommandBuffer​s created after starting and committed before stopping it are captured.
215        #[unsafe(method(startCaptureWithDescriptor:error:_))]
216        #[unsafe(method_family = none)]
217        pub fn startCaptureWithDescriptor_error(
218            &self,
219            descriptor: &MTLCaptureDescriptor,
220        ) -> Result<(), Retained<NSError>>;
221
222        #[cfg(feature = "MTLDevice")]
223        #[deprecated = "Use startCaptureWithDescriptor:error: instead"]
224        #[unsafe(method(startCaptureWithDevice:))]
225        #[unsafe(method_family = none)]
226        pub fn startCaptureWithDevice(&self, device: &ProtocolObject<dyn MTLDevice>);
227
228        #[cfg(feature = "MTLCommandQueue")]
229        #[deprecated = "Use startCaptureWithDescriptor:error: instead"]
230        #[unsafe(method(startCaptureWithCommandQueue:))]
231        #[unsafe(method_family = none)]
232        pub fn startCaptureWithCommandQueue(
233            &self,
234            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
235        );
236
237        #[cfg(feature = "MTLCaptureScope")]
238        #[deprecated = "Use startCaptureWithDescriptor:error: instead"]
239        #[unsafe(method(startCaptureWithScope:))]
240        #[unsafe(method_family = none)]
241        pub fn startCaptureWithScope(&self, capture_scope: &ProtocolObject<dyn MTLCaptureScope>);
242
243        #[unsafe(method(stopCapture))]
244        #[unsafe(method_family = none)]
245        pub fn stopCapture(&self);
246
247        #[cfg(feature = "MTLCaptureScope")]
248        #[unsafe(method(defaultCaptureScope))]
249        #[unsafe(method_family = none)]
250        pub fn defaultCaptureScope(&self) -> Option<Retained<ProtocolObject<dyn MTLCaptureScope>>>;
251
252        #[cfg(feature = "MTLCaptureScope")]
253        /// Setter for [`defaultCaptureScope`][Self::defaultCaptureScope].
254        #[unsafe(method(setDefaultCaptureScope:))]
255        #[unsafe(method_family = none)]
256        pub fn setDefaultCaptureScope(
257            &self,
258            default_capture_scope: Option<&ProtocolObject<dyn MTLCaptureScope>>,
259        );
260
261        #[unsafe(method(isCapturing))]
262        #[unsafe(method_family = none)]
263        pub fn isCapturing(&self) -> bool;
264    );
265}
266
267/// Methods declared on superclass `NSObject`.
268impl MTLCaptureManager {
269    extern_methods!(
270        #[unsafe(method(new))]
271        #[unsafe(method_family = new)]
272        pub fn new() -> Retained<Self>;
273    );
274}
275
276impl DefaultRetained for MTLCaptureManager {
277    #[inline]
278    fn default_retained() -> Retained<Self> {
279        Self::new()
280    }
281}