Files
shinyobjectz 1a516a8de1 A compute's uniforms follow the frame, in a PNG render and an mp4
Two gaps a launch film found in <Compute>, both of one cause: its uniforms never reached it after frame 0.

A compute's uniforms travelled only inside its `shader` spec, which a row holds from its first frame, so an inline
compute (or one as written) saw frame 0's values on every frame. They now also go as a keyed `uniforms` column, as a
frame pass's do. raea-sys-compute's `follow` repacks them when the column changes: an inline compute's into its slots
by name (a name it wasn't built with is refused), one as written through its packer (written::follow_uniforms;
`Ranged` is kept for every compute as written, and a field that is a mesh's slab range is still packed each frame).

An mp4 render draws its 3D live (LiveScene): each frame's changed columns are set on the live rows. The compute's and
the frame pass's `follow` read the timeline's columns (`FrameRows::cols`), which in a live render hold only the load's
first frame, so an mp4 of a compute driven by its uniforms stayed black. FrameRows::at reads a row's value by its
place, the live row's when there is one; both follows use it.

bench/compute-frames/check.sh renders level.tsx (an inline compute filling an image with the grey `level`, f / 20,
gives) to PNGs and to an mp4: frame 0 is black and frame 10 grey 188 in both (the mp4 within 4, its YUV round trip).
Before, frame 10 was black in both. shader/compute_shader_game_of_life, shader_advanced/compute_mesh,
custom_phase_item and custom_post_processing still pass pixel for pixel.
2026-11-08 12:00:17 -08:00

31 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# An inline <Compute> whose uniform changes every frame (level.tsx: `level` f / 20, the grey it fills a render image
# with). Each frame must show its own frame's grey, both in a PNG render (-o DIR) and in an mp4 (the fed render, whose
# 3D is live): frame 10 is level 0.5, sRGB 188; frame 0 is black. Before, a compute's uniforms were its first frame's
# (the spec is held from frame 0), and the mp4's live rows were read from the load's columns, so an mp4 of a compute
# driven by its uniforms stayed black. Exits 1 on a failure.
# bench/compute-frames/check.sh (RAEA_BIN: the raea to run, default target/release/raea)
cd "$(dirname "$0")/../.." || exit 2
BIN=${RAEA_BIN:-$PWD/target/release/raea}
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0
OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-compute-frames.XXXXXX")
trap 'rm -rf "$OUT"' EXIT
grey() { magick "$1" -format "%[fx:round(255*p{64,64}.r)]" info:; }
status=0
"$BIN" render bench/compute-frames/level.tsx -o "$OUT/dir" > "$OUT/dir.log" 2>&1 || { echo "FAIL: the PNG render failed"; grep -v WARN "$OUT/dir.log" | tail -3; exit 1; }
for k in 0 10; do
want=$([ $k = 0 ] && echo 0 || echo 188)
got=$(grey "$OUT/dir/$(printf 'frame-%05d.png' $k)")
[ "$got" = "$want" ] || { echo "FAIL: PNG frame $k is grey $got, not $want"; status=1; }
done
"$BIN" render bench/compute-frames/level.tsx -o "$OUT/out.mp4" > "$OUT/mp4.log" 2>&1 || { echo "FAIL: the mp4 render failed"; grep -v WARN "$OUT/mp4.log" | tail -3; exit 1; }
for k in 0 10; do
want=$([ $k = 0 ] && echo 0 || echo 188)
ffmpeg -v error -i "$OUT/out.mp4" -vf "select=eq(n\,$k)" -frames:v 1 -y "$OUT/mp4-$k.png" || { echo "FAIL: no mp4 frame $k"; status=1; continue; }
got=$(grey "$OUT/mp4-$k.png")
# the mp4's YUV round trip moves a grey by a few levels
[ $(( got > want ? got - want : want - got )) -le 4 ] || { echo "FAIL: mp4 frame $k is grey $got, not $want (within 4)"; status=1; }
done
[ $status = 0 ] && echo "PASS: a compute's per-frame uniform reaches frame 10 in a PNG render (188) and an mp4 (within 4)"
exit $status