1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLSamplerMinMagFilter(pub NSUInteger);
impl MTLSamplerMinMagFilter {
    #[doc(alias = "MTLSamplerMinMagFilterNearest")]
    pub const Nearest: Self = Self(0);
    #[doc(alias = "MTLSamplerMinMagFilterLinear")]
    pub const Linear: Self = Self(1);
}

unsafe impl Encode for MTLSamplerMinMagFilter {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLSamplerMinMagFilter {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLSamplerMipFilter(pub NSUInteger);
impl MTLSamplerMipFilter {
    #[doc(alias = "MTLSamplerMipFilterNotMipmapped")]
    pub const NotMipmapped: Self = Self(0);
    #[doc(alias = "MTLSamplerMipFilterNearest")]
    pub const Nearest: Self = Self(1);
    #[doc(alias = "MTLSamplerMipFilterLinear")]
    pub const Linear: Self = Self(2);
}

unsafe impl Encode for MTLSamplerMipFilter {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLSamplerMipFilter {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLSamplerAddressMode(pub NSUInteger);
impl MTLSamplerAddressMode {
    #[doc(alias = "MTLSamplerAddressModeClampToEdge")]
    pub const ClampToEdge: Self = Self(0);
    #[doc(alias = "MTLSamplerAddressModeMirrorClampToEdge")]
    pub const MirrorClampToEdge: Self = Self(1);
    #[doc(alias = "MTLSamplerAddressModeRepeat")]
    pub const Repeat: Self = Self(2);
    #[doc(alias = "MTLSamplerAddressModeMirrorRepeat")]
    pub const MirrorRepeat: Self = Self(3);
    #[doc(alias = "MTLSamplerAddressModeClampToZero")]
    pub const ClampToZero: Self = Self(4);
    #[doc(alias = "MTLSamplerAddressModeClampToBorderColor")]
    pub const ClampToBorderColor: Self = Self(5);
}

unsafe impl Encode for MTLSamplerAddressMode {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLSamplerAddressMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLSamplerBorderColor(pub NSUInteger);
impl MTLSamplerBorderColor {
    #[doc(alias = "MTLSamplerBorderColorTransparentBlack")]
    pub const TransparentBlack: Self = Self(0);
    #[doc(alias = "MTLSamplerBorderColorOpaqueBlack")]
    pub const OpaqueBlack: Self = Self(1);
    #[doc(alias = "MTLSamplerBorderColorOpaqueWhite")]
    pub const OpaqueWhite: Self = Self(2);
}

unsafe impl Encode for MTLSamplerBorderColor {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLSamplerBorderColor {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLSamplerDescriptor;

    unsafe impl ClassType for MTLSamplerDescriptor {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSCopying for MTLSamplerDescriptor {}

unsafe impl NSObjectProtocol for MTLSamplerDescriptor {}

extern_methods!(
    unsafe impl MTLSamplerDescriptor {
        #[method(minFilter)]
        pub fn minFilter(&self) -> MTLSamplerMinMagFilter;

        #[method(setMinFilter:)]
        pub fn setMinFilter(&self, min_filter: MTLSamplerMinMagFilter);

        #[method(magFilter)]
        pub fn magFilter(&self) -> MTLSamplerMinMagFilter;

        #[method(setMagFilter:)]
        pub fn setMagFilter(&self, mag_filter: MTLSamplerMinMagFilter);

        #[method(mipFilter)]
        pub fn mipFilter(&self) -> MTLSamplerMipFilter;

        #[method(setMipFilter:)]
        pub fn setMipFilter(&self, mip_filter: MTLSamplerMipFilter);

        #[method(maxAnisotropy)]
        pub fn maxAnisotropy(&self) -> NSUInteger;

        #[method(setMaxAnisotropy:)]
        pub fn setMaxAnisotropy(&self, max_anisotropy: NSUInteger);

        #[method(sAddressMode)]
        pub fn sAddressMode(&self) -> MTLSamplerAddressMode;

        #[method(setSAddressMode:)]
        pub fn setSAddressMode(&self, s_address_mode: MTLSamplerAddressMode);

        #[method(tAddressMode)]
        pub fn tAddressMode(&self) -> MTLSamplerAddressMode;

        #[method(setTAddressMode:)]
        pub fn setTAddressMode(&self, t_address_mode: MTLSamplerAddressMode);

        #[method(rAddressMode)]
        pub fn rAddressMode(&self) -> MTLSamplerAddressMode;

        #[method(setRAddressMode:)]
        pub fn setRAddressMode(&self, r_address_mode: MTLSamplerAddressMode);

        #[method(borderColor)]
        pub fn borderColor(&self) -> MTLSamplerBorderColor;

        #[method(setBorderColor:)]
        pub fn setBorderColor(&self, border_color: MTLSamplerBorderColor);

        #[method(normalizedCoordinates)]
        pub fn normalizedCoordinates(&self) -> bool;

        #[method(setNormalizedCoordinates:)]
        pub fn setNormalizedCoordinates(&self, normalized_coordinates: bool);

        #[method(lodMinClamp)]
        pub fn lodMinClamp(&self) -> c_float;

        #[method(setLodMinClamp:)]
        pub fn setLodMinClamp(&self, lod_min_clamp: c_float);

        #[method(lodMaxClamp)]
        pub fn lodMaxClamp(&self) -> c_float;

        #[method(setLodMaxClamp:)]
        pub fn setLodMaxClamp(&self, lod_max_clamp: c_float);

        #[method(lodAverage)]
        pub fn lodAverage(&self) -> bool;

        #[method(setLodAverage:)]
        pub fn setLodAverage(&self, lod_average: bool);

        #[cfg(feature = "MTLDepthStencil")]
        #[method(compareFunction)]
        pub fn compareFunction(&self) -> MTLCompareFunction;

        #[cfg(feature = "MTLDepthStencil")]
        #[method(setCompareFunction:)]
        pub fn setCompareFunction(&self, compare_function: MTLCompareFunction);

        #[method(supportArgumentBuffers)]
        pub fn supportArgumentBuffers(&self) -> bool;

        #[method(setSupportArgumentBuffers:)]
        pub fn setSupportArgumentBuffers(&self, support_argument_buffers: bool);

        #[method_id(@__retain_semantics Other label)]
        pub fn label(&self) -> Option<Retained<NSString>>;

        #[method(setLabel:)]
        pub fn setLabel(&self, label: Option<&NSString>);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl MTLSamplerDescriptor {
        #[method_id(@__retain_semantics Init init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub fn new() -> Retained<Self>;
    }
);

impl DefaultRetained for MTLSamplerDescriptor {
    #[inline]
    fn default_id() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    pub unsafe trait MTLSamplerState: NSObjectProtocol + IsRetainable {
        #[method_id(@__retain_semantics Other label)]
        fn label(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "MTLDevice")]
        #[method_id(@__retain_semantics Other device)]
        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;

        #[cfg(feature = "MTLTypes")]
        #[method(gpuResourceID)]
        unsafe fn gpuResourceID(&self) -> MTLResourceID;
    }

    unsafe impl ProtocolType for dyn MTLSamplerState {}
);