GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
scripts/web-probe/run (1.5K)
1 #!/usr/bin/env bash
2 # web-probe/run <out.rgba> — draw the renderer probe (examples/probe/scene.rs)
3 # through the WebGPU renderer in headless Chromium and write the frame it read
4 # back from the GPU: 1280x800 premultiplied RGBA8.
5 #
6 # Its other half is the same scene through the Vulkan renderer,
7 # `cargo run --example probe_native`, screenshotted in a compositor; compare.py
8 # composites this frame over that compositor's background and diffs the two.
9 #
10 # Needs: the wasm32-unknown-unknown target, wasm-bindgen-cli at the version in
11 # Cargo.lock, node with Playwright (see capture.mjs), and the DejaVu fonts
12 # ($PROBE_FONTS_DIR, default /usr/share/fonts/truetype/dejavu) — the native
13 # half must see the same fonts, or text is the difference you measure.
14 set -euo pipefail
15 here=$(cd "$(dirname "$0")" && pwd)
16 out=$(realpath -m "${1:?usage: web-probe/run <out.rgba>}")
17 fonts=${PROBE_FONTS_DIR:-/usr/share/fonts/truetype/dejavu}
18 cd "$here/../.."
19
20 cargo build --release --target wasm32-unknown-unknown --example probe_web
21 site=$(mktemp -d)
22 trap 'rm -rf "$site"' EXIT
23 wasm-bindgen --target web --no-typescript --out-dir "$site" \
24 target/wasm32-unknown-unknown/release/examples/probe_web.wasm
25 cp "$here/page.html" "$site/index.html"
26 mkdir "$site/fonts"
27 cp "$fonts"/*.ttf "$site/fonts/"
28 (cd "$site/fonts" && printf '%s\n' *.ttf | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read().split()))') > "$site/fonts.json"
29 node "$here/capture.mjs" "$site" "$out"
30 echo "web-probe: wrote $out"