Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
#20: the same page renders to the same frames every time. Vello's fine stage (area antialiasing, what raea-page draws with) summed a tile's coverage in f32 in the order its segments arrived, and path_count hands out their slots with atomicAdd, so the order, and the sum's last bits, changed from run to run: a pixel now and then came out a level apart, so frame hashes and the export cache disagreed between renders. Each contribution is now summed as a fixed-point i32 (2^20 to the pixel), which no order changes, and made a float once. bench/html-repeat/check.sh renders #20's page 8 times to frame hashes and needs every run the same as the first: before, 6 of 7 runs differed (frames 161, 175, 269); after, all 8 match (and 12 of 12 in a longer run). Speed, two builds of this tree with and without the change, five runs each back to back, to frame hashes: the #23 bench page 154-194 fps before, 167-193 after (medians 193.2 and 191.8); #20's page 145-160 before, 154-160 after (medians 155.9 and 157.1). Ten pictures (eight parity cases and bench/rotated-paint's two) are pixel-identical before and after; only frames that fell on that rounding change, by a level.
shinyobjectzabc859cf5d66
diff --git a/bench/html-repeat/check.sh b/bench/html-repeat/check.shnew file mode 100755index 00000000..8062a241--- /dev/null+++ b/bench/html-repeat/check.sh@@ -0,0 +1,20 @@+#!/bin/bash+# #20: the same HTML page rendered again gives the same frames. index.html is rendered RUNS times (8) to frame hashes+# (.txt, the NV12 bytes before any encoder) and every run must match the first. Before Vello's fine stage summed a+# tile's coverage in fixed point, about one run in three differed from the first, on a frame or a few.+# bench/html-repeat/check.sh (RAEA_BIN: the raea to run, default target/release/raea; RUNS: how many runs)+cd "$(dirname "$0")/../.." || exit 2+BIN=${RAEA_BIN:-$PWD/target/release/raea}+RUNS=${RUNS:-8}+export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0+OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-html-repeat.XXXXXX")+trap 'rm -rf "$OUT"' EXIT+status=0+for i in $(seq 1 "$RUNS"); do+ "$BIN" render bench/html-repeat/index.html -o "$OUT/$i.txt" > "$OUT/$i.log" 2>&1 || { echo "FAIL: run $i failed"; tail -5 "$OUT/$i.log"; exit 1; }+ [ "$i" = 1 ] && continue+ d=$(diff "$OUT/1.txt" "$OUT/$i.txt" | awk '/^>/ {print $2}' | tr '\n' ' ')+ [ -z "$d" ] || { echo "FAIL: run $i differs from run 1 at frames $d"; status=1; }+done+[ $status = 0 ] && echo "PASS: $RUNS runs, every frame the same"+exit $statusdiff --git a/bench/html-repeat/index.html b/bench/html-repeat/index.htmlnew file mode 100644index 00000000..9ae54dd3--- /dev/null+++ b/bench/html-repeat/index.html@@ -0,0 +1,24 @@+<!doctype html>+<!-- #20: a rounded panel with three children scaling 1 -> 1.014 and back (GSAP). Its frames came out a level apart on+ some renders, as a tile's coverage was summed in the order its segments arrived. bench/html-repeat/check.sh -->+<html><head><meta charset="utf-8">+<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>+<style>+*{box-sizing:border-box}html,body{margin:0;width:1920px;height:1080px;overflow:hidden;background:#0a0a0b;color:#f4f4f5;font-family:sans-serif}+#root{position:relative;width:100%;height:100%;overflow:hidden}+#panel{position:absolute;left:120px;bottom:205px;width:760px;height:118px;border:1px solid rgba(255,255,255,.14);border-radius:12px;background:#121214;display:flex;align-items:center;padding:0 34px;gap:24px}+#check{width:42px;height:42px;border-radius:50%;border:2px solid #ffb517;color:#ffb517;display:grid;place-items:center;font-size:26px;line-height:1}+#label{font-size:30px;letter-spacing:-.015em}+#stamp{margin-left:auto;font:500 13px/1 monospace;letter-spacing:.08em;text-transform:uppercase;color:#ffb517}+</style></head><body>+<div id="root" data-composition-id="main" data-start="0" data-width="1920" data-height="1080" data-duration="9">+<div id="panel"><div id="check">+</div><div id="label">Headline</div><div id="stamp">Button</div></div>+</div><script>+window.__timelines=window.__timelines||{};+var tl=gsap.timeline({paused:true}),drift={p:0};+gsap.set('#panel',{opacity:0});+tl.fromTo('#panel',{opacity:0,y:28},{opacity:1,y:0,duration:.8,ease:'power3.out'},2.2);+tl.to(drift,{p:1,duration:9.5,ease:'none'},0);+tl.to('#panel',{scale:1.014,duration:2.2,ease:'sine.inOut',yoyo:true,repeat:1},5.2);+window.__timelines.main=tl;+</script></body></html>diff --git a/vendor/vello_shaders/shader/fine.wgsl b/vendor/vello_shaders/shader/fine.wgslindex 4e2fde00..999a7334 100644--- a/vendor/vello_shaders/shader/fine.wgsl+++ b/vendor/vello_shaders/shader/fine.wgsl@@ -1002,13 +1002,19 @@ const PIXELS_PER_THREAD = 4u;// to wire this so it's a dynamic choice (even per-path).//// FIXME: This should return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed.+// raea #20: a tile's segments come in the order path_count's atomicAdd gave them, which changes from run to run, and+// f32 sums of their coverage in another order differ in the last bits, so a few pixels of the same scene came out a+// level apart between renders. Each contribution is summed as a fixed-point i32 (2^20 to the pixel), which no order+// changes, then made a float once.+const AREA_ONE: f32 = 1048576.0;+fn fill_path(fill: CmdFill, xy: vec2<f32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {let n_segs = fill.size_and_rule >> 1u;let even_odd = (fill.size_and_rule & 1u) != 0u;var area: array<f32, PIXELS_PER_THREAD>;- let backdrop_f = f32(fill.backdrop);+ var acc: array<i32, PIXELS_PER_THREAD>;for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {- area[i] = backdrop_f;+ acc[i] = fill.backdrop << 20u;}for (var i = 0u; i < n_segs; i++) {let seg_off = fill.seg_data + i;@@ -1035,14 +1041,17 @@ fn fill_path(fill: CmdFill, xy: vec2<f32>, result: ptr<function, array<f32, PIXElet c = max(b, 0.0);let d = max(xmin, 0.0);let a = (b + 0.5 * (d * d - c * c) - xmin) / (xmax - xmin);- area[i] += a * dy;+ acc[i] += i32(round(a * dy * AREA_ONE));}}- let y_edge = sign(delta.x) * clamp(xy.y - segment.y_edge + 1.0, 0.0, 1.0);+ let y_edge = i32(round(sign(delta.x) * clamp(xy.y - segment.y_edge + 1.0, 0.0, 1.0) * AREA_ONE));for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {- area[i] += y_edge;+ acc[i] += y_edge;}}+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {+ area[i] = f32(acc[i]) / AREA_ONE;+ }if even_odd {// even-odd winding rulefor (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {diff --git a/vendor/vendor.toml b/vendor/vendor.tomlindex ecb4a362..66ea2999 100644--- a/vendor/vendor.toml+++ b/vendor/vendor.toml@@ -148,7 +148,7 @@ exit = "a Firewheel release with #144"path = "vendor/vello_shaders"upstream = "crates.io:0.11.0"kind = "patch"-reason = "linear-light blending in fine.wgsl (Config.blend_linear, set by vello_encoding's set_blend_linear): every colour, ramp and texel decoded from sRGB, blended, and encoded once, the blend stack kept sRGB-encoded, so raea-page blends a bevy_ui page as Bevy's UI does on an sRGB target"+reason = "linear-light blending in fine.wgsl (Config.blend_linear, set by vello_encoding's set_blend_linear): every colour, ramp and texel decoded from sRGB, blended, and encoded once, the blend stack kept sRGB-encoded, so raea-page blends a bevy_ui page as Bevy's UI does on an sRGB target; area coverage summed in fixed point (i32, 2^20 a pixel) so a scene draws the same whatever order its segments arrive in (raea #20)"exit = "a Vello release that blends in linear light on request"[rune-taffy]