The fine shader wrapped a repeating bitmap's taps with ((q % size) + size) % size.
naga (30.0.1) writes WGSL's integer % as GLSL's, which is undefined for
negative operands, and the bilinear tap left of or above the edge is -1. On
the GL backend (llvmpipe in the FreeBSD VM, which has no Vulkan driver) the
edge texels came out wrong: bitmap repeated max 79, filtered bitmap max 16, so
FreeBSD x86_64 has failed since bitmap fills landed (0dae205). Vulkan, DX12
and Metal define the remainder, so Linux CI passed.
wrap() takes the unsigned remainder of |i| instead, defined on every backend.
shaders_take_no_signed_remainder parses every shader with naga and fails on a
% whose left operand is a signed integer; it fails on fine.wgsl before this.
The start-up self-test checks the GPU binning apart: if it comes back wrong only the
binning stays on the CPU (gpu_binning_off says why), instead of the whole GPU stage
switching off; the tests require it to work wherever the GPU stage runs (lavapipe in CI).
On Direct3D 12 the binning passes cost more per stage tile than the CPU binning (onion
+-5 at 1080p in tiles: 9.7 -> 14.4 ms, measured twice), so Auto keeps the CPU's there
and on backends not yet measured; ANICRAFT_GPU_BINNING=gpu still forces it.
A hairline segment went into every tile within 2 px of it; 1.25 px is enough (a pixel
centre within its reach is within 1 px of a point of it, plus rounding). The room for
its pieces is its padded box's tiles, row by row only for long segments. Onion outlines
against tinted, GPU stage, best of three: 1080p tiles 10.2 vs 9.5 ms, 4K tiles 15.1 vs
15.4 ms, one texture 7.2 vs 7.1 ms.
Mapping the GPU-binned index at creation zeroed and copied its whole room for entries on
the CPU; the headers and op headers now go through the queue and the rest starts zeroed
on the GPU. 50k shapes at 4K, direct: 50 -> 24 ms (CPU-binned: 121 ms).
Auto bins on the GPU from 32,768 edges: forcing it on every 512 px stage tile made the
1,000-shape 4K stage 1.9x slower and the 10k-shape one 1.3x (per-tile pass set-up); with
the threshold the tiled stage never loses (10k at 4K 10.5 -> 10.0 ms, 50k 63.6 -> 38.4 ms).
A hairline segment whose box is out of reach of a pixel is skipped before the distance
(same coverage). gpu_bench compares CPU and Auto binning and checks budgets (--check).
The CPU lays out the fills' points, each fill's tile range, each tile row's fills in
drawing order and room for every tile the fills' bounds cover, with an upper bound of the
pieces, so every buffer is sized up front and nothing is read back. bin.wgsl splits the
edges (one invocation per row of tiles of each fill, so no atomics), scan.wgsl places the
pieces, and a pass per tile keeps the fills with pieces or a backdrop there, in order: the
same lists as the CPU binning, which stays the reference and the way for fills in masks
and groups. Binning::Auto bins on the GPU from 4,096 edges; ANICRAFT_GPU_BINNING overrides.
Tests: the GPU's lists against the CPU's, entry by entry and pixel by pixel (stress
frames, outlines, the analytic scenes), and GPU-binned frames against the oracle, on
Vulkan and Direct3D 12.
Crossings computed apart from the splitting could disagree with it by a rounding near a
tile corner and count one crossing twice (the backdrop and a step): 543 pixels off by up
to 133/255 on a stress frame. The steps now come from consecutive pieces of a tile row in
different columns, so the backdrop and the steps always describe the same pieces. A test
on stress frames at awkward scales catches it. Also drops leftover timing prints.
Outline mode (an outlined layer, onion skin's outlines) draws hairlines straight from
the flattened path: coverage 1 - the distance to the nearest segment, one edge per
segment where a stroked hairline was four plus a disc at every bend. Exact for axis-
aligned lines, no darkening at overlaps and joins. The GPU stage computes the same.
The binning's per-row float backdrops become one integer per tile plus a piece on the
tile's left edge wherever the outline crosses it (Vello's backdrops and y-edges), which
lets the GPU compute the same lists without float atomics. Parity unchanged.
Commands read and write files through engine::vfs: std::fs on the desktop, an in-memory
store in the browser that the web shell fills from the file picker and empties into
downloads (ADR 0036). file.open opens .fla bytes through it and gains unsaved?: true for
restored copies. Instant/SystemTime come from web-time; rayon's deferred drops run inline
on wasm; the GPU crate plans layers in turn where wgpu handles aren't Sync; video export
says why it can't run in a browser; system font discovery is native-only.
The shell's gpu-stage feature is on by default and Preferences > Stage >
Renderer defaults to Graphics card (GPU), with the CPU drawing whenever
there is no usable card, a tile is past the GPU's limits or anything
fails. The setting is stored under a new key: every earlier build wrote
the old one as Cpu without anyone choosing it. CI installs lavapipe so the
parity tests run on a software adapter.
Measured (release, RTX 5090): 4K filtered sample 3.9 ms on Vulkan and
4.2 ms on DX12 (CPU 31.5 ms); 200 bitmap fills 4.4 / 4.3 ms (CPU 37.2 ms).
Docs: ADR 0031, performance, roadmap, architecture, CHANGELOG.
FXC must unroll loops that index vector components and could not unroll
blend's and adjust's, so the GPU stage never started on a DX12 window.
Both are vector code now, with the same arithmetic order. The parity
suite passes on DX12 as on Vulkan. A software adapter (WARP, llvmpipe)
is refused for the stage, since the CPU oracle is faster;
GpuRenderer::software() opens one for tests. The self-test now compares
against the oracle (bitmap and filtered symbol included) and says where
it went wrong. The benchmark gains a filtered sample and 200 bitmaps.
The oracle now hands filtered groups to other renderers as layers
(prepare_scene: Scene::layers, Fill::layer) and resolves each filter into
the exact steps it runs (filters::resolve); apply runs those same steps.
The GPU stage samples bitmaps from textures uploaded once per image
(bilinear by hand, the oracle's colour effect and repeat rules) and draws
each filtered layer, runs its filters as compute passes and composites it
like any fill. Parity: bitmaps byte-identical, filters max 1/255.
The GPU stage shares eframe's wgpu device (egui_wgpu::RenderState) and
draws each stage tile into a storage texture the shell registers with
egui as it is. Fallbacks: a headless device with readback (window on
OpenGL), then the CPU oracle. Every call runs in thread-local error
scopes; nothing is installed on the window's device; a work bound per
dispatch guards the driver watchdog.
The engine stays GPU-free: Raster::Native carries an opaque image, cached
under its own 384 MB budget; only the shell downcasts it.
perf, gpu_bench on RTX 5090 (Vulkan), 32 threads:
4K, 1,000 shapes: CPU 16.2-19.6 ms, read-back 8.4, direct 2.1-2.4 ms
4K, 10k shapes: CPU 25.8-28.1 ms, read-back 23.2, stage tiles 10.2 ms
4K, masked 10k: CPU 74.8-80.0 ms, stage tiles 10.9 ms
Binning stays on the CPU (ADR 0029: not the bottleneck as stage tiles).
render::prepare_scene hands the oracle's prepared fills with their clips
(artwork, cleaned parents, bounds) and groups (chains, sanitized alpha,
blend) to the GPU. The binning emits per-tile streams with clip-level and
group open/close entries; fine.wgsl keeps a per-pixel group stack and clip
coverage and blends with the oracle's separable W3C formulas. Parity on
the RTX 5090: max 1/255, mean <= 0.0011/255 on every new scene.
Also a texture entry point (main_texture) and GpuRenderer::shared for the
window's device; render_texture draws without readback.
The stage draws the camera frame in the camera layer's colour; the Camera tool
(C) pans, turns (round handle) and zooms (wheel), one undo step per drag;
View > Preview Through Camera renders stage tiles through the camera; the
timeline header toggles the camera; Properties gets a Camera section and a
layer Depth row. GPU parity and the accessibility audit cover camera scenes.
New crate anicraft-gpu (L3): the CPU oracle prepares the fills
(render::plain_fills: flattening, strokes, shaders and gradient tables,
culling), binning sorts edge pieces into 16x16 tiles with per-row
backdrops, and one compute pass computes each pixel's exact area coverage
and composites in display-list order. Masks, groups and bitmaps are
handed back (NeedsFull) for the CPU to draw.
Parity on an RTX 5090 (Vulkan): max 1/255, mean < 0.0001/255 on the
sample and stress scenes; tests skip with a message without an adapter.