pub mod bindings {
use ispc_rt::ispc_module;
ispc_module!(kernel);
ispc_module!(kernel_astc);
}
pub mod astc;
pub mod bc1;
pub mod bc3;
pub mod bc4;
pub mod bc5;
pub mod bc6h;
pub mod bc7;
pub mod etc1;
#[derive(Debug, Copy, Clone)]
pub struct Surface<'a, const COMPONENTS: usize> {
pub data: &'a [u8],
pub width: u32,
pub height: u32,
pub stride: u32,
}
impl<'a, const COMPONENTS: usize> Surface<'a, COMPONENTS> {
pub fn new(data: &'a [u8], width: u32, height: u32, stride: u32) -> Self {
assert!(
i32::try_from(width).is_ok(),
"width {width} exceeds i32::MAX"
);
assert!(
i32::try_from(height).is_ok(),
"height {height} exceeds i32::MAX"
);
assert!(
i32::try_from(stride).is_ok(),
"stride {stride} exceeds i32::MAX"
);
let required = stride as usize * height as usize;
assert!(
data.len() >= required,
"data length {} is less than stride * height ({required})",
data.len()
);
Self {
data,
width,
height,
stride,
}
}
}
pub type RgbaSurface<'a> = Surface<'a, 4>;
pub type RgSurface<'a> = Surface<'a, 2>;
pub type RSurface<'a> = Surface<'a, 1>;
pub type Rgba16Surface<'a> = Surface<'a, 8>;