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
319
320
321
322
323
324
325
326
327
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
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!(
#[cfg(feature = "MTLRenderPass")]
/// Accesses the array of state information for render attachments that store color data.
#[unsafe(method(colorAttachments))]
#[unsafe(method_family = none)]
pub fn colorAttachments(&self) -> Retained<MTLRenderPassColorAttachmentDescriptorArray>;
#[cfg(feature = "MTLRenderPass")]
/// Accesses state information for a render attachment that stores depth data.
#[unsafe(method(depthAttachment))]
#[unsafe(method_family = none)]
pub fn depthAttachment(&self) -> Retained<MTLRenderPassDepthAttachmentDescriptor>;
#[cfg(feature = "MTLRenderPass")]
/// Setter for [`depthAttachment`][Self::depthAttachment].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setDepthAttachment:))]
#[unsafe(method_family = none)]
pub fn setDepthAttachment(
&self,
depth_attachment: Option<&MTLRenderPassDepthAttachmentDescriptor>,
);
#[cfg(feature = "MTLRenderPass")]
/// Accesses state information for a render attachment that stores stencil data.
#[unsafe(method(stencilAttachment))]
#[unsafe(method_family = none)]
pub fn stencilAttachment(&self) -> Retained<MTLRenderPassStencilAttachmentDescriptor>;
#[cfg(feature = "MTLRenderPass")]
/// Setter for [`stencilAttachment`][Self::stencilAttachment].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setStencilAttachment:))]
#[unsafe(method_family = none)]
pub fn setStencilAttachment(
&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 renderTargetArrayLength(&self) -> NSUInteger;
/// Setter for [`renderTargetArrayLength`][Self::renderTargetArrayLength].
#[unsafe(method(setRenderTargetArrayLength:))]
#[unsafe(method_family = none)]
pub fn setRenderTargetArrayLength(&self, render_target_array_length: NSUInteger);
/// 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 imageblockSampleLength(&self) -> NSUInteger;
/// Setter for [`imageblockSampleLength`][Self::imageblockSampleLength].
#[unsafe(method(setImageblockSampleLength:))]
#[unsafe(method_family = none)]
pub fn setImageblockSampleLength(&self, imageblock_sample_length: NSUInteger);
/// 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 threadgroupMemoryLength(&self) -> NSUInteger;
/// Setter for [`threadgroupMemoryLength`][Self::threadgroupMemoryLength].
#[unsafe(method(setThreadgroupMemoryLength:))]
#[unsafe(method_family = none)]
pub fn setThreadgroupMemoryLength(&self, threadgroup_memory_length: NSUInteger);
/// 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 tileWidth(&self) -> NSUInteger;
/// Setter for [`tileWidth`][Self::tileWidth].
#[unsafe(method(setTileWidth:))]
#[unsafe(method_family = none)]
pub fn setTileWidth(&self, tile_width: NSUInteger);
/// 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 tileHeight(&self) -> NSUInteger;
/// Setter for [`tileHeight`][Self::tileHeight].
#[unsafe(method(setTileHeight:))]
#[unsafe(method_family = none)]
pub fn setTileHeight(&self, tile_height: NSUInteger);
/// Sets the default raster sample count for the render pass when it references no attachments.
#[unsafe(method(defaultRasterSampleCount))]
#[unsafe(method_family = none)]
pub fn defaultRasterSampleCount(&self) -> NSUInteger;
/// Setter for [`defaultRasterSampleCount`][Self::defaultRasterSampleCount].
///
/// # Safety
///
/// This might not be bounds-checked.
#[unsafe(method(setDefaultRasterSampleCount:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultRasterSampleCount(&self, default_raster_sample_count: NSUInteger);
/// 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 renderTargetWidth(&self) -> NSUInteger;
/// Setter for [`renderTargetWidth`][Self::renderTargetWidth].
#[unsafe(method(setRenderTargetWidth:))]
#[unsafe(method_family = none)]
pub fn setRenderTargetWidth(&self, render_target_width: NSUInteger);
/// 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 renderTargetHeight(&self) -> NSUInteger;
/// Setter for [`renderTargetHeight`][Self::renderTargetHeight].
#[unsafe(method(setRenderTargetHeight:))]
#[unsafe(method_family = none)]
pub fn setRenderTargetHeight(&self, render_target_height: NSUInteger);
#[cfg(feature = "MTLRasterizationRate")]
/// 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 rasterizationRateMap(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLRasterizationRateMap>>>;
#[cfg(feature = "MTLRasterizationRate")]
/// Setter for [`rasterizationRateMap`][Self::rasterizationRateMap].
#[unsafe(method(setRasterizationRateMap:))]
#[unsafe(method_family = none)]
pub fn setRasterizationRateMap(
&self,
rasterization_rate_map: Option<&ProtocolObject<dyn MTLRasterizationRateMap>>,
);
#[cfg(all(
feature = "MTLAllocation",
feature = "MTLBuffer",
feature = "MTLResource"
))]
/// 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 visibilityResultBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
#[cfg(all(
feature = "MTLAllocation",
feature = "MTLBuffer",
feature = "MTLResource"
))]
/// Setter for [`visibilityResultBuffer`][Self::visibilityResultBuffer].
///
/// # Safety
///
/// - `visibility_result_buffer` may need to be synchronized.
/// - `visibility_result_buffer` may be unretained, you must ensure it is kept alive while in use.
/// - `visibility_result_buffer` contents should be of the correct type.
#[unsafe(method(setVisibilityResultBuffer:))]
#[unsafe(method_family = none)]
pub unsafe fn setVisibilityResultBuffer(
&self,
visibility_result_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
);
#[cfg(feature = "MTLRenderPass")]
/// Determines if Metal accumulates visibility results between render encoders or resets them.
#[unsafe(method(visibilityResultType))]
#[unsafe(method_family = none)]
pub fn visibilityResultType(&self) -> MTLVisibilityResultType;
#[cfg(feature = "MTLRenderPass")]
/// Setter for [`visibilityResultType`][Self::visibilityResultType].
#[unsafe(method(setVisibilityResultType:))]
#[unsafe(method_family = none)]
pub fn setVisibilityResultType(&self, visibility_result_type: MTLVisibilityResultType);
#[cfg(feature = "MTLTypes")]
/// 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.
/// - `count` might not be bounds-checked.
#[unsafe(method(setSamplePositions:count:))]
#[unsafe(method_family = none)]
pub unsafe fn setSamplePositions_count(
&self,
positions: *const MTLSamplePosition,
count: NSUInteger,
);
#[cfg(feature = "MTLTypes")]
/// 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.
/// - `count` might not be bounds-checked.
#[unsafe(method(getSamplePositions:count:))]
#[unsafe(method_family = none)]
pub unsafe fn getSamplePositions_count(
&self,
positions: *mut MTLSamplePosition,
count: NSUInteger,
) -> NSUInteger;
/// Controls if the render pass supports color attachment mapping.
#[unsafe(method(supportColorAttachmentMapping))]
#[unsafe(method_family = none)]
pub fn supportColorAttachmentMapping(&self) -> bool;
/// Setter for [`supportColorAttachmentMapping`][Self::supportColorAttachmentMapping].
#[unsafe(method(setSupportColorAttachmentMapping:))]
#[unsafe(method_family = none)]
pub fn setSupportColorAttachmentMapping(&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>;
);
}
impl DefaultRetained for MTL4RenderPassDescriptor {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}