GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
scripts/web-probe/probe3d (1.6K)
1 #!/usr/bin/env bash
2 # web-probe/probe3d <out.rgba> [traced] — run the 3D probe
3 # (examples/probe3d/scene.rs) on the browser shell and WebGPU renderer in
4 # headless Chromium, and write a frame read back from the GPU: 1280x800
5 # premultiplied RGBA8. With `traced`, the path-traced probe, given time to
6 # take its eight samples ($PROBE3D_SETTLE ms, default 60000).
7 #
8 # Its other half is `cargo run --example probe3d_native`, screenshotted in a
9 # compositor; compare.py composites this frame over that compositor's
10 # background and diffs the two. The scene names DejaVu Sans, handed over from
11 # $PROBE_FONTS_DIR (default /usr/share/fonts/truetype/dejavu). Needs what
12 # `run` needs.
13 set -euo pipefail
14 here=$(cd "$(dirname "$0")" && pwd)
15 out=$(realpath -m "${1:?usage: web-probe/probe3d <out.rgba> [traced]}")
16 mode=${2:-}
17 fonts=${PROBE_FONTS_DIR:-/usr/share/fonts/truetype/dejavu}
18 cd "$here/../.."
19 cargo build --release --target wasm32-unknown-unknown --example probe3d_web
20 site=$(mktemp -d)
21 trap 'rm -rf "$site"' EXIT
22 wasm-bindgen --target web --no-typescript --out-dir "$site" \
23 target/wasm32-unknown-unknown/release/examples/probe3d_web.wasm
24 cp "$here/demo.html" "$site/demo.html"
25 mkdir "$site/fonts"
26 cp "$fonts"/*.ttf "$site/fonts/"
27 (cd "$site/fonts" && printf '%s\n' *.ttf | python3 -c 'import json,sys; print(json.dumps({"files": sys.stdin.read().split(), "families": ""}))') > "$site/fonts.json"
28 if [ "$mode" = traced ]; then
29 node "$here/capture-app.mjs" "$site" probe3d_web "$out" "${PROBE3D_SETTLE:-60000}" start_traced
30 else
31 node "$here/capture-app.mjs" "$site" probe3d_web "$out"
32 fi
33 echo "web-probe: wrote $out"