chuda
A CUDA-only, high-quality truecolour ANSI renderer for image-training pipelines. It implements the expensive part of Chafa's effort-9 symbol mode: exhaustive foreground/background fitting and error scoring over the narrow symbol atlas. PNG decode, high-quality resize and stateful ANSI emission stay in Rust; independent cell/symbol evaluation runs on CUDA.
RGBA images are optimized jointly for either a detailed opaque foreground and
background cell or a composable foreground-only cell. Alpha-mask agreement is
part of symbol scoring, so antialiased sprite edges do not require two renders
and a cell-level merge pass. --transparent-threshold controls the bias toward
opaque interior detail and defaults to 0.10.
The atlas is generated from the vendored Chafa reference source and checked into the Rust binary. Chafa is not a build-time or runtime dependency.
Requirements
- Rust 1.85 or newer
- NVIDIA driver
- CUDA Toolkit (
nvccandlibcudart; Ubuntu package:nvidia-cuda-toolkit)
Build and run
Directory mode recursively mirrors PNG paths and changes their suffix to
.ansi:
Only ANSI is written. Directory mode does not leave resized images or other intermediates behind.
Architecture note
The production scorer is implemented directly in cuda/renderer.cu and
exposed to Rust through a small C ABI.
Updating the symbol atlas
After updating the Chafa sources in vendor/chafa, run:
The generated atlas is LGPL-derived and this project is correspondingly
licensed LGPL-3.0-or-later. See LICENSE and NOTICE.
Benchmark against Chafa
The benchmark excludes compilation, warms both programs once, and reports the median end-to-end batch time. It also writes one output from each renderer for visual inspection:
Machine-readable measurements are saved in benchmark-results/report.json.