Commit Graph
30 Commits
Author SHA1 Message Date
Tanish Manku b6cfa585c6 chore: merge main (colour effects, ADR 0056) into button sounds; hit-area tint on ColorTransform (M5) 2026-11-11 14:31:13 -07:00
Tanish Manku 54c27ef0d4 fix(symbol): 9-slice guides switched off are kept and come back when switched on (M5) 2026-11-11 14:00:10 -07:00
Tanish Manku cadfe62913 chore: merge main (9-slice, ActionScript logic, v0.2.0) into colour effects (M2) 2026-11-11 13:55:28 -07:00
Tanish Manku e24a23cd95 chore: merge main (ActionScript logic, v0.2.0) into 9-slice scaling (M2) 2026-11-11 13:43:27 -07:00
FredApps 1897f901d2 fix(gpu): wrap repeating bitmaps without a signed remainder, undefined on GL (M3)
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.
2026-11-11 14:40:07 +01:00
Tanish Manku f78ae40e89 feat(doc): colour effect styles as one exact colour transform, rendered, exported and edited everywhere (M2) 2026-11-11 04:50:41 -07:00
Tanish Manku 224fc84012 test(gpu): 9-sliced instances bin like the oracle draws them (M2) 2026-11-11 04:34:52 -07:00
Tanish Manku 3b6f59f65b chore: merge main (GPU binning) into Library management (M2) 2026-11-11 00:11:30 -07:00
Tanish Manku 18b07fffe0 feat(render): bitmaps without Allow Smoothing keep hard pixel edges in the oracle, the GPU stage, SVG and HTML (M2) 2026-11-10 23:43:59 -07:00
Tanish Manku a6df58e30d fix(gpu): as_chunks_mut for the input layout (newer clippy) (M3) 2026-11-10 23:40:02 -07:00
Tanish Manku 750c90edec fix(gpu): a device whose GPU binning fails its self-test bins on the CPU; Auto bins on the GPU on Vulkan only (M3)
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.
2026-11-10 20:23:56 -07:00
Tanish Manku ba34521d0c perf(gpu): hairlines reach only the tiles they can touch, and bound in O(1) (M3)
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.
2026-11-10 20:23:56 -07:00
Tanish Manku f375849413 perf(gpu): upload only the tile headers when the GPU bins, bin from 32,768 edges, cheap hairline rejects (M3)
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).
2026-11-10 20:23:56 -07:00
Tanish Manku f18cf5bd68 feat(gpu): tile binning on the GPU: count, prefix sum, scatter, tile lists (M3)
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.
2026-11-10 20:23:56 -07:00
Tanish Manku 72da28d74c fix(gpu): keep the binning's helpers private (M3) 2026-11-10 20:23:56 -07:00
Tanish Manku 660bdcb0d8 fix(gpu): take the tiles' left-edge steps from the split pieces themselves (M3)
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.
2026-11-10 20:23:55 -07:00
Tanish Manku 0fbf8c5d0f feat(render): hairlines for outline mode, and integer tile backdrops in the GPU binning (M3)
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.
2026-11-10 20:23:55 -07:00
Tanish Manku a1482962bc feat(render): stroke caps, joins, miter limit and dashes in the model and the CPU oracle (M7) 2026-11-10 18:41:53 -07:00
Tanish Manku 06c004b294 feat(engine): engine crates build and run on wasm32: vfs file layer, web clocks, single-threaded fallbacks (M8)
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.
2026-11-09 22:12:56 -07:00
Tanish Manku 863e8af60a fix(gpu): tests and bench build with merge drawing's Shape.merge; ADR renumbered to 0032 after merge drawing took 0031 (M3) 2026-11-09 20:45:47 -07:00
Tanish Manku 313745b204 feat(gpu): the GPU is the default stage renderer; ADR 0031 (M3)
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.
2026-11-09 19:48:49 -07:00
Tanish Manku 5bed9916dd fix(gpu): the stage shaders build with Direct3D's FXC; no software adapters for the stage (M3)
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.
2026-11-09 19:48:49 -07:00
Tanish Manku 0dae2056eb feat(gpu): bitmap fills and filters on the GPU stage (M3)
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.
2026-11-09 19:48:49 -07:00
Tanish Manku eb85dd2411 feat(gpu): GPU stage draws into the window's textures, no readback; ADR 0029 (M3)
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).
2026-11-09 16:58:49 -07:00
Tanish Manku d1627efc0c feat(gpu): masks, nested masks, group alpha and blend modes on the GPU stage (M3)
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.
2026-11-09 16:49:09 -07:00
Tanish Manku 5b431ec1d3 feat(app): Camera tool, camera frame on the stage, Preview Through Camera and the camera toggle (M7)
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.
2026-11-09 12:50:31 -07:00
Tanish Manku d85e398c4a chore: merge main (GPU stage, SVG clips) into variable-width strokes; GPU parity covers width profiles (M7) 2026-11-09 04:17:57 -07:00
Tanish Manku 9173796835 docs: GPU stage ADR is 0019, as assigned by the lead (M3) 2026-11-09 03:44:33 -07:00
Tanish Manku 3fc4063446 fix(gpu): as_chunks instead of chunks_exact with constant sizes (newer clippy) (M3) 2026-11-09 03:44:33 -07:00
Tanish Manku 2f3ab271d9 feat(gpu): wgpu stage renderer over the oracle's fills, with parity tests (M3)
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.
2026-11-09 03:44:28 -07:00