Learn/Remade with Rust

Exact to the byte: an ASTC decoder in pure Rust

rusty_dds 0.11.0 matches ARM's reference ASTC decoder on 506,671,729 blocks with zero differing bytes, and decodes 1.45 to 2.1 times faster than its AVX2 build on one thread.

Signed by Tim Almond·
Two square sheets of small terracotta, ochre, sage and cream ceramic tiles lie on a light oak table, with a brass magnifying glass over one sheet and a speckled cup by the window
Is the rusty_dds ASTC decoder exact against ARM's astcenc?

Yes. The ASTC decoder in rusty_dds 0.11.0 matched ARM astcenc 5.7.1 in all six decode modes on 506,671,729 random, mutated and real blocks across all 24 block sizes, with zero differing bytes. A census also hit all 2,888 block-size and block-type cells.

I work on rusty_dds, a Remade with Rust texture toolkit that sits under MATA. Version 0.11.0 went out just after midnight on 22 November 2026, and it adds ASTC: a decoder, an encoder, and the containers ASTC ships in. The part I care about most is narrow. The ASTC decoder matches ARM's reference decoder to the byte.

That needs one caveat up front. This is not the first pure-Rust ASTC code. ktx-rs ports ARM's encoder and oxideav-dds has an LDR encoder, so "first" would be false. What is unusual is the word exact. The two most-downloaded standalone Rust ASTC decoders on crates.io, astc-decode and texture2ddecoder, do not match ARM's output. On our four test textures each one differed from it on 16% to 41% of pixels, and on more than a third of pixels in most runs.

The cause is small. ASTC interpolates each texel at 16 bits. The Khronos decode-mode extension says 8-bit output keeps the top 8 bits of that value. Both crates round instead, so a large share of pixels land one level off. One level sounds harmless until a test compares bytes, or a content pipeline hashes its output.

Why an exact ASTC decoder was worth a day

ASTC is the compressed texture format used on mobile GPUs, Apple GPUs and the web. The request came from a real user. ArtCraft's Material app had moved its DDS loading onto rusty_dds, and ASTC was the last reason it still pulled in two other crates, dds 0.2 and astc-decode 0.3. Issue #6 spells out their acceptance test, and it is a sharp one: decode against ARM's astcenc -d output, exact for LDR, plus paired speed runs against astc-decode.

The work split in two. One agent wrote the plan, a document addressed to a builder who had not seen the research. A second agent built the toolkit against it. The ground rule never moved: astcenc 5.7.1 is the reference, and close enough does not count.

The timestamps back up the "in a day" part. The issue was reopened at 2:33 PM MST on 21 November. The plan landed at 3:11 PM, the first decoder commit at 3:34 PM, and the release was published at 12:06 AM on 22 November.

How we proved the output matches astcenc

Exact needs a definition before it means anything. astcenc picks its decode rule from the output type, so the conformance artifact defines six cells: sRGB and linear LDR, each at 8-bit and half-float output, then HDR colour with LDR alpha, then full HDR. Half floats are compared as raw bit patterns. A decoder that passes one cell and fails another is not exact.

Half a billion blocks, zero differences

The main sweep fed 10 million uniformly random blocks, 10 million mutated blocks (one to eight bit flips of real ones) and a million legal-biased blocks per block size through both decoders. With a natural corpus of 956 astcenc-encoded files on top, that is 506,671,729 blocks across all 24 block sizes, 14 flat and 10 volumetric, each decoded in all six cells. Differing bytes: 0. That is 3.04 billion block decodes compared.

A census for the rare block types

Random input can miss rare corners of the format. So the census enumerates every reachable pairing of block size and block class, down to endpoint sub-modes, and requires at least 32 exact blocks in each. The result is 2,888 of 2,888 cells. Block-mode tables (49,152 of 49,152) and partition maps (73,728 of 73,728) were also checked against the reference, one by one.

Fuzzing and bad input

Malformed input returns an error. It never panics. The astc_decode fuzz target ran for one CPU-hour, 3,380,934 executions, with 0 crashes. The container target ran another 30 minutes with 0 crashes. The issue reply counts about 1.8 CPU-hours once the encode round-trip target is added; the committed artifacts record the first 1.5. A truncated payload returns TruncatedData, which issue #6 asked for by name.

Speed, containers, and what is not finished

An exact ASTC decoder would be a weak sell if it were slow. This one is not. The decode benchmark ran one thread pinned to one core with 8-bit output, over four 2048 by 2048 textures at 4x4, 6x6, 8x8 and 12x12. The arms were interleaved and reversed every round, and a null arm (our own decoder under a second name) put the noise floor at 6% or less.

Faster than the crates it replaces

Against the faster of astc-decode 0.3.1 and texture2ddecoder 0.1.2, rusty_dds measured 1.91 to 2.83 times the throughput. Against ARM's own astcenc-avx2, run single-threaded, it measured 1.45 to 2.10 times. Only one of the 16 cells reached 2.0 times astcenc, so that stretch goal is still open. The bench runs under rusty_alloc, the same pairing as the game-stream measurements.

Every container ASTC travels in

The decoder reads raw .astc files, KTX 1.0, KTX 2.0 and DDS files with DXGI ASTC formats. KTX 2.0 files with Zstd supercompression open through rusty_zstd, our pure-Rust Zstandard codec, behind an optional feature. There is also an encoder nobody asked for. Four presets are measured against astcenc, from Fastest to Thorough, and a fifth, Exhaustive, is still a first cut. Every block it emitted in the quality runs decoded identically in astcenc.

The limits, and the handoff

The encoder has no SIMD yet and runs at 0.17 to 0.31 times astcenc-avx2. HDR encoding is well behind astcenc and is not claimed. Medium at 12x12 sits exactly on its speed floor, with no margin. And testing found an older bug: DDS mip chains for non-power-of-two BCn textures come out short, now issue #12.

Issue #6 was answered with this evidence and closed when 0.11.0 reached crates.io. ArtCraft's own comparison is the real-world check, and it is still pending. When their numbers arrive, they will be posted on that issue. The crate lives on the rusty_dds page, next to the rest of the Remade with Rust catalog, and the Learn index has the other house notes, including the FFmpeg 9.1 container work.

FAQ

Short answers already in this article.

What is ASTC, and why would a Rust program need to read it?

ASTC (Adaptive Scalable Texture Compression) is the compressed texture format used on mobile GPUs, Apple GPUs and the web. A tool that loads, inspects or converts those textures on the CPU has to decode the 128-bit blocks itself. rusty_dds 0.11.0 does that in pure Rust.

Why aren't astc-decode and texture2ddecoder exact?

Both interpolate 16-bit values and then round to 8 bits. The Khronos UNORM8 decode mode takes the top 8 bits instead, and that is what ARM's astcenc does. On the four 2048 by 2048 test textures, the two crates differed from astcenc on 16% to 41% of pixels, most often by one level.

How fast is the rusty_dds ASTC decoder?

On one pinned thread with 8-bit output, across four 2048 by 2048 textures at 4x4, 6x6, 8x8 and 12x12, it measured 1.91 to 2.83 times the faster of astc-decode 0.3.1 and texture2ddecoder 0.1.2, and 1.45 to 2.10 times astcenc-avx2 run with -j 1.

Which ASTC containers can rusty_dds 0.11.0 read?

Raw .astc files, KTX 1.0, KTX 2.0 (including Zstd supercompression behind the optional ktx2-zstd feature, inflated by rusty_zstd) and DDS files that carry DXGI ASTC formats. It also writes .astc, KTX 1.0, KTX 2.0 and DDS.

What is still unfinished in the ASTC work?

The encoder has no SIMD yet and runs at 0.17 to 0.31 times astcenc-avx2. HDR encoding is well behind astcenc and is not claimed. Medium at 12x12 sits exactly on its speed floor. Separately, rusty_dds issue 12 tracks short non-power-of-two BCn mip chains.