use crate::api::{SourceFormat, TargetFormat};
fn is_astc_target(target: TargetFormat) -> bool {
use TargetFormat::*;
matches!(
target,
Astc4x4Rgba
| AstcHdr6x6Rgba
| AstcLdr5x4Rgba
| AstcLdr5x5Rgba
| AstcLdr6x5Rgba
| AstcLdr6x6Rgba
| AstcLdr8x5Rgba
| AstcLdr8x6Rgba
| AstcLdr10x5Rgba
| AstcLdr10x6Rgba
| AstcLdr8x8Rgba
| AstcLdr10x8Rgba
| AstcLdr10x10Rgba
| AstcLdr12x10Rgba
| AstcLdr12x12Rgba
)
}
pub fn is_format_supported(target: TargetFormat, source: SourceFormat) -> bool {
use TargetFormat::*;
let hdr_target = matches!(
target,
Bc6h | AstcHdr4x4Rgba | AstcHdr6x6Rgba | RgbHalf | RgbaHalf | Rgb9e5
);
let non4x4_ldr_astc = is_astc_target(target) && !hdr_target && target != Astc4x4Rgba;
match source {
#[allow(clippy::needless_return)]
SourceFormat::XuastcLdr(b) => {
return crate::support::is_format_supported(target, SourceFormat::AstcLdr(b));
}
SourceFormat::UastcLdr => {
!hdr_target
&& !non4x4_ldr_astc
&& !matches!(
target,
Pvrtc2_4Rgb | Pvrtc2_4Rgba | AtcRgb | AtcRgba | Fxt1Rgb
)
}
SourceFormat::Etc1s => !hdr_target && !non4x4_ldr_astc,
SourceFormat::UastcHdr4x4 => {
matches!(target, Bc6h | AstcHdr4x4Rgba | RgbHalf | RgbaHalf | Rgb9e5)
}
SourceFormat::AstcLdr(b) => {
target == b.passthrough_target()
|| matches!(
target,
Etc1Rgb
| Etc2Rgba
| Bc1Rgb
| Bc3Rgba
| Bc4R
| Bc5Rg
| Bc7Rgba
| EacR11
| EacRg11
| Pvrtc1_4Rgb
| Pvrtc1_4Rgba
| Rgba32
| Rgb565
| Bgr565
| Rgba4444
)
}
SourceFormat::AstcHdr6x6 | SourceFormat::UastcHdr6x6 => {
matches!(target, AstcHdr6x6Rgba | Bc6h | RgbHalf | RgbaHalf | Rgb9e5)
}
}
}