CI / test (push) Canceled after 0s
The MoonBit host (wasmhost/, build/wasmhost) is the only host now. Gone: host-wasm/ (Rust on the wasmtime crate, ~5,700 lines incl. Cargo.lock), the run-rust, run-drm-rust and host-wasm recipes, and `just install --rust` (both the recipe and session/install.py now stop with an error naming the removal instead of quietly ignoring the flag). remote-build.sh builds and pulls build/wasmhost. README, wasmhost/README and docs no longer describe a second host, apart from short history notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hiBxpbLoeUM9xfZayq
67 lines
3.7 KiB
Markdown
67 lines
3.7 KiB
Markdown
# Rendering, animations and machines without a GPU
|
|
|
|
Chandra draws the desktop on the CPU on every machine: the host (build/wasmhost)
|
|
rasterises each frame into its own framebuffer and hands it to the display (KMS, X11, a
|
|
nested Wayland window). A GPU never makes Chandra's own frames cheaper. What it changes is how
|
|
much CPU is left: with a GPU, apps (browsers, video, games) draw there; without one they draw
|
|
with llvmpipe or their own software paths on the same cores as Chandra.
|
|
|
|
## Software or hardware mode
|
|
|
|
At start Chandra looks for a GPU and logs what it decided:
|
|
|
|
rendering: software (no GPU found)
|
|
rendering: hardware (GPU: amdgpu)
|
|
|
|
- A DRM render node (`/sys/class/drm/renderD*`) whose driver drives a real GPU (i915, xe,
|
|
amdgpu, radeon, nouveau, nvidia, SoC GPUs), or NVIDIA's proprietary driver
|
|
(`/proc/driver/nvidia/version`), means **hardware**.
|
|
- No render node, or only display-only / virtual ones (simpledrm, vkms, virtio_gpu, qxl, bochs,
|
|
vmwgfx, ast, ...), or `LIBGL_ALWAYS_SOFTWARE=1`, means **software**.
|
|
|
|
Overrides, strongest first:
|
|
|
|
- `CHANDRA_RENDER=software` or `CHANDRA_RENDER=hardware` in the environment.
|
|
- Settings > Session > **Lighter animations (no GPU found / GPU found)**: on is software mode.
|
|
Saved in state.edn as `:render :software` or `:render :hardware`, only when it differs from
|
|
what was detected (so the same state.edn follows you between machines).
|
|
|
|
What software mode changes: window previews that keep changing (a video in the overview or
|
|
Alt+Tab) are remade every 200 ms instead of 100 ms, and a desktop module (Live Starfield) gets at
|
|
most ~30 frames a second however often it asks.
|
|
|
|
## What makes animations smooth everywhere
|
|
|
|
- At most one frame is drawn ahead of the output: while a drawn frame waits for the page flip in
|
|
flight (KMS) or for the previous frame to be shown (nested, X11), no other one is drawn. Before,
|
|
frames drawn meanwhile were thrown away (the KMS loop runs at 125 Hz), each costing a whole
|
|
frame of CPU. Drawing the next frame while the X server copies the last one keeps both busy:
|
|
waiting for the copy first halved the frame rate on Xorg. An output that never says it is ready
|
|
(a hidden nested window) still gets a frame every 250 ms.
|
|
- A backdrop (wallpaper or desktop module) whose ops change every frame but begin the same, like
|
|
Live Starfield's sky and nebulae under moving stars, keeps that common start cached as pixels and
|
|
draws only the rest over a copy of it (MoonBit host).
|
|
- Animations are timed by the clock, so a slow frame makes the next one jump ahead instead of
|
|
slowing the animation down.
|
|
- The rasteriser blends two colour channels at a time (16-bit lanes, exact division by 255),
|
|
draws filled circles as row spans (big translucent discs cost a square root per pixel before),
|
|
and scales images with 32-bit sums.
|
|
- Window previews gliding in the overview are sampled straight from the preview at each frame's
|
|
size (nearest pixel), not filtered and cached at a size used once; once the overview settles
|
|
they are drawn at the size they were made at. On the MoonBit host other large images drawn
|
|
at a new size every frame are treated the same way from their second frame on.
|
|
|
|
## Measuring
|
|
|
|
`CHANDRA_FRAME_TRACE=1` logs one line per drawn frame:
|
|
|
|
frame 1795657160219 compose 1 raster 3
|
|
|
|
(the clock in ms, then how long composing the scene and rasterising it took). The benchmark in
|
|
the project files (`smooth-anim/anim-bench.sh`) runs a headless 1920x1080 session with four
|
|
windows, opens and closes the overview six times and runs Live Starfield, and prints frame
|
|
rates, frame gaps and raster times from that trace.
|
|
|
|
Window frames, their shadow included, are draw ops from `@scene.build_window_decoration`
|
|
(docs/window-frames.md): plain spans, redrawn only when the window or what is above it changes.
|