diff --git a/examples/main.rs b/examples/main.rs index d832bd2..9943096 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -56,7 +56,7 @@ fn main() { let surface = intel_tex_2::RgbaSurface { width, height, - stride: width * 4, + stride_in_bytes: width * 4, data: &rgba_img, }; diff --git a/src/astc.rs b/src/astc.rs index c555c08..af37b74 100644 --- a/src/astc.rs +++ b/src/astc.rs @@ -163,7 +163,7 @@ pub fn compress_blocks_into(settings: &EncodeSettings, surface: &RgbaSurface, bl let mut surface = kernel_astc::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; diff --git a/src/bc1.rs b/src/bc1.rs index caac2e8..374e77b 100644 --- a/src/bc1.rs +++ b/src/bc1.rs @@ -23,7 +23,7 @@ pub fn compress_blocks_into(surface: &RgbaSurface, blocks: &mut [u8]) { let mut surface = kernel::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; diff --git a/src/bc3.rs b/src/bc3.rs index 13499bf..ff923f3 100644 --- a/src/bc3.rs +++ b/src/bc3.rs @@ -23,7 +23,7 @@ pub fn compress_blocks_into(surface: &RgbaSurface, blocks: &mut [u8]) { let mut surface = kernel::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; diff --git a/src/bc6h.rs b/src/bc6h.rs index caaa2cc..e5d50b7 100644 --- a/src/bc6h.rs +++ b/src/bc6h.rs @@ -32,7 +32,7 @@ pub fn compress_blocks_into(settings: &EncodeSettings, surface: &RgbaSurface, bl let mut surface = kernel::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; let mut settings = kernel::bc6h_enc_settings { diff --git a/src/bc7.rs b/src/bc7.rs index ec694ba..1112524 100644 --- a/src/bc7.rs +++ b/src/bc7.rs @@ -36,7 +36,7 @@ pub fn compress_blocks_into(settings: &EncodeSettings, surface: &RgbaSurface, bl let mut surface = kernel::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; let mut settings = kernel::bc7_enc_settings { diff --git a/src/etc1.rs b/src/etc1.rs index fec149c..a399a76 100644 --- a/src/etc1.rs +++ b/src/etc1.rs @@ -28,7 +28,7 @@ pub fn compress_blocks_into(settings: EncodeSettings, surface: &RgbaSurface, blo let mut surface = kernel::rgba_surface { width: surface.width as i32, height: surface.height as i32, - stride: surface.stride as i32, + stride: surface.stride_in_bytes as i32, ptr: surface.data.as_ptr() as *mut u8, }; let mut settings = kernel::etc_enc_settings { diff --git a/src/lib.rs b/src/lib.rs index 7a876a2..ef771a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,12 +13,18 @@ pub mod bc6h; pub mod bc7; pub mod etc1; +/// Describes a 2D uncompressed little endian RGBA image. #[derive(Debug, Copy, Clone)] pub struct RgbaSurface<'a> { + /// The pixel data for the image. + /// The data does not need to be tightly packed, but if it isn't, stride must be different from `width * 4`. + /// + /// Expected to be at least `stride * height` bytes long. pub data: &'a [u8], pub width: u32, pub height: u32, - pub stride: u32, + /// The stride between the rows of pixels, in bytes. + pub stride_in_bytes: u32, } #[inline(always)]