sgl-3d 0.7.0

Caller-driven 3D rendering for SGL games, native and in the browser (WebGPU)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
//! The settings, the frame and the device resolved into the effective
//! configuration (`view::effective`): once per frame, and the size-affecting
//! choices at `Renderer::resize`.
use crate::FrameInput;
use crate::scene::RayData;
use crate::settings::{
    AmbientOcclusionQuality, Antialiasing, DynamicGiQuality, FogQuality, FsrVersion,
    ReflectionMethod, RenderPreset, SceneResolution, ScreenSpaceReflections, Settings,
    ShadowQuality, WorldSpaceReflections,
};
use crate::shading::RayQueryForm;
use crate::shading::bind::BindingTier;
use crate::stages::reflections::velvet;
use crate::view::effective::CompositeDraws;
use crate::view::effective::{
    AmbientOcclusion, Effective, HardwareRayTracing, ScreenSpace, ShadowFilter, Sizing,
};
use crate::view::pipelines::LayerConstants;

/// `effective` for a frame whose rays trace in hardware where `hardware`
/// and whose slots may hold `lights`: the ray-traced shadow stage runs
/// where the setting asks for it, the rays trace in hardware and a slot
/// holds a light, and the opaque stage then takes its two-pass form, the
/// stage between its parts.
pub(super) fn traced_shadows(
    effective: Effective,
    hardware: bool,
    lights: &crate::stages::shadows::traced::slots::SlotLights,
) -> Effective {
    let ray_traced_shadows = effective.ray_traced_shadows && hardware && !lights.is_empty();
    Effective {
        ray_traced_shadows,
        fused: effective.fused && !ray_traced_shadows,
        ..effective
    }
}

/// The size-affecting choices of `settings`.
pub(super) fn sizing(settings: &Settings) -> Sizing {
    Sizing {
        fsr: settings
            .antialiasing
            .resolve(settings.low())
            .fsr()
            .map(|version| (version, settings.fsr_quality)),
        bloom_targets: settings.preset == RenderPreset::High,
    }
}

/// The scene size for an output of `size` at `device_scale` physical
/// pixels per logical pixel, under the preset and scene resolution.
pub(super) fn scene_size(
    size: [u32; 2],
    preset: RenderPreset,
    resolution: SceneResolution,
    device_scale: f32,
) -> [u32; 2] {
    let scale = match resolution {
        SceneResolution::Preset => {
            let cap = if preset == RenderPreset::Low {
                1.
            } else {
                1.75
            };
            (cap / device_scale.max(1.)).min(1.)
        }
        SceneResolution::Hd => (1280. / size[0].max(1) as f32)
            .min(720. / size[1].max(1) as f32)
            .min(1.),
        SceneResolution::FullHd => (1920. / size[0].max(1) as f32)
            .min(1080. / size[1].max(1) as f32)
            .min(1.),
        SceneResolution::Full => 1.,
        SceneResolution::ThreeQuarter => 0.75,
        SceneResolution::Half => 0.5,
    };
    size.map(|x| ((x as f32 * scale).floor() as u32).max(1))
}

/// The antialiasing that runs for `settings`: their choice resolved for the
/// preset, with TAA where FSR is chosen but not `fsr_running`. The saved
/// choice is unchanged.
pub(super) fn antialiasing(settings: &Settings, fsr_running: Option<FsrVersion>) -> Antialiasing {
    match settings.antialiasing.resolve(settings.low()) {
        choice if choice.fsr().is_some() && choice.fsr() != fsr_running => Antialiasing::Taa,
        other => other,
    }
}

/// The volumetric fog and mist run: the setting, the frame's atmosphere and
/// the diagnostics layer.
pub(super) fn atmosphere(settings: &Settings, input: &FrameInput) -> bool {
    settings.atmosphere && input.atmosphere && !settings.diagnostics_in_effect().disable.atmosphere
}

/// The volumetric fog's quality while it runs: with the frame's atmosphere,
/// a medium (a positive density, or the scene's `fog_volumes`), a volume of
/// positive, finite length, and a `perspective` camera (`perspective`),
/// whose clip w is view depth, which the froxels' slices and reprojection
/// take. Without a medium there is nothing to fog, and the frame is as it
/// would be with the fog run.
fn fog(
    settings: &Settings,
    input: &FrameInput,
    fog_volumes: bool,
    perspective: bool,
) -> Option<FogQuality> {
    let fog = input.fog;
    let medium = fog.density > 0. || fog_volumes;
    let volume = fog.length.is_finite() && fog.length > 0.;
    (atmosphere(settings, input) && medium && volume && perspective).then_some(settings.fog_quality)
}

/// Motion blur's shutter: the frame's authored one scaled by the setting,
/// while that is positive and finite. It also needs `perspective`'s
/// projection, whose depth it linearises.
fn motion_blur(settings: &Settings, input: &FrameInput) -> Option<f32> {
    let shutter = input.motion_blur.shutter_angle * settings.motion_blur.shutter_scale();
    (shutter.is_finite() && shutter > 0.).then_some(shutter)
}

/// FSR's sharpness while `fsr` runs and the setting sharpens: within
/// AMD's 0..=1, NaN as the least.
fn fsr_sharpness(settings: &Settings, fsr: bool) -> Option<f32> {
    let sharpness = settings.fsr_sharpness;
    (fsr && settings.fsr_sharpening).then(|| {
        if sharpness.is_nan() {
            0.
        } else {
            sharpness.clamp(0., 1.)
        }
    })
}

/// The effective configuration of a first frame from a `perspective` camera
/// with `FrameInput::new`'s values and a scene with no fog volumes or
/// receivers: what `Renderer::new` builds stages for, so that such a frame
/// finds their pipelines built. `device` is as for `resolve`.
pub(super) fn first_frame(settings: &Settings, device: Device) -> Effective {
    let camera = crate::Camera {
        view: glam::Mat4::IDENTITY,
        projection: crate::perspective(1., 1., 0.1),
        eye: glam::Vec3::ZERO,
    };
    resolve(
        settings,
        &FrameInput::new(camera),
        SceneContent::default(),
        device,
    )
}

/// What the renderer's device runs that the effective configuration
/// follows.
#[derive(Clone, Copy)]
pub(super) struct Device {
    /// FSR's context runs on it.
    pub fsr_running: Option<FsrVersion>,
    /// It has the fused pass's attachments.
    pub fused_supported: bool,
    /// It binds the depth pyramid's storage textures.
    pub occlusion_supported: bool,
    /// It traces rays in hardware, in this form
    /// (`scene::rays::acceleration::supported`, `DeviceRayForm::form`).
    pub ray_queries: Option<RayQueryForm>,
    /// Its binding tier, `Extended` alone binding the dynamic GI volume's
    /// probes.
    pub tier: BindingTier,
}

/// `Settings::dynamic_gi` on a device of `tier`: the setting on the
/// Extended binding tier, else `Off`. The saved choice is unchanged.
pub(super) fn dynamic_gi(
    settings: &Settings,
    tier: BindingTier,
    ray_data: RayData,
) -> DynamicGiQuality {
    if ray_data == RayData::Disabled {
        return DynamicGiQuality::Off;
    }
    match tier {
        BindingTier::Extended => settings.dynamic_gi,
        BindingTier::Basic => DynamicGiQuality::Off,
    }
}

/// `Settings::volume_paths` on a device of `tier`: the setting on the
/// Extended binding tier, which alone binds the volume layers, else off.
/// The saved choice is unchanged.
pub(super) fn volume_paths(settings: &Settings, tier: BindingTier) -> bool {
    settings.volume_paths && tier == BindingTier::Extended
}

/// What a frame's scene holds that its effective configuration follows.
#[derive(Clone, Copy, Default)]
pub(super) struct SceneContent {
    pub ray_data: RayData,
    pub fog_volumes: bool,
    /// A blended receiver of screen-space reflections.
    pub receivers: bool,
    /// A dynamic GI volume.
    pub dynamic_gi_volume: bool,
    /// Blended or transmissive materials.
    pub blended: bool,
    /// An opaque or masked material whose shading moves
    /// (`Material::surface_moves`).
    pub moving_surfaces: bool,
    /// Glow, mist and heat distortion to draw.
    pub glow: bool,
    pub mist: bool,
    pub heat: bool,
}

impl SceneContent {
    pub fn of(scene: &crate::Scene) -> Self {
        Self {
            ray_data: scene.ray_data(),
            fog_volumes: !scene.transient.fog_volume_corners.is_empty(),
            receivers: scene.materials.holds_receivers(),
            dynamic_gi_volume: scene.dynamic_gi.is_some(),
            blended: scene.materials.holds_blended() || scene.materials.holds_transmissive(),
            moving_surfaces: scene.materials.holds_moving_surfaces(),
            glow: scene.transient.glow_count > 0,
            mist: !scene.transient.mist_positions.is_empty(),
            heat: scene.transient.heat_count > 0,
        }
    }
}

/// The perceptual roughness at which `method` stops tracing and the width
/// of the fade below it: Crystal's DiligentFX `RoughnessThreshold`, fading
/// over the last 0.05 as Bevy's SSR fades out; Velvet's Godot cutoff and
/// forward-pass fade.
fn trace_cutoff(method: ReflectionMethod) -> (f32, f32) {
    match method {
        ReflectionMethod::Crystal => (
            crate::view::post_fx::ssr_attribs().roughness_threshold,
            0.05,
        ),
        ReflectionMethod::Velvet => (velvet::ROUGHNESS_CUTOFF, velvet::ROUGHNESS_FADE),
    }
}

/// The effective configuration of a frame of a scene holding `content` on
/// a device that runs what `device` says.
pub(super) fn resolve(
    settings: &Settings,
    input: &FrameInput,
    content: SceneContent,
    device: Device,
) -> Effective {
    let Device {
        fsr_running,
        fused_supported,
        occlusion_supported,
        ray_queries,
        tier,
    } = device;
    let low = settings.low();
    let diagnostics = settings.diagnostics_in_effect();
    let disable = diagnostics.disable;
    let p = input.camera.projection.to_cols_array_2d();
    // XeGTAO's depth unpack/reconstruction is for centered reversed-Z
    // perspective projections, not orthographic cameras.
    let ambient_occlusion = (settings.ambient_occlusion != AmbientOcclusionQuality::Off
        && p[3][3] == 0.
        && p[2][3] == -1.
        && p[2][0] == 0.
        && p[2][1] == 0.
        && p[2][2] >= 0.
        && p[3][2] > 0.)
        .then_some(AmbientOcclusion {
            quality: settings.ambient_occlusion,
            radius: input.ambient_occlusion_radius,
        });
    // DiligentFX's and FSR's camera inputs are for `perspective`'s
    // infinite reversed-Z projection; with other cameras SSR is off and
    // SMAA replaces TAA, and FSR's render-size frame is presented as it
    // is.
    let post_fx_camera = p[3][3] == 0. && p[2][3] == -1. && p[2][2] == 0. && p[3][2] > 0.;
    let antialiasing = antialiasing(settings, fsr_running);
    let taa = antialiasing == Antialiasing::Taa && !disable.taa && post_fx_camera;
    let fsr = antialiasing.fsr().is_some() && !disable.fsr && post_fx_camera;
    let screen_space = match settings.screen_space_reflections {
        _ if !post_fx_camera => None,
        ScreenSpaceReflections::Off => None,
        ScreenSpaceReflections::Half => Some(true),
        ScreenSpaceReflections::Full => Some(false),
    }
    .map(|half_resolution| {
        let (cutoff, fade) = trace_cutoff(settings.reflection_method);
        ScreenSpace {
            method: settings.reflection_method,
            half_resolution,
            cutoff,
            fade,
        }
    });
    // DiligentFX's SSR shares TAA's post-effect context.
    let crystal = screen_space.is_some_and(|ssr| ssr.method == ReflectionMethod::Crystal);
    // The camera's shadow filter: Godot's hard tap at Low; at High, Bevy's
    // spiral while temporal antialiasing resolves it, else its Gaussian.
    let shadow_filter = match settings.shadow_quality {
        ShadowQuality::Low => ShadowFilter::Hardware,
        ShadowQuality::High if taa || fsr => ShadowFilter::Temporal,
        ShadowQuality::High => ShadowFilter::Gaussian,
    };
    let motion_blur = motion_blur(settings, input).filter(|_| post_fx_camera);
    // What draws onto the composite, each of which marks the temporal
    // masks while the frame has them (Frame item 8). TAA reads the masks
    // only in a frame one of them can mark; FSR's dispatch binds them in
    // every frame.
    let composite = CompositeDraws {
        blended: content.blended,
        moving_surfaces: content.moving_surfaces,
        glow: content.glow && !disable.effects,
        mist: content.mist && atmosphere(settings, input),
        heat: content.heat && settings.heat_distortion,
    };
    let temporal_masks = fsr || taa && composite.any();
    let hardware_ray_tracing = match (settings.hardware_ray_tracing, content.ray_data, ray_queries)
    {
        (false, _, _) => HardwareRayTracing::Off,
        (true, RayData::Disabled, _) => HardwareRayTracing::DisabledByScene,
        (true, _, None) => HardwareRayTracing::Unsupported,
        (true, _, Some(form)) => HardwareRayTracing::On(form),
    };
    // Ray-traced shadows trace through the hardware path alone (the
    // architecture's Ray-traced shadows); elsewhere the maps shadow, their
    // path without hardware ray tracing (D-30). The
    // frame narrows it to whether the stage runs (`traced_shadows`).
    let ray_traced_shadows =
        settings.ray_traced_shadows && matches!(hardware_ray_tracing, HardwareRayTracing::On(_));
    let occlusion_culling = settings.occlusion_culling && occlusion_supported && !disable.culling;
    Effective {
        antialiasing,
        taa,
        fsr,
        temporal_masks,
        fsr_sharpness: fsr_sharpness(settings, fsr),
        post_fx: taa || crystal,
        shadow_quality: settings.shadow_quality,
        shadow_filter,
        ambient_occlusion,
        screen_space,
        world_space: world_space(settings, content.ray_data, screen_space.is_some()),
        hardware_ray_tracing,
        ray_traced_shadows,
        ray_traced_shadow_quality: settings.ray_traced_shadow_quality.resolve(low),
        receivers: content.receivers
            && (screen_space.is_some() || taa || fsr || motion_blur.is_some()),
        // Occlusion culling's late phase falls between the G-buffer passes,
        // so the opaque stage takes its two-pass form.
        fused: fused_supported && !disable.fused_opaque && !occlusion_culling,
        occlusion_culling,
        local_lights: !disable.local_lights,
        fog: fog(
            settings,
            input,
            content.fog_volumes,
            p[3][3] == 0. && p[2][3] == -1.,
        ),
        fog_filter: settings.fog_filter,
        dynamic_gi: dynamic_gi(settings, tier, content.ray_data)
            .rays()
            .filter(|_| content.dynamic_gi_volume),
        volume_paths: volume_paths(settings, tier),
        bloom: settings.bloom.enabled(low) && !disable.bloom,
        motion_blur,
        composite,
        culling: !disable.culling,
        smaa: !disable.smaa,
        smaa_quality: settings.smaa_quality,
        tone_mapping: settings.tone_mapping,
        upscaling: settings.upscaling,
        anisotropy: settings.anisotropic_filtering.clamp(),
        layers: LayerConstants::new(&disable),
        source_environment: !disable.source_environment,
        #[cfg(feature = "diagnostics")]
        frame_probe: diagnostics.frame_probe,
        #[cfg(feature = "diagnostics")]
        dynamic_gi_observation: diagnostics.dynamic_gi,
        capture_tone_target: diagnostics.frame_probe || diagnostics.capture_tone_target,
    }
}

/// World-space reflections need both screen-space receivers and retained
/// ray data; the requested choice itself is never rewritten.
pub(super) fn world_space(
    settings: &Settings,
    ray_data: RayData,
    screen_space: bool,
) -> WorldSpaceReflections {
    if ray_data == RayData::Enabled && screen_space {
        settings.world_space_reflections
    } else {
        WorldSpaceReflections::Off
    }
}

#[cfg(test)]
mod ray_data_tests {
    use super::*;
    use wasm_bindgen_test::wasm_bindgen_test;

    // Scene policy must gate the actual effective stage configuration, even
    // on a hypothetical device with every ray feature. SSR, volume layers,
    // ambient and shadow maps remain independently available.
    #[wasm_bindgen_test(unsupported = test)]
    fn disabled_scene_gates_rays_without_changing_requested_settings() {
        let settings = Settings {
            screen_space_reflections: ScreenSpaceReflections::Full,
            world_space_reflections: WorldSpaceReflections::Moving,
            hardware_ray_tracing: true,
            ray_traced_shadows: true,
            dynamic_gi: DynamicGiQuality::High,
            volume_paths: true,
            ..Settings::default()
        };
        let requested = settings;
        let camera = crate::Camera {
            view: glam::Mat4::IDENTITY,
            projection: crate::perspective(1., 1., 0.1),
            eye: glam::Vec3::ZERO,
        };
        let input = FrameInput::new(camera);
        let device = Device {
            fsr_running: None,
            fused_supported: true,
            occlusion_supported: true,
            ray_queries: Some(RayQueryForm::Baseline),
            tier: BindingTier::Extended,
        };
        let content = SceneContent {
            dynamic_gi_volume: true,
            ..SceneContent::default()
        };
        let enabled = resolve(&settings, &input, content, device);
        assert!(enabled.dynamic_gi.is_some());
        assert_eq!(enabled.world_space, WorldSpaceReflections::Moving);
        assert!(enabled.ray_traced_shadows);
        let disabled = resolve(
            &settings,
            &input,
            SceneContent {
                ray_data: RayData::Disabled,
                ..content
            },
            device,
        );
        assert!(disabled.dynamic_gi.is_none());
        assert_eq!(disabled.world_space, WorldSpaceReflections::Off);
        assert_eq!(
            disabled.hardware_ray_tracing,
            HardwareRayTracing::DisabledByScene
        );
        assert!(!disabled.ray_traced_shadows);
        assert_eq!(enabled.screen_space, disabled.screen_space);
        assert!(disabled.volume_paths);
        assert_eq!(enabled.shadow_quality, disabled.shadow_quality);
        assert_eq!(enabled.ambient_occlusion, disabled.ambient_occlusion);
        assert_eq!(settings, requested);
    }

    // A preceding scene's error is not a capability of this one. Synthetic
    // hardware support reaches the no-consumer On branch on Metal/WebGPU too;
    // that branch must not attempt a hardware build or retain NO_RAY_DATA.
    #[cfg(not(target_arch = "wasm32"))]
    #[test]
    fn enabled_scene_without_ray_consumers_clears_previous_disabled_reason() {
        use crate::view::history::{CameraFrame, CameraHistory};
        use crate::{Renderer, Scene, SceneOptions, test_support};
        let Some((device, queue)) = test_support::device() else {
            return;
        };
        let settings = Settings {
            hardware_ray_tracing: true,
            dynamic_gi: DynamicGiQuality::Off,
            ..Settings::default()
        };
        let mut renderer = Renderer::for_test(&device, &queue, [16; 2], &settings);
        let input = FrameInput::new(crate::Camera {
            view: glam::Mat4::IDENTITY,
            projection: crate::perspective(1., 1., 0.1),
            eye: glam::Vec3::ZERO,
        });
        let synthetic = Device {
            fsr_running: None,
            fused_supported: true,
            occlusion_supported: true,
            ray_queries: Some(RayQueryForm::Baseline),
            tier: renderer.binding_tier(),
        };
        for mode in [RayData::Disabled, RayData::Enabled] {
            let mut scene = Scene::with_options(&device, &queue, SceneOptions { ray_data: mode });
            let effective = resolve(&settings, &input, SceneContent::of(&scene), synthetic);
            let history = CameraHistory::default().begin(
                CameraFrame {
                    view: input.camera.view,
                    projection: input.camera.projection,
                    jitter: [0.; 2],
                },
                true,
                glam::DVec3::ZERO,
                0.,
                input.visibility_mask,
            );
            let before = crate::counters::snapshot();
            renderer.prepare.run(
                &device,
                &queue,
                &mut scene,
                &input,
                history,
                &effective,
                None,
                [16; 2],
                &mut renderer.views,
                &renderer.bindings.frame,
            );
            assert_eq!(
                renderer.ray_tracing_error().is_some(),
                mode == RayData::Disabled
            );
            if mode == RayData::Enabled {
                assert_eq!(
                    effective.hardware_ray_tracing,
                    HardwareRayTracing::On(RayQueryForm::Baseline)
                );
                let delta = crate::counters::snapshot().since(&before);
                assert_eq!(delta.blas_builds + delta.tlas_builds, 0);
            }
        }
    }
}

#[cfg(all(test, feature = "diagnostics"))]
mod temporal_mask_tests {
    use super::*;
    use crate::settings::{Antialiasing, FsrVersion};
    use wasm_bindgen_test::wasm_bindgen_test;

    // Plausible defects: TAA frames allocate the temporal masks though
    // nothing draws into them, or not when one writer alone draws; a writer
    // counted although its own draw is off (glow with effects disabled, mist
    // without the frame's atmosphere, heat with the setting off); FSR frames
    // left without the masks their dispatch binds. The oracle is Frame item
    // 8's rule as a table: the masks are held for every FSR frame, and for a
    // TAA frame exactly when blended or moving-shading materials, or glow,
    // mist or heat that draws, can mark them.
    #[wasm_bindgen_test(unsupported = test)]
    fn the_temporal_masks_are_held_exactly_while_a_writer_can_mark_them() {
        let camera = crate::Camera {
            view: glam::Mat4::IDENTITY,
            projection: crate::perspective(1., 1., 0.1),
            eye: glam::Vec3::ZERO,
        };
        let mut input = FrameInput::new(camera);
        input.atmosphere = true;
        let device = Device {
            fsr_running: Some(FsrVersion::Fsr2),
            fused_supported: true,
            occlusion_supported: true,
            ray_queries: None,
            tier: BindingTier::Extended,
        };
        let taa = Settings {
            antialiasing: Antialiasing::Taa,
            atmosphere: true,
            heat_distortion: true,
            ..Settings::default()
        };
        let none = SceneContent::default();
        let alone = [
            SceneContent {
                blended: true,
                ..none
            },
            SceneContent {
                moving_surfaces: true,
                ..none
            },
            SceneContent { glow: true, ..none },
            SceneContent { mist: true, ..none },
            SceneContent { heat: true, ..none },
        ];
        let held = |settings: &Settings, content| {
            resolve(settings, &input, content, device).temporal_masks
        };
        assert!(!held(&taa, none), "a TAA frame nothing can mark");
        for content in alone {
            assert!(held(&taa, content), "one writer alone");
        }
        let mut no_effects = taa;
        no_effects.diagnostics.disable.effects = true;
        assert!(!held(&no_effects, alone[2]), "glow with effects disabled");
        let no_atmosphere = Settings {
            atmosphere: false,
            ..taa
        };
        assert!(!held(&no_atmosphere, alone[3]), "mist without atmosphere");
        let no_heat = Settings {
            heat_distortion: false,
            ..taa
        };
        assert!(!held(&no_heat, alone[4]), "heat with the setting off");
        let fsr = Settings {
            antialiasing: Antialiasing::Fsr2,
            ..taa
        };
        assert!(held(&fsr, none), "an FSR frame, whose dispatch binds them");
        let off = Settings {
            antialiasing: Antialiasing::Off,
            ..taa
        };
        for content in alone {
            assert!(!held(&off, content), "no temporal antialiasing");
        }
    }
}