dream-soft-render
A CPU rasterizer for 2D triangle meshes and egui frames. It writes premultiplied RGBA8 into a buffer you own, and the same draw calls produce the same bytes on every platform, AArch64's NEON code included.
There is no GPU here, no window and no swapchain. You hand it rectangles, textured rectangles and meshes, or an egui UI closure, and you get pixels back. Whether they go to a Linux framebuffer, a PNG or a golden-test hash is up to you. It was pulled out of dream-ini, whose PortMaster build draws its whole egui interface through it on handhelds with no usable GPU.
Documentation, including the full API reference: https://dreamweave-mp.github.io/dream-soft-render/
Install
Rust 1.95 or newer. Without features the crate has no dependencies. The egui adapter is the egui
feature:
[]
= { = "2", = ["egui"] }
Drawing
use ;
Each call rasterizes before it returns, in call order. begin_frame does not clear: call clear
for a background. Colors and texture pixels are premultiplied, pixels are sampled at their
centers, and bad input, such as an index past the vertices or a NaN rectangle, is an error rather
than a quietly wrong frame. The rules
state all of it exactly.
Drawing egui
use SoftwareRenderer;
use ;
render_egui needs the egui feature. It runs the closure, applies egui's texture uploads,
tessellates at one pixel per point and rasterizes into the same surface. A frame identical to the
last one is skipped, and surface_changed says so, so the host can skip presenting it too.
Where to read next
- Start here: draw a frame and save it as an image
- Hosting egui: textures, unchanged frames, feathering and failures
- Fast frames: what the rasterizer recognizes, and the benchmarks
- Platforms: the NEON kernels, and testing them under qemu
- Rust API and the changelog
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Support
Has dream-soft-render been useful to you? Consider amplifying the signal through ko-fi.