objc2_metal_performance_shaders/generated/MPSRayIntersector/MPSTemporalAA.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::*;
7use objc2_metal::*;
8
9use crate::*;
10
11extern_class!(
12 /// Reduces aliasing in an image by accumulating samples over multiple frames
13 ///
14 ///
15 /// The color for the previous frame will be sampled using the provided motion vector
16 /// texture and blended with the current frame according to the blendFactor property. The colors
17 /// from the previous frame will be clamped to the color-space bounding box formed by the center
18 /// pixel's neighbors to avoid reprojection artifacts, and the motion vector texture will be
19 /// dilated to avoid aliased silhouette edges under motion.
20 ///
21 /// For the best result, the sample positions produced by the renderer should be jittered every
22 /// frame, ideally using a low discrepency sequence. This will ensure that different sample
23 /// positions along edges will be visited over time even if the camera is not moving. This will
24 /// also reduce aliasing due to textures and high-frequency shading.
25 ///
26 /// For reference, see "High-Quality Temporal Supersampling" by Karis.
27 ///
28 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpstemporalaa?language=objc)
29 #[unsafe(super(MPSKernel, NSObject))]
30 #[derive(Debug, PartialEq, Eq, Hash)]
31 #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
32 pub struct MPSTemporalAA;
33);
34
35#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
36extern_conformance!(
37 unsafe impl NSCoding for MPSTemporalAA {}
38);
39
40#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
41extern_conformance!(
42 unsafe impl NSCopying for MPSTemporalAA {}
43);
44
45#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
46unsafe impl CopyingHelper for MPSTemporalAA {
47 type Result = Self;
48}
49
50#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
51extern_conformance!(
52 unsafe impl NSObjectProtocol for MPSTemporalAA {}
53);
54
55#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
56extern_conformance!(
57 unsafe impl NSSecureCoding for MPSTemporalAA {}
58);
59
60#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
61impl MPSTemporalAA {
62 extern_methods!(
63 /// How much to blend the current frame with the previous frame during temporal antialiasing.
64 /// The final value is given by
65 /// current * blendFactor + previous * (1 - blendFactor). Must be between zero
66 /// and one, inclusive. Defaults to 0.1.
67 #[unsafe(method(blendFactor))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn blendFactor(&self) -> c_float;
70
71 /// Setter for [`blendFactor`][Self::blendFactor].
72 #[unsafe(method(setBlendFactor:))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn setBlendFactor(&self, blend_factor: c_float);
75
76 #[unsafe(method(initWithDevice:))]
77 #[unsafe(method_family = init)]
78 pub unsafe fn initWithDevice(
79 this: Allocated<Self>,
80 device: &ProtocolObject<dyn MTLDevice>,
81 ) -> Retained<Self>;
82
83 /// # Safety
84 ///
85 /// `a_decoder` possibly has further requirements.
86 #[unsafe(method(initWithCoder:device:))]
87 #[unsafe(method_family = init)]
88 pub unsafe fn initWithCoder_device(
89 this: Allocated<Self>,
90 a_decoder: &NSCoder,
91 device: &ProtocolObject<dyn MTLDevice>,
92 ) -> Option<Retained<Self>>;
93
94 /// # Safety
95 ///
96 /// `zone` must be a valid pointer or null.
97 #[unsafe(method(copyWithZone:device:))]
98 #[unsafe(method_family = copy)]
99 pub unsafe fn copyWithZone_device(
100 &self,
101 zone: *mut NSZone,
102 device: Option<&ProtocolObject<dyn MTLDevice>>,
103 ) -> Retained<Self>;
104
105 /// # Safety
106 ///
107 /// `coder` possibly has further requirements.
108 #[unsafe(method(encodeWithCoder:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
111
112 /// Encode temporal antialiasing a command buffer
113 ///
114 ///
115 /// The motion vector texture must be at least a two channel texture representing how
116 /// many texels each texel in the source image(s) have moved since the previous frame. The remaining
117 /// channels will be ignored if present. This texture may be nil, in which case the motion vector is
118 /// assumed to be zero, which is suitable for static images.
119 ///
120 /// The depth texture must contain the depth values for directly visible geometry for the current
121 /// frame for each pixel. The first channel must store the depth value from zero to infinity.
122 /// The depth texture may be nil, but this will prevent motion vectors from being dilated and
123 /// may introduce aliasing along silhouette edges.
124 ///
125 /// The destination texture should be used as the previous texture in the next frame.
126 ///
127 ///
128 /// Parameter `commandBuffer`: Command buffer to encode into
129 ///
130 /// Parameter `sourceTexture`: Current frame to denoise
131 ///
132 /// Parameter `previousTexture`: Previous denoised frame to reproject into current
133 /// frame
134 ///
135 /// Parameter `destinationTexture`: Output blended image
136 ///
137 /// Parameter `motionVectorTexture`: Motion vector texture
138 ///
139 /// Parameter `depthTexture`: The depth values for the current frame
140 ///
141 /// # Safety
142 ///
143 /// - `source_texture` may need to be synchronized.
144 /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
145 /// - `previous_texture` may need to be synchronized.
146 /// - `previous_texture` may be unretained, you must ensure it is kept alive while in use.
147 /// - `destination_texture` may need to be synchronized.
148 /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
149 /// - `motion_vector_texture` may need to be synchronized.
150 /// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
151 /// - `depth_texture` may need to be synchronized.
152 /// - `depth_texture` may be unretained, you must ensure it is kept alive while in use.
153 #[unsafe(method(encodeToCommandBuffer:sourceTexture:previousTexture:destinationTexture:motionVectorTexture:depthTexture:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn encodeToCommandBuffer_sourceTexture_previousTexture_destinationTexture_motionVectorTexture_depthTexture(
156 &self,
157 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
158 source_texture: &ProtocolObject<dyn MTLTexture>,
159 previous_texture: &ProtocolObject<dyn MTLTexture>,
160 destination_texture: &ProtocolObject<dyn MTLTexture>,
161 motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
162 depth_texture: Option<&ProtocolObject<dyn MTLTexture>>,
163 );
164 );
165}
166
167/// Methods declared on superclass `MPSKernel`.
168#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
169impl MPSTemporalAA {
170 extern_methods!(
171 /// Called by NSCoder to decode MPSKernels
172 ///
173 /// This isn't the right interface to decode a MPSKernel, but
174 /// it is the one that NSCoder uses. To enable your NSCoder
175 /// (e.g. NSKeyedUnarchiver) to set which device to use
176 /// extend the object to adopt the MPSDeviceProvider
177 /// protocol. Otherwise, the Metal system default device
178 /// will be used.
179 ///
180 /// # Safety
181 ///
182 /// `a_decoder` possibly has further requirements.
183 #[unsafe(method(initWithCoder:))]
184 #[unsafe(method_family = init)]
185 pub unsafe fn initWithCoder(
186 this: Allocated<Self>,
187 a_decoder: &NSCoder,
188 ) -> Option<Retained<Self>>;
189 );
190}
191
192/// Methods declared on superclass `NSObject`.
193#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
194impl MPSTemporalAA {
195 extern_methods!(
196 #[unsafe(method(init))]
197 #[unsafe(method_family = init)]
198 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
199
200 #[unsafe(method(new))]
201 #[unsafe(method_family = new)]
202 pub unsafe fn new() -> Retained<Self>;
203 );
204}