use wgpu::TextureFormat;
pub(crate) use backdrop_blur_core::{
PingPongKey, RETENTION_FRAMES, TargetEncoding, backdrop_uv_remap, evict_decision,
kawase_halfpixel, kawase_level_size, resolve_gaussian, resolve_kawase_levels, use_dual_kawase,
};
pub(crate) const SCRATCH_FORMAT: TextureFormat = TextureFormat::Rgba16Float;
pub(crate) fn composite_encode_srgb(format: TextureFormat) -> Option<TargetEncoding> {
match format {
TextureFormat::Rgba8UnormSrgb | TextureFormat::Bgra8UnormSrgb => {
Some(TargetEncoding::Linear)
}
TextureFormat::Rgba8Unorm | TextureFormat::Bgra8Unorm => Some(TargetEncoding::Srgb),
TextureFormat::Rgba16Float => Some(TargetEncoding::Linear),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn composite_encode_srgb_allowlist() {
assert_eq!(
composite_encode_srgb(TextureFormat::Rgba8UnormSrgb),
Some(TargetEncoding::Linear)
);
assert_eq!(
composite_encode_srgb(TextureFormat::Bgra8UnormSrgb),
Some(TargetEncoding::Linear)
);
assert_eq!(
composite_encode_srgb(TextureFormat::Rgba8Unorm),
Some(TargetEncoding::Srgb)
);
assert_eq!(
composite_encode_srgb(TextureFormat::Bgra8Unorm),
Some(TargetEncoding::Srgb)
);
assert_eq!(
composite_encode_srgb(TextureFormat::Rgba16Float),
Some(TargetEncoding::Linear)
);
assert_eq!(composite_encode_srgb(TextureFormat::R8Unorm), None);
}
}