intel_tex_2/
lib.rs

1#[allow(deref_nullptr)]
2pub mod bindings {
3    use ispc_rt::ispc_module;
4    ispc_module!(kernel);
5    ispc_module!(kernel_astc);
6}
7
8pub mod astc;
9pub mod bc1;
10pub mod bc3;
11pub mod bc4;
12pub mod bc5;
13pub mod bc6h;
14pub mod bc7;
15pub mod etc1;
16
17/// Describes a 2D image to block-compress.
18#[derive(Debug, Copy, Clone)]
19pub struct Surface<'a, const COMPONENTS: usize> {
20    /// The pixel data for the image.
21    /// The data does not need to be tightly packed, but if it isn't, stride must be different from `width * 4`.
22    ///
23    /// Expected to be at least `stride * height`.
24    pub data: &'a [u8],
25    /// The width of the image in texels.
26    pub width: u32,
27    /// The height of the image in texels.
28    pub height: u32,
29    /// The stride between the rows of the image, in bytes.
30    /// If `data` is tightly packed, this is expected to be `width * 4`.
31    pub stride: u32,
32}
33
34pub type RgbaSurface<'a> = Surface<'a, 4>;
35pub type RgSurface<'a> = Surface<'a, 2>;
36pub type RSurface<'a> = Surface<'a, 1>;
37
38#[inline(always)]
39pub fn divide_up_by_multiple(val: u32, align: u32) -> u32 {
40    let mask: u32 = align - 1;
41    (val + mask) / align
42}