objc2_metal_performance_shaders/generated/MPSRayIntersector/
MPSSVGF.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
11/// Controls how samples are weighted over time
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpstemporalweighting?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct MPSTemporalWeighting(pub NSUInteger);
18impl MPSTemporalWeighting {
19    /// Compute an average of all samples. This will fully utilize all samples but may lead
20    /// to excessive ghosting artifacts under motion. Therefore, this is best for static images.
21    #[doc(alias = "MPSTemporalWeightingAverage")]
22    pub const Average: Self = Self(0);
23    /// Compute an exponential moving average by blending linearly between the previous
24    /// accumulated samples and the current sample according to the temporalReprojectionBlendFactor
25    /// property. This will cause older samples to lose their contribution over time, which will
26    /// prevent ghosting artifacts but will also never converge to a stable value. Therefore, this
27    /// is best for images with motion.
28    #[doc(alias = "MPSTemporalWeightingExponentialMovingAverage")]
29    pub const ExponentialMovingAverage: Self = Self(1);
30}
31
32unsafe impl Encode for MPSTemporalWeighting {
33    const ENCODING: Encoding = NSUInteger::ENCODING;
34}
35
36unsafe impl RefEncode for MPSTemporalWeighting {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// Reduces noise in images rendered with Monte Carlo ray tracing methods
42    ///
43    ///
44    /// This filter uses temporal reprojection to accumulate samples over time, followed by
45    /// an edge-avoiding blur to smooth out the noise. It uses depth and surface normal textures to
46    /// detect edges in the image(s) to be denoised. The filter also computes an estimate of the
47    /// luminance variance of the accumulated samples for each pixel to reject neighboring pixels whose
48    /// luminance is too dissimilar while blurring.
49    ///
50    /// This filter requires noise-free depth and normal textures, so it is not compatible with
51    /// stochastic visibility effects such as depth of field, motion blur, or pixel subsampling. These
52    /// effects need to be applied as a post-process instead. Furthermore, because the depth and normal
53    /// textures can only represent directly visible geometry, the filter may over-blur reflections.
54    /// The use of temporal reprojection may introduce artifacts such as ghosting or streaking, as well
55    /// as a temporal lag for changes in luminance such as moving shadows. However, the filter is
56    /// relatively fast as it is intended for realtime use. Slower but higher quality filters are
57    /// available in the literature.
58    ///
59    /// This filter can process up to two images simultaneously assuming they share the same depth and
60    /// normal textures. This is typically faster than processing the two images independently because
61    /// memory bandwidth spent fetching depth and normal values and ALU time spent computing various
62    /// weighting functions can be shared by both images. This is useful if e.g. you want to denoise
63    /// direct and indirect lighting terms separately to avoid mixing the two terms. The filter is also
64    /// optimized for processing single-channel images for effects such as shadows and ambient
65    /// occlusion. Denoising these images can be much faster than denoising a full RGB image, so it may
66    /// be useful to separate out these terms and denoise them specifically.
67    ///
68    /// This filter operates in three stages: temporal reprojection, variance estimation, and finally a
69    /// series of edge-avoiding bilateral blurs. The temporal reprojection stage accepts the image to
70    /// be denoised for the current frame and the denoised image from the previous frame, the depth and
71    /// normal textures from the current and previous frame and, finally, a motion vector texture. It
72    /// uses the motion vector texture to look up the accumulated samples from the previous frame. It
73    /// then compares the depth and normals to determine if those samples are consistent with the
74    /// current frame. If so, the previous frame is blended with the current frame. This stage also
75    /// accumulates the first and second moments of the sample luminance which is used to compute the
76    /// luminance variance in the next stage.
77    ///
78    /// The variance estimation stage computes an estimate of the variance of the luminance of the
79    /// accumulated samples for each pixel. This stage may fall back to a spatial estimate if not enough
80    /// samples have been accumulated. The luminance variance is used in the final stage to reject
81    /// outlying neighboring pixels while blurring to avoid blurring across luminance discontinuities
82    /// such as shadow boundaries.
83    ///
84    /// The final stage performs consecutive edge-avoiding bilateral blurs to smooth out noise in the
85    /// image. The blurs are dilated with increasing power of two step distances starting from 1,
86    /// which cheaply approximates a very large radius bilateral blur. Each iteration blurs both the
87    /// input image and the variance image as variance is reduced after each iteration. It is
88    /// recommended that the output of the first iteration be used as the input to the next frame's
89    /// reprojection stage to further reduce noise.
90    ///
91    /// Tips:
92    ///
93    /// - It may be helpful to further divide out texture details such as surface albedo before
94    /// denoising to avoid blurring texture detail and to preserve any careful texture filtering that
95    /// may have been performed. The albedo can be reapplied after denoising.
96    /// - High frequency geometry and normal maps may cause excessive disocclusions during reprojection
97    /// manifesting as noise.
98    /// - Jittering sample positions from frame to frame for temporal antialiasing may also cause
99    /// disocclusions. However, this can be partially hidden by the temporal antialiasing algorithm
100    /// itself.
101    /// - This kernel, like many convolutions, requires quite a bit of bandwidth. Use the texture pixel
102    /// formats with the smallest number of bits-per-pixel and the lowest resolution possible for the
103    /// required quality level. Lower resolution images can be combined with a bilateral upsampling
104    /// filter, especially if the image being denoised is mostly low frequency lighting or ambient
105    /// occlusion.
106    /// - The increasing dilation during the bilateral blurring stage can introduce ringing artifacts
107    /// around geometric discontinuities. These can be partially hidden at the cost of potentially
108    /// increased noise by reducing the bilateral blur's sigma value slightly after each iteration.
109    /// - Use lower precision pixel formats if possible to reduce memory bandwidth.
110    ///
111    /// Refer to "Spatiotemporal Variance-Guided Filtering: Real-Time Reconstruction for Path-Traced
112    /// Global Illumination" for more information.
113    ///
114    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpssvgf?language=objc)
115    #[unsafe(super(MPSKernel, NSObject))]
116    #[derive(Debug, PartialEq, Eq, Hash)]
117    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
118    pub struct MPSSVGF;
119);
120
121#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
122extern_conformance!(
123    unsafe impl NSCoding for MPSSVGF {}
124);
125
126#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
127extern_conformance!(
128    unsafe impl NSCopying for MPSSVGF {}
129);
130
131#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
132unsafe impl CopyingHelper for MPSSVGF {
133    type Result = Self;
134}
135
136#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
137extern_conformance!(
138    unsafe impl NSObjectProtocol for MPSSVGF {}
139);
140
141#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
142extern_conformance!(
143    unsafe impl NSSecureCoding for MPSSVGF {}
144);
145
146#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
147impl MPSSVGF {
148    extern_methods!(
149        /// Controls how samples' depths are compared during reprojection, variance estimation, and
150        /// bilateral filtering. The final weight is given by exp(-abs(Z1 - Z2) / depthWeight). Must be
151        /// greater than zero. Defaults to 1.0.
152        #[unsafe(method(depthWeight))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn depthWeight(&self) -> c_float;
155
156        /// Setter for [`depthWeight`][Self::depthWeight].
157        #[unsafe(method(setDepthWeight:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setDepthWeight(&self, depth_weight: c_float);
160
161        /// Controls how samples' normals are compared during reprojection, variance estimation, and
162        /// bilateral filtering. The final weight is given by pow(max(dot(N1, N2)), normalWeight). Must be
163        /// greater than or equal to zero. Defaults to 128.
164        #[unsafe(method(normalWeight))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn normalWeight(&self) -> c_float;
167
168        /// Setter for [`normalWeight`][Self::normalWeight].
169        #[unsafe(method(setNormalWeight:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setNormalWeight(&self, normal_weight: c_float);
172
173        /// Controls how samples' luminance values are compared during bilateral filtering. The final
174        /// weight is given by exp(-abs(L1 - L2) / (luminanceWeight * luminanceVariance + EPSILON)). Must be
175        /// greater than or equal to zero. Defaults to 4.
176        #[unsafe(method(luminanceWeight))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn luminanceWeight(&self) -> c_float;
179
180        /// Setter for [`luminanceWeight`][Self::luminanceWeight].
181        #[unsafe(method(setLuminanceWeight:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn setLuminanceWeight(&self, luminance_weight: c_float);
184
185        /// How to weight samples during temporal reprojection. Defaults to
186        /// MPSTemporalWeightingAverage.
187        #[unsafe(method(temporalWeighting))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn temporalWeighting(&self) -> MPSTemporalWeighting;
190
191        /// Setter for [`temporalWeighting`][Self::temporalWeighting].
192        #[unsafe(method(setTemporalWeighting:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn setTemporalWeighting(&self, temporal_weighting: MPSTemporalWeighting);
195
196        /// When using MPSTemporalWeightingExponentialMovingAverage, how much to blend
197        /// the current frame with the previous frame during reprojection. The final value is given by
198        /// current * temporalReprojectionBlendFactor + previous * (1 - temporalReprojectionBlendFactor).
199        /// Must be between zero and one, inclusive. Defaults to 0.2.
200        #[unsafe(method(temporalReprojectionBlendFactor))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn temporalReprojectionBlendFactor(&self) -> c_float;
203
204        /// Setter for [`temporalReprojectionBlendFactor`][Self::temporalReprojectionBlendFactor].
205        #[unsafe(method(setTemporalReprojectionBlendFactor:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn setTemporalReprojectionBlendFactor(
208            &self,
209            temporal_reprojection_blend_factor: c_float,
210        );
211
212        /// During reprojection, minimum combined depth and normal weight needed to consider a pixel
213        /// from the previous frame consistent with a pixel from the current frame. Must be greater than or
214        /// equal to zero. Defaults to 0.01.
215        #[unsafe(method(reprojectionThreshold))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn reprojectionThreshold(&self) -> c_float;
218
219        /// Setter for [`reprojectionThreshold`][Self::reprojectionThreshold].
220        #[unsafe(method(setReprojectionThreshold:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn setReprojectionThreshold(&self, reprojection_threshold: c_float);
223
224        /// The minimum number of frames which must be accumulated before variance can be computed
225        /// directly from the accumulated luminance moments. If enough frames have not been accumulated,
226        /// variance will be estimated with a spatial filter instead. Defaults to 4.
227        #[unsafe(method(minimumFramesForVarianceEstimation))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn minimumFramesForVarianceEstimation(&self) -> NSUInteger;
230
231        /// Setter for [`minimumFramesForVarianceEstimation`][Self::minimumFramesForVarianceEstimation].
232        #[unsafe(method(setMinimumFramesForVarianceEstimation:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setMinimumFramesForVarianceEstimation(
235            &self,
236            minimum_frames_for_variance_estimation: NSUInteger,
237        );
238
239        /// The radius of the spatial filter used when not enough frames have been accumulated to
240        /// compute variance from accumulated luminance moments. Defaults to 3 resulting in a 7x7 filter.
241        #[unsafe(method(varianceEstimationRadius))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn varianceEstimationRadius(&self) -> NSUInteger;
244
245        /// Setter for [`varianceEstimationRadius`][Self::varianceEstimationRadius].
246        #[unsafe(method(setVarianceEstimationRadius:))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn setVarianceEstimationRadius(&self, variance_estimation_radius: NSUInteger);
249
250        /// The sigma value of the Gaussian function used by the spatial filter used when not enough
251        /// frames have been accumulated to compute variance from accumulated luminance moments. Must be
252        /// greater than zero. Defaults to 2.0.
253        #[unsafe(method(varianceEstimationSigma))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn varianceEstimationSigma(&self) -> c_float;
256
257        /// Setter for [`varianceEstimationSigma`][Self::varianceEstimationSigma].
258        #[unsafe(method(setVarianceEstimationSigma:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn setVarianceEstimationSigma(&self, variance_estimation_sigma: c_float);
261
262        /// The sigma value of the Gaussian function used by the variance pre-filter of the
263        /// bilateral filter. Must be greater than zero. Defaults to 1.33.
264        #[unsafe(method(variancePrefilterSigma))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn variancePrefilterSigma(&self) -> c_float;
267
268        /// Setter for [`variancePrefilterSigma`][Self::variancePrefilterSigma].
269        #[unsafe(method(setVariancePrefilterSigma:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn setVariancePrefilterSigma(&self, variance_prefilter_sigma: c_float);
272
273        /// The radius of the variance pre-filter of the bilateral filter. Defaults to 1 resulting in
274        /// a 3x3 filter.
275        #[unsafe(method(variancePrefilterRadius))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn variancePrefilterRadius(&self) -> NSUInteger;
278
279        /// Setter for [`variancePrefilterRadius`][Self::variancePrefilterRadius].
280        #[unsafe(method(setVariancePrefilterRadius:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setVariancePrefilterRadius(&self, variance_prefilter_radius: NSUInteger);
283
284        /// The sigma value of the Gaussian function used by the bilateral filter. Must be greater
285        /// than zero. Defaults to 1.2.
286        #[unsafe(method(bilateralFilterSigma))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn bilateralFilterSigma(&self) -> c_float;
289
290        /// Setter for [`bilateralFilterSigma`][Self::bilateralFilterSigma].
291        #[unsafe(method(setBilateralFilterSigma:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn setBilateralFilterSigma(&self, bilateral_filter_sigma: c_float);
294
295        /// The radius of the bilateral filter. Defaults to 2 resulting in a 5x5 filter.
296        #[unsafe(method(bilateralFilterRadius))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn bilateralFilterRadius(&self) -> NSUInteger;
299
300        /// Setter for [`bilateralFilterRadius`][Self::bilateralFilterRadius].
301        #[unsafe(method(setBilateralFilterRadius:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn setBilateralFilterRadius(&self, bilateral_filter_radius: NSUInteger);
304
305        /// The number of channels to filter in the source image. Must be at least one and at most
306        /// three. Defaults to 3.
307        #[unsafe(method(channelCount))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn channelCount(&self) -> NSUInteger;
310
311        /// Setter for [`channelCount`][Self::channelCount].
312        #[unsafe(method(setChannelCount:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn setChannelCount(&self, channel_count: NSUInteger);
315
316        /// The number of channels to filter in the second source image. Must be at least one and at
317        /// most three. Defaults to 3.
318        #[unsafe(method(channelCount2))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn channelCount2(&self) -> NSUInteger;
321
322        /// Setter for [`channelCount2`][Self::channelCount2].
323        #[unsafe(method(setChannelCount2:))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn setChannelCount2(&self, channel_count2: NSUInteger);
326
327        #[unsafe(method(initWithDevice:))]
328        #[unsafe(method_family = init)]
329        pub unsafe fn initWithDevice(
330            this: Allocated<Self>,
331            device: &ProtocolObject<dyn MTLDevice>,
332        ) -> Retained<Self>;
333
334        /// # Safety
335        ///
336        /// `a_decoder` possibly has further requirements.
337        #[unsafe(method(initWithCoder:device:))]
338        #[unsafe(method_family = init)]
339        pub unsafe fn initWithCoder_device(
340            this: Allocated<Self>,
341            a_decoder: &NSCoder,
342            device: &ProtocolObject<dyn MTLDevice>,
343        ) -> Option<Retained<Self>>;
344
345        /// # Safety
346        ///
347        /// `zone` must be a valid pointer or null.
348        #[unsafe(method(copyWithZone:device:))]
349        #[unsafe(method_family = copy)]
350        pub unsafe fn copyWithZone_device(
351            &self,
352            zone: *mut NSZone,
353            device: Option<&ProtocolObject<dyn MTLDevice>>,
354        ) -> Retained<Self>;
355
356        /// # Safety
357        ///
358        /// `coder` possibly has further requirements.
359        #[unsafe(method(encodeWithCoder:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
362
363        /// Encode reprojection into a command buffer
364        ///
365        ///
366        /// Normal and depth values from the previous frame will be compared with normal and
367        /// depth values from the current frame to determine if they are similar enough to reproject into
368        /// the current frame. These values are weighted by the depthWeight and normalWeight properties.
369        /// If the combined weight exceeds the reprojectionThreshold property's value, the previous frame
370        /// will be blended with the current frame according to the temporalWeighting and
371        /// temporalReprojectionBlendFactor properties.
372        ///
373        /// The reprojection kernel can operate on two sets of source and destination textures
374        /// simultaneously to share costs such as loading depth and normal values from memory, computing
375        /// various weights, etc. The second set of textures may be nil. The two images are assumed to share
376        /// the same depth and normal values.
377        ///
378        /// The number of channels in the source image(s), previous frame's image(s), and destination
379        /// image(s) are given by the channelCount and channelCount2 properties. These images must have at
380        /// least as many channels as given by these properties. Channels beyond the required number are
381        /// ignored when reading from source images and set to zero when writing to the destination images,
382        /// except the alpha channel which will be set to one if present. The previous frame's image will
383        /// be ignored on the first frame.
384        ///
385        /// The source and destination luminance moments textures must be at least two-channel textures,
386        /// which will be set to the accumulated first and second moments of luminance. Channels beyond the
387        /// first two will be ignored when reading from the previous frame's texture and set to zero when
388        /// writing to the destination texture. The previous frame's luminance moments will be ignored on
389        /// the first frame.
390        ///
391        /// The frame count textures track the number of accumulated frames and must be at least R32Uint
392        /// textures. The remaining channels will be ignored when reading from the source texture and set to
393        /// zero when writing to the destination texture, if present. The previous frame count texture must
394        /// be cleared to zero on the first frame or to reset the accumulated images to the current frame's
395        /// image.
396        ///
397        /// The motion vector texture must be at least a two channel texture representing how many texels
398        /// each texel in the source image(s) have moved since the previous frame. The remaining channels
399        /// will be ignored if present. This texture may be nil, in which case the motion vector is assumed
400        /// to be zero, which is suitable for static images.
401        ///
402        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
403        /// for the current frame for each pixel. These values are packed into a four channel texture to
404        /// reduce the number of texture sampling instructions required to load them. The first channel must
405        /// store the depth value from zero to infinity. The normals must be stored in the last three
406        /// channels as the three signed X, Y, and z components each between negative one and one.
407        /// The depth and normal values are not required if the motion vector texture is nil.
408        ///
409        /// The destination texture, destination luminance moments texture, and destination frame count
410        /// texture are used by subsequent stages of the denoising filter. The destination frame count
411        /// texture is also used as the source frame count texture the reprojection kernel in the next
412        /// frame.
413        ///
414        ///
415        /// Parameter `commandBuffer`: Command buffer to encode into
416        ///
417        /// Parameter `sourceTexture`: Current frame to denoise
418        ///
419        /// Parameter `previousTexture`: Previous denoised frame to reproject into current
420        /// frame
421        ///
422        /// Parameter `destinationTexture`: Output blended image
423        ///
424        /// Parameter `previousLuminanceMomentsTexture`: Previous accumulated luminance moments image
425        ///
426        /// Parameter `destinationLuminanceMomentsTexture`: Output accumulated luminance moments image
427        ///
428        /// Parameter `previousFrameCountTexture`: The number of frames accumulated in the previous
429        /// source image
430        ///
431        /// Parameter `destinationFrameCountTexture`: The number of frames accumulated in the destination
432        /// texture(s) including the current frame
433        ///
434        /// Parameter `motionVectorTexture`: Motion vector texture
435        ///
436        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
437        ///
438        /// Parameter `previousDepthNormalTexture`: The depth and normal values for the previous frame
439        ///
440        /// # Safety
441        ///
442        /// - `source_texture` may need to be synchronized.
443        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
444        /// - `previous_texture` may need to be synchronized.
445        /// - `previous_texture` may be unretained, you must ensure it is kept alive while in use.
446        /// - `destination_texture` may need to be synchronized.
447        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
448        /// - `previous_luminance_moments_texture` may need to be synchronized.
449        /// - `previous_luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
450        /// - `destination_luminance_moments_texture` may need to be synchronized.
451        /// - `destination_luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
452        /// - `previous_frame_count_texture` may need to be synchronized.
453        /// - `previous_frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
454        /// - `destination_frame_count_texture` may need to be synchronized.
455        /// - `destination_frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
456        /// - `motion_vector_texture` may need to be synchronized.
457        /// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
458        /// - `depth_normal_texture` may need to be synchronized.
459        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
460        /// - `previous_depth_normal_texture` may need to be synchronized.
461        /// - `previous_depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
462        #[unsafe(method(encodeReprojectionToCommandBuffer:sourceTexture:previousTexture:destinationTexture:previousLuminanceMomentsTexture:destinationLuminanceMomentsTexture:previousFrameCountTexture:destinationFrameCountTexture:motionVectorTexture:depthNormalTexture:previousDepthNormalTexture:))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn encodeReprojectionToCommandBuffer_sourceTexture_previousTexture_destinationTexture_previousLuminanceMomentsTexture_destinationLuminanceMomentsTexture_previousFrameCountTexture_destinationFrameCountTexture_motionVectorTexture_depthNormalTexture_previousDepthNormalTexture(
465            &self,
466            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
467            source_texture: &ProtocolObject<dyn MTLTexture>,
468            previous_texture: &ProtocolObject<dyn MTLTexture>,
469            destination_texture: &ProtocolObject<dyn MTLTexture>,
470            previous_luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
471            destination_luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
472            previous_frame_count_texture: &ProtocolObject<dyn MTLTexture>,
473            destination_frame_count_texture: &ProtocolObject<dyn MTLTexture>,
474            motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
475            depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
476            previous_depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
477        );
478
479        /// Encode reprojection into a command buffer
480        ///
481        ///
482        /// Normal and depth values from the previous frame will be compared with normal and
483        /// depth values from the current frame to determine if they are similar enough to reproject into
484        /// the current frame. These values are weighted by the depthWeight and normalWeight properties.
485        /// If the combined weight exceeds the reprojectionThreshold property's value, the previous frame
486        /// will be blended with the current frame according to the temporalWeighting and
487        /// temporalReprojectionBlendFactor properties.
488        ///
489        /// The reprojection kernel can operate on two sets of source and destination textures
490        /// simultaneously to share costs such as loading depth and normal values from memory, computing
491        /// various weights, etc. The second set of textures may be nil. The two images are assumed to share
492        /// the same depth and normal values.
493        ///
494        /// The number of channels in the source image(s), previous frame's image(s), and destination
495        /// image(s) are given by the channelCount and channelCount2 properties. These images must have at
496        /// least as many channels as given by these properties. Channels beyond the required number are
497        /// ignored when reading from source images and set to zero when writing to the destination images,
498        /// except the alpha channel which will be set to one if present. The previous frame's image will
499        /// be ignored on the first frame.
500        ///
501        /// The source and destination luminance moments textures must be at least two-channel textures,
502        /// which will be set to the accumulated first and second moments of luminance. Channels beyond the
503        /// first two will be ignored when reading from the previous frame's texture and set to zero when
504        /// writing to the destination texture. The previous frame's luminance moments will be ignored on
505        /// the first frame.
506        ///
507        /// The frame count textures track the number of accumulated frames and must be at least R32Uint
508        /// textures. The remaining channels will be ignored when reading from the source texture and set to
509        /// zero when writing to the destination texture, if present. The previous frame count texture must
510        /// be cleared to zero on the first frame or to reset the accumulated images to the current frame's
511        /// image.
512        ///
513        /// The motion vector texture must be at least a two channel texture representing how many texels
514        /// each texel in the source image(s) have moved since the previous frame. The remaining channels
515        /// will be ignored if present. This texture may be nil, in which case the motion vector is assumed
516        /// to be zero, which is suitable for static images.
517        ///
518        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
519        /// for the current frame for each pixel. These values are packed into a four channel texture to
520        /// reduce the number of texture sampling instructions required to load them. The first channel must
521        /// store the depth value from zero to infinity. The normals must be stored in the last three
522        /// channels as the three signed X, Y, and z components each between negative one and one.
523        /// The depth and normal values are not required if the motion vector texture is nil.
524        ///
525        /// The destination texture, destination luminance moments texture, and destination frame count
526        /// texture are used by subsequent stages of the denoising filter. The destination frame count
527        /// texture is also used as the source frame count texture the reprojection kernel in the next
528        /// frame.
529        ///
530        ///
531        /// Parameter `commandBuffer`: Command buffer to encode into
532        ///
533        /// Parameter `sourceTexture`: Current frame to denoise
534        ///
535        /// Parameter `previousTexture`: Previous denoised frame to reproject into current
536        /// frame
537        ///
538        /// Parameter `destinationTexture`: Output blended image
539        ///
540        /// Parameter `previousLuminanceMomentsTexture`: Previous accumulated luminance moments image
541        ///
542        /// Parameter `destinationLuminanceMomentsTexture`: Output accumulated luminance moments image
543        ///
544        /// Parameter `sourceTexture2`: Second source image
545        ///
546        /// Parameter `previousTexture2`: Second previous image
547        ///
548        /// Parameter `destinationTexture2`: Second destination image
549        ///
550        /// Parameter `previousLuminanceMomentsTexture2`: Second previous luminance moments texture
551        ///
552        /// Parameter `destinationLuminanceMomentsTexture2`: Second destination luminance moments texture
553        ///
554        /// Parameter `previousFrameCountTexture`: The number of frames accumulated in the previous
555        /// source image
556        ///
557        /// Parameter `destinationFrameCountTexture`: The number of frames accumulated in the destination
558        /// texture(s) including the current frame
559        ///
560        /// Parameter `motionVectorTexture`: Motion vector texture
561        ///
562        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
563        ///
564        /// Parameter `previousDepthNormalTexture`: The depth and normal values for the previous frame
565        ///
566        /// # Safety
567        ///
568        /// - `source_texture` may need to be synchronized.
569        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
570        /// - `previous_texture` may need to be synchronized.
571        /// - `previous_texture` may be unretained, you must ensure it is kept alive while in use.
572        /// - `destination_texture` may need to be synchronized.
573        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
574        /// - `previous_luminance_moments_texture` may need to be synchronized.
575        /// - `previous_luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
576        /// - `destination_luminance_moments_texture` may need to be synchronized.
577        /// - `destination_luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
578        /// - `source_texture2` may need to be synchronized.
579        /// - `source_texture2` may be unretained, you must ensure it is kept alive while in use.
580        /// - `previous_texture2` may need to be synchronized.
581        /// - `previous_texture2` may be unretained, you must ensure it is kept alive while in use.
582        /// - `destination_texture2` may need to be synchronized.
583        /// - `destination_texture2` may be unretained, you must ensure it is kept alive while in use.
584        /// - `previous_luminance_moments_texture2` may need to be synchronized.
585        /// - `previous_luminance_moments_texture2` may be unretained, you must ensure it is kept alive while in use.
586        /// - `destination_luminance_moments_texture2` may need to be synchronized.
587        /// - `destination_luminance_moments_texture2` may be unretained, you must ensure it is kept alive while in use.
588        /// - `previous_frame_count_texture` may need to be synchronized.
589        /// - `previous_frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
590        /// - `destination_frame_count_texture` may need to be synchronized.
591        /// - `destination_frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
592        /// - `motion_vector_texture` may need to be synchronized.
593        /// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
594        /// - `depth_normal_texture` may need to be synchronized.
595        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
596        /// - `previous_depth_normal_texture` may need to be synchronized.
597        /// - `previous_depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
598        #[unsafe(method(encodeReprojectionToCommandBuffer:sourceTexture:previousTexture:destinationTexture:previousLuminanceMomentsTexture:destinationLuminanceMomentsTexture:sourceTexture2:previousTexture2:destinationTexture2:previousLuminanceMomentsTexture2:destinationLuminanceMomentsTexture2:previousFrameCountTexture:destinationFrameCountTexture:motionVectorTexture:depthNormalTexture:previousDepthNormalTexture:))]
599        #[unsafe(method_family = none)]
600        pub unsafe fn encodeReprojectionToCommandBuffer_sourceTexture_previousTexture_destinationTexture_previousLuminanceMomentsTexture_destinationLuminanceMomentsTexture_sourceTexture2_previousTexture2_destinationTexture2_previousLuminanceMomentsTexture2_destinationLuminanceMomentsTexture2_previousFrameCountTexture_destinationFrameCountTexture_motionVectorTexture_depthNormalTexture_previousDepthNormalTexture(
601            &self,
602            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
603            source_texture: &ProtocolObject<dyn MTLTexture>,
604            previous_texture: &ProtocolObject<dyn MTLTexture>,
605            destination_texture: &ProtocolObject<dyn MTLTexture>,
606            previous_luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
607            destination_luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
608            source_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
609            previous_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
610            destination_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
611            previous_luminance_moments_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
612            destination_luminance_moments_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
613            previous_frame_count_texture: &ProtocolObject<dyn MTLTexture>,
614            destination_frame_count_texture: &ProtocolObject<dyn MTLTexture>,
615            motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
616            depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
617            previous_depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
618        );
619
620        /// Encode variance estimation into a command buffer
621        ///
622        ///
623        /// Variance is computed from the accumulated first and second luminance moments. If the
624        /// number of accumulated frames is below the minimumFramesForVarianceEstimation property, the
625        /// luminance variance will be computed using a spatial estimate instead. The spatial estimate is
626        /// computed using a bilateral filter with radius given by the varianceEstimationRadius property.
627        /// Neighboring samples will be weighted according to a gaussian function with sigma given by the
628        /// varianceEstimationSigma property. Normal and depth values from neighboring pixels will be
629        /// compared with depth and normal values of the center pixel to determine if they are similar
630        /// enough to include in the spatial blur. These values are weighted by the depthWeight and
631        /// normalWeight properties.
632        ///
633        /// The variance kernel can operate on two sets of source and destination textures
634        /// simultaneously to share costs such as loading depth and normal values from memory, computing
635        /// various weights, etc. The second set of textures may be nil. The two images are assumed to share
636        /// the same depth and normal values.
637        ///
638        /// The reprojected source texture, luminance moments texture and frame count texture are computed
639        /// by the reprojection kernel.
640        ///
641        /// The computed variance will be stored in the last channel of the destination image, while the
642        /// source image will be copied into the previous channels, to reduce the number of texture sample
643        /// instructured required by the bilateral filter in the final stage of the denoising kernel. The
644        /// number of channels in the source image(s) are given by the channelCount and channelCount2
645        /// properties. Therefore, the destination image(s) must have at least channelCount + 1 and
646        /// channelCount2 + 1 channels and the source image(s) must have at least channelCount and
647        /// channelCount2 channels. Channels beyond the required number are ignored when reading from
648        /// source textures and set to zero when writing to destination textures.
649        ///
650        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
651        /// for the current frame for each pixel. These values are packed into a four channel texture to
652        /// reduce the number of texture sampling instructions required to load them. The first channel must
653        /// store the depth value from zero to infinity. The normals must be stored in the last three
654        /// channels as the three signed X, Y, and z components each between negative one and one.
655        /// If the minimumFramesForVarianceEstimation property is less than or equal to one, variance will
656        /// be estimated directly from the accumulated luminance moments so the depth/normal texture may be
657        /// nil.
658        ///
659        ///
660        /// Parameter `commandBuffer`: Command buffer to encode into
661        ///
662        /// Parameter `sourceTexture`: Current reprojected frame to denoise
663        ///
664        /// Parameter `luminanceMomentsTexture`: Luminance moments texture
665        ///
666        /// Parameter `destinationTexture`: Output packed color and variance image
667        ///
668        /// Parameter `frameCountTexture`: Number of frames accumulated into the source image
669        ///
670        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
671        ///
672        /// # Safety
673        ///
674        /// - `source_texture` may need to be synchronized.
675        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
676        /// - `luminance_moments_texture` may need to be synchronized.
677        /// - `luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
678        /// - `destination_texture` may need to be synchronized.
679        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
680        /// - `frame_count_texture` may need to be synchronized.
681        /// - `frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
682        /// - `depth_normal_texture` may need to be synchronized.
683        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
684        #[unsafe(method(encodeVarianceEstimationToCommandBuffer:sourceTexture:luminanceMomentsTexture:destinationTexture:frameCountTexture:depthNormalTexture:))]
685        #[unsafe(method_family = none)]
686        pub unsafe fn encodeVarianceEstimationToCommandBuffer_sourceTexture_luminanceMomentsTexture_destinationTexture_frameCountTexture_depthNormalTexture(
687            &self,
688            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
689            source_texture: &ProtocolObject<dyn MTLTexture>,
690            luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
691            destination_texture: &ProtocolObject<dyn MTLTexture>,
692            frame_count_texture: &ProtocolObject<dyn MTLTexture>,
693            depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
694        );
695
696        /// Encode variance estimation into a command buffer
697        ///
698        ///
699        /// Variance is computed from the accumulated first and second luminance moments. If the
700        /// number of accumulated frames is below the minimumFramesForVarianceEstimation property, the
701        /// luminance variance will be computed using a spatial estimate instead. The spatial estimate is
702        /// computed using a bilateral filter with radius given by the varianceEstimationRadius property.
703        /// Neighboring samples will be weighted according to a gaussian function with sigma given by the
704        /// varianceEstimationSigma property. Normal and depth values from neighboring pixels will be
705        /// compared with depth and normal values of the center pixel to determine if they are similar
706        /// enough to include in the spatial blur. These values are weighted by the depthWeight and
707        /// normalWeight properties.
708        ///
709        /// The variance kernel can operate on two sets of source and destination textures
710        /// simultaneously to share costs such as loading depth and normal values from memory, computing
711        /// various weights, etc. The second set of textures may be nil. The two images are assumed to share
712        /// the same depth and normal values.
713        ///
714        /// The reprojected source texture, luminance moments texture and frame count texture are computed
715        /// by the reprojection kernel.
716        ///
717        /// The computed variance will be stored in the last channel of the destination image, while the
718        /// source image will be copied into the previous channels, to reduce the number of texture sample
719        /// instructured required by the bilateral filter in the final stage of the denoising kernel. The
720        /// number of channels in the source image(s) are given by the channelCount and channelCount2
721        /// properties. Therefore, the destination image(s) must have at least channelCount + 1 and
722        /// channelCount2 + 1 channels and the source image(s) must have at least channelCount and
723        /// channelCount2 channels. Channels beyond the required number are ignored when reading from
724        /// source textures and set to zero when writing to destination textures.
725        ///
726        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
727        /// for the current frame for each pixel. These values are packed into a four channel texture to
728        /// reduce the number of texture sampling instructions required to load them. The first channel must
729        /// store the depth value from zero to infinity. The normals must be stored in the last three
730        /// channels as the three signed X, Y, and z components each between negative one and one.
731        /// If the minimumFramesForVarianceEstimation property is less than or equal to one, variance will
732        /// be estimated directly from the accumulated luminance moments so the depth/normal texture may be
733        /// nil.
734        ///
735        ///
736        /// Parameter `commandBuffer`: Command buffer to encode into
737        ///
738        /// Parameter `sourceTexture`: Current reprojected frame to denoise
739        ///
740        /// Parameter `luminanceMomentsTexture`: Luminance moments texture
741        ///
742        /// Parameter `destinationTexture`: Output packed color and variance image
743        ///
744        /// Parameter `sourceTexture2`: Second source image
745        ///
746        /// Parameter `luminanceMomentsTexture2`: Second luminance moments image
747        ///
748        /// Parameter `destinationTexture2`: Second destination image
749        ///
750        /// Parameter `frameCountTexture`: Number of frames accumulated into the source image
751        ///
752        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
753        ///
754        /// # Safety
755        ///
756        /// - `source_texture` may need to be synchronized.
757        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
758        /// - `luminance_moments_texture` may need to be synchronized.
759        /// - `luminance_moments_texture` may be unretained, you must ensure it is kept alive while in use.
760        /// - `destination_texture` may need to be synchronized.
761        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
762        /// - `source_texture2` may need to be synchronized.
763        /// - `source_texture2` may be unretained, you must ensure it is kept alive while in use.
764        /// - `luminance_moments_texture2` may need to be synchronized.
765        /// - `luminance_moments_texture2` may be unretained, you must ensure it is kept alive while in use.
766        /// - `destination_texture2` may need to be synchronized.
767        /// - `destination_texture2` may be unretained, you must ensure it is kept alive while in use.
768        /// - `frame_count_texture` may need to be synchronized.
769        /// - `frame_count_texture` may be unretained, you must ensure it is kept alive while in use.
770        /// - `depth_normal_texture` may need to be synchronized.
771        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
772        #[unsafe(method(encodeVarianceEstimationToCommandBuffer:sourceTexture:luminanceMomentsTexture:destinationTexture:sourceTexture2:luminanceMomentsTexture2:destinationTexture2:frameCountTexture:depthNormalTexture:))]
773        #[unsafe(method_family = none)]
774        pub unsafe fn encodeVarianceEstimationToCommandBuffer_sourceTexture_luminanceMomentsTexture_destinationTexture_sourceTexture2_luminanceMomentsTexture2_destinationTexture2_frameCountTexture_depthNormalTexture(
775            &self,
776            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
777            source_texture: &ProtocolObject<dyn MTLTexture>,
778            luminance_moments_texture: &ProtocolObject<dyn MTLTexture>,
779            destination_texture: &ProtocolObject<dyn MTLTexture>,
780            source_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
781            luminance_moments_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
782            destination_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
783            frame_count_texture: &ProtocolObject<dyn MTLTexture>,
784            depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
785        );
786
787        /// Encode bilateral filter into a command buffer
788        ///
789        ///
790        /// Performs an edge avoiding blur with radius given by the bilateraFilterRadius
791        /// property with sampling weighted by a Gaussian filter with sigma given by the bilteralFilterSigma
792        /// property. Normal and depth values from neighboring pixels will be compared with depth and normal
793        /// values of the center pixel to determine if they are similar enough to include in the blur. These
794        /// values are weighted by the depthWeight, normalWeight, and luminanceWeight properties.
795        ///
796        /// Before the variance values are used for luminance weighting, the variance is prefiltered with a
797        /// small Gaussian blur with radius given by the variancePrefilterRadius property and sigma given by
798        /// the variancePrefilterSigma property.
799        ///
800        /// This kernel should be run multiple times with a step distance of pow(2, i), starting with i = 0.
801        /// It is recommended that the output of the first iteration be used as the image to be reprojected
802        /// in the next frame. Then several more iterations should be run to compute the denoised image for
803        /// the current frame. 5 total iterations is reasonable.
804        ///
805        /// The bilateral filter can operate on two sets of source and destination textures simultaneously
806        /// to share costs such as loading depth and normal values from memory, computing various weights,
807        /// etc. The second set of textures may be nil. The two images are assumed to share the same normal
808        /// and depth values.
809        ///
810        /// The number of channels to filter in the source image(s) are given by the channelCount and
811        /// channelCount2 properties. Furthermore, the luminance variance is packed into the final channel
812        /// of the source image(s) to reduce the number of texture sample instructions required. The
813        /// filtered color and variance values are packed the same way in the destination image(s).
814        /// Therefore, the source and destination images must have at least channelCount + 1 and
815        /// channelCount2 + 1 channels. Channels beyond the required number are ignored when reading from
816        /// source images and set to zero when writing to destination images. The source image should be
817        /// produced by either the variance estimation kernel or a previous iteration of the bilateral
818        /// filter.
819        ///
820        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
821        /// for the current frame for each pixel. These values are packed into a four channel texture to
822        /// reduce the number of texture sampling instructions required to load them. The first channel must
823        /// store the depth value from zero to infinity. The normals must be stored in the last three
824        /// channels as the three signed X, Y, and z components each between negative one and one.
825        ///
826        ///
827        /// Parameter `commandBuffer`: Command buffer to encode into
828        ///
829        /// Parameter `stepDistance`: Number of pixels to skip between samples
830        ///
831        /// Parameter `sourceTexture`: Source packed color and variance texture
832        ///
833        /// Parameter `destinationTexture`: Destination packed color and variance texture
834        ///
835        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
836        ///
837        /// # Safety
838        ///
839        /// - `source_texture` may need to be synchronized.
840        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
841        /// - `destination_texture` may need to be synchronized.
842        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
843        /// - `depth_normal_texture` may need to be synchronized.
844        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
845        #[unsafe(method(encodeBilateralFilterToCommandBuffer:stepDistance:sourceTexture:destinationTexture:depthNormalTexture:))]
846        #[unsafe(method_family = none)]
847        pub unsafe fn encodeBilateralFilterToCommandBuffer_stepDistance_sourceTexture_destinationTexture_depthNormalTexture(
848            &self,
849            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
850            step_distance: NSUInteger,
851            source_texture: &ProtocolObject<dyn MTLTexture>,
852            destination_texture: &ProtocolObject<dyn MTLTexture>,
853            depth_normal_texture: &ProtocolObject<dyn MTLTexture>,
854        );
855
856        /// Encode bilateral filter into a command buffer
857        ///
858        ///
859        /// Performs an edge avoiding blur with radius given by the bilateraFilterRadius
860        /// property with sampling weighted by a Gaussian filter with sigma given by the bilteralFilterSigma
861        /// property. Normal and depth values from neighboring pixels will be compared with depth and normal
862        /// values of the center pixel to determine if they are similar enough to include in the blur. These
863        /// values are weighted by the depthWeight, normalWeight, and luminanceWeight properties.
864        ///
865        /// Before the variance values are used for luminance weighting, the variance is prefiltered with a
866        /// small Gaussian blur with radius given by the variancePrefilterRadius property and sigma given by
867        /// the variancePrefilterSigma property.
868        ///
869        /// This kernel should be run multiple times with a step distance of pow(2, i), starting with i = 0.
870        /// It is recommended that the output of the first iteration be used as the image to be reprojected
871        /// in the next frame. Then several more iterations should be run to compute the denoised image for
872        /// the current frame. 5 total iterations is reasonable.
873        ///
874        /// The bilateral filter can operate on two sets of source and destination textures simultaneously
875        /// to share costs such as loading depth and normal values from memory, computing various weights,
876        /// etc. The second set of textures may be nil. The two images are assumed to share the same normal
877        /// and depth values.
878        ///
879        /// The number of channels to filter in the source image(s) are given by the channelCount and
880        /// channelCount2 properties. Furthermore, the luminance variance is packed into the final channel
881        /// of the source image(s) to reduce the number of texture sample instructions required. The
882        /// filtered color and variance values are packed the same way in the destination image(s).
883        /// Therefore, the source and destination images must have at least channelCount + 1 and
884        /// channelCount2 + 1 channels. Channels beyond the required number are ignored when reading from
885        /// source images and set to zero when writing to destination images. The source image should be
886        /// produced by either the variance estimation kernel or a previous iteration of the bilateral
887        /// filter.
888        ///
889        /// The depth/normal texture must contain the depth and normal values for directly visible geometry
890        /// for the current frame for each pixel. These values are packed into a four channel texture to
891        /// reduce the number of texture sampling instructions required to load them. The first channel must
892        /// store the depth value from zero to infinity. The normals must be stored in the last three
893        /// channels as the three signed X, Y, and z components each between negative one and one.
894        ///
895        ///
896        /// Parameter `commandBuffer`: Command buffer to encode into
897        ///
898        /// Parameter `stepDistance`: Number of pixels to skip between samples
899        ///
900        /// Parameter `sourceTexture`: Source packed color and variance texture
901        ///
902        /// Parameter `destinationTexture`: Destination packed color and variance texture
903        ///
904        /// Parameter `sourceTexture2`: Second source image
905        ///
906        /// Parameter `destinationTexture2`: Second destination image
907        ///
908        /// Parameter `depthNormalTexture`: The depth and normal values for the current frame
909        ///
910        /// # Safety
911        ///
912        /// - `source_texture` may need to be synchronized.
913        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
914        /// - `destination_texture` may need to be synchronized.
915        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
916        /// - `source_texture2` may need to be synchronized.
917        /// - `source_texture2` may be unretained, you must ensure it is kept alive while in use.
918        /// - `destination_texture2` may need to be synchronized.
919        /// - `destination_texture2` may be unretained, you must ensure it is kept alive while in use.
920        /// - `depth_normal_texture` may need to be synchronized.
921        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
922        #[unsafe(method(encodeBilateralFilterToCommandBuffer:stepDistance:sourceTexture:destinationTexture:sourceTexture2:destinationTexture2:depthNormalTexture:))]
923        #[unsafe(method_family = none)]
924        pub unsafe fn encodeBilateralFilterToCommandBuffer_stepDistance_sourceTexture_destinationTexture_sourceTexture2_destinationTexture2_depthNormalTexture(
925            &self,
926            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
927            step_distance: NSUInteger,
928            source_texture: &ProtocolObject<dyn MTLTexture>,
929            destination_texture: &ProtocolObject<dyn MTLTexture>,
930            source_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
931            destination_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
932            depth_normal_texture: &ProtocolObject<dyn MTLTexture>,
933        );
934    );
935}
936
937/// Methods declared on superclass `MPSKernel`.
938#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
939impl MPSSVGF {
940    extern_methods!(
941        /// Called by NSCoder to decode MPSKernels
942        ///
943        /// This isn't the right interface to decode a MPSKernel, but
944        /// it is the one that NSCoder uses. To enable your NSCoder
945        /// (e.g. NSKeyedUnarchiver) to set which device to use
946        /// extend the object to adopt the MPSDeviceProvider
947        /// protocol. Otherwise, the Metal system default device
948        /// will be used.
949        ///
950        /// # Safety
951        ///
952        /// `a_decoder` possibly has further requirements.
953        #[unsafe(method(initWithCoder:))]
954        #[unsafe(method_family = init)]
955        pub unsafe fn initWithCoder(
956            this: Allocated<Self>,
957            a_decoder: &NSCoder,
958        ) -> Option<Retained<Self>>;
959    );
960}
961
962/// Methods declared on superclass `NSObject`.
963#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
964impl MPSSVGF {
965    extern_methods!(
966        #[unsafe(method(init))]
967        #[unsafe(method_family = init)]
968        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
969
970        #[unsafe(method(new))]
971        #[unsafe(method_family = new)]
972        pub unsafe fn new() -> Retained<Self>;
973    );
974}
975
976extern_protocol!(
977    /// Protocol dictating how texture allocator objects should operate so that they can be used
978    /// by an MPSSVGFDenoiser object to allocate and reuse intermediate and output textures during the
979    /// denoising process.
980    ///
981    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpssvgftextureallocator?language=objc)
982    pub unsafe trait MPSSVGFTextureAllocator: NSObjectProtocol {
983        /// Returns an autoreleased Metal 2D texture with a matching pixel format, width, and height.
984        #[unsafe(method(textureWithPixelFormat:width:height:))]
985        #[unsafe(method_family = none)]
986        unsafe fn textureWithPixelFormat_width_height(
987            &self,
988            pixel_format: MTLPixelFormat,
989            width: NSUInteger,
990            height: NSUInteger,
991        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
992
993        /// Return a texture to the allocator. The allocator operate in such a way as to reduce the
994        /// allocation cost should another texture be requested with the same width, height, and pixel
995        /// format.
996        ///
997        /// # Safety
998        ///
999        /// - `texture` may need to be synchronized.
1000        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
1001        #[unsafe(method(returnTexture:))]
1002        #[unsafe(method_family = none)]
1003        unsafe fn returnTexture(&self, texture: &ProtocolObject<dyn MTLTexture>);
1004    }
1005);
1006
1007extern_class!(
1008    /// A default implementation of the MPSSVGFTextureAllocator protocol. Maintains a cache of
1009    /// textures which is checked first when a texture is requested. If there is no suitable texture in
1010    /// the cache, allocates a texture directly from the Metal device.
1011    ///
1012    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpssvgfdefaulttextureallocator?language=objc)
1013    #[unsafe(super(NSObject))]
1014    #[derive(Debug, PartialEq, Eq, Hash)]
1015    pub struct MPSSVGFDefaultTextureAllocator;
1016);
1017
1018extern_conformance!(
1019    unsafe impl MPSSVGFTextureAllocator for MPSSVGFDefaultTextureAllocator {}
1020);
1021
1022extern_conformance!(
1023    unsafe impl NSObjectProtocol for MPSSVGFDefaultTextureAllocator {}
1024);
1025
1026impl MPSSVGFDefaultTextureAllocator {
1027    extern_methods!(
1028        /// Metal device this object was allocated from
1029        #[unsafe(method(device))]
1030        #[unsafe(method_family = none)]
1031        pub unsafe fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
1032
1033        /// The number of textures which have been allocated from this allocator
1034        #[unsafe(method(allocatedTextureCount))]
1035        #[unsafe(method_family = none)]
1036        pub unsafe fn allocatedTextureCount(&self) -> NSUInteger;
1037
1038        /// Initialize the MPSSVGFDefaultTextureAllocator with a Metal device
1039        #[unsafe(method(initWithDevice:))]
1040        #[unsafe(method_family = init)]
1041        pub unsafe fn initWithDevice(
1042            this: Allocated<Self>,
1043            device: &ProtocolObject<dyn MTLDevice>,
1044        ) -> Retained<Self>;
1045
1046        #[unsafe(method(textureWithPixelFormat:width:height:))]
1047        #[unsafe(method_family = none)]
1048        pub unsafe fn textureWithPixelFormat_width_height(
1049            &self,
1050            pixel_format: MTLPixelFormat,
1051            width: NSUInteger,
1052            height: NSUInteger,
1053        ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
1054
1055        /// # Safety
1056        ///
1057        /// - `texture` may need to be synchronized.
1058        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
1059        #[unsafe(method(returnTexture:))]
1060        #[unsafe(method_family = none)]
1061        pub unsafe fn returnTexture(&self, texture: &ProtocolObject<dyn MTLTexture>);
1062
1063        /// Remove all textures from the cache
1064        #[unsafe(method(reset))]
1065        #[unsafe(method_family = none)]
1066        pub unsafe fn reset(&self);
1067    );
1068}
1069
1070/// Methods declared on superclass `NSObject`.
1071impl MPSSVGFDefaultTextureAllocator {
1072    extern_methods!(
1073        #[unsafe(method(init))]
1074        #[unsafe(method_family = init)]
1075        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1076
1077        #[unsafe(method(new))]
1078        #[unsafe(method_family = new)]
1079        pub unsafe fn new() -> Retained<Self>;
1080    );
1081}
1082
1083extern_class!(
1084    /// A convenience object which uses an MPSSVGF object to manage the denoising process
1085    ///
1086    ///
1087    /// The MPSSVGF object can also be used directly to customize the denoising process.
1088    /// This object keeps track of auxilary textures used by the MPSSVGF object, manages a temporal
1089    /// history, and encodes the entire denoising process into a command buffer.
1090    ///
1091    /// To use this class, first create and customize an MPSSVGF object. This object allows you to tweak
1092    /// various aspect of the denoising process such as temporal reprojection and bilateral blur settings.
1093    /// Then create a texture allocator object which will allocate temporary textures during denoising.
1094    /// This can either be an object conforming to the MPSSVGFTextureAllocator protocol or an instance of
1095    /// the MPSSVGFDefaultTextureAllocator class. Next, create an MPSSVGFDenoiser object. To perform
1096    /// denoising, assign inputs textures to the denoiser object's properties and call
1097    /// encodeToCommandBuffer:. Finally, read the output from the destinationTexture property. Note that
1098    /// this class can denoise up to two independent textures simultaneously, e.g. specular and diffuse,
1099    /// direct and indirect lighting, shadows and AO, etc.
1100    ///
1101    ///
1102    /// ```text
1103    ///      MPSSVGF *svgf = [[MPSSVGF alloc] initWithDevice:device];
1104    ///
1105    ///      // configure svgf properties
1106    ///
1107    ///      MPSSVGFDefaultTextureAllocator *allocator =
1108    ///          [[MPSSVGFDefaultTextureAllocator alloc] initWithDevice:device];
1109    ///
1110    ///      MPSSVGFDenoiser *denoiser = [[MPSSVGFDenoiser alloc] initWithSVGF:svgf
1111    ///                                                       textureAllocator:allocator];
1112    ///
1113    ///      // configure denoiser properties
1114    ///
1115    ///      denoiser.sourceTexture = noisyTexture;
1116    ///      denoiser.depthNormalTexture = depthNormalTexture;
1117    ///      denoiser.previousDepthNormalTexture = depthNormalTextureFromPreviousFrame;
1118    ///      denoiser.motionVectorTexture = motionVectorTexture;
1119    ///
1120    ///      [denoiser encodeToCommandBuffer:commandBuffer];
1121    ///
1122    ///      id <MTLTexture> cleanTexture = denoiser.destinationTexture;
1123    /// ```
1124    ///
1125    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpssvgfdenoiser?language=objc)
1126    #[unsafe(super(NSObject))]
1127    #[derive(Debug, PartialEq, Eq, Hash)]
1128    pub struct MPSSVGFDenoiser;
1129);
1130
1131extern_conformance!(
1132    unsafe impl NSObjectProtocol for MPSSVGFDenoiser {}
1133);
1134
1135impl MPSSVGFDenoiser {
1136    extern_methods!(
1137        #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1138        /// The underlying MPSSVGF kernels object which will be used for denoising. Use this object
1139        /// to customize the denoising process.
1140        #[unsafe(method(svgf))]
1141        #[unsafe(method_family = none)]
1142        pub unsafe fn svgf(&self) -> Retained<MPSSVGF>;
1143
1144        /// The object which will be used to allocate intermediate and output textures.
1145        #[unsafe(method(textureAllocator))]
1146        #[unsafe(method_family = none)]
1147        pub unsafe fn textureAllocator(
1148            &self,
1149        ) -> Retained<ProtocolObject<dyn MPSSVGFTextureAllocator>>;
1150
1151        /// The number of bilateral filter iterations to run. More iterations will improve quality at
1152        /// the cost of performance. Defaults to 5. Must be at least 1.
1153        #[unsafe(method(bilateralFilterIterations))]
1154        #[unsafe(method_family = none)]
1155        pub unsafe fn bilateralFilterIterations(&self) -> NSUInteger;
1156
1157        /// Setter for [`bilateralFilterIterations`][Self::bilateralFilterIterations].
1158        #[unsafe(method(setBilateralFilterIterations:))]
1159        #[unsafe(method_family = none)]
1160        pub unsafe fn setBilateralFilterIterations(&self, bilateral_filter_iterations: NSUInteger);
1161
1162        /// Initialize the MPSSVGFDenoiser object
1163        ///
1164        /// Parameter device The Metal device to use for denoising
1165        #[unsafe(method(initWithDevice:))]
1166        #[unsafe(method_family = init)]
1167        pub unsafe fn initWithDevice(
1168            this: Allocated<Self>,
1169            device: &ProtocolObject<dyn MTLDevice>,
1170        ) -> Retained<Self>;
1171
1172        #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1173        /// Initialize the MPSSVGFDenoiser object
1174        ///
1175        /// Parameter svgf             MPSSVGF kernels to use for denoising. This object can be used to
1176        /// configure temporal reprojection, bilateral blur settings, etc.
1177        /// Parameter textureAllocator An object conforming to the MPSSVGFTextureAllocator protocol. This
1178        /// object will be used to allocate temporary intermediate and output
1179        /// textures. This can be a custom object or an instance of the
1180        /// MPSSVGFDefaultTextureAllocator class.
1181        #[unsafe(method(initWithSVGF:textureAllocator:))]
1182        #[unsafe(method_family = init)]
1183        pub unsafe fn initWithSVGF_textureAllocator(
1184            this: Allocated<Self>,
1185            svgf: &MPSSVGF,
1186            texture_allocator: &ProtocolObject<dyn MPSSVGFTextureAllocator>,
1187        ) -> Retained<Self>;
1188
1189        /// Clear the temporal history. Reprojection and temporal accumulation will restart on the
1190        /// next call to encodeToCommandBuffer:
1191        #[unsafe(method(clearTemporalHistory))]
1192        #[unsafe(method_family = none)]
1193        pub unsafe fn clearTemporalHistory(&self);
1194
1195        /// Return any temporary textures to the texture allocator. Also clears the temporal history.
1196        /// This should be called before resizing the source texture(s).
1197        #[unsafe(method(releaseTemporaryTextures))]
1198        #[unsafe(method_family = none)]
1199        pub unsafe fn releaseTemporaryTextures(&self);
1200
1201        /// Encode denoising kernels to a command buffer
1202        ///
1203        ///
1204        /// Removes noise from the source texture, using the additional data in the motion vector,
1205        /// depth/normal, and previous depth/normal textures. Returns the resulting texture. The depth/normal
1206        /// texture should be provided as the previous depth/normal texture for the next call to this method.
1207        /// This method will also update an internally managed temporal history to aid the denoising process.
1208        /// To reset this history, call the clearTemporalHistory method. This method will allocate and return
1209        /// several textures from and to the texture allocator the MPSSVGFDenoiser was initialized with. The
1210        /// number of iterations of the bilateral filter is controlled by the bilateralFilterIterations property.
1211        /// Larger numbers of iterations will improve the quality but reduce performance. To configure other
1212        /// parameters of the denoising process, modify the properties of the MPSSVGF object the
1213        /// MPSSVGFDenoiser was initialized with.
1214        ///
1215        /// Parameter commandBuffer              Command buffer to encode into
1216        /// Parameter sourceTexture              Source image to denoiser
1217        /// Parameter motionVectorTexture        Motion vector texture describing how much each texel has moved,
1218        /// in texels, since the previous frame. See the MPSSVGF object for
1219        /// more details.
1220        /// Parameter depthNormalTexture         Texture containing linear depth in the X component and signed
1221        /// normals in the YZW components. See the MPSSVGF object for more
1222        /// details.
1223        /// Parameter previousDepthNormalTexture Depth/normal texture from the previous frame. See the MPSSVGF
1224        /// object for more details.
1225        ///
1226        /// # Safety
1227        ///
1228        /// - `source_texture` may need to be synchronized.
1229        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
1230        /// - `motion_vector_texture` may need to be synchronized.
1231        /// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
1232        /// - `depth_normal_texture` may need to be synchronized.
1233        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
1234        /// - `previous_depth_normal_texture` may need to be synchronized.
1235        /// - `previous_depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
1236        #[unsafe(method(encodeToCommandBuffer:sourceTexture:motionVectorTexture:depthNormalTexture:previousDepthNormalTexture:))]
1237        #[unsafe(method_family = none)]
1238        pub unsafe fn encodeToCommandBuffer_sourceTexture_motionVectorTexture_depthNormalTexture_previousDepthNormalTexture(
1239            &self,
1240            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
1241            source_texture: &ProtocolObject<dyn MTLTexture>,
1242            motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
1243            depth_normal_texture: &ProtocolObject<dyn MTLTexture>,
1244            previous_depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
1245        ) -> Retained<ProtocolObject<dyn MTLTexture>>;
1246
1247        /// Encode denoising kernels to a command buffer
1248        ///
1249        ///
1250        /// Simultaneously removes noise from the source texture and optional second source texture,
1251        /// using the additional data in the motion vector, depth/normal, and previous depth/normal textures.
1252        /// Returns the result through the destination texture pointers. The depth/normal texture should be
1253        /// provided as the previous depth/normal texture for the next call to this method. This method will
1254        /// also update an internally managed temporal history to aid the denoising process. To reset this
1255        /// history, call the clearTemporalHistory method. This method will allocate and return several
1256        /// textures from and to the texture allocator the MPSSVGFDenoiser was initialized with. The number
1257        /// of iterations of the bilateral filter is controlled by the bilateralFilterIterations property.
1258        /// Larger numbers of iterations will improve the quality but reduce performance. To configure other
1259        /// parameters of the denoising process, modify the properties of the MPSSVGF object the
1260        /// MPSSVGFDenoiser was initialized with.
1261        ///
1262        /// Parameter commandBuffer              Command buffer to encode into
1263        /// Parameter sourceTexture              Source image to denoiser
1264        /// Parameter destinationTexture         Denoised output image
1265        /// Parameter sourceTexture2             Optional second source image to denoise
1266        /// Parameter destinationTexture2        Denoised second output image, if there is a second source image
1267        /// Parameter motionVectorTexture        Motion vector texture describing how much each texel has moved,
1268        /// in texels, since the previous frame. See the MPSSVGF object for
1269        /// more details.
1270        /// Parameter depthNormalTexture         Texture containing linear depth in the X component and signed
1271        /// normals in the YZW components. See the MPSSVGF object for more
1272        /// details.
1273        /// Parameter previousDepthNormalTexture Depth/normal texture from the previous frame. See the MPSSVGF
1274        /// object for more details.
1275        ///
1276        /// # Safety
1277        ///
1278        /// - `source_texture` may need to be synchronized.
1279        /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
1280        /// - `destination_texture` may need to be synchronized.
1281        /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
1282        /// - `source_texture2` may need to be synchronized.
1283        /// - `source_texture2` may be unretained, you must ensure it is kept alive while in use.
1284        /// - `destination_texture2` may need to be synchronized.
1285        /// - `destination_texture2` may be unretained, you must ensure it is kept alive while in use.
1286        /// - `motion_vector_texture` may need to be synchronized.
1287        /// - `motion_vector_texture` may be unretained, you must ensure it is kept alive while in use.
1288        /// - `depth_normal_texture` may need to be synchronized.
1289        /// - `depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
1290        /// - `previous_depth_normal_texture` may need to be synchronized.
1291        /// - `previous_depth_normal_texture` may be unretained, you must ensure it is kept alive while in use.
1292        #[unsafe(method(encodeToCommandBuffer:sourceTexture:destinationTexture:sourceTexture2:destinationTexture2:motionVectorTexture:depthNormalTexture:previousDepthNormalTexture:))]
1293        #[unsafe(method_family = none)]
1294        pub unsafe fn encodeToCommandBuffer_sourceTexture_destinationTexture_sourceTexture2_destinationTexture2_motionVectorTexture_depthNormalTexture_previousDepthNormalTexture(
1295            &self,
1296            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
1297            source_texture: &ProtocolObject<dyn MTLTexture>,
1298            destination_texture: &mut Retained<ProtocolObject<dyn MTLTexture>>,
1299            source_texture2: Option<&ProtocolObject<dyn MTLTexture>>,
1300            destination_texture2: Option<&mut Retained<ProtocolObject<dyn MTLTexture>>>,
1301            motion_vector_texture: Option<&ProtocolObject<dyn MTLTexture>>,
1302            depth_normal_texture: &ProtocolObject<dyn MTLTexture>,
1303            previous_depth_normal_texture: Option<&ProtocolObject<dyn MTLTexture>>,
1304        );
1305    );
1306}
1307
1308/// Methods declared on superclass `NSObject`.
1309impl MPSSVGFDenoiser {
1310    extern_methods!(
1311        #[unsafe(method(init))]
1312        #[unsafe(method_family = init)]
1313        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1314
1315        #[unsafe(method(new))]
1316        #[unsafe(method_family = new)]
1317        pub unsafe fn new() -> Retained<Self>;
1318    );
1319}