objc2_metal/generated/
MTLDepthStencil.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/mtlcomparefunction?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct MTLCompareFunction(pub NSUInteger);
15impl MTLCompareFunction {
16    #[doc(alias = "MTLCompareFunctionNever")]
17    pub const Never: Self = Self(0);
18    #[doc(alias = "MTLCompareFunctionLess")]
19    pub const Less: Self = Self(1);
20    #[doc(alias = "MTLCompareFunctionEqual")]
21    pub const Equal: Self = Self(2);
22    #[doc(alias = "MTLCompareFunctionLessEqual")]
23    pub const LessEqual: Self = Self(3);
24    #[doc(alias = "MTLCompareFunctionGreater")]
25    pub const Greater: Self = Self(4);
26    #[doc(alias = "MTLCompareFunctionNotEqual")]
27    pub const NotEqual: Self = Self(5);
28    #[doc(alias = "MTLCompareFunctionGreaterEqual")]
29    pub const GreaterEqual: Self = Self(6);
30    #[doc(alias = "MTLCompareFunctionAlways")]
31    pub const Always: Self = Self(7);
32}
33
34unsafe impl Encode for MTLCompareFunction {
35    const ENCODING: Encoding = NSUInteger::ENCODING;
36}
37
38unsafe impl RefEncode for MTLCompareFunction {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstenciloperation?language=objc)
43// NS_ENUM
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct MTLStencilOperation(pub NSUInteger);
47impl MTLStencilOperation {
48    #[doc(alias = "MTLStencilOperationKeep")]
49    pub const Keep: Self = Self(0);
50    #[doc(alias = "MTLStencilOperationZero")]
51    pub const Zero: Self = Self(1);
52    #[doc(alias = "MTLStencilOperationReplace")]
53    pub const Replace: Self = Self(2);
54    #[doc(alias = "MTLStencilOperationIncrementClamp")]
55    pub const IncrementClamp: Self = Self(3);
56    #[doc(alias = "MTLStencilOperationDecrementClamp")]
57    pub const DecrementClamp: Self = Self(4);
58    #[doc(alias = "MTLStencilOperationInvert")]
59    pub const Invert: Self = Self(5);
60    #[doc(alias = "MTLStencilOperationIncrementWrap")]
61    pub const IncrementWrap: Self = Self(6);
62    #[doc(alias = "MTLStencilOperationDecrementWrap")]
63    pub const DecrementWrap: Self = Self(7);
64}
65
66unsafe impl Encode for MTLStencilOperation {
67    const ENCODING: Encoding = NSUInteger::ENCODING;
68}
69
70unsafe impl RefEncode for MTLStencilOperation {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74extern_class!(
75    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlstencildescriptor?language=objc)
76    #[unsafe(super(NSObject))]
77    #[derive(Debug, PartialEq, Eq, Hash)]
78    pub struct MTLStencilDescriptor;
79);
80
81extern_conformance!(
82    unsafe impl NSCopying for MTLStencilDescriptor {}
83);
84
85unsafe impl CopyingHelper for MTLStencilDescriptor {
86    type Result = Self;
87}
88
89extern_conformance!(
90    unsafe impl NSObjectProtocol for MTLStencilDescriptor {}
91);
92
93impl MTLStencilDescriptor {
94    extern_methods!(
95        #[unsafe(method(stencilCompareFunction))]
96        #[unsafe(method_family = none)]
97        pub fn stencilCompareFunction(&self) -> MTLCompareFunction;
98
99        /// Setter for [`stencilCompareFunction`][Self::stencilCompareFunction].
100        #[unsafe(method(setStencilCompareFunction:))]
101        #[unsafe(method_family = none)]
102        pub fn setStencilCompareFunction(&self, stencil_compare_function: MTLCompareFunction);
103
104        /// Stencil is tested first.  stencilFailureOperation declares how the stencil buffer is updated when the stencil test fails.
105        #[unsafe(method(stencilFailureOperation))]
106        #[unsafe(method_family = none)]
107        pub fn stencilFailureOperation(&self) -> MTLStencilOperation;
108
109        /// Setter for [`stencilFailureOperation`][Self::stencilFailureOperation].
110        #[unsafe(method(setStencilFailureOperation:))]
111        #[unsafe(method_family = none)]
112        pub fn setStencilFailureOperation(&self, stencil_failure_operation: MTLStencilOperation);
113
114        /// If stencil passes, depth is tested next.  Declare what happens when the depth test fails.
115        #[unsafe(method(depthFailureOperation))]
116        #[unsafe(method_family = none)]
117        pub fn depthFailureOperation(&self) -> MTLStencilOperation;
118
119        /// Setter for [`depthFailureOperation`][Self::depthFailureOperation].
120        #[unsafe(method(setDepthFailureOperation:))]
121        #[unsafe(method_family = none)]
122        pub fn setDepthFailureOperation(&self, depth_failure_operation: MTLStencilOperation);
123
124        /// If both the stencil and depth tests pass, declare how the stencil buffer is updated.
125        #[unsafe(method(depthStencilPassOperation))]
126        #[unsafe(method_family = none)]
127        pub fn depthStencilPassOperation(&self) -> MTLStencilOperation;
128
129        /// Setter for [`depthStencilPassOperation`][Self::depthStencilPassOperation].
130        #[unsafe(method(setDepthStencilPassOperation:))]
131        #[unsafe(method_family = none)]
132        pub fn setDepthStencilPassOperation(
133            &self,
134            depth_stencil_pass_operation: MTLStencilOperation,
135        );
136
137        #[unsafe(method(readMask))]
138        #[unsafe(method_family = none)]
139        pub fn readMask(&self) -> u32;
140
141        /// Setter for [`readMask`][Self::readMask].
142        #[unsafe(method(setReadMask:))]
143        #[unsafe(method_family = none)]
144        pub fn setReadMask(&self, read_mask: u32);
145
146        #[unsafe(method(writeMask))]
147        #[unsafe(method_family = none)]
148        pub fn writeMask(&self) -> u32;
149
150        /// Setter for [`writeMask`][Self::writeMask].
151        #[unsafe(method(setWriteMask:))]
152        #[unsafe(method_family = none)]
153        pub fn setWriteMask(&self, write_mask: u32);
154    );
155}
156
157/// Methods declared on superclass `NSObject`.
158impl MTLStencilDescriptor {
159    extern_methods!(
160        #[unsafe(method(init))]
161        #[unsafe(method_family = init)]
162        pub fn init(this: Allocated<Self>) -> Retained<Self>;
163
164        #[unsafe(method(new))]
165        #[unsafe(method_family = new)]
166        pub fn new() -> Retained<Self>;
167    );
168}
169
170impl DefaultRetained for MTLStencilDescriptor {
171    #[inline]
172    fn default_retained() -> Retained<Self> {
173        Self::new()
174    }
175}
176
177extern_class!(
178    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtldepthstencildescriptor?language=objc)
179    #[unsafe(super(NSObject))]
180    #[derive(Debug, PartialEq, Eq, Hash)]
181    pub struct MTLDepthStencilDescriptor;
182);
183
184extern_conformance!(
185    unsafe impl NSCopying for MTLDepthStencilDescriptor {}
186);
187
188unsafe impl CopyingHelper for MTLDepthStencilDescriptor {
189    type Result = Self;
190}
191
192extern_conformance!(
193    unsafe impl NSObjectProtocol for MTLDepthStencilDescriptor {}
194);
195
196impl MTLDepthStencilDescriptor {
197    extern_methods!(
198        #[unsafe(method(depthCompareFunction))]
199        #[unsafe(method_family = none)]
200        pub fn depthCompareFunction(&self) -> MTLCompareFunction;
201
202        /// Setter for [`depthCompareFunction`][Self::depthCompareFunction].
203        #[unsafe(method(setDepthCompareFunction:))]
204        #[unsafe(method_family = none)]
205        pub fn setDepthCompareFunction(&self, depth_compare_function: MTLCompareFunction);
206
207        #[unsafe(method(isDepthWriteEnabled))]
208        #[unsafe(method_family = none)]
209        pub fn isDepthWriteEnabled(&self) -> bool;
210
211        /// Setter for [`isDepthWriteEnabled`][Self::isDepthWriteEnabled].
212        #[unsafe(method(setDepthWriteEnabled:))]
213        #[unsafe(method_family = none)]
214        pub fn setDepthWriteEnabled(&self, depth_write_enabled: bool);
215
216        #[unsafe(method(frontFaceStencil))]
217        #[unsafe(method_family = none)]
218        pub fn frontFaceStencil(&self) -> Retained<MTLStencilDescriptor>;
219
220        /// Setter for [`frontFaceStencil`][Self::frontFaceStencil].
221        ///
222        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
223        #[unsafe(method(setFrontFaceStencil:))]
224        #[unsafe(method_family = none)]
225        pub fn setFrontFaceStencil(&self, front_face_stencil: Option<&MTLStencilDescriptor>);
226
227        #[unsafe(method(backFaceStencil))]
228        #[unsafe(method_family = none)]
229        pub fn backFaceStencil(&self) -> Retained<MTLStencilDescriptor>;
230
231        /// Setter for [`backFaceStencil`][Self::backFaceStencil].
232        ///
233        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
234        #[unsafe(method(setBackFaceStencil:))]
235        #[unsafe(method_family = none)]
236        pub fn setBackFaceStencil(&self, back_face_stencil: Option<&MTLStencilDescriptor>);
237
238        /// A string to help identify the created object.
239        #[unsafe(method(label))]
240        #[unsafe(method_family = none)]
241        pub fn label(&self) -> Option<Retained<NSString>>;
242
243        /// Setter for [`label`][Self::label].
244        ///
245        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
246        #[unsafe(method(setLabel:))]
247        #[unsafe(method_family = none)]
248        pub fn setLabel(&self, label: Option<&NSString>);
249    );
250}
251
252/// Methods declared on superclass `NSObject`.
253impl MTLDepthStencilDescriptor {
254    extern_methods!(
255        #[unsafe(method(init))]
256        #[unsafe(method_family = init)]
257        pub fn init(this: Allocated<Self>) -> Retained<Self>;
258
259        #[unsafe(method(new))]
260        #[unsafe(method_family = new)]
261        pub fn new() -> Retained<Self>;
262    );
263}
264
265impl DefaultRetained for MTLDepthStencilDescriptor {
266    #[inline]
267    fn default_retained() -> Retained<Self> {
268        Self::new()
269    }
270}
271
272extern_protocol!(
273    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtldepthstencilstate?language=objc)
274    pub unsafe trait MTLDepthStencilState: NSObjectProtocol + Send + Sync {
275        /// A string to help identify this object.
276        #[unsafe(method(label))]
277        #[unsafe(method_family = none)]
278        fn label(&self) -> Option<Retained<NSString>>;
279
280        #[cfg(feature = "MTLDevice")]
281        /// The device this resource was created against.  This resource can only be used with this device.
282        #[unsafe(method(device))]
283        #[unsafe(method_family = none)]
284        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
285
286        #[cfg(feature = "MTLTypes")]
287        /// Handle of the GPU resource suitable for storing in an Argument Buffer
288        #[unsafe(method(gpuResourceID))]
289        #[unsafe(method_family = none)]
290        fn gpuResourceID(&self) -> MTLResourceID;
291    }
292);