pub const PASS_NAMES: [&str; PASS_COUNT] = [
"cull",
"shadow",
"ssr_prepass",
"ssao_prepass",
"ssao_kernel",
"ssao_blur",
"main",
"auto_exposure",
"decals",
"fog",
"particles_sim",
"particles_draw",
"ssr_resolve",
"velocity",
"taa_resolve",
"bloom",
"composite",
"fog_froxel",
"upscale",
"transparent",
"raymarch",
"hiz_build",
"cull2",
"main2",
"ssgi",
"rt_reflections",
"gbuffer_prepass",
"reflection_composite",
"light_cull",
"spot_shadow",
"lines",
"hiz_final",
];
pub const PASS_COUNT: usize = 32;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
pub enum PassId {
Cull = 0,
Shadow = 1,
SsrPrepass = 2,
SsaoPrepass = 3,
SsaoKernel = 4,
SsaoBlur = 5,
Main = 6,
AutoExposure = 7,
Decals = 8,
Fog = 9,
ParticlesSim = 10,
ParticlesDraw = 11,
SsrResolve = 12,
Velocity = 13,
TaaResolve = 14,
Bloom = 15,
Composite = 16,
FogFroxel = 17,
Upscale = 18,
Transparent = 19,
Raymarch = 20,
HizBuild = 21,
Cull2 = 22,
Main2 = 23,
Ssgi = 24,
RtReflections = 25,
GBufferPrepass = 26,
ReflectionComposite = 27,
LightCull = 28,
SpotShadow = 29,
Lines = 30,
HizFinal = 31,
}
impl PassId {
pub fn name(self) -> &'static str {
PASS_NAMES[self as usize]
}
}
#[cfg(test)]
mod tests {
use super::*;
const ALL: [PassId; PASS_COUNT] = [
PassId::Cull,
PassId::Shadow,
PassId::SsrPrepass,
PassId::SsaoPrepass,
PassId::SsaoKernel,
PassId::SsaoBlur,
PassId::Main,
PassId::AutoExposure,
PassId::Decals,
PassId::Fog,
PassId::ParticlesSim,
PassId::ParticlesDraw,
PassId::SsrResolve,
PassId::Velocity,
PassId::TaaResolve,
PassId::Bloom,
PassId::Composite,
PassId::FogFroxel,
PassId::Upscale,
PassId::Transparent,
PassId::Raymarch,
PassId::HizBuild,
PassId::Cull2,
PassId::Main2,
PassId::Ssgi,
PassId::RtReflections,
PassId::GBufferPrepass,
PassId::ReflectionComposite,
PassId::LightCull,
PassId::SpotShadow,
PassId::Lines,
PassId::HizFinal,
];
fn expected_name(pass: PassId) -> &'static str {
match pass {
PassId::Cull => "cull",
PassId::Shadow => "shadow",
PassId::SsrPrepass => "ssr_prepass",
PassId::SsaoPrepass => "ssao_prepass",
PassId::SsaoKernel => "ssao_kernel",
PassId::SsaoBlur => "ssao_blur",
PassId::Main => "main",
PassId::AutoExposure => "auto_exposure",
PassId::Decals => "decals",
PassId::Fog => "fog",
PassId::ParticlesSim => "particles_sim",
PassId::ParticlesDraw => "particles_draw",
PassId::SsrResolve => "ssr_resolve",
PassId::Velocity => "velocity",
PassId::TaaResolve => "taa_resolve",
PassId::Bloom => "bloom",
PassId::Composite => "composite",
PassId::FogFroxel => "fog_froxel",
PassId::Upscale => "upscale",
PassId::Transparent => "transparent",
PassId::Raymarch => "raymarch",
PassId::HizBuild => "hiz_build",
PassId::Cull2 => "cull2",
PassId::Main2 => "main2",
PassId::Ssgi => "ssgi",
PassId::RtReflections => "rt_reflections",
PassId::GBufferPrepass => "gbuffer_prepass",
PassId::ReflectionComposite => "reflection_composite",
PassId::LightCull => "light_cull",
PassId::SpotShadow => "spot_shadow",
PassId::Lines => "lines",
PassId::HizFinal => "hiz_final",
}
}
#[test]
fn pass_names_match_pass_count() {
assert_eq!(PASS_NAMES.len(), PASS_COUNT);
}
#[test]
fn every_pass_id_round_trips_to_its_name() {
for (i, &pass) in ALL.iter().enumerate() {
assert_eq!(pass as usize, i, "{pass:?} index out of order");
assert_eq!(pass.name(), PASS_NAMES[i], "{pass:?} name table mismatch");
assert_eq!(pass.name(), expected_name(pass), "{pass:?} name drifted");
assert!(!pass.name().is_empty(), "{pass:?} has an empty name");
}
assert_eq!(ALL[PASS_COUNT - 1] as usize, PASS_COUNT - 1);
}
}