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
//! 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 objc2_metal::*;
use crate::*;
extern_class!(
/// Reduces aliasing in an image by accumulating samples over multiple frames
///
///
/// The color for the previous frame will be sampled using the provided motion vector
/// texture and blended with the current frame according to the blendFactor property. The colors
/// from the previous frame will be clamped to the color-space bounding box formed by the center
/// pixel's neighbors to avoid reprojection artifacts, and the motion vector texture will be
/// dilated to avoid aliased silhouette edges under motion.
///
/// For the best result, the sample positions produced by the renderer should be jittered every
/// frame, ideally using a low discrepency sequence. This will ensure that different sample
/// positions along edges will be visited over time even if the camera is not moving. This will
/// also reduce aliasing due to textures and high-frequency shading.
///
/// For reference, see "High-Quality Temporal Supersampling" by Karis.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpstemporalaa?language=objc)
#[unsafe(super(MPSKernel, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
pub struct MPSTemporalAA;
);
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
extern_conformance!(
unsafe impl NSCoding for MPSTemporalAA {}
);
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
extern_conformance!(
unsafe impl NSCopying for MPSTemporalAA {}
);
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
unsafe impl CopyingHelper for MPSTemporalAA {
type Result = Self;
}
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
extern_conformance!(
unsafe impl NSObjectProtocol for MPSTemporalAA {}
);
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
extern_conformance!(
unsafe impl NSSecureCoding for MPSTemporalAA {}
);
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
impl MPSTemporalAA {
extern_methods!(
/// How much to blend the current frame with the previous frame during temporal antialiasing.
/// The final value is given by
/// current * blendFactor + previous * (1 - blendFactor). Must be between zero
/// and one, inclusive. Defaults to 0.1.
#[unsafe(method(blendFactor))]
#[unsafe(method_family = none)]
pub unsafe fn blendFactor(&self) -> c_float;
/// Setter for [`blendFactor`][Self::blendFactor].
#[unsafe(method(setBlendFactor:))]
#[unsafe(method_family = none)]
pub unsafe fn setBlendFactor(&self, blend_factor: c_float);
#[unsafe(method(initWithDevice:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithDevice(
this: Allocated<Self>,
device: &ProtocolObject<dyn MTLDevice>,
) -> Retained<Self>;
/// # Safety
///
/// `a_decoder` possibly has further requirements.
#[unsafe(method(initWithCoder:device:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder_device(
this: Allocated<Self>,
a_decoder: &NSCoder,
device: &ProtocolObject<dyn MTLDevice>,
) -> Option<Retained<Self>>;
/// # Safety
///
/// `zone` must be a valid pointer or null.
#[unsafe(method(copyWithZone:device:))]
#[unsafe(method_family = copy)]
pub unsafe fn copyWithZone_device(
&self,
zone: *mut NSZone,
device: Option<&ProtocolObject<dyn MTLDevice>>,
) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(encodeWithCoder:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
/// Encode temporal antialiasing a command buffer
///
///
/// The motion vector texture must be at least a two channel texture representing how
/// many texels each texel in the source image(s) have moved since the previous frame. The remaining
/// channels will be ignored if present. This texture may be nil, in which case the motion vector is
/// assumed to be zero, which is suitable for static images.
///
/// The depth texture must contain the depth values for directly visible geometry for the current
/// frame for each pixel. The first channel must store the depth value from zero to infinity.
/// The depth texture may be nil, but this will prevent motion vectors from being dilated and
/// may introduce aliasing along silhouette edges.
///
/// The destination texture should be used as the previous texture in the next frame.
///
///
/// Parameter `commandBuffer`: Command buffer to encode into
///
/// Parameter `sourceTexture`: Current frame to denoise
///
/// Parameter `previousTexture`: Previous denoised frame to reproject into current
/// frame
///
/// Parameter `destinationTexture`: Output blended image
///
/// Parameter `motionVectorTexture`: Motion vector texture
///
/// Parameter `depthTexture`: The depth values for the current frame
///
/// # Safety
///
/// - `source_texture` may need to be synchronized.
/// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
/// - `previous_texture` may need to be synchronized.
/// - `previous_texture` may be unretained, you must ensure it is kept alive while in use.
/// - `destination_texture` may need to be synchronized.
/// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
/// - `motion_vector_texture` may need to be synchronized.
/// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
/// - `depth_texture` may need to be synchronized.
/// - `depth_texture` may be unretained, you must ensure it is kept alive while in use.
#[unsafe(method(encodeToCommandBuffer:sourceTexture:previousTexture:destinationTexture:motionVectorTexture:depthTexture:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeToCommandBuffer_sourceTexture_previousTexture_destinationTexture_motionVectorTexture_depthTexture(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
source_texture: &ProtocolObject<dyn MTLTexture>,
previous_texture: &ProtocolObject<dyn MTLTexture>,
destination_texture: &ProtocolObject<dyn MTLTexture>,
motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
depth_texture: Option<&ProtocolObject<dyn MTLTexture>>,
);
);
}
/// Methods declared on superclass `MPSKernel`.
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
impl MPSTemporalAA {
extern_methods!(
/// Called by NSCoder to decode MPSKernels
///
/// This isn't the right interface to decode a MPSKernel, but
/// it is the one that NSCoder uses. To enable your NSCoder
/// (e.g. NSKeyedUnarchiver) to set which device to use
/// extend the object to adopt the MPSDeviceProvider
/// protocol. Otherwise, the Metal system default device
/// will be used.
///
/// # Safety
///
/// `a_decoder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
a_decoder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
impl MPSTemporalAA {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}