objc2_metal/generated/
MTLRenderPass.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/mtlclearcolor?language=objc)
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq)]
13pub struct MTLClearColor {
14    pub red: c_double,
15    pub green: c_double,
16    pub blue: c_double,
17    pub alpha: c_double,
18}
19
20unsafe impl Encode for MTLClearColor {
21    const ENCODING: Encoding = Encoding::Struct(
22        "?",
23        &[
24            <c_double>::ENCODING,
25            <c_double>::ENCODING,
26            <c_double>::ENCODING,
27            <c_double>::ENCODING,
28        ],
29    );
30}
31
32unsafe impl RefEncode for MTLClearColor {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36impl MTLClearColor {
37    // TODO: pub fn MTLClearColorMake(red: c_double,green: c_double,blue: c_double,alpha: c_double,) -> MTLClearColor;
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlloadaction?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct MTLLoadAction(pub NSUInteger);
45impl MTLLoadAction {
46    #[doc(alias = "MTLLoadActionDontCare")]
47    pub const DontCare: Self = Self(0);
48    #[doc(alias = "MTLLoadActionLoad")]
49    pub const Load: Self = Self(1);
50    #[doc(alias = "MTLLoadActionClear")]
51    pub const Clear: Self = Self(2);
52}
53
54unsafe impl Encode for MTLLoadAction {
55    const ENCODING: Encoding = NSUInteger::ENCODING;
56}
57
58unsafe impl RefEncode for MTLLoadAction {
59    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
60}
61
62/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstoreaction?language=objc)
63// NS_ENUM
64#[repr(transparent)]
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66pub struct MTLStoreAction(pub NSUInteger);
67impl MTLStoreAction {
68    #[doc(alias = "MTLStoreActionDontCare")]
69    pub const DontCare: Self = Self(0);
70    #[doc(alias = "MTLStoreActionStore")]
71    pub const Store: Self = Self(1);
72    #[doc(alias = "MTLStoreActionMultisampleResolve")]
73    pub const MultisampleResolve: Self = Self(2);
74    #[doc(alias = "MTLStoreActionStoreAndMultisampleResolve")]
75    pub const StoreAndMultisampleResolve: Self = Self(3);
76    #[doc(alias = "MTLStoreActionUnknown")]
77    pub const Unknown: Self = Self(4);
78    #[doc(alias = "MTLStoreActionCustomSampleDepthStore")]
79    pub const CustomSampleDepthStore: Self = Self(5);
80}
81
82unsafe impl Encode for MTLStoreAction {
83    const ENCODING: Encoding = NSUInteger::ENCODING;
84}
85
86unsafe impl RefEncode for MTLStoreAction {
87    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstoreactionoptions?language=objc)
91// NS_OPTIONS
92#[repr(transparent)]
93#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
94pub struct MTLStoreActionOptions(pub NSUInteger);
95bitflags::bitflags! {
96    impl MTLStoreActionOptions: NSUInteger {
97        #[doc(alias = "MTLStoreActionOptionNone")]
98        const None = 0;
99        #[doc(alias = "MTLStoreActionOptionCustomSamplePositions")]
100        const CustomSamplePositions = 1<<0;
101    }
102}
103
104unsafe impl Encode for MTLStoreActionOptions {
105    const ENCODING: Encoding = NSUInteger::ENCODING;
106}
107
108unsafe impl RefEncode for MTLStoreActionOptions {
109    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
110}
111
112/// This enumeration controls if Metal accumulates visibility results between render encoders or resets them.
113///
114/// You can specify this property for ``MTLRenderCommandEncoders`` and for ``MTL4RenderCommandEncoders`` through
115/// their descriptors' ``MTLRenderCommandEncoder/visibilityResultType`` and ``MTL4RenderCommandEncoder/visibilityResultType``
116/// methods.
117///
118/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlvisibilityresulttype?language=objc)
119// NS_ENUM
120#[repr(transparent)]
121#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
122pub struct MTLVisibilityResultType(pub NSInteger);
123impl MTLVisibilityResultType {
124    /// Reset visibility result data when you create a render command encoder.
125    #[doc(alias = "MTLVisibilityResultTypeReset")]
126    pub const Reset: Self = Self(0);
127    /// Accumulate visibility results data across multiple render passes.
128    #[doc(alias = "MTLVisibilityResultTypeAccumulate")]
129    pub const Accumulate: Self = Self(1);
130}
131
132unsafe impl Encode for MTLVisibilityResultType {
133    const ENCODING: Encoding = NSInteger::ENCODING;
134}
135
136unsafe impl RefEncode for MTLVisibilityResultType {
137    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
138}
139
140extern_class!(
141    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpassattachmentdescriptor?language=objc)
142    #[unsafe(super(NSObject))]
143    #[derive(Debug, PartialEq, Eq, Hash)]
144    pub struct MTLRenderPassAttachmentDescriptor;
145);
146
147extern_conformance!(
148    unsafe impl NSCopying for MTLRenderPassAttachmentDescriptor {}
149);
150
151unsafe impl CopyingHelper for MTLRenderPassAttachmentDescriptor {
152    type Result = Self;
153}
154
155extern_conformance!(
156    unsafe impl NSObjectProtocol for MTLRenderPassAttachmentDescriptor {}
157);
158
159impl MTLRenderPassAttachmentDescriptor {
160    extern_methods!(
161        #[cfg(all(
162            feature = "MTLAllocation",
163            feature = "MTLResource",
164            feature = "MTLTexture"
165        ))]
166        /// The MTLTexture object for this attachment.
167        #[unsafe(method(texture))]
168        #[unsafe(method_family = none)]
169        pub fn texture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
170
171        #[cfg(all(
172            feature = "MTLAllocation",
173            feature = "MTLResource",
174            feature = "MTLTexture"
175        ))]
176        /// Setter for [`texture`][Self::texture].
177        #[unsafe(method(setTexture:))]
178        #[unsafe(method_family = none)]
179        pub fn setTexture(&self, texture: Option<&ProtocolObject<dyn MTLTexture>>);
180
181        /// The mipmap level of the texture to be used for rendering.  Default is zero.
182        #[unsafe(method(level))]
183        #[unsafe(method_family = none)]
184        pub fn level(&self) -> NSUInteger;
185
186        /// Setter for [`level`][Self::level].
187        #[unsafe(method(setLevel:))]
188        #[unsafe(method_family = none)]
189        pub fn setLevel(&self, level: NSUInteger);
190
191        /// The slice of the texture to be used for rendering.  Default is zero.
192        #[unsafe(method(slice))]
193        #[unsafe(method_family = none)]
194        pub fn slice(&self) -> NSUInteger;
195
196        /// Setter for [`slice`][Self::slice].
197        #[unsafe(method(setSlice:))]
198        #[unsafe(method_family = none)]
199        pub fn setSlice(&self, slice: NSUInteger);
200
201        /// The depth plane of the texture to be used for rendering.  Default is zero.
202        #[unsafe(method(depthPlane))]
203        #[unsafe(method_family = none)]
204        pub fn depthPlane(&self) -> NSUInteger;
205
206        /// Setter for [`depthPlane`][Self::depthPlane].
207        #[unsafe(method(setDepthPlane:))]
208        #[unsafe(method_family = none)]
209        pub fn setDepthPlane(&self, depth_plane: NSUInteger);
210
211        #[cfg(all(
212            feature = "MTLAllocation",
213            feature = "MTLResource",
214            feature = "MTLTexture"
215        ))]
216        /// The texture used for multisample resolve operations.  Only used (and required)
217        /// if the store action is set to MTLStoreActionMultisampleResolve.
218        #[unsafe(method(resolveTexture))]
219        #[unsafe(method_family = none)]
220        pub fn resolveTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
221
222        #[cfg(all(
223            feature = "MTLAllocation",
224            feature = "MTLResource",
225            feature = "MTLTexture"
226        ))]
227        /// Setter for [`resolveTexture`][Self::resolveTexture].
228        #[unsafe(method(setResolveTexture:))]
229        #[unsafe(method_family = none)]
230        pub fn setResolveTexture(&self, resolve_texture: Option<&ProtocolObject<dyn MTLTexture>>);
231
232        /// The mipmap level of the resolve texture to be used for multisample resolve.  Defaults to zero.
233        #[unsafe(method(resolveLevel))]
234        #[unsafe(method_family = none)]
235        pub fn resolveLevel(&self) -> NSUInteger;
236
237        /// Setter for [`resolveLevel`][Self::resolveLevel].
238        #[unsafe(method(setResolveLevel:))]
239        #[unsafe(method_family = none)]
240        pub fn setResolveLevel(&self, resolve_level: NSUInteger);
241
242        /// The texture slice of the resolve texture to be used for multisample resolve.  Defaults to zero.
243        #[unsafe(method(resolveSlice))]
244        #[unsafe(method_family = none)]
245        pub fn resolveSlice(&self) -> NSUInteger;
246
247        /// Setter for [`resolveSlice`][Self::resolveSlice].
248        #[unsafe(method(setResolveSlice:))]
249        #[unsafe(method_family = none)]
250        pub fn setResolveSlice(&self, resolve_slice: NSUInteger);
251
252        /// The texture depth plane of the resolve texture to be used for multisample resolve.  Defaults to zero.
253        #[unsafe(method(resolveDepthPlane))]
254        #[unsafe(method_family = none)]
255        pub fn resolveDepthPlane(&self) -> NSUInteger;
256
257        /// Setter for [`resolveDepthPlane`][Self::resolveDepthPlane].
258        #[unsafe(method(setResolveDepthPlane:))]
259        #[unsafe(method_family = none)]
260        pub fn setResolveDepthPlane(&self, resolve_depth_plane: NSUInteger);
261
262        /// The action to be performed with this attachment at the beginning of a render pass.  Default is
263        /// MTLLoadActionDontCare unless specified by a creation or init method.
264        #[unsafe(method(loadAction))]
265        #[unsafe(method_family = none)]
266        pub fn loadAction(&self) -> MTLLoadAction;
267
268        /// Setter for [`loadAction`][Self::loadAction].
269        #[unsafe(method(setLoadAction:))]
270        #[unsafe(method_family = none)]
271        pub fn setLoadAction(&self, load_action: MTLLoadAction);
272
273        /// The action to be performed with this attachment at the end of a render pass.  Default is
274        /// MTLStoreActionDontCare unless specified by a creation or init method.
275        #[unsafe(method(storeAction))]
276        #[unsafe(method_family = none)]
277        pub fn storeAction(&self) -> MTLStoreAction;
278
279        /// Setter for [`storeAction`][Self::storeAction].
280        #[unsafe(method(setStoreAction:))]
281        #[unsafe(method_family = none)]
282        pub fn setStoreAction(&self, store_action: MTLStoreAction);
283
284        /// Optional configuration for the store action performed with this attachment at the end of a render pass.  Default is
285        /// MTLStoreActionOptionNone.
286        #[unsafe(method(storeActionOptions))]
287        #[unsafe(method_family = none)]
288        pub fn storeActionOptions(&self) -> MTLStoreActionOptions;
289
290        /// Setter for [`storeActionOptions`][Self::storeActionOptions].
291        #[unsafe(method(setStoreActionOptions:))]
292        #[unsafe(method_family = none)]
293        pub fn setStoreActionOptions(&self, store_action_options: MTLStoreActionOptions);
294    );
295}
296
297/// Methods declared on superclass `NSObject`.
298impl MTLRenderPassAttachmentDescriptor {
299    extern_methods!(
300        #[unsafe(method(init))]
301        #[unsafe(method_family = init)]
302        pub fn init(this: Allocated<Self>) -> Retained<Self>;
303
304        #[unsafe(method(new))]
305        #[unsafe(method_family = new)]
306        pub fn new() -> Retained<Self>;
307    );
308}
309
310impl DefaultRetained for MTLRenderPassAttachmentDescriptor {
311    #[inline]
312    fn default_retained() -> Retained<Self> {
313        Self::new()
314    }
315}
316
317extern_class!(
318    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpasscolorattachmentdescriptor?language=objc)
319    #[unsafe(super(MTLRenderPassAttachmentDescriptor, NSObject))]
320    #[derive(Debug, PartialEq, Eq, Hash)]
321    pub struct MTLRenderPassColorAttachmentDescriptor;
322);
323
324extern_conformance!(
325    unsafe impl NSCopying for MTLRenderPassColorAttachmentDescriptor {}
326);
327
328unsafe impl CopyingHelper for MTLRenderPassColorAttachmentDescriptor {
329    type Result = Self;
330}
331
332extern_conformance!(
333    unsafe impl NSObjectProtocol for MTLRenderPassColorAttachmentDescriptor {}
334);
335
336impl MTLRenderPassColorAttachmentDescriptor {
337    extern_methods!(
338        /// The clear color to be used if the loadAction property is MTLLoadActionClear
339        #[unsafe(method(clearColor))]
340        #[unsafe(method_family = none)]
341        pub fn clearColor(&self) -> MTLClearColor;
342
343        /// Setter for [`clearColor`][Self::clearColor].
344        #[unsafe(method(setClearColor:))]
345        #[unsafe(method_family = none)]
346        pub fn setClearColor(&self, clear_color: MTLClearColor);
347    );
348}
349
350/// Methods declared on superclass `NSObject`.
351impl MTLRenderPassColorAttachmentDescriptor {
352    extern_methods!(
353        #[unsafe(method(init))]
354        #[unsafe(method_family = init)]
355        pub fn init(this: Allocated<Self>) -> Retained<Self>;
356
357        #[unsafe(method(new))]
358        #[unsafe(method_family = new)]
359        pub fn new() -> Retained<Self>;
360    );
361}
362
363impl DefaultRetained for MTLRenderPassColorAttachmentDescriptor {
364    #[inline]
365    fn default_retained() -> Retained<Self> {
366        Self::new()
367    }
368}
369
370/// Controls the MSAA depth resolve operation. Supported on iOS GPU Family 3 and later.
371///
372/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlmultisampledepthresolvefilter?language=objc)
373// NS_ENUM
374#[repr(transparent)]
375#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
376pub struct MTLMultisampleDepthResolveFilter(pub NSUInteger);
377impl MTLMultisampleDepthResolveFilter {
378    #[doc(alias = "MTLMultisampleDepthResolveFilterSample0")]
379    pub const Sample0: Self = Self(0);
380    #[doc(alias = "MTLMultisampleDepthResolveFilterMin")]
381    pub const Min: Self = Self(1);
382    #[doc(alias = "MTLMultisampleDepthResolveFilterMax")]
383    pub const Max: Self = Self(2);
384}
385
386unsafe impl Encode for MTLMultisampleDepthResolveFilter {
387    const ENCODING: Encoding = NSUInteger::ENCODING;
388}
389
390unsafe impl RefEncode for MTLMultisampleDepthResolveFilter {
391    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
392}
393
394extern_class!(
395    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpassdepthattachmentdescriptor?language=objc)
396    #[unsafe(super(MTLRenderPassAttachmentDescriptor, NSObject))]
397    #[derive(Debug, PartialEq, Eq, Hash)]
398    pub struct MTLRenderPassDepthAttachmentDescriptor;
399);
400
401extern_conformance!(
402    unsafe impl NSCopying for MTLRenderPassDepthAttachmentDescriptor {}
403);
404
405unsafe impl CopyingHelper for MTLRenderPassDepthAttachmentDescriptor {
406    type Result = Self;
407}
408
409extern_conformance!(
410    unsafe impl NSObjectProtocol for MTLRenderPassDepthAttachmentDescriptor {}
411);
412
413impl MTLRenderPassDepthAttachmentDescriptor {
414    extern_methods!(
415        /// The clear depth value to be used if the loadAction property is MTLLoadActionClear
416        #[unsafe(method(clearDepth))]
417        #[unsafe(method_family = none)]
418        pub fn clearDepth(&self) -> c_double;
419
420        /// Setter for [`clearDepth`][Self::clearDepth].
421        #[unsafe(method(setClearDepth:))]
422        #[unsafe(method_family = none)]
423        pub fn setClearDepth(&self, clear_depth: c_double);
424
425        /// The filter to be used for depth multisample resolve.  Defaults to MTLMultisampleDepthResolveFilterSample0.
426        #[unsafe(method(depthResolveFilter))]
427        #[unsafe(method_family = none)]
428        pub fn depthResolveFilter(&self) -> MTLMultisampleDepthResolveFilter;
429
430        /// Setter for [`depthResolveFilter`][Self::depthResolveFilter].
431        #[unsafe(method(setDepthResolveFilter:))]
432        #[unsafe(method_family = none)]
433        pub fn setDepthResolveFilter(&self, depth_resolve_filter: MTLMultisampleDepthResolveFilter);
434    );
435}
436
437/// Methods declared on superclass `NSObject`.
438impl MTLRenderPassDepthAttachmentDescriptor {
439    extern_methods!(
440        #[unsafe(method(init))]
441        #[unsafe(method_family = init)]
442        pub fn init(this: Allocated<Self>) -> Retained<Self>;
443
444        #[unsafe(method(new))]
445        #[unsafe(method_family = new)]
446        pub fn new() -> Retained<Self>;
447    );
448}
449
450impl DefaultRetained for MTLRenderPassDepthAttachmentDescriptor {
451    #[inline]
452    fn default_retained() -> Retained<Self> {
453        Self::new()
454    }
455}
456
457/// Controls the MSAA stencil resolve operation.
458///
459/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlmultisamplestencilresolvefilter?language=objc)
460// NS_ENUM
461#[repr(transparent)]
462#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
463pub struct MTLMultisampleStencilResolveFilter(pub NSUInteger);
464impl MTLMultisampleStencilResolveFilter {
465    /// The stencil sample corresponding to sample 0. This is the default behavior.
466    #[doc(alias = "MTLMultisampleStencilResolveFilterSample0")]
467    pub const Sample0: Self = Self(0);
468    /// The stencil sample corresponding to whichever depth sample is selected by the depth resolve filter. If depth resolve is not enabled, the stencil sample is chosen based on what a depth resolve filter would have selected.
469    #[doc(alias = "MTLMultisampleStencilResolveFilterDepthResolvedSample")]
470    pub const DepthResolvedSample: Self = Self(1);
471}
472
473unsafe impl Encode for MTLMultisampleStencilResolveFilter {
474    const ENCODING: Encoding = NSUInteger::ENCODING;
475}
476
477unsafe impl RefEncode for MTLMultisampleStencilResolveFilter {
478    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
479}
480
481extern_class!(
482    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpassstencilattachmentdescriptor?language=objc)
483    #[unsafe(super(MTLRenderPassAttachmentDescriptor, NSObject))]
484    #[derive(Debug, PartialEq, Eq, Hash)]
485    pub struct MTLRenderPassStencilAttachmentDescriptor;
486);
487
488extern_conformance!(
489    unsafe impl NSCopying for MTLRenderPassStencilAttachmentDescriptor {}
490);
491
492unsafe impl CopyingHelper for MTLRenderPassStencilAttachmentDescriptor {
493    type Result = Self;
494}
495
496extern_conformance!(
497    unsafe impl NSObjectProtocol for MTLRenderPassStencilAttachmentDescriptor {}
498);
499
500impl MTLRenderPassStencilAttachmentDescriptor {
501    extern_methods!(
502        /// The clear stencil value to be used if the loadAction property is MTLLoadActionClear
503        #[unsafe(method(clearStencil))]
504        #[unsafe(method_family = none)]
505        pub fn clearStencil(&self) -> u32;
506
507        /// Setter for [`clearStencil`][Self::clearStencil].
508        #[unsafe(method(setClearStencil:))]
509        #[unsafe(method_family = none)]
510        pub fn setClearStencil(&self, clear_stencil: u32);
511
512        /// The filter to be used for stencil multisample resolve. Defaults to MTLMultisampleStencilResolveFilterSample0.
513        #[unsafe(method(stencilResolveFilter))]
514        #[unsafe(method_family = none)]
515        pub fn stencilResolveFilter(&self) -> MTLMultisampleStencilResolveFilter;
516
517        /// Setter for [`stencilResolveFilter`][Self::stencilResolveFilter].
518        #[unsafe(method(setStencilResolveFilter:))]
519        #[unsafe(method_family = none)]
520        pub fn setStencilResolveFilter(
521            &self,
522            stencil_resolve_filter: MTLMultisampleStencilResolveFilter,
523        );
524    );
525}
526
527/// Methods declared on superclass `NSObject`.
528impl MTLRenderPassStencilAttachmentDescriptor {
529    extern_methods!(
530        #[unsafe(method(init))]
531        #[unsafe(method_family = init)]
532        pub fn init(this: Allocated<Self>) -> Retained<Self>;
533
534        #[unsafe(method(new))]
535        #[unsafe(method_family = new)]
536        pub fn new() -> Retained<Self>;
537    );
538}
539
540impl DefaultRetained for MTLRenderPassStencilAttachmentDescriptor {
541    #[inline]
542    fn default_retained() -> Retained<Self> {
543        Self::new()
544    }
545}
546
547extern_class!(
548    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpasscolorattachmentdescriptorarray?language=objc)
549    #[unsafe(super(NSObject))]
550    #[derive(Debug, PartialEq, Eq, Hash)]
551    pub struct MTLRenderPassColorAttachmentDescriptorArray;
552);
553
554extern_conformance!(
555    unsafe impl NSObjectProtocol for MTLRenderPassColorAttachmentDescriptorArray {}
556);
557
558impl MTLRenderPassColorAttachmentDescriptorArray {
559    extern_methods!(
560        /// # Safety
561        ///
562        /// `attachmentIndex` might not be bounds-checked.
563        #[unsafe(method(objectAtIndexedSubscript:))]
564        #[unsafe(method_family = none)]
565        pub unsafe fn objectAtIndexedSubscript(
566            &self,
567            attachment_index: NSUInteger,
568        ) -> Retained<MTLRenderPassColorAttachmentDescriptor>;
569
570        /// # Safety
571        ///
572        /// `attachmentIndex` might not be bounds-checked.
573        #[unsafe(method(setObject:atIndexedSubscript:))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn setObject_atIndexedSubscript(
576            &self,
577            attachment: Option<&MTLRenderPassColorAttachmentDescriptor>,
578            attachment_index: NSUInteger,
579        );
580    );
581}
582
583/// Methods declared on superclass `NSObject`.
584impl MTLRenderPassColorAttachmentDescriptorArray {
585    extern_methods!(
586        #[unsafe(method(init))]
587        #[unsafe(method_family = init)]
588        pub fn init(this: Allocated<Self>) -> Retained<Self>;
589
590        #[unsafe(method(new))]
591        #[unsafe(method_family = new)]
592        pub fn new() -> Retained<Self>;
593    );
594}
595
596impl DefaultRetained for MTLRenderPassColorAttachmentDescriptorArray {
597    #[inline]
598    fn default_retained() -> Retained<Self> {
599        Self::new()
600    }
601}
602
603extern_class!(
604    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpasssamplebufferattachmentdescriptor?language=objc)
605    #[unsafe(super(NSObject))]
606    #[derive(Debug, PartialEq, Eq, Hash)]
607    pub struct MTLRenderPassSampleBufferAttachmentDescriptor;
608);
609
610extern_conformance!(
611    unsafe impl NSCopying for MTLRenderPassSampleBufferAttachmentDescriptor {}
612);
613
614unsafe impl CopyingHelper for MTLRenderPassSampleBufferAttachmentDescriptor {
615    type Result = Self;
616}
617
618extern_conformance!(
619    unsafe impl NSObjectProtocol for MTLRenderPassSampleBufferAttachmentDescriptor {}
620);
621
622impl MTLRenderPassSampleBufferAttachmentDescriptor {
623    extern_methods!(
624        #[cfg(feature = "MTLCounters")]
625        /// The sample buffer to store samples for the render-pass defined samples.
626        /// If sampleBuffer is non-nil, the sample indices will be used to store samples into
627        /// the sample buffer.  If no sample buffer is provided, no samples will be taken.
628        /// If any of the sample indices are specified as MTLCounterDontSample, no sample
629        /// will be taken for that action.
630        #[unsafe(method(sampleBuffer))]
631        #[unsafe(method_family = none)]
632        pub fn sampleBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLCounterSampleBuffer>>>;
633
634        #[cfg(feature = "MTLCounters")]
635        /// Setter for [`sampleBuffer`][Self::sampleBuffer].
636        #[unsafe(method(setSampleBuffer:))]
637        #[unsafe(method_family = none)]
638        pub fn setSampleBuffer(
639            &self,
640            sample_buffer: Option<&ProtocolObject<dyn MTLCounterSampleBuffer>>,
641        );
642
643        /// The sample index to use to store the sample taken at the start of
644        /// vertex processing.  Setting the value to MTLCounterDontSample will cause
645        /// this sample to be omitted.
646        ///
647        /// On devices where MTLCounterSamplingPointAtStageBoundary is unsupported,
648        /// this sample index is invalid and must be set to MTLCounterDontSample or creation of a render pass will fail.
649        #[unsafe(method(startOfVertexSampleIndex))]
650        #[unsafe(method_family = none)]
651        pub fn startOfVertexSampleIndex(&self) -> NSUInteger;
652
653        /// Setter for [`startOfVertexSampleIndex`][Self::startOfVertexSampleIndex].
654        ///
655        /// # Safety
656        ///
657        /// This might not be bounds-checked.
658        #[unsafe(method(setStartOfVertexSampleIndex:))]
659        #[unsafe(method_family = none)]
660        pub unsafe fn setStartOfVertexSampleIndex(&self, start_of_vertex_sample_index: NSUInteger);
661
662        /// The sample index to use to store the sample taken at the end of
663        /// vertex processing.  Setting the value to MTLCounterDontSample will cause
664        /// this sample to be omitted.
665        ///
666        /// On devices where MTLCounterSamplingPointAtStageBoundary is unsupported,
667        /// this sample index is invalid and must be set to MTLCounterDontSample or creation of a render pass will fail.
668        #[unsafe(method(endOfVertexSampleIndex))]
669        #[unsafe(method_family = none)]
670        pub fn endOfVertexSampleIndex(&self) -> NSUInteger;
671
672        /// Setter for [`endOfVertexSampleIndex`][Self::endOfVertexSampleIndex].
673        ///
674        /// # Safety
675        ///
676        /// This might not be bounds-checked.
677        #[unsafe(method(setEndOfVertexSampleIndex:))]
678        #[unsafe(method_family = none)]
679        pub unsafe fn setEndOfVertexSampleIndex(&self, end_of_vertex_sample_index: NSUInteger);
680
681        /// The sample index to use to store the sample taken at the start of
682        /// fragment processing.  Setting the value to MTLCounterDontSample will cause
683        /// this sample to be omitted.
684        ///
685        /// On devices where MTLCounterSamplingPointAtStageBoundary is unsupported,
686        /// this sample index is invalid and must be set to MTLCounterDontSample or creation of a render pass will fail.
687        #[unsafe(method(startOfFragmentSampleIndex))]
688        #[unsafe(method_family = none)]
689        pub fn startOfFragmentSampleIndex(&self) -> NSUInteger;
690
691        /// Setter for [`startOfFragmentSampleIndex`][Self::startOfFragmentSampleIndex].
692        ///
693        /// # Safety
694        ///
695        /// This might not be bounds-checked.
696        #[unsafe(method(setStartOfFragmentSampleIndex:))]
697        #[unsafe(method_family = none)]
698        pub unsafe fn setStartOfFragmentSampleIndex(
699            &self,
700            start_of_fragment_sample_index: NSUInteger,
701        );
702
703        /// The sample index to use to store the sample taken at the end of
704        /// fragment processing.  Setting the value to MTLCounterDontSample will cause
705        /// this sample to be omitted.
706        ///
707        /// On devices where MTLCounterSamplingPointAtStageBoundary is unsupported,
708        /// this sample index is invalid and must be set to MTLCounterDontSample or creation of a render pass will fail.
709        #[unsafe(method(endOfFragmentSampleIndex))]
710        #[unsafe(method_family = none)]
711        pub fn endOfFragmentSampleIndex(&self) -> NSUInteger;
712
713        /// Setter for [`endOfFragmentSampleIndex`][Self::endOfFragmentSampleIndex].
714        ///
715        /// # Safety
716        ///
717        /// This might not be bounds-checked.
718        #[unsafe(method(setEndOfFragmentSampleIndex:))]
719        #[unsafe(method_family = none)]
720        pub unsafe fn setEndOfFragmentSampleIndex(&self, end_of_fragment_sample_index: NSUInteger);
721    );
722}
723
724/// Methods declared on superclass `NSObject`.
725impl MTLRenderPassSampleBufferAttachmentDescriptor {
726    extern_methods!(
727        #[unsafe(method(init))]
728        #[unsafe(method_family = init)]
729        pub fn init(this: Allocated<Self>) -> Retained<Self>;
730
731        #[unsafe(method(new))]
732        #[unsafe(method_family = new)]
733        pub fn new() -> Retained<Self>;
734    );
735}
736
737impl DefaultRetained for MTLRenderPassSampleBufferAttachmentDescriptor {
738    #[inline]
739    fn default_retained() -> Retained<Self> {
740        Self::new()
741    }
742}
743
744extern_class!(
745    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpasssamplebufferattachmentdescriptorarray?language=objc)
746    #[unsafe(super(NSObject))]
747    #[derive(Debug, PartialEq, Eq, Hash)]
748    pub struct MTLRenderPassSampleBufferAttachmentDescriptorArray;
749);
750
751extern_conformance!(
752    unsafe impl NSObjectProtocol for MTLRenderPassSampleBufferAttachmentDescriptorArray {}
753);
754
755impl MTLRenderPassSampleBufferAttachmentDescriptorArray {
756    extern_methods!(
757        /// # Safety
758        ///
759        /// `attachmentIndex` might not be bounds-checked.
760        #[unsafe(method(objectAtIndexedSubscript:))]
761        #[unsafe(method_family = none)]
762        pub unsafe fn objectAtIndexedSubscript(
763            &self,
764            attachment_index: NSUInteger,
765        ) -> Retained<MTLRenderPassSampleBufferAttachmentDescriptor>;
766
767        /// # Safety
768        ///
769        /// `attachmentIndex` might not be bounds-checked.
770        #[unsafe(method(setObject:atIndexedSubscript:))]
771        #[unsafe(method_family = none)]
772        pub unsafe fn setObject_atIndexedSubscript(
773            &self,
774            attachment: Option<&MTLRenderPassSampleBufferAttachmentDescriptor>,
775            attachment_index: NSUInteger,
776        );
777    );
778}
779
780/// Methods declared on superclass `NSObject`.
781impl MTLRenderPassSampleBufferAttachmentDescriptorArray {
782    extern_methods!(
783        #[unsafe(method(init))]
784        #[unsafe(method_family = init)]
785        pub fn init(this: Allocated<Self>) -> Retained<Self>;
786
787        #[unsafe(method(new))]
788        #[unsafe(method_family = new)]
789        pub fn new() -> Retained<Self>;
790    );
791}
792
793impl DefaultRetained for MTLRenderPassSampleBufferAttachmentDescriptorArray {
794    #[inline]
795    fn default_retained() -> Retained<Self> {
796        Self::new()
797    }
798}
799
800extern_class!(
801    /// MTLRenderPassDescriptor represents a collection of attachments to be used to create a concrete render command encoder
802    ///
803    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlrenderpassdescriptor?language=objc)
804    #[unsafe(super(NSObject))]
805    #[derive(Debug, PartialEq, Eq, Hash)]
806    pub struct MTLRenderPassDescriptor;
807);
808
809extern_conformance!(
810    unsafe impl NSCopying for MTLRenderPassDescriptor {}
811);
812
813unsafe impl CopyingHelper for MTLRenderPassDescriptor {
814    type Result = Self;
815}
816
817extern_conformance!(
818    unsafe impl NSObjectProtocol for MTLRenderPassDescriptor {}
819);
820
821impl MTLRenderPassDescriptor {
822    extern_methods!(
823        /// Create an autoreleased default frame buffer descriptor
824        #[unsafe(method(renderPassDescriptor))]
825        #[unsafe(method_family = none)]
826        pub fn renderPassDescriptor() -> Retained<MTLRenderPassDescriptor>;
827
828        #[unsafe(method(colorAttachments))]
829        #[unsafe(method_family = none)]
830        pub fn colorAttachments(&self) -> Retained<MTLRenderPassColorAttachmentDescriptorArray>;
831
832        #[unsafe(method(depthAttachment))]
833        #[unsafe(method_family = none)]
834        pub fn depthAttachment(&self) -> Retained<MTLRenderPassDepthAttachmentDescriptor>;
835
836        /// Setter for [`depthAttachment`][Self::depthAttachment].
837        ///
838        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
839        #[unsafe(method(setDepthAttachment:))]
840        #[unsafe(method_family = none)]
841        pub fn setDepthAttachment(
842            &self,
843            depth_attachment: Option<&MTLRenderPassDepthAttachmentDescriptor>,
844        );
845
846        #[unsafe(method(stencilAttachment))]
847        #[unsafe(method_family = none)]
848        pub fn stencilAttachment(&self) -> Retained<MTLRenderPassStencilAttachmentDescriptor>;
849
850        /// Setter for [`stencilAttachment`][Self::stencilAttachment].
851        ///
852        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
853        #[unsafe(method(setStencilAttachment:))]
854        #[unsafe(method_family = none)]
855        pub fn setStencilAttachment(
856            &self,
857            stencil_attachment: Option<&MTLRenderPassStencilAttachmentDescriptor>,
858        );
859
860        #[cfg(all(
861            feature = "MTLAllocation",
862            feature = "MTLBuffer",
863            feature = "MTLResource"
864        ))]
865        /// Buffer into which samples passing the depth and stencil tests are counted.
866        #[unsafe(method(visibilityResultBuffer))]
867        #[unsafe(method_family = none)]
868        pub fn visibilityResultBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
869
870        #[cfg(all(
871            feature = "MTLAllocation",
872            feature = "MTLBuffer",
873            feature = "MTLResource"
874        ))]
875        /// Setter for [`visibilityResultBuffer`][Self::visibilityResultBuffer].
876        #[unsafe(method(setVisibilityResultBuffer:))]
877        #[unsafe(method_family = none)]
878        pub fn setVisibilityResultBuffer(
879            &self,
880            visibility_result_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
881        );
882
883        /// The number of active layers
884        #[unsafe(method(renderTargetArrayLength))]
885        #[unsafe(method_family = none)]
886        pub fn renderTargetArrayLength(&self) -> NSUInteger;
887
888        /// Setter for [`renderTargetArrayLength`][Self::renderTargetArrayLength].
889        #[unsafe(method(setRenderTargetArrayLength:))]
890        #[unsafe(method_family = none)]
891        pub fn setRenderTargetArrayLength(&self, render_target_array_length: NSUInteger);
892
893        /// The per sample size in bytes of the largest explicit imageblock layout in the renderPass.
894        #[unsafe(method(imageblockSampleLength))]
895        #[unsafe(method_family = none)]
896        pub fn imageblockSampleLength(&self) -> NSUInteger;
897
898        /// Setter for [`imageblockSampleLength`][Self::imageblockSampleLength].
899        #[unsafe(method(setImageblockSampleLength:))]
900        #[unsafe(method_family = none)]
901        pub fn setImageblockSampleLength(&self, imageblock_sample_length: NSUInteger);
902
903        /// The per tile size in bytes of the persistent threadgroup memory allocation.
904        #[unsafe(method(threadgroupMemoryLength))]
905        #[unsafe(method_family = none)]
906        pub fn threadgroupMemoryLength(&self) -> NSUInteger;
907
908        /// Setter for [`threadgroupMemoryLength`][Self::threadgroupMemoryLength].
909        #[unsafe(method(setThreadgroupMemoryLength:))]
910        #[unsafe(method_family = none)]
911        pub fn setThreadgroupMemoryLength(&self, threadgroup_memory_length: NSUInteger);
912
913        /// The width in pixels of the tile.
914        ///
915        /// Defaults to 0. Zero means Metal chooses a width that fits within the local memory.
916        #[unsafe(method(tileWidth))]
917        #[unsafe(method_family = none)]
918        pub fn tileWidth(&self) -> NSUInteger;
919
920        /// Setter for [`tileWidth`][Self::tileWidth].
921        #[unsafe(method(setTileWidth:))]
922        #[unsafe(method_family = none)]
923        pub fn setTileWidth(&self, tile_width: NSUInteger);
924
925        /// The height in pixels of the tile.
926        ///
927        /// Defaults to 0. Zero means Metal chooses a height that fits within the local memory.
928        #[unsafe(method(tileHeight))]
929        #[unsafe(method_family = none)]
930        pub fn tileHeight(&self) -> NSUInteger;
931
932        /// Setter for [`tileHeight`][Self::tileHeight].
933        #[unsafe(method(setTileHeight:))]
934        #[unsafe(method_family = none)]
935        pub fn setTileHeight(&self, tile_height: NSUInteger);
936
937        /// The raster sample count for the render pass when no attachments are given.
938        #[unsafe(method(defaultRasterSampleCount))]
939        #[unsafe(method_family = none)]
940        pub fn defaultRasterSampleCount(&self) -> NSUInteger;
941
942        /// Setter for [`defaultRasterSampleCount`][Self::defaultRasterSampleCount].
943        #[unsafe(method(setDefaultRasterSampleCount:))]
944        #[unsafe(method_family = none)]
945        pub fn setDefaultRasterSampleCount(&self, default_raster_sample_count: NSUInteger);
946
947        /// The width in pixels to constrain the render target to.
948        ///
949        /// Defaults to 0. If non-zero the value must be smaller than or equal to the minimum width of all attachments.
950        #[unsafe(method(renderTargetWidth))]
951        #[unsafe(method_family = none)]
952        pub fn renderTargetWidth(&self) -> NSUInteger;
953
954        /// Setter for [`renderTargetWidth`][Self::renderTargetWidth].
955        #[unsafe(method(setRenderTargetWidth:))]
956        #[unsafe(method_family = none)]
957        pub fn setRenderTargetWidth(&self, render_target_width: NSUInteger);
958
959        /// The height in pixels to constrain the render target to.
960        ///
961        /// Defaults to 0. If non-zero the value must be smaller than or equal to the minimum height of all attachments.
962        #[unsafe(method(renderTargetHeight))]
963        #[unsafe(method_family = none)]
964        pub fn renderTargetHeight(&self) -> NSUInteger;
965
966        /// Setter for [`renderTargetHeight`][Self::renderTargetHeight].
967        #[unsafe(method(setRenderTargetHeight:))]
968        #[unsafe(method_family = none)]
969        pub fn setRenderTargetHeight(&self, render_target_height: NSUInteger);
970
971        #[cfg(feature = "MTLTypes")]
972        /// Configure the custom sample positions, to be used in MSAA rendering (i.e. when sample count > 1).
973        ///
974        /// Parameter `positions`: The source array for custom sample position data.
975        ///
976        /// Parameter `count`: Specifies the length of the positions array, and must be a valid sample count or 0 (to disable custom sample positions).
977        ///
978        /// # Safety
979        ///
980        /// - `positions` must be a valid pointer or null.
981        /// - `count` might not be bounds-checked.
982        #[unsafe(method(setSamplePositions:count:))]
983        #[unsafe(method_family = none)]
984        pub unsafe fn setSamplePositions_count(
985            &self,
986            positions: *const MTLSamplePosition,
987            count: NSUInteger,
988        );
989
990        #[cfg(feature = "MTLTypes")]
991        /// Retrieve the previously configured custom sample positions. The positions input array will only be modified when count specifies a length sufficient for the number of previously configured positions.
992        ///
993        /// Parameter `positions`: The destination array for custom sample position data.
994        ///
995        /// Parameter `count`: Specifies the length of the positions array, which must be large enough to hold all configured sample positions.
996        ///
997        /// Returns: The number of previously configured custom sample positions.
998        ///
999        /// # Safety
1000        ///
1001        /// - `positions` must be a valid pointer or null.
1002        /// - `count` might not be bounds-checked.
1003        #[unsafe(method(getSamplePositions:count:))]
1004        #[unsafe(method_family = none)]
1005        pub unsafe fn getSamplePositions_count(
1006            &self,
1007            positions: *mut MTLSamplePosition,
1008            count: NSUInteger,
1009        ) -> NSUInteger;
1010
1011        #[cfg(feature = "MTLRasterizationRate")]
1012        /// The variable rasterization rate map to use when rendering this pass, or nil to not use variable rasterization rate.
1013        ///
1014        /// The default value is nil. Enabling variable rasterization rate allows for decreasing the rasterization rate in unimportant regions of screen space.
1015        #[unsafe(method(rasterizationRateMap))]
1016        #[unsafe(method_family = none)]
1017        pub fn rasterizationRateMap(
1018            &self,
1019        ) -> Option<Retained<ProtocolObject<dyn MTLRasterizationRateMap>>>;
1020
1021        #[cfg(feature = "MTLRasterizationRate")]
1022        /// Setter for [`rasterizationRateMap`][Self::rasterizationRateMap].
1023        #[unsafe(method(setRasterizationRateMap:))]
1024        #[unsafe(method_family = none)]
1025        pub fn setRasterizationRateMap(
1026            &self,
1027            rasterization_rate_map: Option<&ProtocolObject<dyn MTLRasterizationRateMap>>,
1028        );
1029
1030        /// An array of sample buffers and associated sample indices.
1031        #[unsafe(method(sampleBufferAttachments))]
1032        #[unsafe(method_family = none)]
1033        pub fn sampleBufferAttachments(
1034            &self,
1035        ) -> Retained<MTLRenderPassSampleBufferAttachmentDescriptorArray>;
1036
1037        /// Specifies if Metal accumulates visibility results between render encoders or resets them.
1038        #[unsafe(method(visibilityResultType))]
1039        #[unsafe(method_family = none)]
1040        pub fn visibilityResultType(&self) -> MTLVisibilityResultType;
1041
1042        /// Setter for [`visibilityResultType`][Self::visibilityResultType].
1043        #[unsafe(method(setVisibilityResultType:))]
1044        #[unsafe(method_family = none)]
1045        pub fn setVisibilityResultType(&self, visibility_result_type: MTLVisibilityResultType);
1046
1047        /// Specifies if the render pass should support color attachment mapping.
1048        #[unsafe(method(supportColorAttachmentMapping))]
1049        #[unsafe(method_family = none)]
1050        pub fn supportColorAttachmentMapping(&self) -> bool;
1051
1052        /// Setter for [`supportColorAttachmentMapping`][Self::supportColorAttachmentMapping].
1053        #[unsafe(method(setSupportColorAttachmentMapping:))]
1054        #[unsafe(method_family = none)]
1055        pub fn setSupportColorAttachmentMapping(&self, support_color_attachment_mapping: bool);
1056    );
1057}
1058
1059/// Methods declared on superclass `NSObject`.
1060impl MTLRenderPassDescriptor {
1061    extern_methods!(
1062        #[unsafe(method(init))]
1063        #[unsafe(method_family = init)]
1064        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1065
1066        #[unsafe(method(new))]
1067        #[unsafe(method_family = new)]
1068        pub fn new() -> Retained<Self>;
1069    );
1070}
1071
1072impl DefaultRetained for MTLRenderPassDescriptor {
1073    #[inline]
1074    fn default_retained() -> Retained<Self> {
1075        Self::new()
1076    }
1077}
1078
1079impl MTLClearColor {
1080    // TODO: pub fn MTLClearColorMake(red: c_double,green: c_double,blue: c_double,alpha: c_double,) -> MTLClearColor;
1081}