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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::{
extern_class, extern_conformance, extern_methods,
rc::{Allocated, Retained},
runtime::ProtocolObject,
};
use objc2_foundation::{CopyingHelper, NSCopying, NSObject, NSObjectProtocol};
use crate::*;
extern_class!(
/// Describes a render pass.
///
/// You use render pass descriptors to create instances of ``MTL4RenderCommandEncoder`` and encode draw
/// commands into instances of ``MTL4CommandBuffer``.
///
/// To create render command encoders, you typically call ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:``.
/// The ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:options:`` variant of this method allows you to specify
/// additional options to encode a render pass in parallel from multiple CPU cores by creating *suspending* and *resuming*
/// render passes.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4renderpassdescriptor?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4RenderPassDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTL4RenderPassDescriptor {}
);
unsafe impl CopyingHelper for MTL4RenderPassDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4RenderPassDescriptor {}
);
impl MTL4RenderPassDescriptor {
extern_methods!(
/// Accesses the array of state information for render attachments that store color data.
#[unsafe(method(colorAttachments))]
#[unsafe(method_family = none)]
pub fn color_attachments(&self) -> Retained<MTLRenderPassColorAttachmentDescriptorArray>;
/// Accesses state information for a render attachment that stores depth data.
#[unsafe(method(depthAttachment))]
#[unsafe(method_family = none)]
pub fn depth_attachment(&self) -> Retained<MTLRenderPassDepthAttachmentDescriptor>;
/// Setter for [`depthAttachment`][Self::depthAttachment].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setDepthAttachment:))]
#[unsafe(method_family = none)]
pub fn set_depth_attachment(
&self,
depth_attachment: Option<&MTLRenderPassDepthAttachmentDescriptor>,
);
/// Accesses state information for a render attachment that stores stencil data.
#[unsafe(method(stencilAttachment))]
#[unsafe(method_family = none)]
pub fn stencil_attachment(&self) -> Retained<MTLRenderPassStencilAttachmentDescriptor>;
/// Setter for [`stencilAttachment`][Self::stencilAttachment].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setStencilAttachment:))]
#[unsafe(method_family = none)]
pub fn set_stencil_attachment(
&self,
stencil_attachment: Option<&MTLRenderPassStencilAttachmentDescriptor>,
);
/// Assigns the number of layers that all attachments this descriptor references have.
#[unsafe(method(renderTargetArrayLength))]
#[unsafe(method_family = none)]
pub fn render_target_array_length(&self) -> usize;
/// Setter for [`renderTargetArrayLength`][Self::renderTargetArrayLength].
#[unsafe(method(setRenderTargetArrayLength:))]
#[unsafe(method_family = none)]
pub fn set_render_target_array_length(
&self,
render_target_array_length: usize,
);
/// Assigns the per-sample size, in bytes, of the largest explicit imageblock layout in the render pass.
#[unsafe(method(imageblockSampleLength))]
#[unsafe(method_family = none)]
pub fn imageblock_sample_length(&self) -> usize;
/// Setter for [`imageblockSampleLength`][Self::imageblockSampleLength].
#[unsafe(method(setImageblockSampleLength:))]
#[unsafe(method_family = none)]
pub fn set_imageblock_sample_length(
&self,
imageblock_sample_length: usize,
);
/// Assigns the per-tile size, in bytes, of the persistent threadgroup memory allocation of this render pass.
#[unsafe(method(threadgroupMemoryLength))]
#[unsafe(method_family = none)]
pub fn threadgroup_memory_length(&self) -> usize;
/// Setter for [`threadgroupMemoryLength`][Self::threadgroupMemoryLength].
#[unsafe(method(setThreadgroupMemoryLength:))]
#[unsafe(method_family = none)]
pub fn set_threadgroup_memory_length(
&self,
threadgroup_memory_length: usize,
);
/// The width of the tiles, in pixels, a render pass you create with this descriptor applies to its attachments.
///
/// For tile-based rendering, Metal divides each render attachment into smaller regions, or _tiles_.
/// The property's default is `0`, which tells Metal to select a size that fits in tile memory.
///
/// See
/// <doc
/// :tailor-your-apps-for-apple-gpus-and-tile-based-deferred-rendering>
/// for more information about tiles, tile memory, and deferred rendering.
#[unsafe(method(tileWidth))]
#[unsafe(method_family = none)]
pub fn tile_width(&self) -> usize;
/// Setter for [`tileWidth`][Self::tileWidth].
#[unsafe(method(setTileWidth:))]
#[unsafe(method_family = none)]
pub fn set_tile_width(
&self,
tile_width: usize,
);
/// The height of the tiles, in pixels, a render pass you create with this descriptor applies to its attachments.
///
/// For tile-based rendering, Metal divides each render attachment into smaller regions, or _tiles_.
/// The property's default is `0`, which tells Metal to select a size that fits in tile memory.
///
/// See
/// <doc
/// :tailor-your-apps-for-apple-gpus-and-tile-based-deferred-rendering>
/// for more information about tiles, tile memory, and deferred rendering.
#[unsafe(method(tileHeight))]
#[unsafe(method_family = none)]
pub fn tile_height(&self) -> usize;
/// Setter for [`tileHeight`][Self::tileHeight].
#[unsafe(method(setTileHeight:))]
#[unsafe(method_family = none)]
pub fn set_tile_height(
&self,
tile_height: usize,
);
/// Sets the default raster sample count for the render pass when it references no attachments.
#[unsafe(method(defaultRasterSampleCount))]
#[unsafe(method_family = none)]
pub fn default_raster_sample_count(&self) -> usize;
/// Setter for [`defaultRasterSampleCount`][Self::defaultRasterSampleCount].
#[unsafe(method(setDefaultRasterSampleCount:))]
#[unsafe(method_family = none)]
pub fn set_default_raster_sample_count(
&self,
default_raster_sample_count: usize,
);
/// Sets the width, in pixels, to which Metal constrains the render target.
///
/// When this value is non-zero, you need to assign it to be smaller than or equal to the minimum width of all attachments.
///
/// The default value of this property is `0`.
#[unsafe(method(renderTargetWidth))]
#[unsafe(method_family = none)]
pub fn render_target_width(&self) -> usize;
/// Setter for [`renderTargetWidth`][Self::renderTargetWidth].
#[unsafe(method(setRenderTargetWidth:))]
#[unsafe(method_family = none)]
pub fn set_render_target_width(
&self,
render_target_width: usize,
);
/// Sets the height, in pixels, to which Metal constrains the render target.
///
/// When this value is non-zero, you need to assign it to be smaller than or equal to the minimum height of all attachments.
///
/// The default value of this property is `0`.
#[unsafe(method(renderTargetHeight))]
#[unsafe(method_family = none)]
pub fn render_target_height(&self) -> usize;
/// Setter for [`renderTargetHeight`][Self::renderTargetHeight].
#[unsafe(method(setRenderTargetHeight:))]
#[unsafe(method_family = none)]
pub fn set_render_target_height(
&self,
render_target_height: usize,
);
/// Assigns an optional variable rasterization rate map that Metal uses in the render pass.
///
/// Enabling variable rasterization rate allows Metal to decrease the rasterization rate, typically in unimportant
/// regions of color attachments, to accelerate processing.
///
/// When set to `nil`, the default, Metal doesn't use variable rasterization rate.
#[unsafe(method(rasterizationRateMap))]
#[unsafe(method_family = none)]
pub fn rasterization_rate_map(&self) -> Option<Retained<ProtocolObject<dyn MTLRasterizationRateMap>>>;
/// Setter for [`rasterizationRateMap`][Self::rasterizationRateMap].
#[unsafe(method(setRasterizationRateMap:))]
#[unsafe(method_family = none)]
pub fn set_rasterization_rate_map(
&self,
rasterization_rate_map: Option<&ProtocolObject<dyn MTLRasterizationRateMap>>,
);
/// Configures a buffer into which Metal writes counts of fragments (pixels) passing the depth and stencil tests.
#[unsafe(method(visibilityResultBuffer))]
#[unsafe(method_family = none)]
pub fn visibility_result_buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
/// Setter for [`visibilityResultBuffer`][Self::visibilityResultBuffer].
#[unsafe(method(setVisibilityResultBuffer:))]
#[unsafe(method_family = none)]
pub fn set_visibility_result_buffer(
&self,
visibility_result_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
);
/// Determines if Metal accumulates visibility results between render encoders or resets them.
#[unsafe(method(visibilityResultType))]
#[unsafe(method_family = none)]
pub fn visibility_result_type(&self) -> MTLVisibilityResultType;
/// Setter for [`visibilityResultType`][Self::visibilityResultType].
#[unsafe(method(setVisibilityResultType:))]
#[unsafe(method_family = none)]
pub fn set_visibility_result_type(
&self,
visibility_result_type: MTLVisibilityResultType,
);
/// Configures the custom sample positions to use in MSAA rendering.
///
/// - Parameters:
/// - positions: Array of ``MTLSamplePosition`` instances.
/// - count: Number of ``MTLSamplePosition`` instances in the array. This value
/// needs to be a valid sample count, or `0` to disable custom sample positions.
///
/// # Safety
///
/// `positions` must be a valid pointer or null.
#[unsafe(method(setSamplePositions:count:))]
#[unsafe(method_family = none)]
pub fn set_sample_positions_count(
&self,
positions: *const MTLSamplePosition,
count: usize,
);
/// Retrieves the previously-configured custom sample positions.
///
/// This method stores the app's last set custom sample positions into an output array. Metal only modifies the array
/// when the `count` parameter consists of a length sufficient to store the number of sample positions.
///
/// - Parameters:
/// - positions: The destination array where Metal stores ``MTLSamplePosition`` instances.
/// - count: Number of ``MTLSamplePosition`` instances in the array. This array
/// needs to be large enough to store all sample positions.
///
/// - Returns: The number of previously-configured custom sample positions.
///
/// # Safety
///
/// `positions` must be a valid pointer or null.
#[unsafe(method(getSamplePositions:count:))]
#[unsafe(method_family = none)]
pub fn get_sample_positions_count(
&self,
positions: *mut MTLSamplePosition,
count: usize,
) -> usize;
/// Controls if the render pass supports color attachment mapping.
#[unsafe(method(supportColorAttachmentMapping))]
#[unsafe(method_family = none)]
pub fn support_color_attachment_mapping(&self) -> bool;
/// Setter for [`supportColorAttachmentMapping`][Self::supportColorAttachmentMapping].
#[unsafe(method(setSupportColorAttachmentMapping:))]
#[unsafe(method_family = none)]
pub fn set_support_color_attachment_mapping(
&self,
support_color_attachment_mapping: bool,
);
);
}
/// Methods declared on superclass `NSObject`.
impl MTL4RenderPassDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}