objc2_metal/generated/
MTL4RenderPass.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
10extern_class!(
11    /// Describes a render pass.
12    ///
13    /// You use render pass descriptors to create instances of ``MTL4RenderCommandEncoder`` and encode draw
14    /// commands into instances of ``MTL4CommandBuffer``.
15    ///
16    /// To create render command encoders, you typically call ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:``.
17    /// The ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:options:`` variant of this method allows you to specify
18    /// additional options to encode a render pass in parallel from multiple CPU cores by creating *suspending* and *resuming*
19    /// render passes.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4renderpassdescriptor?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct MTL4RenderPassDescriptor;
25);
26
27extern_conformance!(
28    unsafe impl NSCopying for MTL4RenderPassDescriptor {}
29);
30
31unsafe impl CopyingHelper for MTL4RenderPassDescriptor {
32    type Result = Self;
33}
34
35extern_conformance!(
36    unsafe impl NSObjectProtocol for MTL4RenderPassDescriptor {}
37);
38
39impl MTL4RenderPassDescriptor {
40    extern_methods!(
41        #[cfg(feature = "MTLRenderPass")]
42        /// Accesses the array of state information for render attachments that store color data.
43        #[unsafe(method(colorAttachments))]
44        #[unsafe(method_family = none)]
45        pub fn colorAttachments(&self) -> Retained<MTLRenderPassColorAttachmentDescriptorArray>;
46
47        #[cfg(feature = "MTLRenderPass")]
48        /// Accesses state information for a render attachment that stores depth data.
49        #[unsafe(method(depthAttachment))]
50        #[unsafe(method_family = none)]
51        pub fn depthAttachment(&self) -> Retained<MTLRenderPassDepthAttachmentDescriptor>;
52
53        #[cfg(feature = "MTLRenderPass")]
54        /// Setter for [`depthAttachment`][Self::depthAttachment].
55        ///
56        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
57        #[unsafe(method(setDepthAttachment:))]
58        #[unsafe(method_family = none)]
59        pub fn setDepthAttachment(
60            &self,
61            depth_attachment: Option<&MTLRenderPassDepthAttachmentDescriptor>,
62        );
63
64        #[cfg(feature = "MTLRenderPass")]
65        /// Accesses state information for a render attachment that stores stencil data.
66        #[unsafe(method(stencilAttachment))]
67        #[unsafe(method_family = none)]
68        pub fn stencilAttachment(&self) -> Retained<MTLRenderPassStencilAttachmentDescriptor>;
69
70        #[cfg(feature = "MTLRenderPass")]
71        /// Setter for [`stencilAttachment`][Self::stencilAttachment].
72        ///
73        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
74        #[unsafe(method(setStencilAttachment:))]
75        #[unsafe(method_family = none)]
76        pub fn setStencilAttachment(
77            &self,
78            stencil_attachment: Option<&MTLRenderPassStencilAttachmentDescriptor>,
79        );
80
81        /// Assigns the number of layers that all attachments this descriptor references have.
82        #[unsafe(method(renderTargetArrayLength))]
83        #[unsafe(method_family = none)]
84        pub fn renderTargetArrayLength(&self) -> NSUInteger;
85
86        /// Setter for [`renderTargetArrayLength`][Self::renderTargetArrayLength].
87        #[unsafe(method(setRenderTargetArrayLength:))]
88        #[unsafe(method_family = none)]
89        pub fn setRenderTargetArrayLength(&self, render_target_array_length: NSUInteger);
90
91        /// Assigns the per-sample size, in bytes, of the largest explicit imageblock layout in the render pass.
92        #[unsafe(method(imageblockSampleLength))]
93        #[unsafe(method_family = none)]
94        pub fn imageblockSampleLength(&self) -> NSUInteger;
95
96        /// Setter for [`imageblockSampleLength`][Self::imageblockSampleLength].
97        #[unsafe(method(setImageblockSampleLength:))]
98        #[unsafe(method_family = none)]
99        pub fn setImageblockSampleLength(&self, imageblock_sample_length: NSUInteger);
100
101        /// Assigns the per-tile size, in bytes, of the persistent threadgroup memory allocation of this render pass.
102        #[unsafe(method(threadgroupMemoryLength))]
103        #[unsafe(method_family = none)]
104        pub fn threadgroupMemoryLength(&self) -> NSUInteger;
105
106        /// Setter for [`threadgroupMemoryLength`][Self::threadgroupMemoryLength].
107        #[unsafe(method(setThreadgroupMemoryLength:))]
108        #[unsafe(method_family = none)]
109        pub fn setThreadgroupMemoryLength(&self, threadgroup_memory_length: NSUInteger);
110
111        /// The width of the tiles, in pixels, a render pass you create with this descriptor applies to its attachments.
112        ///
113        /// For tile-based rendering, Metal divides each render attachment into smaller regions, or _tiles_.
114        /// The property's default is `0`, which tells Metal to select a size that fits in tile memory.
115        ///
116        /// See
117        /// <doc
118        /// :tailor-your-apps-for-apple-gpus-and-tile-based-deferred-rendering>
119        /// for more information about tiles, tile memory, and deferred rendering.
120        #[unsafe(method(tileWidth))]
121        #[unsafe(method_family = none)]
122        pub fn tileWidth(&self) -> NSUInteger;
123
124        /// Setter for [`tileWidth`][Self::tileWidth].
125        #[unsafe(method(setTileWidth:))]
126        #[unsafe(method_family = none)]
127        pub fn setTileWidth(&self, tile_width: NSUInteger);
128
129        /// The height of the tiles, in pixels, a render pass you create with this descriptor applies to its attachments.
130        ///
131        /// For tile-based rendering, Metal divides each render attachment into smaller regions, or _tiles_.
132        /// The property's default is `0`, which tells Metal to select a size that fits in tile memory.
133        ///
134        /// See
135        /// <doc
136        /// :tailor-your-apps-for-apple-gpus-and-tile-based-deferred-rendering>
137        /// for more information about tiles, tile memory, and deferred rendering.
138        #[unsafe(method(tileHeight))]
139        #[unsafe(method_family = none)]
140        pub fn tileHeight(&self) -> NSUInteger;
141
142        /// Setter for [`tileHeight`][Self::tileHeight].
143        #[unsafe(method(setTileHeight:))]
144        #[unsafe(method_family = none)]
145        pub fn setTileHeight(&self, tile_height: NSUInteger);
146
147        /// Sets the default raster sample count for the render pass when it references no attachments.
148        #[unsafe(method(defaultRasterSampleCount))]
149        #[unsafe(method_family = none)]
150        pub fn defaultRasterSampleCount(&self) -> NSUInteger;
151
152        /// Setter for [`defaultRasterSampleCount`][Self::defaultRasterSampleCount].
153        ///
154        /// # Safety
155        ///
156        /// This might not be bounds-checked.
157        #[unsafe(method(setDefaultRasterSampleCount:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setDefaultRasterSampleCount(&self, default_raster_sample_count: NSUInteger);
160
161        /// Sets the width, in pixels, to which Metal constrains the render target.
162        ///
163        /// When this value is non-zero, you need to assign it to be smaller than or equal to the minimum width of all attachments.
164        ///
165        /// The default value of this property is `0`.
166        #[unsafe(method(renderTargetWidth))]
167        #[unsafe(method_family = none)]
168        pub fn renderTargetWidth(&self) -> NSUInteger;
169
170        /// Setter for [`renderTargetWidth`][Self::renderTargetWidth].
171        #[unsafe(method(setRenderTargetWidth:))]
172        #[unsafe(method_family = none)]
173        pub fn setRenderTargetWidth(&self, render_target_width: NSUInteger);
174
175        /// Sets the height, in pixels, to which Metal constrains the render target.
176        ///
177        /// When this value is non-zero, you need to assign it to be smaller than or equal to the minimum height of all attachments.
178        ///
179        /// The default value of this property is `0`.
180        #[unsafe(method(renderTargetHeight))]
181        #[unsafe(method_family = none)]
182        pub fn renderTargetHeight(&self) -> NSUInteger;
183
184        /// Setter for [`renderTargetHeight`][Self::renderTargetHeight].
185        #[unsafe(method(setRenderTargetHeight:))]
186        #[unsafe(method_family = none)]
187        pub fn setRenderTargetHeight(&self, render_target_height: NSUInteger);
188
189        #[cfg(feature = "MTLRasterizationRate")]
190        /// Assigns an optional variable rasterization rate map that Metal uses in the render pass.
191        ///
192        /// Enabling variable rasterization rate allows Metal to decrease the rasterization rate, typically in unimportant
193        /// regions of color attachments, to accelerate processing.
194        ///
195        /// When set to `nil`, the default, Metal doesn't use variable rasterization rate.
196        #[unsafe(method(rasterizationRateMap))]
197        #[unsafe(method_family = none)]
198        pub fn rasterizationRateMap(
199            &self,
200        ) -> Option<Retained<ProtocolObject<dyn MTLRasterizationRateMap>>>;
201
202        #[cfg(feature = "MTLRasterizationRate")]
203        /// Setter for [`rasterizationRateMap`][Self::rasterizationRateMap].
204        #[unsafe(method(setRasterizationRateMap:))]
205        #[unsafe(method_family = none)]
206        pub fn setRasterizationRateMap(
207            &self,
208            rasterization_rate_map: Option<&ProtocolObject<dyn MTLRasterizationRateMap>>,
209        );
210
211        #[cfg(all(
212            feature = "MTLAllocation",
213            feature = "MTLBuffer",
214            feature = "MTLResource"
215        ))]
216        /// Configures a buffer into which Metal writes counts of fragments (pixels) passing the depth and stencil tests.
217        #[unsafe(method(visibilityResultBuffer))]
218        #[unsafe(method_family = none)]
219        pub fn visibilityResultBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
220
221        #[cfg(all(
222            feature = "MTLAllocation",
223            feature = "MTLBuffer",
224            feature = "MTLResource"
225        ))]
226        /// Setter for [`visibilityResultBuffer`][Self::visibilityResultBuffer].
227        ///
228        /// # Safety
229        ///
230        /// - `visibility_result_buffer` may need to be synchronized.
231        /// - `visibility_result_buffer` may be unretained, you must ensure it is kept alive while in use.
232        /// - `visibility_result_buffer` contents should be of the correct type.
233        #[unsafe(method(setVisibilityResultBuffer:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setVisibilityResultBuffer(
236            &self,
237            visibility_result_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
238        );
239
240        #[cfg(feature = "MTLRenderPass")]
241        /// Determines if Metal accumulates visibility results between render encoders or resets them.
242        #[unsafe(method(visibilityResultType))]
243        #[unsafe(method_family = none)]
244        pub fn visibilityResultType(&self) -> MTLVisibilityResultType;
245
246        #[cfg(feature = "MTLRenderPass")]
247        /// Setter for [`visibilityResultType`][Self::visibilityResultType].
248        #[unsafe(method(setVisibilityResultType:))]
249        #[unsafe(method_family = none)]
250        pub fn setVisibilityResultType(&self, visibility_result_type: MTLVisibilityResultType);
251
252        #[cfg(feature = "MTLTypes")]
253        /// Configures the custom sample positions to use in MSAA rendering.
254        ///
255        /// - Parameters:
256        /// - positions: Array of ``MTLSamplePosition`` instances.
257        /// - count:     Number of ``MTLSamplePosition`` instances in the array. This value
258        /// needs to be a valid sample count, or `0` to disable custom sample positions.
259        ///
260        /// # Safety
261        ///
262        /// - `positions` must be a valid pointer or null.
263        /// - `count` might not be bounds-checked.
264        #[unsafe(method(setSamplePositions:count:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn setSamplePositions_count(
267            &self,
268            positions: *const MTLSamplePosition,
269            count: NSUInteger,
270        );
271
272        #[cfg(feature = "MTLTypes")]
273        /// Retrieves the previously-configured custom sample positions.
274        ///
275        /// This method stores the app's last set custom sample positions into an output array. Metal only modifies the array
276        /// when the `count` parameter consists of a length sufficient to store the number of sample positions.
277        ///
278        /// - Parameters:
279        /// - positions: The destination array where Metal stores ``MTLSamplePosition`` instances.
280        /// - count:     Number of ``MTLSamplePosition`` instances in the array. This array
281        /// needs to be large enough to store all sample positions.
282        ///
283        /// - Returns: The number of previously-configured custom sample positions.
284        ///
285        /// # Safety
286        ///
287        /// - `positions` must be a valid pointer or null.
288        /// - `count` might not be bounds-checked.
289        #[unsafe(method(getSamplePositions:count:))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn getSamplePositions_count(
292            &self,
293            positions: *mut MTLSamplePosition,
294            count: NSUInteger,
295        ) -> NSUInteger;
296
297        /// Controls if the render pass supports color attachment mapping.
298        #[unsafe(method(supportColorAttachmentMapping))]
299        #[unsafe(method_family = none)]
300        pub fn supportColorAttachmentMapping(&self) -> bool;
301
302        /// Setter for [`supportColorAttachmentMapping`][Self::supportColorAttachmentMapping].
303        #[unsafe(method(setSupportColorAttachmentMapping:))]
304        #[unsafe(method_family = none)]
305        pub fn setSupportColorAttachmentMapping(&self, support_color_attachment_mapping: bool);
306    );
307}
308
309/// Methods declared on superclass `NSObject`.
310impl MTL4RenderPassDescriptor {
311    extern_methods!(
312        #[unsafe(method(init))]
313        #[unsafe(method_family = init)]
314        pub fn init(this: Allocated<Self>) -> Retained<Self>;
315
316        #[unsafe(method(new))]
317        #[unsafe(method_family = new)]
318        pub fn new() -> Retained<Self>;
319    );
320}
321
322impl DefaultRetained for MTL4RenderPassDescriptor {
323    #[inline]
324    fn default_retained() -> Retained<Self> {
325        Self::new()
326    }
327}