tbc

A pure-Rust library for BCn texture block compression, encoding images to BC1, BC3, and BC4 formats.

Library
Cargo
v0.3.0
11stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
21/100Needs Attention
Development Activity0
Maintenance0
Community12
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
62/100Good
Architecture68
Code Quality55
Innovation66
Learning Curve62

tbc is a pure-Rust implementation of BCn texture block compression, the family of formats used to compress GPU textures. Block compression dramatically lowers the memory bandwidth needed to sample textures, which is especially valuable on integrated GPUs with slower memory, and virtually every GPU since the late 1990s includes a hardware decompressor so there is no runtime cost to using compressed textures.

The library encodes raw image data into BC1 (DXT1), BC3 (DXT5), and BC4 (both R8 and RG8) blocks, with helper variants that convert directly from u8 buffers. It has zero external dependencies and exposes a small set of free functions for compressing whole images or individual 4x4 blocks.

What You Get

  • Pure-Rust encoders for BC1 (DXT1), BC3 (DXT5), and BC4 texture block compression
  • BC4 support for both single-channel R8 and two-channel RG8 layouts
  • Convenience variants that convert directly from u8 image buffers
  • Block-level and whole-image encoding entry points
  • Zero external dependencies for easy integration

Common Use Cases

  • Compressing textures ahead of GPU upload in a renderer or game engine
  • Reducing texture memory footprint for integrated or low-bandwidth GPUs
  • Building offline texture-conversion tooling in an asset pipeline

Under The Hood

Architecture - The crate is split into one module per format: bc1.rs, bc3.rs, and bc4.rs each implement encoding for their block layout, supported by shared helpers in color.rs (the Rgba8 color type) and utils.rs. The public API in lib.rs re-exports a flat set of free functions such as encode_image_bc1, encode_image_bc3, and encode_image_bc4_r8, plus _conv_u8 variants that accept plain byte buffers.

Tech Stack - Written in Rust (edition 2018) with no external crate dependencies at all, keeping the build footprint minimal. The entire implementation is roughly 19 KB of Rust source across six files.

Code Quality - The code is small and focused, organized cleanly by format. A single unit test in lib.rs exercises BC1 block encoding, so test coverage is minimal and correctness rests largely on the documented reference algorithms the implementation follows. The crate has not seen commits since 2021, making it stable but effectively unmaintained.

API Design - The public surface is a small, predictable set of free functions with consistent naming (encode_image_<format> and encode_block_<format>), and the _conv_u8 variants remove boilerplate when working directly from raw byte buffers. Module-level documentation links to the authoritative BCn references, which helps developers understand the format tradeoffs.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search