Expand description
Multi-format texture compression (BC1 and BC4) for OxiGDAL GPU.
This module provides both pure-Rust CPU implementations and GPU-accelerated (wgpu compute shader) paths for compressing raster data into BC1 (DXT1) and BC4 (ATI1) block-compressed texture formats.
§Format overview
| Format | Input | Output | Ratio |
|---|---|---|---|
TextureFormat::Bc1RgbUnorm | RGBA8 (4 B/px) | 8 B / 4×4 block | 6:1 |
TextureFormat::Bc4RUnorm | R8 (1 B/px) | 8 B / 4×4 block | 2:1 |
§BC1 block layout (8 bytes)
[u16 c0 LE] [u16 c1 LE] [u32 lookup LE]When c0 > c1 four colours are interpolated (opaque mode, always used
here). When c0 <= c1 three colours + transparent; this module never
emits that mode.
§BC4 block layout (8 bytes)
[u8 ep0] [u8 ep1] [48-bit LE packed 3-bit indices for 16 pixels]When ep0 > ep1 eight interpolated values are used (always in this
module).
§GPU path
TextureCompressor drives a wgpu compute shader that processes one 4×4
block per workgroup thread. When wgpu is unavailable the compress method
falls back silently to the CPU path.
Structs§
- Texture
Compressor - GPU-accelerated texture compressor for BC1 and BC4 block formats.
Enums§
- Texture
Format - Target block-compressed texture format produced by
TextureCompressor.
Functions§
- compress_
bc1_ block_ cpu - Compress one 4×4 RGBA block (64 bytes, row-major) to an 8-byte BC1 block.
- compress_
bc4_ block_ cpu - Compress one 4×4 R-channel block (16 bytes) to an 8-byte BC4 block.
- dequantize_
rgb565 - Reverse a packed RGB565 value back to approximate 8-bit R, G, B.
- nearest_
index_ 4 - Return the index (0..4) of the endpoint in
endpointsnearest tovalue_rgbunder the squared-Euclidean distance metric in RGB space. - quantize_
rgb565 - Quantise 8-bit RGB components to packed 16-bit RGB565.
- validate_
texture_ dimensions - Validate that
widthandheightare both multiples of 4 (required for block-compressed textures).