Skip to main content

Crate ctt_etcpak

Crate ctt_etcpak 

Source
Expand description

Safe Rust bindings to etcpak — an extremely fast ETC/EAC/BC texture compressor and decompressor.

§ISA dispatch

etcpak uses compile-time SIMD ISA selection. This crate compiles multiple variants and selects the best one at runtime:

  • x86_64: SSE4.1 and AVX2 variants (selected via std::is_x86_feature_detected!)
  • aarch64: NEON (the only variant, always available on AArch64)

§Pixel format

All compression functions expect 4 bytes per pixel, packed as uint32_t. The channel ordering within each pixel depends on the codec:

  • ETC1/ETC2/EAC codecs: B8 G8 R8 A8 (BGRA — blue in lowest byte)
  • BC codecs: R8 G8 B8 A8 (RGBA — red in lowest byte)

Input data must be tightly packed (stride = width × 4 bytes).

Decompression functions output uint32_t per pixel in native etcpak layout.

Modules§

bc1
BC1 (DXT1) block compression — RGB with optional 1-bit alpha.
bc3
BC3 (DXT5) block compression — RGBA.
bc4
BC4 block compression — single channel (red).
bc5
BC5 block compression — dual channel (red + green, typically normals).
decode
Decompression functions for all supported formats.
eac_r
EAC R11 block compression — single channel (red).
eac_rg
EAC RG11 block compression — dual channel (red + green).
etc1
ETC1 block compression — RGB, no alpha.
etc2_rgb
ETC2 RGB block compression — RGB, no alpha.
etc2_rgba
ETC2 RGBA block compression — RGB with alpha.

Structs§

Surface
Describes a 2D image for compression.

Functions§

output_size_64bpb
Output size for formats using 64-bit (8-byte) blocks: ETC1, ETC2 RGB, EAC R, BC1, BC4.
output_size_128bpb
Output size for formats using 128-bit (16-byte) blocks: ETC2 RGBA, EAC RG, BC3, BC5.